2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/dhcp/dhcp_proxy.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include "vat/json_format.h"
61 #define vl_typedefs /* define message structures */
62 #include <vpp/api/vpe_all_api_h.h>
65 /* declare message handlers for each api */
67 #define vl_endianfun /* define message structures */
68 #include <vpp/api/vpe_all_api_h.h>
71 /* instantiate all the print functions we know about */
72 #define vl_print(handle, ...)
74 #include <vpp/api/vpe_all_api_h.h>
77 #define __plugin_msg_base 0
78 #include <vlibapi/vat_helper_macros.h>
80 #if VPP_API_TEST_BUILTIN == 0
90 vat_socket_connect (vat_main_t * vam)
92 vam->socket_client_main = &socket_client_main;
93 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
94 0 /* default socket rx, tx buffer */ );
96 #else /* vpp built-in case, we don't do sockets... */
98 vat_socket_connect (vat_main_t * vam)
104 vl_socket_client_read (int wait)
110 vl_socket_client_write ()
116 vl_socket_client_msg_alloc (int nbytes)
124 vat_time_now (vat_main_t * vam)
126 #if VPP_API_TEST_BUILTIN
127 return vlib_time_now (vam->vlib_main);
129 return clib_time_now (&vam->clib_time);
134 errmsg (char *fmt, ...)
136 vat_main_t *vam = &vat_main;
141 s = va_format (0, fmt, &va);
146 #if VPP_API_TEST_BUILTIN
147 vlib_cli_output (vam->vlib_main, (char *) s);
150 if (vam->ifp != stdin)
151 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
152 vam->input_line_number);
153 fformat (vam->ofp, (char *) s);
161 #if VPP_API_TEST_BUILTIN == 0
163 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
165 vat_main_t *vam = va_arg (*args, vat_main_t *);
166 u32 *result = va_arg (*args, u32 *);
170 if (!unformat (input, "%s", &if_name))
173 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
181 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
186 /* Parse an IP4 address %d.%d.%d.%d. */
188 unformat_ip4_address (unformat_input_t * input, va_list * args)
190 u8 *result = va_arg (*args, u8 *);
193 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
196 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
208 unformat_ethernet_address (unformat_input_t * input, va_list * args)
210 u8 *result = va_arg (*args, u8 *);
213 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
214 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
218 for (i = 0; i < 6; i++)
219 if (a[i] >= (1 << 8))
222 for (i = 0; i < 6; i++)
228 /* Returns ethernet type as an int in host byte order. */
230 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
233 u16 *result = va_arg (*args, u16 *);
237 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
239 if (type >= (1 << 16))
247 /* Parse an IP6 address. */
249 unformat_ip6_address (unformat_input_t * input, va_list * args)
251 ip6_address_t *result = va_arg (*args, ip6_address_t *);
253 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
254 uword c, n_colon, double_colon_index;
256 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
257 double_colon_index = ARRAY_LEN (hex_quads);
258 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
261 if (c >= '0' && c <= '9')
263 else if (c >= 'a' && c <= 'f')
264 hex_digit = c + 10 - 'a';
265 else if (c >= 'A' && c <= 'F')
266 hex_digit = c + 10 - 'A';
267 else if (c == ':' && n_colon < 2)
271 unformat_put_input (input);
275 /* Too many hex quads. */
276 if (n_hex_quads >= ARRAY_LEN (hex_quads))
281 hex_quad = (hex_quad << 4) | hex_digit;
283 /* Hex quad must fit in 16 bits. */
284 if (n_hex_digits >= 4)
291 /* Save position of :: */
294 /* More than one :: ? */
295 if (double_colon_index < ARRAY_LEN (hex_quads))
297 double_colon_index = n_hex_quads;
300 if (n_colon > 0 && n_hex_digits > 0)
302 hex_quads[n_hex_quads++] = hex_quad;
308 if (n_hex_digits > 0)
309 hex_quads[n_hex_quads++] = hex_quad;
314 /* Expand :: to appropriate number of zero hex quads. */
315 if (double_colon_index < ARRAY_LEN (hex_quads))
317 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
319 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
320 hex_quads[n_zero + i] = hex_quads[i];
322 for (i = 0; i < n_zero; i++)
323 hex_quads[double_colon_index + i] = 0;
325 n_hex_quads = ARRAY_LEN (hex_quads);
328 /* Too few hex quads given. */
329 if (n_hex_quads < ARRAY_LEN (hex_quads))
332 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
333 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
340 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
342 u32 *r = va_arg (*args, u32 *);
345 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
346 foreach_ipsec_policy_action
354 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
356 u32 *r = va_arg (*args, u32 *);
359 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
360 foreach_ipsec_crypto_alg
368 format_ipsec_crypto_alg (u8 * s, va_list * args)
370 u32 i = va_arg (*args, u32);
375 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
376 foreach_ipsec_crypto_alg
379 return format (s, "unknown");
381 return format (s, "%s", t);
385 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
387 u32 *r = va_arg (*args, u32 *);
390 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
391 foreach_ipsec_integ_alg
399 format_ipsec_integ_alg (u8 * s, va_list * args)
401 u32 i = va_arg (*args, u32);
406 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
407 foreach_ipsec_integ_alg
410 return format (s, "unknown");
412 return format (s, "%s", t);
416 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
418 u32 *r = va_arg (*args, u32 *);
421 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
422 foreach_ikev2_auth_method
430 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
432 u32 *r = va_arg (*args, u32 *);
435 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
436 foreach_ikev2_id_type
442 #else /* VPP_API_TEST_BUILTIN == 1 */
444 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
446 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
447 vnet_main_t *vnm = vnet_get_main ();
448 u32 *result = va_arg (*args, u32 *);
450 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
454 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
456 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
457 vnet_main_t *vnm = vnet_get_main ();
458 u32 *result = va_arg (*args, u32 *);
460 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
463 #endif /* VPP_API_TEST_BUILTIN */
466 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
468 u8 *r = va_arg (*args, u8 *);
470 if (unformat (input, "kbps"))
471 *r = SSE2_QOS_RATE_KBPS;
472 else if (unformat (input, "pps"))
473 *r = SSE2_QOS_RATE_PPS;
480 unformat_policer_round_type (unformat_input_t * input, va_list * args)
482 u8 *r = va_arg (*args, u8 *);
484 if (unformat (input, "closest"))
485 *r = SSE2_QOS_ROUND_TO_CLOSEST;
486 else if (unformat (input, "up"))
487 *r = SSE2_QOS_ROUND_TO_UP;
488 else if (unformat (input, "down"))
489 *r = SSE2_QOS_ROUND_TO_DOWN;
496 unformat_policer_type (unformat_input_t * input, va_list * args)
498 u8 *r = va_arg (*args, u8 *);
500 if (unformat (input, "1r2c"))
501 *r = SSE2_QOS_POLICER_TYPE_1R2C;
502 else if (unformat (input, "1r3c"))
503 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
504 else if (unformat (input, "2r3c-2698"))
505 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
506 else if (unformat (input, "2r3c-4115"))
507 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
508 else if (unformat (input, "2r3c-mef5cf1"))
509 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
516 unformat_dscp (unformat_input_t * input, va_list * va)
518 u8 *r = va_arg (*va, u8 *);
521 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
530 unformat_policer_action_type (unformat_input_t * input, va_list * va)
532 sse2_qos_pol_action_params_st *a
533 = va_arg (*va, sse2_qos_pol_action_params_st *);
535 if (unformat (input, "drop"))
536 a->action_type = SSE2_QOS_ACTION_DROP;
537 else if (unformat (input, "transmit"))
538 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
539 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
540 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
547 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
549 u32 *r = va_arg (*va, u32 *);
552 if (unformat (input, "ip4"))
553 tid = POLICER_CLASSIFY_TABLE_IP4;
554 else if (unformat (input, "ip6"))
555 tid = POLICER_CLASSIFY_TABLE_IP6;
556 else if (unformat (input, "l2"))
557 tid = POLICER_CLASSIFY_TABLE_L2;
566 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
568 u32 *r = va_arg (*va, u32 *);
571 if (unformat (input, "ip4"))
572 tid = FLOW_CLASSIFY_TABLE_IP4;
573 else if (unformat (input, "ip6"))
574 tid = FLOW_CLASSIFY_TABLE_IP6;
582 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
583 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
584 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
585 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
587 #if (VPP_API_TEST_BUILTIN==0)
589 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
591 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
592 mfib_itf_attribute_t attr;
595 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
597 if (unformat (input, mfib_itf_flag_long_names[attr]))
598 *iflags |= (1 << attr);
600 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
602 if (unformat (input, mfib_itf_flag_names[attr]))
603 *iflags |= (1 << attr);
606 return (old == *iflags ? 0 : 1);
610 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
612 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
613 mfib_entry_attribute_t attr;
616 FOR_EACH_MFIB_ATTRIBUTE (attr)
618 if (unformat (input, mfib_flag_long_names[attr]))
619 *eflags |= (1 << attr);
621 FOR_EACH_MFIB_ATTRIBUTE (attr)
623 if (unformat (input, mfib_flag_names[attr]))
624 *eflags |= (1 << attr);
627 return (old == *eflags ? 0 : 1);
631 format_ip4_address (u8 * s, va_list * args)
633 u8 *a = va_arg (*args, u8 *);
634 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
638 format_ip6_address (u8 * s, va_list * args)
640 ip6_address_t *a = va_arg (*args, ip6_address_t *);
641 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
643 i_max_n_zero = ARRAY_LEN (a->as_u16);
645 i_first_zero = i_max_n_zero;
647 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
649 u32 is_zero = a->as_u16[i] == 0;
650 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
656 if ((!is_zero && n_zeros > max_n_zeros)
657 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
659 i_max_n_zero = i_first_zero;
660 max_n_zeros = n_zeros;
661 i_first_zero = ARRAY_LEN (a->as_u16);
666 last_double_colon = 0;
667 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
669 if (i == i_max_n_zero && max_n_zeros > 1)
671 s = format (s, "::");
672 i += max_n_zeros - 1;
673 last_double_colon = 1;
677 s = format (s, "%s%x",
678 (last_double_colon || i == 0) ? "" : ":",
679 clib_net_to_host_u16 (a->as_u16[i]));
680 last_double_colon = 0;
687 /* Format an IP46 address. */
689 format_ip46_address (u8 * s, va_list * args)
691 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
692 ip46_type_t type = va_arg (*args, ip46_type_t);
698 is_ip4 = ip46_address_is_ip4 (ip46);
709 format (s, "%U", format_ip4_address, &ip46->ip4) :
710 format (s, "%U", format_ip6_address, &ip46->ip6);
714 format_ethernet_address (u8 * s, va_list * args)
716 u8 *a = va_arg (*args, u8 *);
718 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
719 a[0], a[1], a[2], a[3], a[4], a[5]);
724 increment_v4_address (ip4_address_t * a)
728 v = ntohl (a->as_u32) + 1;
729 a->as_u32 = ntohl (v);
733 increment_v6_address (ip6_address_t * a)
737 v0 = clib_net_to_host_u64 (a->as_u64[0]);
738 v1 = clib_net_to_host_u64 (a->as_u64[1]);
743 a->as_u64[0] = clib_net_to_host_u64 (v0);
744 a->as_u64[1] = clib_net_to_host_u64 (v1);
748 increment_mac_address (u8 * mac)
750 u64 tmp = *((u64 *) mac);
751 tmp = clib_net_to_host_u64 (tmp);
752 tmp += 1 << 16; /* skip unused (least significant) octets */
753 tmp = clib_host_to_net_u64 (tmp);
755 clib_memcpy (mac, &tmp, 6);
758 static void vl_api_create_loopback_reply_t_handler
759 (vl_api_create_loopback_reply_t * mp)
761 vat_main_t *vam = &vat_main;
762 i32 retval = ntohl (mp->retval);
764 vam->retval = retval;
765 vam->regenerate_interface_table = 1;
766 vam->sw_if_index = ntohl (mp->sw_if_index);
767 vam->result_ready = 1;
770 static void vl_api_create_loopback_reply_t_handler_json
771 (vl_api_create_loopback_reply_t * mp)
773 vat_main_t *vam = &vat_main;
774 vat_json_node_t node;
776 vat_json_init_object (&node);
777 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
778 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
780 vat_json_print (vam->ofp, &node);
781 vat_json_free (&node);
782 vam->retval = ntohl (mp->retval);
783 vam->result_ready = 1;
786 static void vl_api_create_loopback_instance_reply_t_handler
787 (vl_api_create_loopback_instance_reply_t * mp)
789 vat_main_t *vam = &vat_main;
790 i32 retval = ntohl (mp->retval);
792 vam->retval = retval;
793 vam->regenerate_interface_table = 1;
794 vam->sw_if_index = ntohl (mp->sw_if_index);
795 vam->result_ready = 1;
798 static void vl_api_create_loopback_instance_reply_t_handler_json
799 (vl_api_create_loopback_instance_reply_t * mp)
801 vat_main_t *vam = &vat_main;
802 vat_json_node_t node;
804 vat_json_init_object (&node);
805 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
806 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
808 vat_json_print (vam->ofp, &node);
809 vat_json_free (&node);
810 vam->retval = ntohl (mp->retval);
811 vam->result_ready = 1;
814 static void vl_api_af_packet_create_reply_t_handler
815 (vl_api_af_packet_create_reply_t * mp)
817 vat_main_t *vam = &vat_main;
818 i32 retval = ntohl (mp->retval);
820 vam->retval = retval;
821 vam->regenerate_interface_table = 1;
822 vam->sw_if_index = ntohl (mp->sw_if_index);
823 vam->result_ready = 1;
826 static void vl_api_af_packet_create_reply_t_handler_json
827 (vl_api_af_packet_create_reply_t * mp)
829 vat_main_t *vam = &vat_main;
830 vat_json_node_t node;
832 vat_json_init_object (&node);
833 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
834 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
836 vat_json_print (vam->ofp, &node);
837 vat_json_free (&node);
839 vam->retval = ntohl (mp->retval);
840 vam->result_ready = 1;
843 static void vl_api_create_vlan_subif_reply_t_handler
844 (vl_api_create_vlan_subif_reply_t * mp)
846 vat_main_t *vam = &vat_main;
847 i32 retval = ntohl (mp->retval);
849 vam->retval = retval;
850 vam->regenerate_interface_table = 1;
851 vam->sw_if_index = ntohl (mp->sw_if_index);
852 vam->result_ready = 1;
855 static void vl_api_create_vlan_subif_reply_t_handler_json
856 (vl_api_create_vlan_subif_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 vat_json_node_t node;
861 vat_json_init_object (&node);
862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
863 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
865 vat_json_print (vam->ofp, &node);
866 vat_json_free (&node);
868 vam->retval = ntohl (mp->retval);
869 vam->result_ready = 1;
872 static void vl_api_create_subif_reply_t_handler
873 (vl_api_create_subif_reply_t * mp)
875 vat_main_t *vam = &vat_main;
876 i32 retval = ntohl (mp->retval);
878 vam->retval = retval;
879 vam->regenerate_interface_table = 1;
880 vam->sw_if_index = ntohl (mp->sw_if_index);
881 vam->result_ready = 1;
884 static void vl_api_create_subif_reply_t_handler_json
885 (vl_api_create_subif_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 vat_json_node_t node;
890 vat_json_init_object (&node);
891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
892 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
901 static void vl_api_interface_name_renumber_reply_t_handler
902 (vl_api_interface_name_renumber_reply_t * mp)
904 vat_main_t *vam = &vat_main;
905 i32 retval = ntohl (mp->retval);
907 vam->retval = retval;
908 vam->regenerate_interface_table = 1;
909 vam->result_ready = 1;
912 static void vl_api_interface_name_renumber_reply_t_handler_json
913 (vl_api_interface_name_renumber_reply_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t node;
918 vat_json_init_object (&node);
919 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
921 vat_json_print (vam->ofp, &node);
922 vat_json_free (&node);
924 vam->retval = ntohl (mp->retval);
925 vam->result_ready = 1;
929 * Special-case: build the interface table, maintain
930 * the next loopback sw_if_index vbl.
932 static void vl_api_sw_interface_details_t_handler
933 (vl_api_sw_interface_details_t * mp)
935 vat_main_t *vam = &vat_main;
936 u8 *s = format (0, "%s%c", mp->interface_name, 0);
938 hash_set_mem (vam->sw_if_index_by_interface_name, s,
939 ntohl (mp->sw_if_index));
941 /* In sub interface case, fill the sub interface table entry */
942 if (mp->sw_if_index != mp->sup_sw_if_index)
944 sw_interface_subif_t *sub = NULL;
946 vec_add2 (vam->sw_if_subif_table, sub, 1);
948 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
949 strncpy ((char *) sub->interface_name, (char *) s,
950 vec_len (sub->interface_name));
951 sub->sw_if_index = ntohl (mp->sw_if_index);
952 sub->sub_id = ntohl (mp->sub_id);
954 sub->sub_dot1ad = mp->sub_dot1ad;
955 sub->sub_number_of_tags = mp->sub_number_of_tags;
956 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
957 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
958 sub->sub_exact_match = mp->sub_exact_match;
959 sub->sub_default = mp->sub_default;
960 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
961 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
963 /* vlan tag rewrite */
964 sub->vtr_op = ntohl (mp->vtr_op);
965 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
966 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
967 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
971 static void vl_api_sw_interface_details_t_handler_json
972 (vl_api_sw_interface_details_t * mp)
974 vat_main_t *vam = &vat_main;
975 vat_json_node_t *node = NULL;
977 if (VAT_JSON_ARRAY != vam->json_tree.type)
979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
980 vat_json_init_array (&vam->json_tree);
982 node = vat_json_array_add (&vam->json_tree);
984 vat_json_init_object (node);
985 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
986 vat_json_object_add_uint (node, "sup_sw_if_index",
987 ntohl (mp->sup_sw_if_index));
988 vat_json_object_add_uint (node, "l2_address_length",
989 ntohl (mp->l2_address_length));
990 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
991 sizeof (mp->l2_address));
992 vat_json_object_add_string_copy (node, "interface_name",
994 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
995 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
996 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
997 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
998 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
999 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1000 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1001 vat_json_object_add_uint (node, "sub_number_of_tags",
1002 mp->sub_number_of_tags);
1003 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1004 ntohs (mp->sub_outer_vlan_id));
1005 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1006 ntohs (mp->sub_inner_vlan_id));
1007 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1008 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1009 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1010 mp->sub_outer_vlan_id_any);
1011 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1012 mp->sub_inner_vlan_id_any);
1013 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1014 vat_json_object_add_uint (node, "vtr_push_dot1q",
1015 ntohl (mp->vtr_push_dot1q));
1016 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1017 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1020 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1022 format_ethernet_address,
1024 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1026 format_ethernet_address,
1028 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1029 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1033 #if VPP_API_TEST_BUILTIN == 0
1034 static void vl_api_sw_interface_event_t_handler
1035 (vl_api_sw_interface_event_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 if (vam->interface_event_display)
1039 errmsg ("interface flags: sw_if_index %d %s %s",
1040 ntohl (mp->sw_if_index),
1041 mp->admin_up_down ? "admin-up" : "admin-down",
1042 mp->link_up_down ? "link-up" : "link-down");
1046 static void vl_api_sw_interface_event_t_handler_json
1047 (vl_api_sw_interface_event_t * mp)
1049 /* JSON output not supported */
1053 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1055 vat_main_t *vam = &vat_main;
1056 i32 retval = ntohl (mp->retval);
1058 vam->retval = retval;
1059 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1060 vam->result_ready = 1;
1064 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1066 vat_main_t *vam = &vat_main;
1067 vat_json_node_t node;
1068 api_main_t *am = &api_main;
1072 vat_json_init_object (&node);
1073 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1074 vat_json_object_add_uint (&node, "reply_in_shmem",
1075 ntohl (mp->reply_in_shmem));
1076 /* Toss the shared-memory original... */
1077 pthread_mutex_lock (&am->vlib_rp->mutex);
1078 oldheap = svm_push_data_heap (am->vlib_rp);
1080 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1083 svm_pop_heap (oldheap);
1084 pthread_mutex_unlock (&am->vlib_rp->mutex);
1086 vat_json_print (vam->ofp, &node);
1087 vat_json_free (&node);
1089 vam->retval = ntohl (mp->retval);
1090 vam->result_ready = 1;
1094 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1096 vat_main_t *vam = &vat_main;
1097 i32 retval = ntohl (mp->retval);
1098 u32 length = ntohl (mp->length);
1100 vec_reset_length (vam->cmd_reply);
1102 vam->retval = retval;
1105 vec_validate (vam->cmd_reply, length);
1106 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1107 vam->cmd_reply[length] = 0;
1109 vam->result_ready = 1;
1113 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1115 vat_main_t *vam = &vat_main;
1116 vat_json_node_t node;
1118 vec_reset_length (vam->cmd_reply);
1120 vat_json_init_object (&node);
1121 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1122 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1124 vat_json_print (vam->ofp, &node);
1125 vat_json_free (&node);
1127 vam->retval = ntohl (mp->retval);
1128 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 i32 retval = ntohl (mp->retval);
1136 if (vam->async_mode)
1138 vam->async_errors += (retval < 0);
1142 vam->retval = retval;
1144 ((mp->new_table_index != 0xFFFFFFFF) ||
1145 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1146 (mp->match_n_vectors != 0xFFFFFFFF)))
1148 * Note: this is just barely thread-safe, depends on
1149 * the main thread spinning waiting for an answer...
1151 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1152 ntohl (mp->new_table_index),
1153 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1154 vam->result_ready = 1;
1158 static void vl_api_classify_add_del_table_reply_t_handler_json
1159 (vl_api_classify_add_del_table_reply_t * mp)
1161 vat_main_t *vam = &vat_main;
1162 vat_json_node_t node;
1164 vat_json_init_object (&node);
1165 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1166 vat_json_object_add_uint (&node, "new_table_index",
1167 ntohl (mp->new_table_index));
1168 vat_json_object_add_uint (&node, "skip_n_vectors",
1169 ntohl (mp->skip_n_vectors));
1170 vat_json_object_add_uint (&node, "match_n_vectors",
1171 ntohl (mp->match_n_vectors));
1173 vat_json_print (vam->ofp, &node);
1174 vat_json_free (&node);
1176 vam->retval = ntohl (mp->retval);
1177 vam->result_ready = 1;
1180 static void vl_api_get_node_index_reply_t_handler
1181 (vl_api_get_node_index_reply_t * mp)
1183 vat_main_t *vam = &vat_main;
1184 i32 retval = ntohl (mp->retval);
1185 if (vam->async_mode)
1187 vam->async_errors += (retval < 0);
1191 vam->retval = retval;
1193 errmsg ("node index %d", ntohl (mp->node_index));
1194 vam->result_ready = 1;
1198 static void vl_api_get_node_index_reply_t_handler_json
1199 (vl_api_get_node_index_reply_t * mp)
1201 vat_main_t *vam = &vat_main;
1202 vat_json_node_t node;
1204 vat_json_init_object (&node);
1205 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1206 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1208 vat_json_print (vam->ofp, &node);
1209 vat_json_free (&node);
1211 vam->retval = ntohl (mp->retval);
1212 vam->result_ready = 1;
1215 static void vl_api_get_next_index_reply_t_handler
1216 (vl_api_get_next_index_reply_t * mp)
1218 vat_main_t *vam = &vat_main;
1219 i32 retval = ntohl (mp->retval);
1220 if (vam->async_mode)
1222 vam->async_errors += (retval < 0);
1226 vam->retval = retval;
1228 errmsg ("next node index %d", ntohl (mp->next_index));
1229 vam->result_ready = 1;
1233 static void vl_api_get_next_index_reply_t_handler_json
1234 (vl_api_get_next_index_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1243 vat_json_print (vam->ofp, &node);
1244 vat_json_free (&node);
1246 vam->retval = ntohl (mp->retval);
1247 vam->result_ready = 1;
1250 static void vl_api_add_node_next_reply_t_handler
1251 (vl_api_add_node_next_reply_t * mp)
1253 vat_main_t *vam = &vat_main;
1254 i32 retval = ntohl (mp->retval);
1255 if (vam->async_mode)
1257 vam->async_errors += (retval < 0);
1261 vam->retval = retval;
1263 errmsg ("next index %d", ntohl (mp->next_index));
1264 vam->result_ready = 1;
1268 static void vl_api_add_node_next_reply_t_handler_json
1269 (vl_api_add_node_next_reply_t * mp)
1271 vat_main_t *vam = &vat_main;
1272 vat_json_node_t node;
1274 vat_json_init_object (&node);
1275 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1276 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1278 vat_json_print (vam->ofp, &node);
1279 vat_json_free (&node);
1281 vam->retval = ntohl (mp->retval);
1282 vam->result_ready = 1;
1285 static void vl_api_show_version_reply_t_handler
1286 (vl_api_show_version_reply_t * mp)
1288 vat_main_t *vam = &vat_main;
1289 i32 retval = ntohl (mp->retval);
1293 errmsg (" program: %s", mp->program);
1294 errmsg (" version: %s", mp->version);
1295 errmsg (" build date: %s", mp->build_date);
1296 errmsg ("build directory: %s", mp->build_directory);
1298 vam->retval = retval;
1299 vam->result_ready = 1;
1302 static void vl_api_show_version_reply_t_handler_json
1303 (vl_api_show_version_reply_t * mp)
1305 vat_main_t *vam = &vat_main;
1306 vat_json_node_t node;
1308 vat_json_init_object (&node);
1309 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1310 vat_json_object_add_string_copy (&node, "program", mp->program);
1311 vat_json_object_add_string_copy (&node, "version", mp->version);
1312 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1313 vat_json_object_add_string_copy (&node, "build_directory",
1314 mp->build_directory);
1316 vat_json_print (vam->ofp, &node);
1317 vat_json_free (&node);
1319 vam->retval = ntohl (mp->retval);
1320 vam->result_ready = 1;
1324 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1326 u32 sw_if_index = ntohl (mp->sw_if_index);
1327 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1328 mp->mac_ip ? "mac/ip binding" : "address resolution",
1329 ntohl (mp->pid), format_ip4_address, &mp->address,
1330 format_ethernet_address, mp->new_mac, sw_if_index);
1334 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1336 /* JSON output not supported */
1340 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1342 u32 sw_if_index = ntohl (mp->sw_if_index);
1343 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1344 mp->mac_ip ? "mac/ip binding" : "address resolution",
1345 ntohl (mp->pid), format_ip6_address, mp->address,
1346 format_ethernet_address, mp->new_mac, sw_if_index);
1350 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1352 /* JSON output not supported */
1356 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1358 u32 n_macs = ntohl (mp->n_macs);
1359 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1360 ntohl (mp->pid), mp->client_index, n_macs);
1362 for (i = 0; i < n_macs; i++)
1364 vl_api_mac_entry_t *mac = &mp->mac[i];
1365 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1366 i + 1, ntohl (mac->sw_if_index),
1367 format_ethernet_address, mac->mac_addr, mac->action);
1374 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1376 /* JSON output not supported */
1379 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1380 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1383 * Special-case: build the bridge domain table, maintain
1384 * the next bd id vbl.
1386 static void vl_api_bridge_domain_details_t_handler
1387 (vl_api_bridge_domain_details_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1393 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1394 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1396 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1397 ntohl (mp->bd_id), mp->learn, mp->forward,
1398 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1402 vl_api_bridge_domain_sw_if_t *sw_ifs;
1403 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1406 sw_ifs = mp->sw_if_details;
1407 for (i = 0; i < n_sw_ifs; i++)
1413 sw_if_index = ntohl (sw_ifs->sw_if_index);
1416 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1418 if ((u32) p->value[0] == sw_if_index)
1420 sw_if_name = (u8 *)(p->key);
1425 print (vam->ofp, "%7d %3d %s", sw_if_index,
1426 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1427 "sw_if_index not found!");
1434 static void vl_api_bridge_domain_details_t_handler_json
1435 (vl_api_bridge_domain_details_t * mp)
1437 vat_main_t *vam = &vat_main;
1438 vat_json_node_t *node, *array = NULL;
1439 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1441 if (VAT_JSON_ARRAY != vam->json_tree.type)
1443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1444 vat_json_init_array (&vam->json_tree);
1446 node = vat_json_array_add (&vam->json_tree);
1448 vat_json_init_object (node);
1449 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1450 vat_json_object_add_uint (node, "flood", mp->flood);
1451 vat_json_object_add_uint (node, "forward", mp->forward);
1452 vat_json_object_add_uint (node, "learn", mp->learn);
1453 vat_json_object_add_uint (node, "bvi_sw_if_index",
1454 ntohl (mp->bvi_sw_if_index));
1455 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1456 array = vat_json_object_add (node, "sw_if");
1457 vat_json_init_array (array);
1463 vl_api_bridge_domain_sw_if_t *sw_ifs;
1466 sw_ifs = mp->sw_if_details;
1467 for (i = 0; i < n_sw_ifs; i++)
1469 node = vat_json_array_add (array);
1470 vat_json_init_object (node);
1471 vat_json_object_add_uint (node, "sw_if_index",
1472 ntohl (sw_ifs->sw_if_index));
1473 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1479 static void vl_api_control_ping_reply_t_handler
1480 (vl_api_control_ping_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->result_ready = 1;
1493 if (vam->socket_client_main)
1494 vam->socket_client_main->control_pings_outstanding--;
1497 static void vl_api_control_ping_reply_t_handler_json
1498 (vl_api_control_ping_reply_t * mp)
1500 vat_main_t *vam = &vat_main;
1501 i32 retval = ntohl (mp->retval);
1503 if (VAT_JSON_NONE != vam->json_tree.type)
1505 vat_json_print (vam->ofp, &vam->json_tree);
1506 vat_json_free (&vam->json_tree);
1507 vam->json_tree.type = VAT_JSON_NONE;
1512 vat_json_init_array (&vam->json_tree);
1513 vat_json_print (vam->ofp, &vam->json_tree);
1514 vam->json_tree.type = VAT_JSON_NONE;
1517 vam->retval = retval;
1518 vam->result_ready = 1;
1522 vl_api_bridge_domain_set_mac_age_reply_t_handler
1523 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1525 vat_main_t *vam = &vat_main;
1526 i32 retval = ntohl (mp->retval);
1527 if (vam->async_mode)
1529 vam->async_errors += (retval < 0);
1533 vam->retval = retval;
1534 vam->result_ready = 1;
1538 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1539 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1541 vat_main_t *vam = &vat_main;
1542 vat_json_node_t node;
1544 vat_json_init_object (&node);
1545 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1547 vat_json_print (vam->ofp, &node);
1548 vat_json_free (&node);
1550 vam->retval = ntohl (mp->retval);
1551 vam->result_ready = 1;
1555 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1557 vat_main_t *vam = &vat_main;
1558 i32 retval = ntohl (mp->retval);
1559 if (vam->async_mode)
1561 vam->async_errors += (retval < 0);
1565 vam->retval = retval;
1566 vam->result_ready = 1;
1570 static void vl_api_l2_flags_reply_t_handler_json
1571 (vl_api_l2_flags_reply_t * mp)
1573 vat_main_t *vam = &vat_main;
1574 vat_json_node_t node;
1576 vat_json_init_object (&node);
1577 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1578 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1579 ntohl (mp->resulting_feature_bitmap));
1581 vat_json_print (vam->ofp, &node);
1582 vat_json_free (&node);
1584 vam->retval = ntohl (mp->retval);
1585 vam->result_ready = 1;
1588 static void vl_api_bridge_flags_reply_t_handler
1589 (vl_api_bridge_flags_reply_t * mp)
1591 vat_main_t *vam = &vat_main;
1592 i32 retval = ntohl (mp->retval);
1593 if (vam->async_mode)
1595 vam->async_errors += (retval < 0);
1599 vam->retval = retval;
1600 vam->result_ready = 1;
1604 static void vl_api_bridge_flags_reply_t_handler_json
1605 (vl_api_bridge_flags_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1613 ntohl (mp->resulting_feature_bitmap));
1615 vat_json_print (vam->ofp, &node);
1616 vat_json_free (&node);
1618 vam->retval = ntohl (mp->retval);
1619 vam->result_ready = 1;
1622 static void vl_api_tap_connect_reply_t_handler
1623 (vl_api_tap_connect_reply_t * mp)
1625 vat_main_t *vam = &vat_main;
1626 i32 retval = ntohl (mp->retval);
1627 if (vam->async_mode)
1629 vam->async_errors += (retval < 0);
1633 vam->retval = retval;
1634 vam->sw_if_index = ntohl (mp->sw_if_index);
1635 vam->result_ready = 1;
1640 static void vl_api_tap_connect_reply_t_handler_json
1641 (vl_api_tap_connect_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1648 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1650 vat_json_print (vam->ofp, &node);
1651 vat_json_free (&node);
1653 vam->retval = ntohl (mp->retval);
1654 vam->result_ready = 1;
1659 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->sw_if_index = ntohl (mp->sw_if_index);
1671 vam->result_ready = 1;
1675 static void vl_api_tap_modify_reply_t_handler_json
1676 (vl_api_tap_modify_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1693 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 i32 retval = ntohl (mp->retval);
1697 if (vam->async_mode)
1699 vam->async_errors += (retval < 0);
1703 vam->retval = retval;
1704 vam->result_ready = 1;
1708 static void vl_api_tap_delete_reply_t_handler_json
1709 (vl_api_tap_delete_reply_t * mp)
1711 vat_main_t *vam = &vat_main;
1712 vat_json_node_t node;
1714 vat_json_init_object (&node);
1715 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1717 vat_json_print (vam->ofp, &node);
1718 vat_json_free (&node);
1720 vam->retval = ntohl (mp->retval);
1721 vam->result_ready = 1;
1725 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1727 vat_main_t *vam = &vat_main;
1728 i32 retval = ntohl (mp->retval);
1729 if (vam->async_mode)
1731 vam->async_errors += (retval < 0);
1735 vam->retval = retval;
1736 vam->sw_if_index = ntohl (mp->sw_if_index);
1737 vam->result_ready = 1;
1742 static void vl_api_tap_create_v2_reply_t_handler_json
1743 (vl_api_tap_create_v2_reply_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t node;
1748 vat_json_init_object (&node);
1749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1752 vat_json_print (vam->ofp, &node);
1753 vat_json_free (&node);
1755 vam->retval = ntohl (mp->retval);
1756 vam->result_ready = 1;
1761 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1763 vat_main_t *vam = &vat_main;
1764 i32 retval = ntohl (mp->retval);
1765 if (vam->async_mode)
1767 vam->async_errors += (retval < 0);
1771 vam->retval = retval;
1772 vam->result_ready = 1;
1776 static void vl_api_tap_delete_v2_reply_t_handler_json
1777 (vl_api_tap_delete_v2_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 vat_json_node_t node;
1782 vat_json_init_object (&node);
1783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1785 vat_json_print (vam->ofp, &node);
1786 vat_json_free (&node);
1788 vam->retval = ntohl (mp->retval);
1789 vam->result_ready = 1;
1793 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1795 vat_main_t *vam = &vat_main;
1796 i32 retval = ntohl (mp->retval);
1798 if (vam->async_mode)
1800 vam->async_errors += (retval < 0);
1804 vam->retval = retval;
1805 vam->sw_if_index = ntohl (mp->sw_if_index);
1806 vam->result_ready = 1;
1810 static void vl_api_bond_create_reply_t_handler_json
1811 (vl_api_bond_create_reply_t * mp)
1813 vat_main_t *vam = &vat_main;
1814 vat_json_node_t node;
1816 vat_json_init_object (&node);
1817 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1818 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1820 vat_json_print (vam->ofp, &node);
1821 vat_json_free (&node);
1823 vam->retval = ntohl (mp->retval);
1824 vam->result_ready = 1;
1828 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 i32 retval = ntohl (mp->retval);
1833 if (vam->async_mode)
1835 vam->async_errors += (retval < 0);
1839 vam->retval = retval;
1840 vam->result_ready = 1;
1844 static void vl_api_bond_delete_reply_t_handler_json
1845 (vl_api_bond_delete_reply_t * mp)
1847 vat_main_t *vam = &vat_main;
1848 vat_json_node_t node;
1850 vat_json_init_object (&node);
1851 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1853 vat_json_print (vam->ofp, &node);
1854 vat_json_free (&node);
1856 vam->retval = ntohl (mp->retval);
1857 vam->result_ready = 1;
1861 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1863 vat_main_t *vam = &vat_main;
1864 i32 retval = ntohl (mp->retval);
1866 if (vam->async_mode)
1868 vam->async_errors += (retval < 0);
1872 vam->retval = retval;
1873 vam->result_ready = 1;
1877 static void vl_api_bond_enslave_reply_t_handler_json
1878 (vl_api_bond_enslave_reply_t * mp)
1880 vat_main_t *vam = &vat_main;
1881 vat_json_node_t node;
1883 vat_json_init_object (&node);
1884 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1886 vat_json_print (vam->ofp, &node);
1887 vat_json_free (&node);
1889 vam->retval = ntohl (mp->retval);
1890 vam->result_ready = 1;
1894 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1897 vat_main_t *vam = &vat_main;
1898 i32 retval = ntohl (mp->retval);
1900 if (vam->async_mode)
1902 vam->async_errors += (retval < 0);
1906 vam->retval = retval;
1907 vam->result_ready = 1;
1911 static void vl_api_bond_detach_slave_reply_t_handler_json
1912 (vl_api_bond_detach_slave_reply_t * mp)
1914 vat_main_t *vam = &vat_main;
1915 vat_json_node_t node;
1917 vat_json_init_object (&node);
1918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1920 vat_json_print (vam->ofp, &node);
1921 vat_json_free (&node);
1923 vam->retval = ntohl (mp->retval);
1924 vam->result_ready = 1;
1927 static void vl_api_sw_interface_bond_details_t_handler
1928 (vl_api_sw_interface_bond_details_t * mp)
1930 vat_main_t *vam = &vat_main;
1933 "%-16s %-12d %-12U %-13U %-14u %-14u",
1934 mp->interface_name, ntohl (mp->sw_if_index),
1935 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1936 ntohl (mp->active_slaves), ntohl (mp->slaves));
1939 static void vl_api_sw_interface_bond_details_t_handler_json
1940 (vl_api_sw_interface_bond_details_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 vat_json_node_t *node = NULL;
1945 if (VAT_JSON_ARRAY != vam->json_tree.type)
1947 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1948 vat_json_init_array (&vam->json_tree);
1950 node = vat_json_array_add (&vam->json_tree);
1952 vat_json_init_object (node);
1953 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1954 vat_json_object_add_string_copy (node, "interface_name",
1955 mp->interface_name);
1956 vat_json_object_add_uint (node, "mode", mp->mode);
1957 vat_json_object_add_uint (node, "load_balance", mp->lb);
1958 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1959 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1963 api_sw_interface_bond_dump (vat_main_t * vam)
1965 vl_api_sw_interface_bond_dump_t *mp;
1966 vl_api_control_ping_t *mp_ping;
1970 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1971 "interface name", "sw_if_index", "mode", "load balance",
1972 "active slaves", "slaves");
1974 /* Get list of bond interfaces */
1975 M (SW_INTERFACE_BOND_DUMP, mp);
1978 /* Use a control ping for synchronization */
1979 MPING (CONTROL_PING, mp_ping);
1986 static void vl_api_sw_interface_slave_details_t_handler
1987 (vl_api_sw_interface_slave_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1992 "%-25s %-12d %-12d %d", mp->interface_name,
1993 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1996 static void vl_api_sw_interface_slave_details_t_handler_json
1997 (vl_api_sw_interface_slave_details_t * mp)
1999 vat_main_t *vam = &vat_main;
2000 vat_json_node_t *node = NULL;
2002 if (VAT_JSON_ARRAY != vam->json_tree.type)
2004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2005 vat_json_init_array (&vam->json_tree);
2007 node = vat_json_array_add (&vam->json_tree);
2009 vat_json_init_object (node);
2010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2011 vat_json_object_add_string_copy (node, "interface_name",
2012 mp->interface_name);
2013 vat_json_object_add_uint (node, "passive", mp->is_passive);
2014 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2018 api_sw_interface_slave_dump (vat_main_t * vam)
2020 unformat_input_t *i = vam->input;
2021 vl_api_sw_interface_slave_dump_t *mp;
2022 vl_api_control_ping_t *mp_ping;
2023 u32 sw_if_index = ~0;
2024 u8 sw_if_index_set = 0;
2027 /* Parse args required to build the message */
2028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2031 sw_if_index_set = 1;
2032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2033 sw_if_index_set = 1;
2038 if (sw_if_index_set == 0)
2040 errmsg ("missing vpp interface name. ");
2045 "\n%-25s %-12s %-12s %s",
2046 "slave interface name", "sw_if_index", "passive", "long_timeout");
2048 /* Get list of bond interfaces */
2049 M (SW_INTERFACE_SLAVE_DUMP, mp);
2050 mp->sw_if_index = ntohl (sw_if_index);
2053 /* Use a control ping for synchronization */
2054 MPING (CONTROL_PING, mp_ping);
2061 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2062 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2064 vat_main_t *vam = &vat_main;
2065 i32 retval = ntohl (mp->retval);
2066 if (vam->async_mode)
2068 vam->async_errors += (retval < 0);
2072 vam->retval = retval;
2073 vam->result_ready = 1;
2077 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2078 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2080 vat_main_t *vam = &vat_main;
2081 vat_json_node_t node;
2083 vat_json_init_object (&node);
2084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2085 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2086 ntohl (mp->sw_if_index));
2088 vat_json_print (vam->ofp, &node);
2089 vat_json_free (&node);
2091 vam->retval = ntohl (mp->retval);
2092 vam->result_ready = 1;
2095 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2096 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2098 vat_main_t *vam = &vat_main;
2099 i32 retval = ntohl (mp->retval);
2100 if (vam->async_mode)
2102 vam->async_errors += (retval < 0);
2106 vam->retval = retval;
2107 vam->sw_if_index = ntohl (mp->sw_if_index);
2108 vam->result_ready = 1;
2112 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2113 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t node;
2118 vat_json_init_object (&node);
2119 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2120 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2122 vat_json_print (vam->ofp, &node);
2123 vat_json_free (&node);
2125 vam->retval = ntohl (mp->retval);
2126 vam->result_ready = 1;
2129 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2130 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2132 vat_main_t *vam = &vat_main;
2133 i32 retval = ntohl (mp->retval);
2134 if (vam->async_mode)
2136 vam->async_errors += (retval < 0);
2140 vam->retval = retval;
2141 vam->result_ready = 1;
2145 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2146 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2148 vat_main_t *vam = &vat_main;
2149 vat_json_node_t node;
2151 vat_json_init_object (&node);
2152 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2153 vat_json_object_add_uint (&node, "fwd_entry_index",
2154 clib_net_to_host_u32 (mp->fwd_entry_index));
2156 vat_json_print (vam->ofp, &node);
2157 vat_json_free (&node);
2159 vam->retval = ntohl (mp->retval);
2160 vam->result_ready = 1;
2164 format_lisp_transport_protocol (u8 * s, va_list * args)
2166 u32 proto = va_arg (*args, u32);
2171 return format (s, "udp");
2173 return format (s, "api");
2180 static void vl_api_one_get_transport_protocol_reply_t_handler
2181 (vl_api_one_get_transport_protocol_reply_t * mp)
2183 vat_main_t *vam = &vat_main;
2184 i32 retval = ntohl (mp->retval);
2185 if (vam->async_mode)
2187 vam->async_errors += (retval < 0);
2191 u32 proto = mp->protocol;
2192 print (vam->ofp, "Transport protocol: %U",
2193 format_lisp_transport_protocol, proto);
2194 vam->retval = retval;
2195 vam->result_ready = 1;
2199 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2200 (vl_api_one_get_transport_protocol_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vat_json_node_t node;
2206 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2209 vat_json_init_object (&node);
2210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2211 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2214 vat_json_print (vam->ofp, &node);
2215 vat_json_free (&node);
2217 vam->retval = ntohl (mp->retval);
2218 vam->result_ready = 1;
2221 static void vl_api_one_add_del_locator_set_reply_t_handler
2222 (vl_api_one_add_del_locator_set_reply_t * mp)
2224 vat_main_t *vam = &vat_main;
2225 i32 retval = ntohl (mp->retval);
2226 if (vam->async_mode)
2228 vam->async_errors += (retval < 0);
2232 vam->retval = retval;
2233 vam->result_ready = 1;
2237 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2238 (vl_api_one_add_del_locator_set_reply_t * mp)
2240 vat_main_t *vam = &vat_main;
2241 vat_json_node_t node;
2243 vat_json_init_object (&node);
2244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2245 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2247 vat_json_print (vam->ofp, &node);
2248 vat_json_free (&node);
2250 vam->retval = ntohl (mp->retval);
2251 vam->result_ready = 1;
2254 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2255 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 i32 retval = ntohl (mp->retval);
2259 if (vam->async_mode)
2261 vam->async_errors += (retval < 0);
2265 vam->retval = retval;
2266 vam->sw_if_index = ntohl (mp->sw_if_index);
2267 vam->result_ready = 1;
2269 vam->regenerate_interface_table = 1;
2272 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2273 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2275 vat_main_t *vam = &vat_main;
2276 vat_json_node_t node;
2278 vat_json_init_object (&node);
2279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2282 vat_json_print (vam->ofp, &node);
2283 vat_json_free (&node);
2285 vam->retval = ntohl (mp->retval);
2286 vam->result_ready = 1;
2289 static void vl_api_vxlan_offload_rx_reply_t_handler
2290 (vl_api_vxlan_offload_rx_reply_t * mp)
2292 vat_main_t *vam = &vat_main;
2293 i32 retval = ntohl (mp->retval);
2294 if (vam->async_mode)
2296 vam->async_errors += (retval < 0);
2300 vam->retval = retval;
2301 vam->result_ready = 1;
2305 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2306 (vl_api_vxlan_offload_rx_reply_t * mp)
2308 vat_main_t *vam = &vat_main;
2309 vat_json_node_t node;
2311 vat_json_init_object (&node);
2312 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2314 vat_json_print (vam->ofp, &node);
2315 vat_json_free (&node);
2317 vam->retval = ntohl (mp->retval);
2318 vam->result_ready = 1;
2321 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2322 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2324 vat_main_t *vam = &vat_main;
2325 i32 retval = ntohl (mp->retval);
2326 if (vam->async_mode)
2328 vam->async_errors += (retval < 0);
2332 vam->retval = retval;
2333 vam->sw_if_index = ntohl (mp->sw_if_index);
2334 vam->result_ready = 1;
2338 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2339 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2341 vat_main_t *vam = &vat_main;
2342 vat_json_node_t node;
2344 vat_json_init_object (&node);
2345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2346 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2348 vat_json_print (vam->ofp, &node);
2349 vat_json_free (&node);
2351 vam->retval = ntohl (mp->retval);
2352 vam->result_ready = 1;
2355 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2356 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 i32 retval = ntohl (mp->retval);
2360 if (vam->async_mode)
2362 vam->async_errors += (retval < 0);
2366 vam->retval = retval;
2367 vam->sw_if_index = ntohl (mp->sw_if_index);
2368 vam->result_ready = 1;
2370 vam->regenerate_interface_table = 1;
2373 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2374 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2376 vat_main_t *vam = &vat_main;
2377 vat_json_node_t node;
2379 vat_json_init_object (&node);
2380 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2381 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2383 vat_json_print (vam->ofp, &node);
2384 vat_json_free (&node);
2386 vam->retval = ntohl (mp->retval);
2387 vam->result_ready = 1;
2390 static void vl_api_gre_add_del_tunnel_reply_t_handler
2391 (vl_api_gre_add_del_tunnel_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 i32 retval = ntohl (mp->retval);
2395 if (vam->async_mode)
2397 vam->async_errors += (retval < 0);
2401 vam->retval = retval;
2402 vam->sw_if_index = ntohl (mp->sw_if_index);
2403 vam->result_ready = 1;
2407 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2408 (vl_api_gre_add_del_tunnel_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 vat_json_node_t node;
2413 vat_json_init_object (&node);
2414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2415 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2417 vat_json_print (vam->ofp, &node);
2418 vat_json_free (&node);
2420 vam->retval = ntohl (mp->retval);
2421 vam->result_ready = 1;
2424 static void vl_api_create_vhost_user_if_reply_t_handler
2425 (vl_api_create_vhost_user_if_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 i32 retval = ntohl (mp->retval);
2429 if (vam->async_mode)
2431 vam->async_errors += (retval < 0);
2435 vam->retval = retval;
2436 vam->sw_if_index = ntohl (mp->sw_if_index);
2437 vam->result_ready = 1;
2439 vam->regenerate_interface_table = 1;
2442 static void vl_api_create_vhost_user_if_reply_t_handler_json
2443 (vl_api_create_vhost_user_if_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 vat_json_node_t node;
2448 vat_json_init_object (&node);
2449 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2450 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2452 vat_json_print (vam->ofp, &node);
2453 vat_json_free (&node);
2455 vam->retval = ntohl (mp->retval);
2456 vam->result_ready = 1;
2459 static void vl_api_dns_resolve_name_reply_t_handler
2460 (vl_api_dns_resolve_name_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 i32 retval = ntohl (mp->retval);
2464 if (vam->async_mode)
2466 vam->async_errors += (retval < 0);
2470 vam->retval = retval;
2471 vam->result_ready = 1;
2476 clib_warning ("ip4 address %U", format_ip4_address,
2477 (ip4_address_t *) mp->ip4_address);
2479 clib_warning ("ip6 address %U", format_ip6_address,
2480 (ip6_address_t *) mp->ip6_address);
2483 clib_warning ("retval %d", retval);
2487 static void vl_api_dns_resolve_name_reply_t_handler_json
2488 (vl_api_dns_resolve_name_reply_t * mp)
2490 clib_warning ("not implemented");
2493 static void vl_api_dns_resolve_ip_reply_t_handler
2494 (vl_api_dns_resolve_ip_reply_t * mp)
2496 vat_main_t *vam = &vat_main;
2497 i32 retval = ntohl (mp->retval);
2498 if (vam->async_mode)
2500 vam->async_errors += (retval < 0);
2504 vam->retval = retval;
2505 vam->result_ready = 1;
2509 clib_warning ("canonical name %s", mp->name);
2512 clib_warning ("retval %d", retval);
2516 static void vl_api_dns_resolve_ip_reply_t_handler_json
2517 (vl_api_dns_resolve_ip_reply_t * mp)
2519 clib_warning ("not implemented");
2523 static void vl_api_ip_address_details_t_handler
2524 (vl_api_ip_address_details_t * mp)
2526 vat_main_t *vam = &vat_main;
2527 static ip_address_details_t empty_ip_address_details = { {0} };
2528 ip_address_details_t *address = NULL;
2529 ip_details_t *current_ip_details = NULL;
2530 ip_details_t *details = NULL;
2532 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2534 if (!details || vam->current_sw_if_index >= vec_len (details)
2535 || !details[vam->current_sw_if_index].present)
2537 errmsg ("ip address details arrived but not stored");
2538 errmsg ("ip_dump should be called first");
2542 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2544 #define addresses (current_ip_details->addr)
2546 vec_validate_init_empty (addresses, vec_len (addresses),
2547 empty_ip_address_details);
2549 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2551 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2552 address->prefix_length = mp->prefix_length;
2556 static void vl_api_ip_address_details_t_handler_json
2557 (vl_api_ip_address_details_t * mp)
2559 vat_main_t *vam = &vat_main;
2560 vat_json_node_t *node = NULL;
2561 struct in6_addr ip6;
2564 if (VAT_JSON_ARRAY != vam->json_tree.type)
2566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2567 vat_json_init_array (&vam->json_tree);
2569 node = vat_json_array_add (&vam->json_tree);
2571 vat_json_init_object (node);
2574 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2575 vat_json_object_add_ip6 (node, "ip", ip6);
2579 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2580 vat_json_object_add_ip4 (node, "ip", ip4);
2582 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2586 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 static ip_details_t empty_ip_details = { 0 };
2590 ip_details_t *ip = NULL;
2591 u32 sw_if_index = ~0;
2593 sw_if_index = ntohl (mp->sw_if_index);
2595 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2596 sw_if_index, empty_ip_details);
2598 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2605 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2607 vat_main_t *vam = &vat_main;
2609 if (VAT_JSON_ARRAY != vam->json_tree.type)
2611 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2612 vat_json_init_array (&vam->json_tree);
2614 vat_json_array_add_uint (&vam->json_tree,
2615 clib_net_to_host_u32 (mp->sw_if_index));
2618 static void vl_api_map_domain_details_t_handler_json
2619 (vl_api_map_domain_details_t * mp)
2621 vat_json_node_t *node = NULL;
2622 vat_main_t *vam = &vat_main;
2623 struct in6_addr ip6;
2626 if (VAT_JSON_ARRAY != vam->json_tree.type)
2628 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2629 vat_json_init_array (&vam->json_tree);
2632 node = vat_json_array_add (&vam->json_tree);
2633 vat_json_init_object (node);
2635 vat_json_object_add_uint (node, "domain_index",
2636 clib_net_to_host_u32 (mp->domain_index));
2637 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2638 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2639 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2640 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2641 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2642 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2643 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2644 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2645 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2646 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2647 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2648 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2649 vat_json_object_add_uint (node, "flags", mp->flags);
2650 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2651 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2654 static void vl_api_map_domain_details_t_handler
2655 (vl_api_map_domain_details_t * mp)
2657 vat_main_t *vam = &vat_main;
2659 if (mp->is_translation)
2662 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2663 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2664 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2665 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2666 clib_net_to_host_u32 (mp->domain_index));
2671 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2672 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2673 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2674 format_ip6_address, mp->ip6_src,
2675 clib_net_to_host_u32 (mp->domain_index));
2677 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2678 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2679 mp->is_translation ? "map-t" : "");
2682 static void vl_api_map_rule_details_t_handler_json
2683 (vl_api_map_rule_details_t * mp)
2685 struct in6_addr ip6;
2686 vat_json_node_t *node = NULL;
2687 vat_main_t *vam = &vat_main;
2689 if (VAT_JSON_ARRAY != vam->json_tree.type)
2691 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2692 vat_json_init_array (&vam->json_tree);
2695 node = vat_json_array_add (&vam->json_tree);
2696 vat_json_init_object (node);
2698 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2699 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2700 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2704 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2708 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2712 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2714 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2715 "router_addr %U host_mac %U",
2716 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2718 format_ip4_address, &mp->lease.host_address,
2719 format_ip4_address, &mp->lease.router_address,
2720 format_ethernet_address, mp->lease.host_mac);
2723 static void vl_api_dhcp_compl_event_t_handler_json
2724 (vl_api_dhcp_compl_event_t * mp)
2726 /* JSON output not supported */
2730 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2733 vat_main_t *vam = &vat_main;
2734 static u64 default_counter = 0;
2736 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2738 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2739 sw_if_index, default_counter);
2740 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2744 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2745 interface_counter_t counter)
2747 vat_main_t *vam = &vat_main;
2748 static interface_counter_t default_counter = { 0, };
2750 vec_validate_init_empty (vam->combined_interface_counters,
2751 vnet_counter_type, NULL);
2752 vec_validate_init_empty (vam->combined_interface_counters
2753 [vnet_counter_type], sw_if_index, default_counter);
2754 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2757 static void vl_api_vnet_interface_simple_counters_t_handler
2758 (vl_api_vnet_interface_simple_counters_t * mp)
2763 static void vl_api_vnet_interface_combined_counters_t_handler
2764 (vl_api_vnet_interface_combined_counters_t * mp)
2769 static void vl_api_vnet_interface_simple_counters_t_handler_json
2770 (vl_api_vnet_interface_simple_counters_t * mp)
2775 u32 first_sw_if_index;
2778 count = ntohl (mp->count);
2779 first_sw_if_index = ntohl (mp->first_sw_if_index);
2781 v_packets = (u64 *) & mp->data;
2782 for (i = 0; i < count; i++)
2784 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2785 set_simple_interface_counter (mp->vnet_counter_type,
2786 first_sw_if_index + i, packets);
2791 static void vl_api_vnet_interface_combined_counters_t_handler_json
2792 (vl_api_vnet_interface_combined_counters_t * mp)
2794 interface_counter_t counter;
2796 u32 first_sw_if_index;
2800 count = ntohl (mp->count);
2801 first_sw_if_index = ntohl (mp->first_sw_if_index);
2803 v = (vlib_counter_t *) & mp->data;
2804 for (i = 0; i < count; i++)
2807 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2809 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2810 set_combined_interface_counter (mp->vnet_counter_type,
2811 first_sw_if_index + i, counter);
2817 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2819 vat_main_t *vam = &vat_main;
2822 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2824 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2833 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2835 vat_main_t *vam = &vat_main;
2838 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2840 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2848 static void vl_api_vnet_ip4_fib_counters_t_handler
2849 (vl_api_vnet_ip4_fib_counters_t * mp)
2854 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2855 (vl_api_vnet_ip4_fib_counters_t * mp)
2857 vat_main_t *vam = &vat_main;
2858 vl_api_ip4_fib_counter_t *v;
2859 ip4_fib_counter_t *counter;
2866 vrf_id = ntohl (mp->vrf_id);
2867 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2868 if (~0 == vrf_index)
2870 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2871 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2872 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2873 vec_validate (vam->ip4_fib_counters, vrf_index);
2874 vam->ip4_fib_counters[vrf_index] = NULL;
2877 vec_free (vam->ip4_fib_counters[vrf_index]);
2878 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2879 count = ntohl (mp->count);
2880 for (i = 0; i < count; i++)
2882 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2883 counter = &vam->ip4_fib_counters[vrf_index][i];
2884 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2885 counter->address = ip4;
2886 counter->address_length = v->address_length;
2887 counter->packets = clib_net_to_host_u64 (v->packets);
2888 counter->bytes = clib_net_to_host_u64 (v->bytes);
2893 static void vl_api_vnet_ip4_nbr_counters_t_handler
2894 (vl_api_vnet_ip4_nbr_counters_t * mp)
2899 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2900 (vl_api_vnet_ip4_nbr_counters_t * mp)
2902 vat_main_t *vam = &vat_main;
2903 vl_api_ip4_nbr_counter_t *v;
2904 ip4_nbr_counter_t *counter;
2909 sw_if_index = ntohl (mp->sw_if_index);
2910 count = ntohl (mp->count);
2911 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2914 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2916 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2917 for (i = 0; i < count; i++)
2919 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2920 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2921 counter->address.s_addr = v->address;
2922 counter->packets = clib_net_to_host_u64 (v->packets);
2923 counter->bytes = clib_net_to_host_u64 (v->bytes);
2924 counter->linkt = v->link_type;
2929 static void vl_api_vnet_ip6_fib_counters_t_handler
2930 (vl_api_vnet_ip6_fib_counters_t * mp)
2935 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2936 (vl_api_vnet_ip6_fib_counters_t * mp)
2938 vat_main_t *vam = &vat_main;
2939 vl_api_ip6_fib_counter_t *v;
2940 ip6_fib_counter_t *counter;
2941 struct in6_addr ip6;
2947 vrf_id = ntohl (mp->vrf_id);
2948 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2949 if (~0 == vrf_index)
2951 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2952 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2953 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2954 vec_validate (vam->ip6_fib_counters, vrf_index);
2955 vam->ip6_fib_counters[vrf_index] = NULL;
2958 vec_free (vam->ip6_fib_counters[vrf_index]);
2959 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2960 count = ntohl (mp->count);
2961 for (i = 0; i < count; i++)
2963 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2964 counter = &vam->ip6_fib_counters[vrf_index][i];
2965 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2966 counter->address = ip6;
2967 counter->address_length = v->address_length;
2968 counter->packets = clib_net_to_host_u64 (v->packets);
2969 counter->bytes = clib_net_to_host_u64 (v->bytes);
2974 static void vl_api_vnet_ip6_nbr_counters_t_handler
2975 (vl_api_vnet_ip6_nbr_counters_t * mp)
2980 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2981 (vl_api_vnet_ip6_nbr_counters_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 vl_api_ip6_nbr_counter_t *v;
2985 ip6_nbr_counter_t *counter;
2986 struct in6_addr ip6;
2991 sw_if_index = ntohl (mp->sw_if_index);
2992 count = ntohl (mp->count);
2993 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2996 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2998 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2999 for (i = 0; i < count; i++)
3001 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3002 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3003 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3004 counter->address = ip6;
3005 counter->packets = clib_net_to_host_u64 (v->packets);
3006 counter->bytes = clib_net_to_host_u64 (v->bytes);
3011 static void vl_api_get_first_msg_id_reply_t_handler
3012 (vl_api_get_first_msg_id_reply_t * mp)
3014 vat_main_t *vam = &vat_main;
3015 i32 retval = ntohl (mp->retval);
3017 if (vam->async_mode)
3019 vam->async_errors += (retval < 0);
3023 vam->retval = retval;
3024 vam->result_ready = 1;
3028 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3032 static void vl_api_get_first_msg_id_reply_t_handler_json
3033 (vl_api_get_first_msg_id_reply_t * mp)
3035 vat_main_t *vam = &vat_main;
3036 vat_json_node_t node;
3038 vat_json_init_object (&node);
3039 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3040 vat_json_object_add_uint (&node, "first_msg_id",
3041 (uint) ntohs (mp->first_msg_id));
3043 vat_json_print (vam->ofp, &node);
3044 vat_json_free (&node);
3046 vam->retval = ntohl (mp->retval);
3047 vam->result_ready = 1;
3050 static void vl_api_get_node_graph_reply_t_handler
3051 (vl_api_get_node_graph_reply_t * mp)
3053 vat_main_t *vam = &vat_main;
3054 api_main_t *am = &api_main;
3055 i32 retval = ntohl (mp->retval);
3056 u8 *pvt_copy, *reply;
3061 if (vam->async_mode)
3063 vam->async_errors += (retval < 0);
3067 vam->retval = retval;
3068 vam->result_ready = 1;
3071 /* "Should never happen..." */
3075 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3076 pvt_copy = vec_dup (reply);
3078 /* Toss the shared-memory original... */
3079 pthread_mutex_lock (&am->vlib_rp->mutex);
3080 oldheap = svm_push_data_heap (am->vlib_rp);
3084 svm_pop_heap (oldheap);
3085 pthread_mutex_unlock (&am->vlib_rp->mutex);
3087 if (vam->graph_nodes)
3089 hash_free (vam->graph_node_index_by_name);
3091 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3093 node = vam->graph_nodes[0][i];
3094 vec_free (node->name);
3095 vec_free (node->next_nodes);
3098 vec_free (vam->graph_nodes[0]);
3099 vec_free (vam->graph_nodes);
3102 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3103 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3104 vec_free (pvt_copy);
3106 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3108 node = vam->graph_nodes[0][i];
3109 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3113 static void vl_api_get_node_graph_reply_t_handler_json
3114 (vl_api_get_node_graph_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 api_main_t *am = &api_main;
3119 vat_json_node_t node;
3122 /* $$$$ make this real? */
3123 vat_json_init_object (&node);
3124 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3125 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3127 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3129 /* Toss the shared-memory original... */
3130 pthread_mutex_lock (&am->vlib_rp->mutex);
3131 oldheap = svm_push_data_heap (am->vlib_rp);
3135 svm_pop_heap (oldheap);
3136 pthread_mutex_unlock (&am->vlib_rp->mutex);
3138 vat_json_print (vam->ofp, &node);
3139 vat_json_free (&node);
3141 vam->retval = ntohl (mp->retval);
3142 vam->result_ready = 1;
3146 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3148 vat_main_t *vam = &vat_main;
3153 s = format (s, "%=16d%=16d%=16d",
3154 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3158 s = format (s, "%=16U%=16d%=16d",
3159 mp->is_ipv6 ? format_ip6_address :
3161 mp->ip_address, mp->priority, mp->weight);
3164 print (vam->ofp, "%v", s);
3169 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3171 vat_main_t *vam = &vat_main;
3172 vat_json_node_t *node = NULL;
3173 struct in6_addr ip6;
3176 if (VAT_JSON_ARRAY != vam->json_tree.type)
3178 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3179 vat_json_init_array (&vam->json_tree);
3181 node = vat_json_array_add (&vam->json_tree);
3182 vat_json_init_object (node);
3184 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3185 vat_json_object_add_uint (node, "priority", mp->priority);
3186 vat_json_object_add_uint (node, "weight", mp->weight);
3189 vat_json_object_add_uint (node, "sw_if_index",
3190 clib_net_to_host_u32 (mp->sw_if_index));
3195 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3196 vat_json_object_add_ip6 (node, "address", ip6);
3200 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3201 vat_json_object_add_ip4 (node, "address", ip4);
3207 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3210 vat_main_t *vam = &vat_main;
3213 ls_name = format (0, "%s", mp->ls_name);
3215 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3221 vl_api_one_locator_set_details_t_handler_json
3222 (vl_api_one_locator_set_details_t * mp)
3224 vat_main_t *vam = &vat_main;
3225 vat_json_node_t *node = 0;
3228 ls_name = format (0, "%s", mp->ls_name);
3229 vec_add1 (ls_name, 0);
3231 if (VAT_JSON_ARRAY != vam->json_tree.type)
3233 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3234 vat_json_init_array (&vam->json_tree);
3236 node = vat_json_array_add (&vam->json_tree);
3238 vat_json_init_object (node);
3239 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3240 vat_json_object_add_uint (node, "ls_index",
3241 clib_net_to_host_u32 (mp->ls_index));
3249 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3252 unformat_nsh_address (unformat_input_t * input, va_list * args)
3254 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3255 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3259 format_nsh_address_vat (u8 * s, va_list * args)
3261 nsh_t *a = va_arg (*args, nsh_t *);
3262 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3266 format_lisp_flat_eid (u8 * s, va_list * args)
3268 u32 type = va_arg (*args, u32);
3269 u8 *eid = va_arg (*args, u8 *);
3270 u32 eid_len = va_arg (*args, u32);
3275 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3277 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3279 return format (s, "%U", format_ethernet_address, eid);
3281 return format (s, "%U", format_nsh_address_vat, eid);
3287 format_lisp_eid_vat (u8 * s, va_list * args)
3289 u32 type = va_arg (*args, u32);
3290 u8 *eid = va_arg (*args, u8 *);
3291 u32 eid_len = va_arg (*args, u32);
3292 u8 *seid = va_arg (*args, u8 *);
3293 u32 seid_len = va_arg (*args, u32);
3294 u32 is_src_dst = va_arg (*args, u32);
3297 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3299 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3305 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3307 vat_main_t *vam = &vat_main;
3308 u8 *s = 0, *eid = 0;
3310 if (~0 == mp->locator_set_index)
3311 s = format (0, "action: %d", mp->action);
3313 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3315 eid = format (0, "%U", format_lisp_eid_vat,
3319 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3322 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3323 clib_net_to_host_u32 (mp->vni),
3325 mp->is_local ? "local" : "remote",
3326 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3327 clib_net_to_host_u16 (mp->key_id), mp->key);
3334 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3337 vat_main_t *vam = &vat_main;
3338 vat_json_node_t *node = 0;
3341 if (VAT_JSON_ARRAY != vam->json_tree.type)
3343 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3344 vat_json_init_array (&vam->json_tree);
3346 node = vat_json_array_add (&vam->json_tree);
3348 vat_json_init_object (node);
3349 if (~0 == mp->locator_set_index)
3350 vat_json_object_add_uint (node, "action", mp->action);
3352 vat_json_object_add_uint (node, "locator_set_index",
3353 clib_net_to_host_u32 (mp->locator_set_index));
3355 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3356 if (mp->eid_type == 3)
3358 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3359 vat_json_init_object (nsh_json);
3360 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3361 vat_json_object_add_uint (nsh_json, "spi",
3362 clib_net_to_host_u32 (nsh->spi));
3363 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3367 eid = format (0, "%U", format_lisp_eid_vat,
3371 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3373 vat_json_object_add_string_copy (node, "eid", eid);
3376 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3377 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3378 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3382 vat_json_object_add_uint (node, "key_id",
3383 clib_net_to_host_u16 (mp->key_id));
3384 vat_json_object_add_string_copy (node, "key", mp->key);
3389 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3391 vat_main_t *vam = &vat_main;
3392 u8 *seid = 0, *deid = 0;
3393 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3395 deid = format (0, "%U", format_lisp_eid_vat,
3396 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3398 seid = format (0, "%U", format_lisp_eid_vat,
3399 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3405 format_ip_address_fcn = format_ip4_address;
3407 format_ip_address_fcn = format_ip6_address;
3410 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3411 clib_net_to_host_u32 (mp->vni),
3413 format_ip_address_fcn, mp->lloc,
3414 format_ip_address_fcn, mp->rloc,
3415 clib_net_to_host_u32 (mp->pkt_count),
3416 clib_net_to_host_u32 (mp->bytes));
3423 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3425 struct in6_addr ip6;
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t *node = 0;
3429 u8 *deid = 0, *seid = 0;
3431 if (VAT_JSON_ARRAY != vam->json_tree.type)
3433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3434 vat_json_init_array (&vam->json_tree);
3436 node = vat_json_array_add (&vam->json_tree);
3438 vat_json_init_object (node);
3439 deid = format (0, "%U", format_lisp_eid_vat,
3440 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3442 seid = format (0, "%U", format_lisp_eid_vat,
3443 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3448 vat_json_object_add_string_copy (node, "seid", seid);
3449 vat_json_object_add_string_copy (node, "deid", deid);
3450 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3454 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3455 vat_json_object_add_ip4 (node, "lloc", ip4);
3456 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3457 vat_json_object_add_ip4 (node, "rloc", ip4);
3461 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3462 vat_json_object_add_ip6 (node, "lloc", ip6);
3463 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3464 vat_json_object_add_ip6 (node, "rloc", ip6);
3466 vat_json_object_add_uint (node, "pkt_count",
3467 clib_net_to_host_u32 (mp->pkt_count));
3468 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3475 vl_api_one_eid_table_map_details_t_handler
3476 (vl_api_one_eid_table_map_details_t * mp)
3478 vat_main_t *vam = &vat_main;
3480 u8 *line = format (0, "%=10d%=10d",
3481 clib_net_to_host_u32 (mp->vni),
3482 clib_net_to_host_u32 (mp->dp_table));
3483 print (vam->ofp, "%v", line);
3488 vl_api_one_eid_table_map_details_t_handler_json
3489 (vl_api_one_eid_table_map_details_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 vat_json_node_t *node = NULL;
3494 if (VAT_JSON_ARRAY != vam->json_tree.type)
3496 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3497 vat_json_init_array (&vam->json_tree);
3499 node = vat_json_array_add (&vam->json_tree);
3500 vat_json_init_object (node);
3501 vat_json_object_add_uint (node, "dp_table",
3502 clib_net_to_host_u32 (mp->dp_table));
3503 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3507 vl_api_one_eid_table_vni_details_t_handler
3508 (vl_api_one_eid_table_vni_details_t * mp)
3510 vat_main_t *vam = &vat_main;
3512 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3513 print (vam->ofp, "%v", line);
3518 vl_api_one_eid_table_vni_details_t_handler_json
3519 (vl_api_one_eid_table_vni_details_t * mp)
3521 vat_main_t *vam = &vat_main;
3522 vat_json_node_t *node = NULL;
3524 if (VAT_JSON_ARRAY != vam->json_tree.type)
3526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3527 vat_json_init_array (&vam->json_tree);
3529 node = vat_json_array_add (&vam->json_tree);
3530 vat_json_init_object (node);
3531 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3535 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3536 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 int retval = clib_net_to_host_u32 (mp->retval);
3541 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3542 print (vam->ofp, "fallback threshold value: %d", mp->value);
3544 vam->retval = retval;
3545 vam->result_ready = 1;
3549 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3550 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3552 vat_main_t *vam = &vat_main;
3553 vat_json_node_t _node, *node = &_node;
3554 int retval = clib_net_to_host_u32 (mp->retval);
3556 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3557 vat_json_init_object (node);
3558 vat_json_object_add_uint (node, "value", mp->value);
3560 vat_json_print (vam->ofp, node);
3561 vat_json_free (node);
3563 vam->retval = retval;
3564 vam->result_ready = 1;
3568 vl_api_show_one_map_register_state_reply_t_handler
3569 (vl_api_show_one_map_register_state_reply_t * mp)
3571 vat_main_t *vam = &vat_main;
3572 int retval = clib_net_to_host_u32 (mp->retval);
3574 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3576 vam->retval = retval;
3577 vam->result_ready = 1;
3581 vl_api_show_one_map_register_state_reply_t_handler_json
3582 (vl_api_show_one_map_register_state_reply_t * mp)
3584 vat_main_t *vam = &vat_main;
3585 vat_json_node_t _node, *node = &_node;
3586 int retval = clib_net_to_host_u32 (mp->retval);
3588 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3590 vat_json_init_object (node);
3591 vat_json_object_add_string_copy (node, "state", s);
3593 vat_json_print (vam->ofp, node);
3594 vat_json_free (node);
3596 vam->retval = retval;
3597 vam->result_ready = 1;
3602 vl_api_show_one_rloc_probe_state_reply_t_handler
3603 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3605 vat_main_t *vam = &vat_main;
3606 int retval = clib_net_to_host_u32 (mp->retval);
3611 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3613 vam->retval = retval;
3614 vam->result_ready = 1;
3618 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3619 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3621 vat_main_t *vam = &vat_main;
3622 vat_json_node_t _node, *node = &_node;
3623 int retval = clib_net_to_host_u32 (mp->retval);
3625 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3626 vat_json_init_object (node);
3627 vat_json_object_add_string_copy (node, "state", s);
3629 vat_json_print (vam->ofp, node);
3630 vat_json_free (node);
3632 vam->retval = retval;
3633 vam->result_ready = 1;
3638 vl_api_show_one_stats_enable_disable_reply_t_handler
3639 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3641 vat_main_t *vam = &vat_main;
3642 int retval = clib_net_to_host_u32 (mp->retval);
3647 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3654 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3655 (vl_api_show_one_stats_enable_disable_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_en ? "enabled" : "disabled");
3662 vat_json_init_object (node);
3663 vat_json_object_add_string_copy (node, "state", s);
3665 vat_json_print (vam->ofp, node);
3666 vat_json_free (node);
3668 vam->retval = retval;
3669 vam->result_ready = 1;
3674 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3676 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3677 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3678 e->vni = clib_net_to_host_u32 (e->vni);
3682 gpe_fwd_entries_get_reply_t_net_to_host
3683 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3687 mp->count = clib_net_to_host_u32 (mp->count);
3688 for (i = 0; i < mp->count; i++)
3690 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3695 format_gpe_encap_mode (u8 * s, va_list * args)
3697 u32 mode = va_arg (*args, u32);
3702 return format (s, "lisp");
3704 return format (s, "vxlan");
3710 vl_api_gpe_get_encap_mode_reply_t_handler
3711 (vl_api_gpe_get_encap_mode_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3715 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3716 vam->retval = ntohl (mp->retval);
3717 vam->result_ready = 1;
3721 vl_api_gpe_get_encap_mode_reply_t_handler_json
3722 (vl_api_gpe_get_encap_mode_reply_t * mp)
3724 vat_main_t *vam = &vat_main;
3725 vat_json_node_t node;
3727 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3728 vec_add1 (encap_mode, 0);
3730 vat_json_init_object (&node);
3731 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3733 vec_free (encap_mode);
3734 vat_json_print (vam->ofp, &node);
3735 vat_json_free (&node);
3737 vam->retval = ntohl (mp->retval);
3738 vam->result_ready = 1;
3742 vl_api_gpe_fwd_entry_path_details_t_handler
3743 (vl_api_gpe_fwd_entry_path_details_t * mp)
3745 vat_main_t *vam = &vat_main;
3746 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3748 if (mp->lcl_loc.is_ip4)
3749 format_ip_address_fcn = format_ip4_address;
3751 format_ip_address_fcn = format_ip6_address;
3753 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3754 format_ip_address_fcn, &mp->lcl_loc,
3755 format_ip_address_fcn, &mp->rmt_loc);
3759 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3761 struct in6_addr ip6;
3766 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3767 vat_json_object_add_ip4 (n, "address", ip4);
3771 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3772 vat_json_object_add_ip6 (n, "address", ip6);
3774 vat_json_object_add_uint (n, "weight", loc->weight);
3778 vl_api_gpe_fwd_entry_path_details_t_handler_json
3779 (vl_api_gpe_fwd_entry_path_details_t * mp)
3781 vat_main_t *vam = &vat_main;
3782 vat_json_node_t *node = NULL;
3783 vat_json_node_t *loc_node;
3785 if (VAT_JSON_ARRAY != vam->json_tree.type)
3787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3788 vat_json_init_array (&vam->json_tree);
3790 node = vat_json_array_add (&vam->json_tree);
3791 vat_json_init_object (node);
3793 loc_node = vat_json_object_add (node, "local_locator");
3794 vat_json_init_object (loc_node);
3795 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3797 loc_node = vat_json_object_add (node, "remote_locator");
3798 vat_json_init_object (loc_node);
3799 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3803 vl_api_gpe_fwd_entries_get_reply_t_handler
3804 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3808 int retval = clib_net_to_host_u32 (mp->retval);
3809 vl_api_gpe_fwd_entry_t *e;
3814 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3816 for (i = 0; i < mp->count; i++)
3818 e = &mp->entries[i];
3819 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3820 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3821 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3825 vam->retval = retval;
3826 vam->result_ready = 1;
3830 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3831 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3834 vat_main_t *vam = &vat_main;
3835 vat_json_node_t *e = 0, root;
3837 int retval = clib_net_to_host_u32 (mp->retval);
3838 vl_api_gpe_fwd_entry_t *fwd;
3843 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3844 vat_json_init_array (&root);
3846 for (i = 0; i < mp->count; i++)
3848 e = vat_json_array_add (&root);
3849 fwd = &mp->entries[i];
3851 vat_json_init_object (e);
3852 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3853 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3854 vat_json_object_add_int (e, "vni", fwd->vni);
3855 vat_json_object_add_int (e, "action", fwd->action);
3857 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3858 fwd->leid_prefix_len);
3860 vat_json_object_add_string_copy (e, "leid", s);
3863 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3864 fwd->reid_prefix_len);
3866 vat_json_object_add_string_copy (e, "reid", s);
3870 vat_json_print (vam->ofp, &root);
3871 vat_json_free (&root);
3874 vam->retval = retval;
3875 vam->result_ready = 1;
3879 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3880 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3882 vat_main_t *vam = &vat_main;
3884 int retval = clib_net_to_host_u32 (mp->retval);
3885 vl_api_gpe_native_fwd_rpath_t *r;
3890 n = clib_net_to_host_u32 (mp->count);
3892 for (i = 0; i < n; i++)
3894 r = &mp->entries[i];
3895 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3896 clib_net_to_host_u32 (r->fib_index),
3897 clib_net_to_host_u32 (r->nh_sw_if_index),
3898 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3902 vam->retval = retval;
3903 vam->result_ready = 1;
3907 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3908 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3910 vat_main_t *vam = &vat_main;
3911 vat_json_node_t root, *e;
3913 int retval = clib_net_to_host_u32 (mp->retval);
3914 vl_api_gpe_native_fwd_rpath_t *r;
3920 n = clib_net_to_host_u32 (mp->count);
3921 vat_json_init_array (&root);
3923 for (i = 0; i < n; i++)
3925 e = vat_json_array_add (&root);
3926 vat_json_init_object (e);
3927 r = &mp->entries[i];
3929 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3932 vat_json_object_add_string_copy (e, "ip4", s);
3935 vat_json_object_add_uint (e, "fib_index",
3936 clib_net_to_host_u32 (r->fib_index));
3937 vat_json_object_add_uint (e, "nh_sw_if_index",
3938 clib_net_to_host_u32 (r->nh_sw_if_index));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3951 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3960 n = clib_net_to_host_u32 (mp->count);
3962 for (i = 0; i < n; i++)
3963 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3966 vam->retval = retval;
3967 vam->result_ready = 1;
3971 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3972 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3975 vat_json_node_t root;
3977 int retval = clib_net_to_host_u32 (mp->retval);
3982 n = clib_net_to_host_u32 (mp->count);
3983 vat_json_init_array (&root);
3985 for (i = 0; i < n; i++)
3986 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3988 vat_json_print (vam->ofp, &root);
3989 vat_json_free (&root);
3992 vam->retval = retval;
3993 vam->result_ready = 1;
3997 vl_api_one_ndp_entries_get_reply_t_handler
3998 (vl_api_one_ndp_entries_get_reply_t * mp)
4000 vat_main_t *vam = &vat_main;
4002 int retval = clib_net_to_host_u32 (mp->retval);
4007 n = clib_net_to_host_u32 (mp->count);
4009 for (i = 0; i < n; i++)
4010 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4011 format_ethernet_address, mp->entries[i].mac);
4014 vam->retval = retval;
4015 vam->result_ready = 1;
4019 vl_api_one_ndp_entries_get_reply_t_handler_json
4020 (vl_api_one_ndp_entries_get_reply_t * mp)
4023 vat_main_t *vam = &vat_main;
4024 vat_json_node_t *e = 0, root;
4026 int retval = clib_net_to_host_u32 (mp->retval);
4027 vl_api_one_ndp_entry_t *arp_entry;
4032 n = clib_net_to_host_u32 (mp->count);
4033 vat_json_init_array (&root);
4035 for (i = 0; i < n; i++)
4037 e = vat_json_array_add (&root);
4038 arp_entry = &mp->entries[i];
4040 vat_json_init_object (e);
4041 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4044 vat_json_object_add_string_copy (e, "mac", s);
4047 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4049 vat_json_object_add_string_copy (e, "ip6", s);
4053 vat_json_print (vam->ofp, &root);
4054 vat_json_free (&root);
4057 vam->retval = retval;
4058 vam->result_ready = 1;
4062 vl_api_one_l2_arp_entries_get_reply_t_handler
4063 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4065 vat_main_t *vam = &vat_main;
4067 int retval = clib_net_to_host_u32 (mp->retval);
4072 n = clib_net_to_host_u32 (mp->count);
4074 for (i = 0; i < n; i++)
4075 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4076 format_ethernet_address, mp->entries[i].mac);
4079 vam->retval = retval;
4080 vam->result_ready = 1;
4084 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4085 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4088 vat_main_t *vam = &vat_main;
4089 vat_json_node_t *e = 0, root;
4091 int retval = clib_net_to_host_u32 (mp->retval);
4092 vl_api_one_l2_arp_entry_t *arp_entry;
4097 n = clib_net_to_host_u32 (mp->count);
4098 vat_json_init_array (&root);
4100 for (i = 0; i < n; i++)
4102 e = vat_json_array_add (&root);
4103 arp_entry = &mp->entries[i];
4105 vat_json_init_object (e);
4106 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4109 vat_json_object_add_string_copy (e, "mac", s);
4112 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4114 vat_json_object_add_string_copy (e, "ip4", s);
4118 vat_json_print (vam->ofp, &root);
4119 vat_json_free (&root);
4122 vam->retval = retval;
4123 vam->result_ready = 1;
4127 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4129 vat_main_t *vam = &vat_main;
4131 int retval = clib_net_to_host_u32 (mp->retval);
4136 n = clib_net_to_host_u32 (mp->count);
4138 for (i = 0; i < n; i++)
4140 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4144 vam->retval = retval;
4145 vam->result_ready = 1;
4149 vl_api_one_ndp_bd_get_reply_t_handler_json
4150 (vl_api_one_ndp_bd_get_reply_t * mp)
4152 vat_main_t *vam = &vat_main;
4153 vat_json_node_t root;
4155 int retval = clib_net_to_host_u32 (mp->retval);
4160 n = clib_net_to_host_u32 (mp->count);
4161 vat_json_init_array (&root);
4163 for (i = 0; i < n; i++)
4165 vat_json_array_add_uint (&root,
4166 clib_net_to_host_u32 (mp->bridge_domains[i]));
4169 vat_json_print (vam->ofp, &root);
4170 vat_json_free (&root);
4173 vam->retval = retval;
4174 vam->result_ready = 1;
4178 vl_api_one_l2_arp_bd_get_reply_t_handler
4179 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4181 vat_main_t *vam = &vat_main;
4183 int retval = clib_net_to_host_u32 (mp->retval);
4188 n = clib_net_to_host_u32 (mp->count);
4190 for (i = 0; i < n; i++)
4192 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4196 vam->retval = retval;
4197 vam->result_ready = 1;
4201 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4202 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 vat_json_node_t root;
4207 int retval = clib_net_to_host_u32 (mp->retval);
4212 n = clib_net_to_host_u32 (mp->count);
4213 vat_json_init_array (&root);
4215 for (i = 0; i < n; i++)
4217 vat_json_array_add_uint (&root,
4218 clib_net_to_host_u32 (mp->bridge_domains[i]));
4221 vat_json_print (vam->ofp, &root);
4222 vat_json_free (&root);
4225 vam->retval = retval;
4226 vam->result_ready = 1;
4230 vl_api_one_adjacencies_get_reply_t_handler
4231 (vl_api_one_adjacencies_get_reply_t * mp)
4233 vat_main_t *vam = &vat_main;
4235 int retval = clib_net_to_host_u32 (mp->retval);
4236 vl_api_one_adjacency_t *a;
4241 n = clib_net_to_host_u32 (mp->count);
4243 for (i = 0; i < n; i++)
4245 a = &mp->adjacencies[i];
4246 print (vam->ofp, "%U %40U",
4247 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4248 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4252 vam->retval = retval;
4253 vam->result_ready = 1;
4257 vl_api_one_adjacencies_get_reply_t_handler_json
4258 (vl_api_one_adjacencies_get_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t *e = 0, root;
4264 int retval = clib_net_to_host_u32 (mp->retval);
4265 vl_api_one_adjacency_t *a;
4270 n = clib_net_to_host_u32 (mp->count);
4271 vat_json_init_array (&root);
4273 for (i = 0; i < n; i++)
4275 e = vat_json_array_add (&root);
4276 a = &mp->adjacencies[i];
4278 vat_json_init_object (e);
4279 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4280 a->leid_prefix_len);
4282 vat_json_object_add_string_copy (e, "leid", s);
4285 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4286 a->reid_prefix_len);
4288 vat_json_object_add_string_copy (e, "reid", s);
4292 vat_json_print (vam->ofp, &root);
4293 vat_json_free (&root);
4296 vam->retval = retval;
4297 vam->result_ready = 1;
4301 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4303 vat_main_t *vam = &vat_main;
4305 print (vam->ofp, "%=20U",
4306 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4311 vl_api_one_map_server_details_t_handler_json
4312 (vl_api_one_map_server_details_t * mp)
4314 vat_main_t *vam = &vat_main;
4315 vat_json_node_t *node = NULL;
4316 struct in6_addr ip6;
4319 if (VAT_JSON_ARRAY != vam->json_tree.type)
4321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4322 vat_json_init_array (&vam->json_tree);
4324 node = vat_json_array_add (&vam->json_tree);
4326 vat_json_init_object (node);
4329 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4330 vat_json_object_add_ip6 (node, "map-server", ip6);
4334 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4335 vat_json_object_add_ip4 (node, "map-server", ip4);
4340 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4343 vat_main_t *vam = &vat_main;
4345 print (vam->ofp, "%=20U",
4346 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4351 vl_api_one_map_resolver_details_t_handler_json
4352 (vl_api_one_map_resolver_details_t * mp)
4354 vat_main_t *vam = &vat_main;
4355 vat_json_node_t *node = NULL;
4356 struct in6_addr ip6;
4359 if (VAT_JSON_ARRAY != vam->json_tree.type)
4361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4362 vat_json_init_array (&vam->json_tree);
4364 node = vat_json_array_add (&vam->json_tree);
4366 vat_json_init_object (node);
4369 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4370 vat_json_object_add_ip6 (node, "map resolver", ip6);
4374 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4375 vat_json_object_add_ip4 (node, "map resolver", ip4);
4380 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4382 vat_main_t *vam = &vat_main;
4383 i32 retval = ntohl (mp->retval);
4387 print (vam->ofp, "feature: %s\ngpe: %s",
4388 mp->feature_status ? "enabled" : "disabled",
4389 mp->gpe_status ? "enabled" : "disabled");
4392 vam->retval = retval;
4393 vam->result_ready = 1;
4397 vl_api_show_one_status_reply_t_handler_json
4398 (vl_api_show_one_status_reply_t * mp)
4400 vat_main_t *vam = &vat_main;
4401 vat_json_node_t node;
4402 u8 *gpe_status = NULL;
4403 u8 *feature_status = NULL;
4405 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4406 feature_status = format (0, "%s",
4407 mp->feature_status ? "enabled" : "disabled");
4408 vec_add1 (gpe_status, 0);
4409 vec_add1 (feature_status, 0);
4411 vat_json_init_object (&node);
4412 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4413 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4415 vec_free (gpe_status);
4416 vec_free (feature_status);
4418 vat_json_print (vam->ofp, &node);
4419 vat_json_free (&node);
4421 vam->retval = ntohl (mp->retval);
4422 vam->result_ready = 1;
4426 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4427 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4429 vat_main_t *vam = &vat_main;
4430 i32 retval = ntohl (mp->retval);
4434 print (vam->ofp, "%=20s", mp->locator_set_name);
4437 vam->retval = retval;
4438 vam->result_ready = 1;
4442 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4443 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4445 vat_main_t *vam = &vat_main;
4446 vat_json_node_t *node = NULL;
4448 if (VAT_JSON_ARRAY != vam->json_tree.type)
4450 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4451 vat_json_init_array (&vam->json_tree);
4453 node = vat_json_array_add (&vam->json_tree);
4455 vat_json_init_object (node);
4456 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4458 vat_json_print (vam->ofp, node);
4459 vat_json_free (node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 format_lisp_map_request_mode (u8 * s, va_list * args)
4468 u32 mode = va_arg (*args, u32);
4473 return format (0, "dst-only");
4475 return format (0, "src-dst");
4481 vl_api_show_one_map_request_mode_reply_t_handler
4482 (vl_api_show_one_map_request_mode_reply_t * mp)
4484 vat_main_t *vam = &vat_main;
4485 i32 retval = ntohl (mp->retval);
4489 u32 mode = mp->mode;
4490 print (vam->ofp, "map_request_mode: %U",
4491 format_lisp_map_request_mode, mode);
4494 vam->retval = retval;
4495 vam->result_ready = 1;
4499 vl_api_show_one_map_request_mode_reply_t_handler_json
4500 (vl_api_show_one_map_request_mode_reply_t * mp)
4502 vat_main_t *vam = &vat_main;
4503 vat_json_node_t node;
4508 s = format (0, "%U", format_lisp_map_request_mode, mode);
4511 vat_json_init_object (&node);
4512 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4513 vat_json_print (vam->ofp, &node);
4514 vat_json_free (&node);
4517 vam->retval = ntohl (mp->retval);
4518 vam->result_ready = 1;
4522 vl_api_one_show_xtr_mode_reply_t_handler
4523 (vl_api_one_show_xtr_mode_reply_t * mp)
4525 vat_main_t *vam = &vat_main;
4526 i32 retval = ntohl (mp->retval);
4530 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4533 vam->retval = retval;
4534 vam->result_ready = 1;
4538 vl_api_one_show_xtr_mode_reply_t_handler_json
4539 (vl_api_one_show_xtr_mode_reply_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 vat_json_node_t node;
4545 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4546 vec_add1 (status, 0);
4548 vat_json_init_object (&node);
4549 vat_json_object_add_string_copy (&node, "status", status);
4553 vat_json_print (vam->ofp, &node);
4554 vat_json_free (&node);
4556 vam->retval = ntohl (mp->retval);
4557 vam->result_ready = 1;
4561 vl_api_one_show_pitr_mode_reply_t_handler
4562 (vl_api_one_show_pitr_mode_reply_t * mp)
4564 vat_main_t *vam = &vat_main;
4565 i32 retval = ntohl (mp->retval);
4569 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4572 vam->retval = retval;
4573 vam->result_ready = 1;
4577 vl_api_one_show_pitr_mode_reply_t_handler_json
4578 (vl_api_one_show_pitr_mode_reply_t * mp)
4580 vat_main_t *vam = &vat_main;
4581 vat_json_node_t node;
4584 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4585 vec_add1 (status, 0);
4587 vat_json_init_object (&node);
4588 vat_json_object_add_string_copy (&node, "status", status);
4592 vat_json_print (vam->ofp, &node);
4593 vat_json_free (&node);
4595 vam->retval = ntohl (mp->retval);
4596 vam->result_ready = 1;
4600 vl_api_one_show_petr_mode_reply_t_handler
4601 (vl_api_one_show_petr_mode_reply_t * mp)
4603 vat_main_t *vam = &vat_main;
4604 i32 retval = ntohl (mp->retval);
4608 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4611 vam->retval = retval;
4612 vam->result_ready = 1;
4616 vl_api_one_show_petr_mode_reply_t_handler_json
4617 (vl_api_one_show_petr_mode_reply_t * mp)
4619 vat_main_t *vam = &vat_main;
4620 vat_json_node_t node;
4623 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4624 vec_add1 (status, 0);
4626 vat_json_init_object (&node);
4627 vat_json_object_add_string_copy (&node, "status", status);
4631 vat_json_print (vam->ofp, &node);
4632 vat_json_free (&node);
4634 vam->retval = ntohl (mp->retval);
4635 vam->result_ready = 1;
4639 vl_api_show_one_use_petr_reply_t_handler
4640 (vl_api_show_one_use_petr_reply_t * mp)
4642 vat_main_t *vam = &vat_main;
4643 i32 retval = ntohl (mp->retval);
4647 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4650 print (vam->ofp, "Proxy-ETR address; %U",
4651 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4656 vam->retval = retval;
4657 vam->result_ready = 1;
4661 vl_api_show_one_use_petr_reply_t_handler_json
4662 (vl_api_show_one_use_petr_reply_t * mp)
4664 vat_main_t *vam = &vat_main;
4665 vat_json_node_t node;
4668 struct in6_addr ip6;
4670 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4671 vec_add1 (status, 0);
4673 vat_json_init_object (&node);
4674 vat_json_object_add_string_copy (&node, "status", status);
4679 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4680 vat_json_object_add_ip6 (&node, "address", ip6);
4684 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4685 vat_json_object_add_ip4 (&node, "address", ip4);
4691 vat_json_print (vam->ofp, &node);
4692 vat_json_free (&node);
4694 vam->retval = ntohl (mp->retval);
4695 vam->result_ready = 1;
4699 vl_api_show_one_nsh_mapping_reply_t_handler
4700 (vl_api_show_one_nsh_mapping_reply_t * mp)
4702 vat_main_t *vam = &vat_main;
4703 i32 retval = ntohl (mp->retval);
4707 print (vam->ofp, "%-20s%-16s",
4708 mp->is_set ? "set" : "not-set",
4709 mp->is_set ? (char *) mp->locator_set_name : "");
4712 vam->retval = retval;
4713 vam->result_ready = 1;
4717 vl_api_show_one_nsh_mapping_reply_t_handler_json
4718 (vl_api_show_one_nsh_mapping_reply_t * mp)
4720 vat_main_t *vam = &vat_main;
4721 vat_json_node_t node;
4724 status = format (0, "%s", mp->is_set ? "yes" : "no");
4725 vec_add1 (status, 0);
4727 vat_json_init_object (&node);
4728 vat_json_object_add_string_copy (&node, "is_set", status);
4731 vat_json_object_add_string_copy (&node, "locator_set",
4732 mp->locator_set_name);
4737 vat_json_print (vam->ofp, &node);
4738 vat_json_free (&node);
4740 vam->retval = ntohl (mp->retval);
4741 vam->result_ready = 1;
4745 vl_api_show_one_map_register_ttl_reply_t_handler
4746 (vl_api_show_one_map_register_ttl_reply_t * mp)
4748 vat_main_t *vam = &vat_main;
4749 i32 retval = ntohl (mp->retval);
4751 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4755 print (vam->ofp, "ttl: %u", mp->ttl);
4758 vam->retval = retval;
4759 vam->result_ready = 1;
4763 vl_api_show_one_map_register_ttl_reply_t_handler_json
4764 (vl_api_show_one_map_register_ttl_reply_t * mp)
4766 vat_main_t *vam = &vat_main;
4767 vat_json_node_t node;
4769 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4770 vat_json_init_object (&node);
4771 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4773 vat_json_print (vam->ofp, &node);
4774 vat_json_free (&node);
4776 vam->retval = ntohl (mp->retval);
4777 vam->result_ready = 1;
4781 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4783 vat_main_t *vam = &vat_main;
4784 i32 retval = ntohl (mp->retval);
4788 print (vam->ofp, "%-20s%-16s",
4789 mp->status ? "enabled" : "disabled",
4790 mp->status ? (char *) mp->locator_set_name : "");
4793 vam->retval = retval;
4794 vam->result_ready = 1;
4798 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4800 vat_main_t *vam = &vat_main;
4801 vat_json_node_t node;
4804 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4805 vec_add1 (status, 0);
4807 vat_json_init_object (&node);
4808 vat_json_object_add_string_copy (&node, "status", status);
4811 vat_json_object_add_string_copy (&node, "locator_set",
4812 mp->locator_set_name);
4817 vat_json_print (vam->ofp, &node);
4818 vat_json_free (&node);
4820 vam->retval = ntohl (mp->retval);
4821 vam->result_ready = 1;
4825 format_policer_type (u8 * s, va_list * va)
4827 u32 i = va_arg (*va, u32);
4829 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4830 s = format (s, "1r2c");
4831 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4832 s = format (s, "1r3c");
4833 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4834 s = format (s, "2r3c-2698");
4835 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4836 s = format (s, "2r3c-4115");
4837 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4838 s = format (s, "2r3c-mef5cf1");
4840 s = format (s, "ILLEGAL");
4845 format_policer_rate_type (u8 * s, va_list * va)
4847 u32 i = va_arg (*va, u32);
4849 if (i == SSE2_QOS_RATE_KBPS)
4850 s = format (s, "kbps");
4851 else if (i == SSE2_QOS_RATE_PPS)
4852 s = format (s, "pps");
4854 s = format (s, "ILLEGAL");
4859 format_policer_round_type (u8 * s, va_list * va)
4861 u32 i = va_arg (*va, u32);
4863 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4864 s = format (s, "closest");
4865 else if (i == SSE2_QOS_ROUND_TO_UP)
4866 s = format (s, "up");
4867 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4868 s = format (s, "down");
4870 s = format (s, "ILLEGAL");
4875 format_policer_action_type (u8 * s, va_list * va)
4877 u32 i = va_arg (*va, u32);
4879 if (i == SSE2_QOS_ACTION_DROP)
4880 s = format (s, "drop");
4881 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4882 s = format (s, "transmit");
4883 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4884 s = format (s, "mark-and-transmit");
4886 s = format (s, "ILLEGAL");
4891 format_dscp (u8 * s, va_list * va)
4893 u32 i = va_arg (*va, u32);
4898 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4902 return format (s, "ILLEGAL");
4904 s = format (s, "%s", t);
4909 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4911 vat_main_t *vam = &vat_main;
4912 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4914 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4915 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4917 conform_dscp_str = format (0, "");
4919 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4920 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4922 exceed_dscp_str = format (0, "");
4924 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4925 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4927 violate_dscp_str = format (0, "");
4929 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4930 "rate type %U, round type %U, %s rate, %s color-aware, "
4931 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4932 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4933 "conform action %U%s, exceed action %U%s, violate action %U%s",
4935 format_policer_type, mp->type,
4938 clib_net_to_host_u64 (mp->cb),
4939 clib_net_to_host_u64 (mp->eb),
4940 format_policer_rate_type, mp->rate_type,
4941 format_policer_round_type, mp->round_type,
4942 mp->single_rate ? "single" : "dual",
4943 mp->color_aware ? "is" : "not",
4944 ntohl (mp->cir_tokens_per_period),
4945 ntohl (mp->pir_tokens_per_period),
4947 ntohl (mp->current_limit),
4948 ntohl (mp->current_bucket),
4949 ntohl (mp->extended_limit),
4950 ntohl (mp->extended_bucket),
4951 clib_net_to_host_u64 (mp->last_update_time),
4952 format_policer_action_type, mp->conform_action_type,
4954 format_policer_action_type, mp->exceed_action_type,
4956 format_policer_action_type, mp->violate_action_type,
4959 vec_free (conform_dscp_str);
4960 vec_free (exceed_dscp_str);
4961 vec_free (violate_dscp_str);
4964 static void vl_api_policer_details_t_handler_json
4965 (vl_api_policer_details_t * mp)
4967 vat_main_t *vam = &vat_main;
4968 vat_json_node_t *node;
4969 u8 *rate_type_str, *round_type_str, *type_str;
4970 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4972 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4974 format (0, "%U", format_policer_round_type, mp->round_type);
4975 type_str = format (0, "%U", format_policer_type, mp->type);
4976 conform_action_str = format (0, "%U", format_policer_action_type,
4977 mp->conform_action_type);
4978 exceed_action_str = format (0, "%U", format_policer_action_type,
4979 mp->exceed_action_type);
4980 violate_action_str = format (0, "%U", format_policer_action_type,
4981 mp->violate_action_type);
4983 if (VAT_JSON_ARRAY != vam->json_tree.type)
4985 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4986 vat_json_init_array (&vam->json_tree);
4988 node = vat_json_array_add (&vam->json_tree);
4990 vat_json_init_object (node);
4991 vat_json_object_add_string_copy (node, "name", mp->name);
4992 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4993 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4994 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4995 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4996 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4997 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4998 vat_json_object_add_string_copy (node, "type", type_str);
4999 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5000 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5001 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5002 vat_json_object_add_uint (node, "cir_tokens_per_period",
5003 ntohl (mp->cir_tokens_per_period));
5004 vat_json_object_add_uint (node, "eir_tokens_per_period",
5005 ntohl (mp->pir_tokens_per_period));
5006 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5007 vat_json_object_add_uint (node, "current_bucket",
5008 ntohl (mp->current_bucket));
5009 vat_json_object_add_uint (node, "extended_limit",
5010 ntohl (mp->extended_limit));
5011 vat_json_object_add_uint (node, "extended_bucket",
5012 ntohl (mp->extended_bucket));
5013 vat_json_object_add_uint (node, "last_update_time",
5014 ntohl (mp->last_update_time));
5015 vat_json_object_add_string_copy (node, "conform_action",
5016 conform_action_str);
5017 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5019 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5020 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5021 vec_free (dscp_str);
5023 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5024 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5026 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5027 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5028 vec_free (dscp_str);
5030 vat_json_object_add_string_copy (node, "violate_action",
5031 violate_action_str);
5032 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5034 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5035 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5036 vec_free (dscp_str);
5039 vec_free (rate_type_str);
5040 vec_free (round_type_str);
5041 vec_free (type_str);
5042 vec_free (conform_action_str);
5043 vec_free (exceed_action_str);
5044 vec_free (violate_action_str);
5048 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5051 vat_main_t *vam = &vat_main;
5052 int i, count = ntohl (mp->count);
5055 print (vam->ofp, "classify table ids (%d) : ", count);
5056 for (i = 0; i < count; i++)
5058 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5059 print (vam->ofp, (i < count - 1) ? "," : "");
5061 vam->retval = ntohl (mp->retval);
5062 vam->result_ready = 1;
5066 vl_api_classify_table_ids_reply_t_handler_json
5067 (vl_api_classify_table_ids_reply_t * mp)
5069 vat_main_t *vam = &vat_main;
5070 int i, count = ntohl (mp->count);
5074 vat_json_node_t node;
5076 vat_json_init_object (&node);
5077 for (i = 0; i < count; i++)
5079 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5081 vat_json_print (vam->ofp, &node);
5082 vat_json_free (&node);
5084 vam->retval = ntohl (mp->retval);
5085 vam->result_ready = 1;
5089 vl_api_classify_table_by_interface_reply_t_handler
5090 (vl_api_classify_table_by_interface_reply_t * mp)
5092 vat_main_t *vam = &vat_main;
5095 table_id = ntohl (mp->l2_table_id);
5097 print (vam->ofp, "l2 table id : %d", table_id);
5099 print (vam->ofp, "l2 table id : No input ACL tables configured");
5100 table_id = ntohl (mp->ip4_table_id);
5102 print (vam->ofp, "ip4 table id : %d", table_id);
5104 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5105 table_id = ntohl (mp->ip6_table_id);
5107 print (vam->ofp, "ip6 table id : %d", table_id);
5109 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5110 vam->retval = ntohl (mp->retval);
5111 vam->result_ready = 1;
5115 vl_api_classify_table_by_interface_reply_t_handler_json
5116 (vl_api_classify_table_by_interface_reply_t * mp)
5118 vat_main_t *vam = &vat_main;
5119 vat_json_node_t node;
5121 vat_json_init_object (&node);
5123 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5124 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5125 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5127 vat_json_print (vam->ofp, &node);
5128 vat_json_free (&node);
5130 vam->retval = ntohl (mp->retval);
5131 vam->result_ready = 1;
5134 static void vl_api_policer_add_del_reply_t_handler
5135 (vl_api_policer_add_del_reply_t * mp)
5137 vat_main_t *vam = &vat_main;
5138 i32 retval = ntohl (mp->retval);
5139 if (vam->async_mode)
5141 vam->async_errors += (retval < 0);
5145 vam->retval = retval;
5146 vam->result_ready = 1;
5147 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5149 * Note: this is just barely thread-safe, depends on
5150 * the main thread spinning waiting for an answer...
5152 errmsg ("policer index %d", ntohl (mp->policer_index));
5156 static void vl_api_policer_add_del_reply_t_handler_json
5157 (vl_api_policer_add_del_reply_t * mp)
5159 vat_main_t *vam = &vat_main;
5160 vat_json_node_t node;
5162 vat_json_init_object (&node);
5163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5164 vat_json_object_add_uint (&node, "policer_index",
5165 ntohl (mp->policer_index));
5167 vat_json_print (vam->ofp, &node);
5168 vat_json_free (&node);
5170 vam->retval = ntohl (mp->retval);
5171 vam->result_ready = 1;
5174 /* Format hex dump. */
5176 format_hex_bytes (u8 * s, va_list * va)
5178 u8 *bytes = va_arg (*va, u8 *);
5179 int n_bytes = va_arg (*va, int);
5182 /* Print short or long form depending on byte count. */
5183 uword short_form = n_bytes <= 32;
5184 u32 indent = format_get_indent (s);
5189 for (i = 0; i < n_bytes; i++)
5191 if (!short_form && (i % 32) == 0)
5192 s = format (s, "%08x: ", i);
5193 s = format (s, "%02x", bytes[i]);
5194 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5195 s = format (s, "\n%U", format_white_space, indent);
5202 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5205 vat_main_t *vam = &vat_main;
5206 i32 retval = ntohl (mp->retval);
5209 print (vam->ofp, "classify table info :");
5210 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5211 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5212 ntohl (mp->miss_next_index));
5213 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5214 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5215 ntohl (mp->match_n_vectors));
5216 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5217 ntohl (mp->mask_length));
5219 vam->retval = retval;
5220 vam->result_ready = 1;
5224 vl_api_classify_table_info_reply_t_handler_json
5225 (vl_api_classify_table_info_reply_t * mp)
5227 vat_main_t *vam = &vat_main;
5228 vat_json_node_t node;
5230 i32 retval = ntohl (mp->retval);
5233 vat_json_init_object (&node);
5235 vat_json_object_add_int (&node, "sessions",
5236 ntohl (mp->active_sessions));
5237 vat_json_object_add_int (&node, "nexttbl",
5238 ntohl (mp->next_table_index));
5239 vat_json_object_add_int (&node, "nextnode",
5240 ntohl (mp->miss_next_index));
5241 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5242 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5243 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5244 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5245 ntohl (mp->mask_length), 0);
5246 vat_json_object_add_string_copy (&node, "mask", s);
5248 vat_json_print (vam->ofp, &node);
5249 vat_json_free (&node);
5251 vam->retval = ntohl (mp->retval);
5252 vam->result_ready = 1;
5256 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5259 vat_main_t *vam = &vat_main;
5261 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5262 ntohl (mp->hit_next_index), ntohl (mp->advance),
5263 ntohl (mp->opaque_index));
5264 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5265 ntohl (mp->match_length));
5269 vl_api_classify_session_details_t_handler_json
5270 (vl_api_classify_session_details_t * mp)
5272 vat_main_t *vam = &vat_main;
5273 vat_json_node_t *node = NULL;
5275 if (VAT_JSON_ARRAY != vam->json_tree.type)
5277 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5278 vat_json_init_array (&vam->json_tree);
5280 node = vat_json_array_add (&vam->json_tree);
5282 vat_json_init_object (node);
5283 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5284 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5285 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5287 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5289 vat_json_object_add_string_copy (node, "match", s);
5292 static void vl_api_pg_create_interface_reply_t_handler
5293 (vl_api_pg_create_interface_reply_t * mp)
5295 vat_main_t *vam = &vat_main;
5297 vam->retval = ntohl (mp->retval);
5298 vam->result_ready = 1;
5301 static void vl_api_pg_create_interface_reply_t_handler_json
5302 (vl_api_pg_create_interface_reply_t * mp)
5304 vat_main_t *vam = &vat_main;
5305 vat_json_node_t node;
5307 i32 retval = ntohl (mp->retval);
5310 vat_json_init_object (&node);
5312 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5314 vat_json_print (vam->ofp, &node);
5315 vat_json_free (&node);
5317 vam->retval = ntohl (mp->retval);
5318 vam->result_ready = 1;
5321 static void vl_api_policer_classify_details_t_handler
5322 (vl_api_policer_classify_details_t * mp)
5324 vat_main_t *vam = &vat_main;
5326 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5327 ntohl (mp->table_index));
5330 static void vl_api_policer_classify_details_t_handler_json
5331 (vl_api_policer_classify_details_t * mp)
5333 vat_main_t *vam = &vat_main;
5334 vat_json_node_t *node;
5336 if (VAT_JSON_ARRAY != vam->json_tree.type)
5338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5339 vat_json_init_array (&vam->json_tree);
5341 node = vat_json_array_add (&vam->json_tree);
5343 vat_json_init_object (node);
5344 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5345 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5348 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5349 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5351 vat_main_t *vam = &vat_main;
5352 i32 retval = ntohl (mp->retval);
5353 if (vam->async_mode)
5355 vam->async_errors += (retval < 0);
5359 vam->retval = retval;
5360 vam->sw_if_index = ntohl (mp->sw_if_index);
5361 vam->result_ready = 1;
5363 vam->regenerate_interface_table = 1;
5366 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5367 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5369 vat_main_t *vam = &vat_main;
5370 vat_json_node_t node;
5372 vat_json_init_object (&node);
5373 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5374 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5376 vat_json_print (vam->ofp, &node);
5377 vat_json_free (&node);
5379 vam->retval = ntohl (mp->retval);
5380 vam->result_ready = 1;
5383 static void vl_api_flow_classify_details_t_handler
5384 (vl_api_flow_classify_details_t * mp)
5386 vat_main_t *vam = &vat_main;
5388 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5389 ntohl (mp->table_index));
5392 static void vl_api_flow_classify_details_t_handler_json
5393 (vl_api_flow_classify_details_t * mp)
5395 vat_main_t *vam = &vat_main;
5396 vat_json_node_t *node;
5398 if (VAT_JSON_ARRAY != vam->json_tree.type)
5400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5401 vat_json_init_array (&vam->json_tree);
5403 node = vat_json_array_add (&vam->json_tree);
5405 vat_json_init_object (node);
5406 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5407 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5410 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5411 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5412 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5413 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5414 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5415 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5416 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5417 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5418 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5419 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5420 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5421 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5422 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5423 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5424 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5425 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5426 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5427 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5428 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5429 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5430 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5431 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5434 * Generate boilerplate reply handlers, which
5435 * dig the return value out of the xxx_reply_t API message,
5436 * stick it into vam->retval, and set vam->result_ready
5438 * Could also do this by pointing N message decode slots at
5439 * a single function, but that could break in subtle ways.
5442 #define foreach_standard_reply_retval_handler \
5443 _(sw_interface_set_flags_reply) \
5444 _(sw_interface_add_del_address_reply) \
5445 _(sw_interface_set_rx_mode_reply) \
5446 _(sw_interface_set_table_reply) \
5447 _(sw_interface_set_mpls_enable_reply) \
5448 _(sw_interface_set_vpath_reply) \
5449 _(sw_interface_set_vxlan_bypass_reply) \
5450 _(sw_interface_set_geneve_bypass_reply) \
5451 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5452 _(sw_interface_set_l2_bridge_reply) \
5453 _(bridge_domain_add_del_reply) \
5454 _(sw_interface_set_l2_xconnect_reply) \
5455 _(l2fib_add_del_reply) \
5456 _(l2fib_flush_int_reply) \
5457 _(l2fib_flush_bd_reply) \
5458 _(ip_add_del_route_reply) \
5459 _(ip_table_add_del_reply) \
5460 _(ip_mroute_add_del_reply) \
5461 _(mpls_route_add_del_reply) \
5462 _(mpls_table_add_del_reply) \
5463 _(mpls_ip_bind_unbind_reply) \
5464 _(bier_route_add_del_reply) \
5465 _(bier_table_add_del_reply) \
5466 _(proxy_arp_add_del_reply) \
5467 _(proxy_arp_intfc_enable_disable_reply) \
5468 _(sw_interface_set_unnumbered_reply) \
5469 _(ip_neighbor_add_del_reply) \
5470 _(oam_add_del_reply) \
5471 _(reset_fib_reply) \
5472 _(dhcp_proxy_config_reply) \
5473 _(dhcp_proxy_set_vss_reply) \
5474 _(dhcp_client_config_reply) \
5475 _(set_ip_flow_hash_reply) \
5476 _(sw_interface_ip6_enable_disable_reply) \
5477 _(sw_interface_ip6_set_link_local_address_reply) \
5478 _(ip6nd_proxy_add_del_reply) \
5479 _(sw_interface_ip6nd_ra_prefix_reply) \
5480 _(sw_interface_ip6nd_ra_config_reply) \
5481 _(set_arp_neighbor_limit_reply) \
5482 _(l2_patch_add_del_reply) \
5483 _(sr_policy_add_reply) \
5484 _(sr_policy_mod_reply) \
5485 _(sr_policy_del_reply) \
5486 _(sr_localsid_add_del_reply) \
5487 _(sr_steering_add_del_reply) \
5488 _(classify_add_del_session_reply) \
5489 _(classify_set_interface_ip_table_reply) \
5490 _(classify_set_interface_l2_tables_reply) \
5491 _(l2tpv3_set_tunnel_cookies_reply) \
5492 _(l2tpv3_interface_enable_disable_reply) \
5493 _(l2tpv3_set_lookup_key_reply) \
5494 _(l2_fib_clear_table_reply) \
5495 _(l2_interface_efp_filter_reply) \
5496 _(l2_interface_vlan_tag_rewrite_reply) \
5497 _(modify_vhost_user_if_reply) \
5498 _(delete_vhost_user_if_reply) \
5499 _(ip_probe_neighbor_reply) \
5500 _(ip_scan_neighbor_enable_disable_reply) \
5501 _(want_ip4_arp_events_reply) \
5502 _(want_ip6_nd_events_reply) \
5503 _(want_l2_macs_events_reply) \
5504 _(input_acl_set_interface_reply) \
5505 _(ipsec_spd_add_del_reply) \
5506 _(ipsec_interface_add_del_spd_reply) \
5507 _(ipsec_spd_add_del_entry_reply) \
5508 _(ipsec_sad_add_del_entry_reply) \
5509 _(ipsec_sa_set_key_reply) \
5510 _(ipsec_tunnel_if_add_del_reply) \
5511 _(ipsec_tunnel_if_set_key_reply) \
5512 _(ipsec_tunnel_if_set_sa_reply) \
5513 _(ikev2_profile_add_del_reply) \
5514 _(ikev2_profile_set_auth_reply) \
5515 _(ikev2_profile_set_id_reply) \
5516 _(ikev2_profile_set_ts_reply) \
5517 _(ikev2_set_local_key_reply) \
5518 _(ikev2_set_responder_reply) \
5519 _(ikev2_set_ike_transforms_reply) \
5520 _(ikev2_set_esp_transforms_reply) \
5521 _(ikev2_set_sa_lifetime_reply) \
5522 _(ikev2_initiate_sa_init_reply) \
5523 _(ikev2_initiate_del_ike_sa_reply) \
5524 _(ikev2_initiate_del_child_sa_reply) \
5525 _(ikev2_initiate_rekey_child_sa_reply) \
5526 _(delete_loopback_reply) \
5527 _(bd_ip_mac_add_del_reply) \
5528 _(map_del_domain_reply) \
5529 _(map_add_del_rule_reply) \
5530 _(want_interface_events_reply) \
5531 _(want_stats_reply) \
5532 _(cop_interface_enable_disable_reply) \
5533 _(cop_whitelist_enable_disable_reply) \
5534 _(sw_interface_clear_stats_reply) \
5535 _(ioam_enable_reply) \
5536 _(ioam_disable_reply) \
5537 _(one_add_del_locator_reply) \
5538 _(one_add_del_local_eid_reply) \
5539 _(one_add_del_remote_mapping_reply) \
5540 _(one_add_del_adjacency_reply) \
5541 _(one_add_del_map_resolver_reply) \
5542 _(one_add_del_map_server_reply) \
5543 _(one_enable_disable_reply) \
5544 _(one_rloc_probe_enable_disable_reply) \
5545 _(one_map_register_enable_disable_reply) \
5546 _(one_map_register_set_ttl_reply) \
5547 _(one_set_transport_protocol_reply) \
5548 _(one_map_register_fallback_threshold_reply) \
5549 _(one_pitr_set_locator_set_reply) \
5550 _(one_map_request_mode_reply) \
5551 _(one_add_del_map_request_itr_rlocs_reply) \
5552 _(one_eid_table_add_del_map_reply) \
5553 _(one_use_petr_reply) \
5554 _(one_stats_enable_disable_reply) \
5555 _(one_add_del_l2_arp_entry_reply) \
5556 _(one_add_del_ndp_entry_reply) \
5557 _(one_stats_flush_reply) \
5558 _(one_enable_disable_xtr_mode_reply) \
5559 _(one_enable_disable_pitr_mode_reply) \
5560 _(one_enable_disable_petr_mode_reply) \
5561 _(gpe_enable_disable_reply) \
5562 _(gpe_set_encap_mode_reply) \
5563 _(gpe_add_del_iface_reply) \
5564 _(gpe_add_del_native_fwd_rpath_reply) \
5565 _(af_packet_delete_reply) \
5566 _(policer_classify_set_interface_reply) \
5567 _(netmap_create_reply) \
5568 _(netmap_delete_reply) \
5569 _(set_ipfix_exporter_reply) \
5570 _(set_ipfix_classify_stream_reply) \
5571 _(ipfix_classify_table_add_del_reply) \
5572 _(flow_classify_set_interface_reply) \
5573 _(sw_interface_span_enable_disable_reply) \
5574 _(pg_capture_reply) \
5575 _(pg_enable_disable_reply) \
5576 _(ip_source_and_port_range_check_add_del_reply) \
5577 _(ip_source_and_port_range_check_interface_add_del_reply)\
5578 _(delete_subif_reply) \
5579 _(l2_interface_pbb_tag_rewrite_reply) \
5581 _(feature_enable_disable_reply) \
5582 _(sw_interface_tag_add_del_reply) \
5583 _(hw_interface_set_mtu_reply) \
5584 _(p2p_ethernet_add_reply) \
5585 _(p2p_ethernet_del_reply) \
5586 _(lldp_config_reply) \
5587 _(sw_interface_set_lldp_reply) \
5588 _(tcp_configure_src_addresses_reply) \
5589 _(dns_enable_disable_reply) \
5590 _(dns_name_server_add_del_reply) \
5591 _(session_rule_add_del_reply) \
5592 _(ip_container_proxy_add_del_reply) \
5593 _(output_acl_set_interface_reply) \
5594 _(qos_record_enable_disable_reply)
5597 static void vl_api_##n##_t_handler \
5598 (vl_api_##n##_t * mp) \
5600 vat_main_t * vam = &vat_main; \
5601 i32 retval = ntohl(mp->retval); \
5602 if (vam->async_mode) { \
5603 vam->async_errors += (retval < 0); \
5605 vam->retval = retval; \
5606 vam->result_ready = 1; \
5609 foreach_standard_reply_retval_handler;
5613 static void vl_api_##n##_t_handler_json \
5614 (vl_api_##n##_t * mp) \
5616 vat_main_t * vam = &vat_main; \
5617 vat_json_node_t node; \
5618 vat_json_init_object(&node); \
5619 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5620 vat_json_print(vam->ofp, &node); \
5621 vam->retval = ntohl(mp->retval); \
5622 vam->result_ready = 1; \
5624 foreach_standard_reply_retval_handler;
5628 * Table of message reply handlers, must include boilerplate handlers
5632 #define foreach_vpe_api_reply_msg \
5633 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5634 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5635 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5636 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5637 _(CONTROL_PING_REPLY, control_ping_reply) \
5638 _(CLI_REPLY, cli_reply) \
5639 _(CLI_INBAND_REPLY, cli_inband_reply) \
5640 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5641 sw_interface_add_del_address_reply) \
5642 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5643 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5644 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5645 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5646 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5647 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5648 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5649 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5650 sw_interface_set_l2_xconnect_reply) \
5651 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5652 sw_interface_set_l2_bridge_reply) \
5653 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5654 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5655 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5656 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5657 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5658 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5659 _(L2_FLAGS_REPLY, l2_flags_reply) \
5660 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5661 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5662 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5663 _(TAP_DELETE_REPLY, tap_delete_reply) \
5664 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5665 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5666 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5667 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5668 _(BOND_CREATE_REPLY, bond_create_reply) \
5669 _(BOND_DELETE_REPLY, bond_delete_reply) \
5670 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5671 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5672 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5673 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5674 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5675 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5676 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5677 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5678 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5679 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5680 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5681 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5682 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5683 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5684 proxy_arp_intfc_enable_disable_reply) \
5685 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5686 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5687 sw_interface_set_unnumbered_reply) \
5688 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5689 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5690 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5691 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5692 _(RESET_FIB_REPLY, reset_fib_reply) \
5693 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5694 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5695 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5696 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5697 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5698 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5699 sw_interface_ip6_enable_disable_reply) \
5700 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5701 sw_interface_ip6_set_link_local_address_reply) \
5702 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5703 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5704 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5705 sw_interface_ip6nd_ra_prefix_reply) \
5706 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5707 sw_interface_ip6nd_ra_config_reply) \
5708 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5709 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5710 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5711 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5712 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5713 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5714 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5715 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5716 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5717 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5718 classify_set_interface_ip_table_reply) \
5719 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5720 classify_set_interface_l2_tables_reply) \
5721 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5722 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5723 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5724 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5725 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5726 l2tpv3_interface_enable_disable_reply) \
5727 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5728 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5729 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5730 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5731 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5732 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5733 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5734 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5735 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5736 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5737 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5738 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5739 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5740 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5741 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5742 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5743 _(SHOW_VERSION_REPLY, show_version_reply) \
5744 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5745 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5746 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5747 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5748 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5749 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5750 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5751 _(IP4_ARP_EVENT, ip4_arp_event) \
5752 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5753 _(IP6_ND_EVENT, ip6_nd_event) \
5754 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5755 _(L2_MACS_EVENT, l2_macs_event) \
5756 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5757 _(IP_ADDRESS_DETAILS, ip_address_details) \
5758 _(IP_DETAILS, ip_details) \
5759 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5760 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5761 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5762 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5763 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5764 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5765 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5766 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5767 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5768 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5769 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5770 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5771 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5772 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5773 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5774 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5775 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5776 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5777 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5778 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5779 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5780 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5781 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5782 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5783 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5784 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5785 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5786 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5787 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5788 _(MAP_RULE_DETAILS, map_rule_details) \
5789 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5790 _(WANT_STATS_REPLY, want_stats_reply) \
5791 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5792 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5793 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5794 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5795 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5796 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5797 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5798 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5799 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5800 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5801 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5802 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5803 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5804 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5805 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5806 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5807 one_map_register_enable_disable_reply) \
5808 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5809 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5810 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5811 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5812 one_map_register_fallback_threshold_reply) \
5813 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5814 one_rloc_probe_enable_disable_reply) \
5815 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5816 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5817 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5818 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5819 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5820 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5821 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5822 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5823 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5824 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5825 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5826 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5827 _(ONE_STATS_DETAILS, one_stats_details) \
5828 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5829 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5830 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5831 show_one_stats_enable_disable_reply) \
5832 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5833 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5834 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5835 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5836 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5837 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5838 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5839 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5840 one_enable_disable_pitr_mode_reply) \
5841 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5842 one_enable_disable_petr_mode_reply) \
5843 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5844 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5845 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5846 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5847 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5848 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5849 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5850 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5851 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5852 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5853 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5854 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5855 gpe_add_del_native_fwd_rpath_reply) \
5856 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5857 gpe_fwd_entry_path_details) \
5858 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5859 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5860 one_add_del_map_request_itr_rlocs_reply) \
5861 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5862 one_get_map_request_itr_rlocs_reply) \
5863 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5864 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5865 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5866 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5867 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5868 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5869 show_one_map_register_state_reply) \
5870 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5871 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5872 show_one_map_register_fallback_threshold_reply) \
5873 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5874 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5875 _(AF_PACKET_DETAILS, af_packet_details) \
5876 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5877 _(POLICER_DETAILS, policer_details) \
5878 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5879 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5880 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5881 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5882 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5883 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5884 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5885 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5886 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5887 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5888 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5889 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5890 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5891 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5892 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5893 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5894 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5895 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5896 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5897 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5898 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5899 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5900 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5901 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5902 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5903 ip_source_and_port_range_check_add_del_reply) \
5904 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5905 ip_source_and_port_range_check_interface_add_del_reply) \
5906 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5907 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5908 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5909 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5910 _(PUNT_REPLY, punt_reply) \
5911 _(IP_FIB_DETAILS, ip_fib_details) \
5912 _(IP6_FIB_DETAILS, ip6_fib_details) \
5913 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5914 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5915 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5916 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5917 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5918 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5919 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5920 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5921 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5922 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5923 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5924 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5925 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5926 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5927 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5928 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5929 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5930 _(SESSION_RULES_DETAILS, session_rules_details) \
5931 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5932 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5933 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5934 _(MAP_STATS_SEGMENT_REPLY, map_stats_segment_reply)
5936 #define foreach_standalone_reply_msg \
5937 _(SW_INTERFACE_EVENT, sw_interface_event) \
5938 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5939 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5940 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5941 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5942 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5943 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5951 #define STR_VTR_OP_CASE(op) \
5952 case L2_VTR_ ## op: \
5956 str_vtr_op (u32 vtr_op)
5960 STR_VTR_OP_CASE (DISABLED);
5961 STR_VTR_OP_CASE (PUSH_1);
5962 STR_VTR_OP_CASE (PUSH_2);
5963 STR_VTR_OP_CASE (POP_1);
5964 STR_VTR_OP_CASE (POP_2);
5965 STR_VTR_OP_CASE (TRANSLATE_1_1);
5966 STR_VTR_OP_CASE (TRANSLATE_1_2);
5967 STR_VTR_OP_CASE (TRANSLATE_2_1);
5968 STR_VTR_OP_CASE (TRANSLATE_2_2);
5975 dump_sub_interface_table (vat_main_t * vam)
5977 const sw_interface_subif_t *sub = NULL;
5979 if (vam->json_output)
5982 ("JSON output supported only for VPE API calls and dump_stats_table");
5987 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5988 "Interface", "sw_if_index",
5989 "sub id", "dot1ad", "tags", "outer id",
5990 "inner id", "exact", "default", "outer any", "inner any");
5992 vec_foreach (sub, vam->sw_if_subif_table)
5995 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5996 sub->interface_name,
5998 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5999 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
6000 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6001 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6002 if (sub->vtr_op != L2_VTR_DISABLED)
6005 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6006 "tag1: %d tag2: %d ]",
6007 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6008 sub->vtr_tag1, sub->vtr_tag2);
6016 name_sort_cmp (void *a1, void *a2)
6018 name_sort_t *n1 = a1;
6019 name_sort_t *n2 = a2;
6021 return strcmp ((char *) n1->name, (char *) n2->name);
6025 dump_interface_table (vat_main_t * vam)
6028 name_sort_t *nses = 0, *ns;
6030 if (vam->json_output)
6033 ("JSON output supported only for VPE API calls and dump_stats_table");
6038 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6040 vec_add2 (nses, ns, 1);
6041 ns->name = (u8 *)(p->key);
6042 ns->value = (u32) p->value[0];
6046 vec_sort_with_function (nses, name_sort_cmp);
6048 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6049 vec_foreach (ns, nses)
6051 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6058 dump_ip_table (vat_main_t * vam, int is_ipv6)
6060 const ip_details_t *det = NULL;
6061 const ip_address_details_t *address = NULL;
6064 print (vam->ofp, "%-12s", "sw_if_index");
6066 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6073 print (vam->ofp, "%-12d", i);
6074 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6079 vec_foreach (address, det->addr)
6083 is_ipv6 ? format_ip6_address : format_ip4_address,
6084 address->ip, address->prefix_length);
6092 dump_ipv4_table (vat_main_t * vam)
6094 if (vam->json_output)
6097 ("JSON output supported only for VPE API calls and dump_stats_table");
6101 return dump_ip_table (vam, 0);
6105 dump_ipv6_table (vat_main_t * vam)
6107 if (vam->json_output)
6110 ("JSON output supported only for VPE API calls and dump_stats_table");
6114 return dump_ip_table (vam, 1);
6118 counter_type_to_str (u8 counter_type, u8 is_combined)
6122 switch (counter_type)
6124 case VNET_INTERFACE_COUNTER_DROP:
6126 case VNET_INTERFACE_COUNTER_PUNT:
6128 case VNET_INTERFACE_COUNTER_IP4:
6130 case VNET_INTERFACE_COUNTER_IP6:
6132 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6134 case VNET_INTERFACE_COUNTER_RX_MISS:
6136 case VNET_INTERFACE_COUNTER_RX_ERROR:
6138 case VNET_INTERFACE_COUNTER_TX_ERROR:
6141 return "INVALID-COUNTER-TYPE";
6146 switch (counter_type)
6148 case VNET_INTERFACE_COUNTER_RX:
6150 case VNET_INTERFACE_COUNTER_TX:
6153 return "INVALID-COUNTER-TYPE";
6159 dump_stats_table (vat_main_t * vam)
6161 vat_json_node_t node;
6162 vat_json_node_t *msg_array;
6163 vat_json_node_t *msg;
6164 vat_json_node_t *counter_array;
6165 vat_json_node_t *counter;
6166 interface_counter_t c;
6168 ip4_fib_counter_t *c4;
6169 ip6_fib_counter_t *c6;
6170 ip4_nbr_counter_t *n4;
6171 ip6_nbr_counter_t *n6;
6174 if (!vam->json_output)
6176 clib_warning ("dump_stats_table supported only in JSON format");
6180 vat_json_init_object (&node);
6182 /* interface counters */
6183 msg_array = vat_json_object_add (&node, "interface_counters");
6184 vat_json_init_array (msg_array);
6185 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6187 msg = vat_json_array_add (msg_array);
6188 vat_json_init_object (msg);
6189 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6190 (u8 *) counter_type_to_str (i, 0));
6191 vat_json_object_add_int (msg, "is_combined", 0);
6192 counter_array = vat_json_object_add (msg, "data");
6193 vat_json_init_array (counter_array);
6194 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6196 packets = vam->simple_interface_counters[i][j];
6197 vat_json_array_add_uint (counter_array, packets);
6200 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6202 msg = vat_json_array_add (msg_array);
6203 vat_json_init_object (msg);
6204 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6205 (u8 *) counter_type_to_str (i, 1));
6206 vat_json_object_add_int (msg, "is_combined", 1);
6207 counter_array = vat_json_object_add (msg, "data");
6208 vat_json_init_array (counter_array);
6209 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6211 c = vam->combined_interface_counters[i][j];
6212 counter = vat_json_array_add (counter_array);
6213 vat_json_init_object (counter);
6214 vat_json_object_add_uint (counter, "packets", c.packets);
6215 vat_json_object_add_uint (counter, "bytes", c.bytes);
6219 /* ip4 fib counters */
6220 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6221 vat_json_init_array (msg_array);
6222 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6224 msg = vat_json_array_add (msg_array);
6225 vat_json_init_object (msg);
6226 vat_json_object_add_uint (msg, "vrf_id",
6227 vam->ip4_fib_counters_vrf_id_by_index[i]);
6228 counter_array = vat_json_object_add (msg, "c");
6229 vat_json_init_array (counter_array);
6230 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6232 counter = vat_json_array_add (counter_array);
6233 vat_json_init_object (counter);
6234 c4 = &vam->ip4_fib_counters[i][j];
6235 vat_json_object_add_ip4 (counter, "address", c4->address);
6236 vat_json_object_add_uint (counter, "address_length",
6237 c4->address_length);
6238 vat_json_object_add_uint (counter, "packets", c4->packets);
6239 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6243 /* ip6 fib counters */
6244 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6245 vat_json_init_array (msg_array);
6246 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6248 msg = vat_json_array_add (msg_array);
6249 vat_json_init_object (msg);
6250 vat_json_object_add_uint (msg, "vrf_id",
6251 vam->ip6_fib_counters_vrf_id_by_index[i]);
6252 counter_array = vat_json_object_add (msg, "c");
6253 vat_json_init_array (counter_array);
6254 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6256 counter = vat_json_array_add (counter_array);
6257 vat_json_init_object (counter);
6258 c6 = &vam->ip6_fib_counters[i][j];
6259 vat_json_object_add_ip6 (counter, "address", c6->address);
6260 vat_json_object_add_uint (counter, "address_length",
6261 c6->address_length);
6262 vat_json_object_add_uint (counter, "packets", c6->packets);
6263 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6267 /* ip4 nbr counters */
6268 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6269 vat_json_init_array (msg_array);
6270 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6272 msg = vat_json_array_add (msg_array);
6273 vat_json_init_object (msg);
6274 vat_json_object_add_uint (msg, "sw_if_index", i);
6275 counter_array = vat_json_object_add (msg, "c");
6276 vat_json_init_array (counter_array);
6277 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6279 counter = vat_json_array_add (counter_array);
6280 vat_json_init_object (counter);
6281 n4 = &vam->ip4_nbr_counters[i][j];
6282 vat_json_object_add_ip4 (counter, "address", n4->address);
6283 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6284 vat_json_object_add_uint (counter, "packets", n4->packets);
6285 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6289 /* ip6 nbr counters */
6290 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6291 vat_json_init_array (msg_array);
6292 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6294 msg = vat_json_array_add (msg_array);
6295 vat_json_init_object (msg);
6296 vat_json_object_add_uint (msg, "sw_if_index", i);
6297 counter_array = vat_json_object_add (msg, "c");
6298 vat_json_init_array (counter_array);
6299 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6301 counter = vat_json_array_add (counter_array);
6302 vat_json_init_object (counter);
6303 n6 = &vam->ip6_nbr_counters[i][j];
6304 vat_json_object_add_ip6 (counter, "address", n6->address);
6305 vat_json_object_add_uint (counter, "packets", n6->packets);
6306 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6310 vat_json_print (vam->ofp, &node);
6311 vat_json_free (&node);
6317 * Pass CLI buffers directly in the CLI_INBAND API message,
6318 * instead of an additional shared memory area.
6321 exec_inband (vat_main_t * vam)
6323 vl_api_cli_inband_t *mp;
6324 unformat_input_t *i = vam->input;
6327 if (vec_len (i->buffer) == 0)
6330 if (vam->exec_mode == 0 && unformat (i, "mode"))
6335 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6342 * In order for the CLI command to work, it
6343 * must be a vector ending in \n, not a C-string ending
6346 u32 len = vec_len (vam->input->buffer);
6347 M2 (CLI_INBAND, mp, len);
6348 clib_memcpy (mp->cmd, vam->input->buffer, len);
6349 mp->length = htonl (len);
6353 /* json responses may or may not include a useful reply... */
6354 if (vec_len (vam->cmd_reply))
6355 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6360 exec (vat_main_t * vam)
6362 return exec_inband (vam);
6366 api_create_loopback (vat_main_t * vam)
6368 unformat_input_t *i = vam->input;
6369 vl_api_create_loopback_t *mp;
6370 vl_api_create_loopback_instance_t *mp_lbi;
6373 u8 is_specified = 0;
6374 u32 user_instance = 0;
6377 memset (mac_address, 0, sizeof (mac_address));
6379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6381 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6383 if (unformat (i, "instance %d", &user_instance))
6391 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6392 mp_lbi->is_specified = is_specified;
6394 mp_lbi->user_instance = htonl (user_instance);
6396 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6401 /* Construct the API message */
6402 M (CREATE_LOOPBACK, mp);
6404 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6413 api_delete_loopback (vat_main_t * vam)
6415 unformat_input_t *i = vam->input;
6416 vl_api_delete_loopback_t *mp;
6417 u32 sw_if_index = ~0;
6420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6422 if (unformat (i, "sw_if_index %d", &sw_if_index))
6428 if (sw_if_index == ~0)
6430 errmsg ("missing sw_if_index");
6434 /* Construct the API message */
6435 M (DELETE_LOOPBACK, mp);
6436 mp->sw_if_index = ntohl (sw_if_index);
6444 api_want_stats (vat_main_t * vam)
6446 unformat_input_t *i = vam->input;
6447 vl_api_want_stats_t *mp;
6451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6453 if (unformat (i, "enable"))
6455 else if (unformat (i, "disable"))
6463 errmsg ("missing enable|disable");
6468 mp->enable_disable = enable;
6476 api_want_interface_events (vat_main_t * vam)
6478 unformat_input_t *i = vam->input;
6479 vl_api_want_interface_events_t *mp;
6483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6485 if (unformat (i, "enable"))
6487 else if (unformat (i, "disable"))
6495 errmsg ("missing enable|disable");
6499 M (WANT_INTERFACE_EVENTS, mp);
6500 mp->enable_disable = enable;
6502 vam->interface_event_display = enable;
6510 /* Note: non-static, called once to set up the initial intfc table */
6512 api_sw_interface_dump (vat_main_t * vam)
6514 vl_api_sw_interface_dump_t *mp;
6515 vl_api_control_ping_t *mp_ping;
6517 name_sort_t *nses = 0, *ns;
6518 sw_interface_subif_t *sub = NULL;
6521 /* Toss the old name table */
6523 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6525 vec_add2 (nses, ns, 1);
6526 ns->name = (u8 *)(p->key);
6527 ns->value = (u32) p->value[0];
6531 hash_free (vam->sw_if_index_by_interface_name);
6533 vec_foreach (ns, nses) vec_free (ns->name);
6537 vec_foreach (sub, vam->sw_if_subif_table)
6539 vec_free (sub->interface_name);
6541 vec_free (vam->sw_if_subif_table);
6543 /* recreate the interface name hash table */
6544 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6547 * Ask for all interface names. Otherwise, the epic catalog of
6548 * name filters becomes ridiculously long, and vat ends up needing
6549 * to be taught about new interface types.
6551 M (SW_INTERFACE_DUMP, mp);
6554 /* Use a control ping for synchronization */
6555 MPING (CONTROL_PING, mp_ping);
6563 api_sw_interface_set_flags (vat_main_t * vam)
6565 unformat_input_t *i = vam->input;
6566 vl_api_sw_interface_set_flags_t *mp;
6568 u8 sw_if_index_set = 0;
6572 /* Parse args required to build the message */
6573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "admin-up"))
6577 else if (unformat (i, "admin-down"))
6580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6581 sw_if_index_set = 1;
6582 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6583 sw_if_index_set = 1;
6588 if (sw_if_index_set == 0)
6590 errmsg ("missing interface name or sw_if_index");
6594 /* Construct the API message */
6595 M (SW_INTERFACE_SET_FLAGS, mp);
6596 mp->sw_if_index = ntohl (sw_if_index);
6597 mp->admin_up_down = admin_up;
6602 /* Wait for a reply, return the good/bad news... */
6608 api_sw_interface_set_rx_mode (vat_main_t * vam)
6610 unformat_input_t *i = vam->input;
6611 vl_api_sw_interface_set_rx_mode_t *mp;
6613 u8 sw_if_index_set = 0;
6615 u8 queue_id_valid = 0;
6617 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6619 /* Parse args required to build the message */
6620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6622 if (unformat (i, "queue %d", &queue_id))
6624 else if (unformat (i, "polling"))
6625 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6626 else if (unformat (i, "interrupt"))
6627 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6628 else if (unformat (i, "adaptive"))
6629 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6632 sw_if_index_set = 1;
6633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6634 sw_if_index_set = 1;
6639 if (sw_if_index_set == 0)
6641 errmsg ("missing interface name or sw_if_index");
6644 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6646 errmsg ("missing rx-mode");
6650 /* Construct the API message */
6651 M (SW_INTERFACE_SET_RX_MODE, mp);
6652 mp->sw_if_index = ntohl (sw_if_index);
6654 mp->queue_id_valid = queue_id_valid;
6655 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6660 /* Wait for a reply, return the good/bad news... */
6666 api_sw_interface_clear_stats (vat_main_t * vam)
6668 unformat_input_t *i = vam->input;
6669 vl_api_sw_interface_clear_stats_t *mp;
6671 u8 sw_if_index_set = 0;
6674 /* Parse args required to build the message */
6675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6678 sw_if_index_set = 1;
6679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6680 sw_if_index_set = 1;
6685 /* Construct the API message */
6686 M (SW_INTERFACE_CLEAR_STATS, mp);
6688 if (sw_if_index_set == 1)
6689 mp->sw_if_index = ntohl (sw_if_index);
6691 mp->sw_if_index = ~0;
6696 /* Wait for a reply, return the good/bad news... */
6702 api_sw_interface_add_del_address (vat_main_t * vam)
6704 unformat_input_t *i = vam->input;
6705 vl_api_sw_interface_add_del_address_t *mp;
6707 u8 sw_if_index_set = 0;
6708 u8 is_add = 1, del_all = 0;
6709 u32 address_length = 0;
6710 u8 v4_address_set = 0;
6711 u8 v6_address_set = 0;
6712 ip4_address_t v4address;
6713 ip6_address_t v6address;
6716 /* Parse args required to build the message */
6717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6719 if (unformat (i, "del-all"))
6721 else if (unformat (i, "del"))
6724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6725 sw_if_index_set = 1;
6726 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6727 sw_if_index_set = 1;
6728 else if (unformat (i, "%U/%d",
6729 unformat_ip4_address, &v4address, &address_length))
6731 else if (unformat (i, "%U/%d",
6732 unformat_ip6_address, &v6address, &address_length))
6738 if (sw_if_index_set == 0)
6740 errmsg ("missing interface name or sw_if_index");
6743 if (v4_address_set && v6_address_set)
6745 errmsg ("both v4 and v6 addresses set");
6748 if (!v4_address_set && !v6_address_set && !del_all)
6750 errmsg ("no addresses set");
6754 /* Construct the API message */
6755 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6757 mp->sw_if_index = ntohl (sw_if_index);
6758 mp->is_add = is_add;
6759 mp->del_all = del_all;
6763 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6767 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6769 mp->address_length = address_length;
6774 /* Wait for a reply, return good/bad news */
6780 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6782 unformat_input_t *i = vam->input;
6783 vl_api_sw_interface_set_mpls_enable_t *mp;
6785 u8 sw_if_index_set = 0;
6789 /* Parse args required to build the message */
6790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
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, "disable"))
6798 else if (unformat (i, "dis"))
6804 if (sw_if_index_set == 0)
6806 errmsg ("missing interface name or sw_if_index");
6810 /* Construct the API message */
6811 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6813 mp->sw_if_index = ntohl (sw_if_index);
6814 mp->enable = enable;
6819 /* Wait for a reply... */
6825 api_sw_interface_set_table (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_sw_interface_set_table_t *mp;
6829 u32 sw_if_index, vrf_id = 0;
6830 u8 sw_if_index_set = 0;
6834 /* Parse args required to build the message */
6835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6838 sw_if_index_set = 1;
6839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6840 sw_if_index_set = 1;
6841 else if (unformat (i, "vrf %d", &vrf_id))
6843 else if (unformat (i, "ipv6"))
6849 if (sw_if_index_set == 0)
6851 errmsg ("missing interface name or sw_if_index");
6855 /* Construct the API message */
6856 M (SW_INTERFACE_SET_TABLE, mp);
6858 mp->sw_if_index = ntohl (sw_if_index);
6859 mp->is_ipv6 = is_ipv6;
6860 mp->vrf_id = ntohl (vrf_id);
6865 /* Wait for a reply... */
6870 static void vl_api_sw_interface_get_table_reply_t_handler
6871 (vl_api_sw_interface_get_table_reply_t * mp)
6873 vat_main_t *vam = &vat_main;
6875 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6877 vam->retval = ntohl (mp->retval);
6878 vam->result_ready = 1;
6882 static void vl_api_sw_interface_get_table_reply_t_handler_json
6883 (vl_api_sw_interface_get_table_reply_t * mp)
6885 vat_main_t *vam = &vat_main;
6886 vat_json_node_t node;
6888 vat_json_init_object (&node);
6889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6890 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6892 vat_json_print (vam->ofp, &node);
6893 vat_json_free (&node);
6895 vam->retval = ntohl (mp->retval);
6896 vam->result_ready = 1;
6900 api_sw_interface_get_table (vat_main_t * vam)
6902 unformat_input_t *i = vam->input;
6903 vl_api_sw_interface_get_table_t *mp;
6905 u8 sw_if_index_set = 0;
6909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6912 sw_if_index_set = 1;
6913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6914 sw_if_index_set = 1;
6915 else if (unformat (i, "ipv6"))
6921 if (sw_if_index_set == 0)
6923 errmsg ("missing interface name or sw_if_index");
6927 M (SW_INTERFACE_GET_TABLE, mp);
6928 mp->sw_if_index = htonl (sw_if_index);
6929 mp->is_ipv6 = is_ipv6;
6937 api_sw_interface_set_vpath (vat_main_t * vam)
6939 unformat_input_t *i = vam->input;
6940 vl_api_sw_interface_set_vpath_t *mp;
6941 u32 sw_if_index = 0;
6942 u8 sw_if_index_set = 0;
6946 /* Parse args required to build the message */
6947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6950 sw_if_index_set = 1;
6951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6952 sw_if_index_set = 1;
6953 else if (unformat (i, "enable"))
6955 else if (unformat (i, "disable"))
6961 if (sw_if_index_set == 0)
6963 errmsg ("missing interface name or sw_if_index");
6967 /* Construct the API message */
6968 M (SW_INTERFACE_SET_VPATH, mp);
6970 mp->sw_if_index = ntohl (sw_if_index);
6971 mp->enable = is_enable;
6976 /* Wait for a reply... */
6982 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6984 unformat_input_t *i = vam->input;
6985 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6986 u32 sw_if_index = 0;
6987 u8 sw_if_index_set = 0;
6992 /* Parse args required to build the message */
6993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6996 sw_if_index_set = 1;
6997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6998 sw_if_index_set = 1;
6999 else if (unformat (i, "enable"))
7001 else if (unformat (i, "disable"))
7003 else if (unformat (i, "ip4"))
7005 else if (unformat (i, "ip6"))
7011 if (sw_if_index_set == 0)
7013 errmsg ("missing interface name or sw_if_index");
7017 /* Construct the API message */
7018 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7020 mp->sw_if_index = ntohl (sw_if_index);
7021 mp->enable = is_enable;
7022 mp->is_ipv6 = is_ipv6;
7027 /* Wait for a reply... */
7033 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7035 unformat_input_t *i = vam->input;
7036 vl_api_sw_interface_set_geneve_bypass_t *mp;
7037 u32 sw_if_index = 0;
7038 u8 sw_if_index_set = 0;
7043 /* Parse args required to build the message */
7044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7046 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7047 sw_if_index_set = 1;
7048 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7049 sw_if_index_set = 1;
7050 else if (unformat (i, "enable"))
7052 else if (unformat (i, "disable"))
7054 else if (unformat (i, "ip4"))
7056 else if (unformat (i, "ip6"))
7062 if (sw_if_index_set == 0)
7064 errmsg ("missing interface name or sw_if_index");
7068 /* Construct the API message */
7069 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7071 mp->sw_if_index = ntohl (sw_if_index);
7072 mp->enable = is_enable;
7073 mp->is_ipv6 = is_ipv6;
7078 /* Wait for a reply... */
7084 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7086 unformat_input_t *i = vam->input;
7087 vl_api_sw_interface_set_l2_xconnect_t *mp;
7089 u8 rx_sw_if_index_set = 0;
7091 u8 tx_sw_if_index_set = 0;
7095 /* Parse args required to build the message */
7096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7098 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7099 rx_sw_if_index_set = 1;
7100 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7101 tx_sw_if_index_set = 1;
7102 else if (unformat (i, "rx"))
7104 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7106 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7108 rx_sw_if_index_set = 1;
7113 else if (unformat (i, "tx"))
7115 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7117 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7119 tx_sw_if_index_set = 1;
7124 else if (unformat (i, "enable"))
7126 else if (unformat (i, "disable"))
7132 if (rx_sw_if_index_set == 0)
7134 errmsg ("missing rx interface name or rx_sw_if_index");
7138 if (enable && (tx_sw_if_index_set == 0))
7140 errmsg ("missing tx interface name or tx_sw_if_index");
7144 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7146 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7147 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7148 mp->enable = enable;
7156 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7158 unformat_input_t *i = vam->input;
7159 vl_api_sw_interface_set_l2_bridge_t *mp;
7161 u8 rx_sw_if_index_set = 0;
7169 /* Parse args required to build the message */
7170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7172 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7173 rx_sw_if_index_set = 1;
7174 else if (unformat (i, "bd_id %d", &bd_id))
7178 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7179 rx_sw_if_index_set = 1;
7180 else if (unformat (i, "shg %d", &shg))
7182 else if (unformat (i, "bvi"))
7184 else if (unformat (i, "enable"))
7186 else if (unformat (i, "disable"))
7192 if (rx_sw_if_index_set == 0)
7194 errmsg ("missing rx interface name or sw_if_index");
7198 if (enable && (bd_id_set == 0))
7200 errmsg ("missing bridge domain");
7204 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7206 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7207 mp->bd_id = ntohl (bd_id);
7210 mp->enable = enable;
7218 api_bridge_domain_dump (vat_main_t * vam)
7220 unformat_input_t *i = vam->input;
7221 vl_api_bridge_domain_dump_t *mp;
7222 vl_api_control_ping_t *mp_ping;
7226 /* Parse args required to build the message */
7227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7229 if (unformat (i, "bd_id %d", &bd_id))
7235 M (BRIDGE_DOMAIN_DUMP, mp);
7236 mp->bd_id = ntohl (bd_id);
7239 /* Use a control ping for synchronization */
7240 MPING (CONTROL_PING, mp_ping);
7248 api_bridge_domain_add_del (vat_main_t * vam)
7250 unformat_input_t *i = vam->input;
7251 vl_api_bridge_domain_add_del_t *mp;
7254 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7259 /* Parse args required to build the message */
7260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7262 if (unformat (i, "bd_id %d", &bd_id))
7264 else if (unformat (i, "flood %d", &flood))
7266 else if (unformat (i, "uu-flood %d", &uu_flood))
7268 else if (unformat (i, "forward %d", &forward))
7270 else if (unformat (i, "learn %d", &learn))
7272 else if (unformat (i, "arp-term %d", &arp_term))
7274 else if (unformat (i, "mac-age %d", &mac_age))
7276 else if (unformat (i, "bd-tag %s", &bd_tag))
7278 else if (unformat (i, "del"))
7281 flood = uu_flood = forward = learn = 0;
7289 errmsg ("missing bridge domain");
7296 errmsg ("mac age must be less than 256 ");
7301 if ((bd_tag) && (vec_len (bd_tag) > 63))
7303 errmsg ("bd-tag cannot be longer than 63");
7308 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7310 mp->bd_id = ntohl (bd_id);
7312 mp->uu_flood = uu_flood;
7313 mp->forward = forward;
7315 mp->arp_term = arp_term;
7316 mp->is_add = is_add;
7317 mp->mac_age = (u8) mac_age;
7320 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7321 mp->bd_tag[vec_len (bd_tag)] = 0;
7332 api_l2fib_flush_bd (vat_main_t * vam)
7334 unformat_input_t *i = vam->input;
7335 vl_api_l2fib_flush_bd_t *mp;
7339 /* Parse args required to build the message */
7340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7342 if (unformat (i, "bd_id %d", &bd_id));
7349 errmsg ("missing bridge domain");
7353 M (L2FIB_FLUSH_BD, mp);
7355 mp->bd_id = htonl (bd_id);
7363 api_l2fib_flush_int (vat_main_t * vam)
7365 unformat_input_t *i = vam->input;
7366 vl_api_l2fib_flush_int_t *mp;
7367 u32 sw_if_index = ~0;
7370 /* Parse args required to build the message */
7371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7373 if (unformat (i, "sw_if_index %d", &sw_if_index));
7375 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7380 if (sw_if_index == ~0)
7382 errmsg ("missing interface name or sw_if_index");
7386 M (L2FIB_FLUSH_INT, mp);
7388 mp->sw_if_index = ntohl (sw_if_index);
7396 api_l2fib_add_del (vat_main_t * vam)
7398 unformat_input_t *i = vam->input;
7399 vl_api_l2fib_add_del_t *mp;
7405 u32 sw_if_index = 0;
7406 u8 sw_if_index_set = 0;
7415 /* Parse args required to build the message */
7416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7420 else if (unformat (i, "bd_id %d", &bd_id))
7422 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7423 sw_if_index_set = 1;
7424 else if (unformat (i, "sw_if"))
7426 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7429 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7430 sw_if_index_set = 1;
7435 else if (unformat (i, "static"))
7437 else if (unformat (i, "filter"))
7442 else if (unformat (i, "bvi"))
7447 else if (unformat (i, "del"))
7449 else if (unformat (i, "count %d", &count))
7457 errmsg ("missing mac address");
7463 errmsg ("missing bridge domain");
7467 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7469 errmsg ("missing interface name or sw_if_index");
7475 /* Turn on async mode */
7476 vam->async_mode = 1;
7477 vam->async_errors = 0;
7478 before = vat_time_now (vam);
7481 for (j = 0; j < count; j++)
7483 M (L2FIB_ADD_DEL, mp);
7485 clib_memcpy (mp->mac, mac, 6);
7486 mp->bd_id = ntohl (bd_id);
7487 mp->is_add = is_add;
7488 mp->sw_if_index = ntohl (sw_if_index);
7492 mp->static_mac = static_mac;
7493 mp->filter_mac = filter_mac;
7494 mp->bvi_mac = bvi_mac;
7496 increment_mac_address (mac);
7503 vl_api_control_ping_t *mp_ping;
7506 /* Shut off async mode */
7507 vam->async_mode = 0;
7509 MPING (CONTROL_PING, mp_ping);
7512 timeout = vat_time_now (vam) + 1.0;
7513 while (vat_time_now (vam) < timeout)
7514 if (vam->result_ready == 1)
7519 if (vam->retval == -99)
7522 if (vam->async_errors > 0)
7524 errmsg ("%d asynchronous errors", vam->async_errors);
7527 vam->async_errors = 0;
7528 after = vat_time_now (vam);
7530 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7531 count, after - before, count / (after - before));
7537 /* Wait for a reply... */
7541 /* Return the good/bad news */
7542 return (vam->retval);
7546 api_bridge_domain_set_mac_age (vat_main_t * vam)
7548 unformat_input_t *i = vam->input;
7549 vl_api_bridge_domain_set_mac_age_t *mp;
7554 /* Parse args required to build the message */
7555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7557 if (unformat (i, "bd_id %d", &bd_id));
7558 else if (unformat (i, "mac-age %d", &mac_age));
7565 errmsg ("missing bridge domain");
7571 errmsg ("mac age must be less than 256 ");
7575 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7577 mp->bd_id = htonl (bd_id);
7578 mp->mac_age = (u8) mac_age;
7586 api_l2_flags (vat_main_t * vam)
7588 unformat_input_t *i = vam->input;
7589 vl_api_l2_flags_t *mp;
7592 u8 sw_if_index_set = 0;
7596 /* Parse args required to build the message */
7597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7599 if (unformat (i, "sw_if_index %d", &sw_if_index))
7600 sw_if_index_set = 1;
7601 else if (unformat (i, "sw_if"))
7603 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7606 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7607 sw_if_index_set = 1;
7612 else if (unformat (i, "learn"))
7614 else if (unformat (i, "forward"))
7616 else if (unformat (i, "flood"))
7618 else if (unformat (i, "uu-flood"))
7619 flags |= L2_UU_FLOOD;
7620 else if (unformat (i, "arp-term"))
7621 flags |= L2_ARP_TERM;
7622 else if (unformat (i, "off"))
7624 else if (unformat (i, "disable"))
7630 if (sw_if_index_set == 0)
7632 errmsg ("missing interface name or sw_if_index");
7638 mp->sw_if_index = ntohl (sw_if_index);
7639 mp->feature_bitmap = ntohl (flags);
7640 mp->is_set = is_set;
7648 api_bridge_flags (vat_main_t * vam)
7650 unformat_input_t *i = vam->input;
7651 vl_api_bridge_flags_t *mp;
7658 /* Parse args required to build the message */
7659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7661 if (unformat (i, "bd_id %d", &bd_id))
7663 else if (unformat (i, "learn"))
7665 else if (unformat (i, "forward"))
7667 else if (unformat (i, "flood"))
7669 else if (unformat (i, "uu-flood"))
7670 flags |= L2_UU_FLOOD;
7671 else if (unformat (i, "arp-term"))
7672 flags |= L2_ARP_TERM;
7673 else if (unformat (i, "off"))
7675 else if (unformat (i, "disable"))
7683 errmsg ("missing bridge domain");
7687 M (BRIDGE_FLAGS, mp);
7689 mp->bd_id = ntohl (bd_id);
7690 mp->feature_bitmap = ntohl (flags);
7691 mp->is_set = is_set;
7699 api_bd_ip_mac_add_del (vat_main_t * vam)
7701 unformat_input_t *i = vam->input;
7702 vl_api_bd_ip_mac_add_del_t *mp;
7709 ip4_address_t v4addr;
7710 ip6_address_t v6addr;
7715 /* Parse args required to build the message */
7716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7718 if (unformat (i, "bd_id %d", &bd_id))
7722 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7726 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7731 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7735 else if (unformat (i, "del"))
7743 errmsg ("missing bridge domain");
7746 else if (ip_set == 0)
7748 errmsg ("missing IP address");
7751 else if (mac_set == 0)
7753 errmsg ("missing MAC address");
7757 M (BD_IP_MAC_ADD_DEL, mp);
7759 mp->bd_id = ntohl (bd_id);
7760 mp->is_ipv6 = is_ipv6;
7761 mp->is_add = is_add;
7763 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7765 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7766 clib_memcpy (mp->mac_address, macaddr, 6);
7773 api_tap_connect (vat_main_t * vam)
7775 unformat_input_t *i = vam->input;
7776 vl_api_tap_connect_t *mp;
7782 ip4_address_t ip4_address;
7784 int ip4_address_set = 0;
7785 ip6_address_t ip6_address;
7787 int ip6_address_set = 0;
7790 memset (mac_address, 0, sizeof (mac_address));
7792 /* Parse args required to build the message */
7793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7795 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7799 else if (unformat (i, "random-mac"))
7801 else if (unformat (i, "tapname %s", &tap_name))
7803 else if (unformat (i, "tag %s", &tag))
7805 else if (unformat (i, "address %U/%d",
7806 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7807 ip4_address_set = 1;
7808 else if (unformat (i, "address %U/%d",
7809 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7810 ip6_address_set = 1;
7817 errmsg ("missing tap name");
7820 if (vec_len (tap_name) > 63)
7822 errmsg ("tap name too long");
7825 vec_add1 (tap_name, 0);
7827 if (vec_len (tag) > 63)
7829 errmsg ("tag too long");
7833 /* Construct the API message */
7834 M (TAP_CONNECT, mp);
7836 mp->use_random_mac = random_mac;
7837 clib_memcpy (mp->mac_address, mac_address, 6);
7838 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7840 clib_memcpy (mp->tag, tag, vec_len (tag));
7842 if (ip4_address_set)
7844 mp->ip4_address_set = 1;
7845 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7846 mp->ip4_mask_width = ip4_mask_width;
7848 if (ip6_address_set)
7850 mp->ip6_address_set = 1;
7851 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7852 mp->ip6_mask_width = ip6_mask_width;
7855 vec_free (tap_name);
7861 /* Wait for a reply... */
7867 api_tap_modify (vat_main_t * vam)
7869 unformat_input_t *i = vam->input;
7870 vl_api_tap_modify_t *mp;
7875 u32 sw_if_index = ~0;
7876 u8 sw_if_index_set = 0;
7879 memset (mac_address, 0, sizeof (mac_address));
7881 /* Parse args required to build the message */
7882 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7885 sw_if_index_set = 1;
7886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7887 sw_if_index_set = 1;
7888 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7892 else if (unformat (i, "random-mac"))
7894 else if (unformat (i, "tapname %s", &tap_name))
7900 if (sw_if_index_set == 0)
7902 errmsg ("missing vpp interface name");
7907 errmsg ("missing tap name");
7910 if (vec_len (tap_name) > 63)
7912 errmsg ("tap name too long");
7914 vec_add1 (tap_name, 0);
7916 /* Construct the API message */
7919 mp->use_random_mac = random_mac;
7920 mp->sw_if_index = ntohl (sw_if_index);
7921 clib_memcpy (mp->mac_address, mac_address, 6);
7922 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7923 vec_free (tap_name);
7928 /* Wait for a reply... */
7934 api_tap_delete (vat_main_t * vam)
7936 unformat_input_t *i = vam->input;
7937 vl_api_tap_delete_t *mp;
7938 u32 sw_if_index = ~0;
7939 u8 sw_if_index_set = 0;
7942 /* Parse args required to build the message */
7943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7946 sw_if_index_set = 1;
7947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7948 sw_if_index_set = 1;
7953 if (sw_if_index_set == 0)
7955 errmsg ("missing vpp interface name");
7959 /* Construct the API message */
7962 mp->sw_if_index = ntohl (sw_if_index);
7967 /* Wait for a reply... */
7973 api_tap_create_v2 (vat_main_t * vam)
7975 unformat_input_t *i = vam->input;
7976 vl_api_tap_create_v2_t *mp;
7980 u8 *host_if_name = 0;
7982 u8 host_mac_addr[6];
7983 u8 host_mac_addr_set = 0;
7984 u8 *host_bridge = 0;
7985 ip4_address_t host_ip4_addr;
7986 ip4_address_t host_ip4_gw;
7987 u8 host_ip4_gw_set = 0;
7988 u32 host_ip4_prefix_len = 0;
7989 ip6_address_t host_ip6_addr;
7990 ip6_address_t host_ip6_gw;
7991 u8 host_ip6_gw_set = 0;
7992 u32 host_ip6_prefix_len = 0;
7994 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7996 memset (mac_address, 0, sizeof (mac_address));
7998 /* Parse args required to build the message */
7999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8001 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8005 else if (unformat (i, "id %u", &id))
8007 else if (unformat (i, "host-if-name %s", &host_if_name))
8009 else if (unformat (i, "host-ns %s", &host_ns))
8011 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8013 host_mac_addr_set = 1;
8014 else if (unformat (i, "host-bridge %s", &host_bridge))
8016 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8017 &host_ip4_addr, &host_ip4_prefix_len))
8019 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8020 &host_ip6_addr, &host_ip6_prefix_len))
8022 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8024 host_ip4_gw_set = 1;
8025 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8027 host_ip6_gw_set = 1;
8028 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8030 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8036 if (vec_len (host_if_name) > 63)
8038 errmsg ("tap name too long. ");
8041 if (vec_len (host_ns) > 63)
8043 errmsg ("host name space too long. ");
8046 if (vec_len (host_bridge) > 63)
8048 errmsg ("host bridge name too long. ");
8051 if (host_ip4_prefix_len > 32)
8053 errmsg ("host ip4 prefix length not valid. ");
8056 if (host_ip6_prefix_len > 128)
8058 errmsg ("host ip6 prefix length not valid. ");
8061 if (!is_pow2 (rx_ring_sz))
8063 errmsg ("rx ring size must be power of 2. ");
8066 if (rx_ring_sz > 32768)
8068 errmsg ("rx ring size must be 32768 or lower. ");
8071 if (!is_pow2 (tx_ring_sz))
8073 errmsg ("tx ring size must be power of 2. ");
8076 if (tx_ring_sz > 32768)
8078 errmsg ("tx ring size must be 32768 or lower. ");
8082 /* Construct the API message */
8083 M (TAP_CREATE_V2, mp);
8085 mp->use_random_mac = random_mac;
8087 mp->id = ntohl (id);
8088 mp->host_namespace_set = host_ns != 0;
8089 mp->host_bridge_set = host_bridge != 0;
8090 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8091 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8092 mp->rx_ring_sz = ntohs (rx_ring_sz);
8093 mp->tx_ring_sz = ntohs (tx_ring_sz);
8095 if (random_mac == 0)
8096 clib_memcpy (mp->mac_address, mac_address, 6);
8097 if (host_mac_addr_set)
8098 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8100 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8102 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8104 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8105 if (host_ip4_prefix_len)
8106 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8107 if (host_ip4_prefix_len)
8108 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8109 if (host_ip4_gw_set)
8110 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8111 if (host_ip6_gw_set)
8112 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8115 vec_free (host_if_name);
8116 vec_free (host_bridge);
8121 /* Wait for a reply... */
8127 api_tap_delete_v2 (vat_main_t * vam)
8129 unformat_input_t *i = vam->input;
8130 vl_api_tap_delete_v2_t *mp;
8131 u32 sw_if_index = ~0;
8132 u8 sw_if_index_set = 0;
8135 /* Parse args required to build the message */
8136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8138 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8139 sw_if_index_set = 1;
8140 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8141 sw_if_index_set = 1;
8146 if (sw_if_index_set == 0)
8148 errmsg ("missing vpp interface name. ");
8152 /* Construct the API message */
8153 M (TAP_DELETE_V2, mp);
8155 mp->sw_if_index = ntohl (sw_if_index);
8160 /* Wait for a reply... */
8166 api_bond_create (vat_main_t * vam)
8168 unformat_input_t *i = vam->input;
8169 vl_api_bond_create_t *mp;
8177 memset (mac_address, 0, sizeof (mac_address));
8180 /* Parse args required to build the message */
8181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8183 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8185 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8186 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8188 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8195 if (mode_is_set == 0)
8197 errmsg ("Missing bond mode. ");
8201 /* Construct the API message */
8202 M (BOND_CREATE, mp);
8204 mp->use_custom_mac = custom_mac;
8210 clib_memcpy (mp->mac_address, mac_address, 6);
8215 /* Wait for a reply... */
8221 api_bond_delete (vat_main_t * vam)
8223 unformat_input_t *i = vam->input;
8224 vl_api_bond_delete_t *mp;
8225 u32 sw_if_index = ~0;
8226 u8 sw_if_index_set = 0;
8229 /* Parse args required to build the message */
8230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8233 sw_if_index_set = 1;
8234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8235 sw_if_index_set = 1;
8240 if (sw_if_index_set == 0)
8242 errmsg ("missing vpp interface name. ");
8246 /* Construct the API message */
8247 M (BOND_DELETE, mp);
8249 mp->sw_if_index = ntohl (sw_if_index);
8254 /* Wait for a reply... */
8260 api_bond_enslave (vat_main_t * vam)
8262 unformat_input_t *i = vam->input;
8263 vl_api_bond_enslave_t *mp;
8264 u32 bond_sw_if_index;
8268 u32 bond_sw_if_index_is_set = 0;
8270 u8 sw_if_index_is_set = 0;
8272 /* Parse args required to build the message */
8273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8275 if (unformat (i, "sw_if_index %d", &sw_if_index))
8276 sw_if_index_is_set = 1;
8277 else if (unformat (i, "bond %u", &bond_sw_if_index))
8278 bond_sw_if_index_is_set = 1;
8279 else if (unformat (i, "passive %d", &is_passive))
8281 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8287 if (bond_sw_if_index_is_set == 0)
8289 errmsg ("Missing bond sw_if_index. ");
8292 if (sw_if_index_is_set == 0)
8294 errmsg ("Missing slave sw_if_index. ");
8298 /* Construct the API message */
8299 M (BOND_ENSLAVE, mp);
8301 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8302 mp->sw_if_index = ntohl (sw_if_index);
8303 mp->is_long_timeout = is_long_timeout;
8304 mp->is_passive = is_passive;
8309 /* Wait for a reply... */
8315 api_bond_detach_slave (vat_main_t * vam)
8317 unformat_input_t *i = vam->input;
8318 vl_api_bond_detach_slave_t *mp;
8319 u32 sw_if_index = ~0;
8320 u8 sw_if_index_set = 0;
8323 /* Parse args required to build the message */
8324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8327 sw_if_index_set = 1;
8328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8329 sw_if_index_set = 1;
8334 if (sw_if_index_set == 0)
8336 errmsg ("missing vpp interface name. ");
8340 /* Construct the API message */
8341 M (BOND_DETACH_SLAVE, mp);
8343 mp->sw_if_index = ntohl (sw_if_index);
8348 /* Wait for a reply... */
8354 api_ip_table_add_del (vat_main_t * vam)
8356 unformat_input_t *i = vam->input;
8357 vl_api_ip_table_add_del_t *mp;
8363 /* Parse args required to build the message */
8364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8366 if (unformat (i, "ipv6"))
8368 else if (unformat (i, "del"))
8370 else if (unformat (i, "add"))
8372 else if (unformat (i, "table %d", &table_id))
8376 clib_warning ("parse error '%U'", format_unformat_error, i);
8383 errmsg ("missing table-ID");
8387 /* Construct the API message */
8388 M (IP_TABLE_ADD_DEL, mp);
8390 mp->table_id = ntohl (table_id);
8391 mp->is_ipv6 = is_ipv6;
8392 mp->is_add = is_add;
8397 /* Wait for a reply... */
8404 api_ip_add_del_route (vat_main_t * vam)
8406 unformat_input_t *i = vam->input;
8407 vl_api_ip_add_del_route_t *mp;
8408 u32 sw_if_index = ~0, vrf_id = 0;
8410 u8 is_local = 0, is_drop = 0;
8411 u8 is_unreach = 0, is_prohibit = 0;
8413 u32 next_hop_weight = 1;
8414 u8 is_multipath = 0;
8416 u8 address_length_set = 0;
8417 u32 next_hop_table_id = 0;
8418 u32 resolve_attempts = 0;
8419 u32 dst_address_length = 0;
8420 u8 next_hop_set = 0;
8421 ip4_address_t v4_dst_address, v4_next_hop_address;
8422 ip6_address_t v6_dst_address, v6_next_hop_address;
8426 u32 random_add_del = 0;
8427 u32 *random_vector = 0;
8429 u32 random_seed = 0xdeaddabe;
8430 u32 classify_table_index = ~0;
8432 u8 resolve_host = 0, resolve_attached = 0;
8433 mpls_label_t *next_hop_out_label_stack = NULL;
8434 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8435 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8437 /* Parse args required to build the message */
8438 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8440 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8442 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8444 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8449 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8454 else if (unformat (i, "/%d", &dst_address_length))
8456 address_length_set = 1;
8459 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8460 &v4_next_hop_address))
8464 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8465 &v6_next_hop_address))
8469 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8471 else if (unformat (i, "weight %d", &next_hop_weight))
8473 else if (unformat (i, "drop"))
8477 else if (unformat (i, "null-send-unreach"))
8481 else if (unformat (i, "null-send-prohibit"))
8485 else if (unformat (i, "local"))
8489 else if (unformat (i, "classify %d", &classify_table_index))
8493 else if (unformat (i, "del"))
8495 else if (unformat (i, "add"))
8497 else if (unformat (i, "resolve-via-host"))
8499 else if (unformat (i, "resolve-via-attached"))
8500 resolve_attached = 1;
8501 else if (unformat (i, "multipath"))
8503 else if (unformat (i, "vrf %d", &vrf_id))
8505 else if (unformat (i, "count %d", &count))
8507 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8509 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8511 else if (unformat (i, "out-label %d", &next_hop_out_label))
8512 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8513 else if (unformat (i, "via-label %d", &next_hop_via_label))
8515 else if (unformat (i, "random"))
8517 else if (unformat (i, "seed %d", &random_seed))
8521 clib_warning ("parse error '%U'", format_unformat_error, i);
8526 if (!next_hop_set && !is_drop && !is_local &&
8527 !is_classify && !is_unreach && !is_prohibit &&
8528 MPLS_LABEL_INVALID == next_hop_via_label)
8531 ("next hop / local / drop / unreach / prohibit / classify not set");
8535 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8537 errmsg ("next hop and next-hop via label set");
8540 if (address_set == 0)
8542 errmsg ("missing addresses");
8546 if (address_length_set == 0)
8548 errmsg ("missing address length");
8552 /* Generate a pile of unique, random routes */
8555 u32 this_random_address;
8556 random_hash = hash_create (count, sizeof (uword));
8558 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8559 for (j = 0; j <= count; j++)
8563 this_random_address = random_u32 (&random_seed);
8564 this_random_address =
8565 clib_host_to_net_u32 (this_random_address);
8567 while (hash_get (random_hash, this_random_address));
8568 vec_add1 (random_vector, this_random_address);
8569 hash_set (random_hash, this_random_address, 1);
8571 hash_free (random_hash);
8572 v4_dst_address.as_u32 = random_vector[0];
8577 /* Turn on async mode */
8578 vam->async_mode = 1;
8579 vam->async_errors = 0;
8580 before = vat_time_now (vam);
8583 for (j = 0; j < count; j++)
8585 /* Construct the API message */
8586 M2 (IP_ADD_DEL_ROUTE, mp,
8587 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8589 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8590 mp->table_id = ntohl (vrf_id);
8592 mp->is_add = is_add;
8593 mp->is_drop = is_drop;
8594 mp->is_unreach = is_unreach;
8595 mp->is_prohibit = is_prohibit;
8596 mp->is_ipv6 = is_ipv6;
8597 mp->is_local = is_local;
8598 mp->is_classify = is_classify;
8599 mp->is_multipath = is_multipath;
8600 mp->is_resolve_host = resolve_host;
8601 mp->is_resolve_attached = resolve_attached;
8602 mp->next_hop_weight = next_hop_weight;
8603 mp->dst_address_length = dst_address_length;
8604 mp->next_hop_table_id = ntohl (next_hop_table_id);
8605 mp->classify_table_index = ntohl (classify_table_index);
8606 mp->next_hop_via_label = ntohl (next_hop_via_label);
8607 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8608 if (0 != mp->next_hop_n_out_labels)
8610 memcpy (mp->next_hop_out_label_stack,
8611 next_hop_out_label_stack,
8612 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8613 vec_free (next_hop_out_label_stack);
8618 clib_memcpy (mp->dst_address, &v6_dst_address,
8619 sizeof (v6_dst_address));
8621 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8622 sizeof (v6_next_hop_address));
8623 increment_v6_address (&v6_dst_address);
8627 clib_memcpy (mp->dst_address, &v4_dst_address,
8628 sizeof (v4_dst_address));
8630 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8631 sizeof (v4_next_hop_address));
8633 v4_dst_address.as_u32 = random_vector[j + 1];
8635 increment_v4_address (&v4_dst_address);
8639 /* If we receive SIGTERM, stop now... */
8644 /* When testing multiple add/del ops, use a control-ping to sync */
8647 vl_api_control_ping_t *mp_ping;
8651 /* Shut off async mode */
8652 vam->async_mode = 0;
8654 MPING (CONTROL_PING, mp_ping);
8657 timeout = vat_time_now (vam) + 1.0;
8658 while (vat_time_now (vam) < timeout)
8659 if (vam->result_ready == 1)
8664 if (vam->retval == -99)
8667 if (vam->async_errors > 0)
8669 errmsg ("%d asynchronous errors", vam->async_errors);
8672 vam->async_errors = 0;
8673 after = vat_time_now (vam);
8675 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8679 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8680 count, after - before, count / (after - before));
8686 /* Wait for a reply... */
8691 /* Return the good/bad news */
8692 return (vam->retval);
8696 api_ip_mroute_add_del (vat_main_t * vam)
8698 unformat_input_t *i = vam->input;
8699 vl_api_ip_mroute_add_del_t *mp;
8700 u32 sw_if_index = ~0, vrf_id = 0;
8705 u32 grp_address_length = 0;
8706 ip4_address_t v4_grp_address, v4_src_address;
8707 ip6_address_t v6_grp_address, v6_src_address;
8708 mfib_itf_flags_t iflags = 0;
8709 mfib_entry_flags_t eflags = 0;
8712 /* Parse args required to build the message */
8713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8715 if (unformat (i, "sw_if_index %d", &sw_if_index))
8717 else if (unformat (i, "%U %U",
8718 unformat_ip4_address, &v4_src_address,
8719 unformat_ip4_address, &v4_grp_address))
8721 grp_address_length = 64;
8725 else if (unformat (i, "%U %U",
8726 unformat_ip6_address, &v6_src_address,
8727 unformat_ip6_address, &v6_grp_address))
8729 grp_address_length = 256;
8733 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8735 memset (&v4_src_address, 0, sizeof (v4_src_address));
8736 grp_address_length = 32;
8740 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8742 memset (&v6_src_address, 0, sizeof (v6_src_address));
8743 grp_address_length = 128;
8747 else if (unformat (i, "/%d", &grp_address_length))
8749 else if (unformat (i, "local"))
8753 else if (unformat (i, "del"))
8755 else if (unformat (i, "add"))
8757 else if (unformat (i, "vrf %d", &vrf_id))
8759 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8761 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8765 clib_warning ("parse error '%U'", format_unformat_error, i);
8770 if (address_set == 0)
8772 errmsg ("missing addresses\n");
8776 /* Construct the API message */
8777 M (IP_MROUTE_ADD_DEL, mp);
8779 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8780 mp->table_id = ntohl (vrf_id);
8782 mp->is_add = is_add;
8783 mp->is_ipv6 = is_ipv6;
8784 mp->is_local = is_local;
8785 mp->itf_flags = ntohl (iflags);
8786 mp->entry_flags = ntohl (eflags);
8787 mp->grp_address_length = grp_address_length;
8788 mp->grp_address_length = ntohs (mp->grp_address_length);
8792 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8793 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8797 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8798 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8804 /* Wait for a reply... */
8810 api_mpls_table_add_del (vat_main_t * vam)
8812 unformat_input_t *i = vam->input;
8813 vl_api_mpls_table_add_del_t *mp;
8818 /* Parse args required to build the message */
8819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8821 if (unformat (i, "table %d", &table_id))
8823 else if (unformat (i, "del"))
8825 else if (unformat (i, "add"))
8829 clib_warning ("parse error '%U'", format_unformat_error, i);
8836 errmsg ("missing table-ID");
8840 /* Construct the API message */
8841 M (MPLS_TABLE_ADD_DEL, mp);
8843 mp->mt_table_id = ntohl (table_id);
8844 mp->mt_is_add = is_add;
8849 /* Wait for a reply... */
8856 api_mpls_route_add_del (vat_main_t * vam)
8858 unformat_input_t *i = vam->input;
8859 vl_api_mpls_route_add_del_t *mp;
8860 u32 sw_if_index = ~0, table_id = 0;
8862 u32 next_hop_weight = 1;
8863 u8 is_multipath = 0;
8864 u32 next_hop_table_id = 0;
8865 u8 next_hop_set = 0;
8866 ip4_address_t v4_next_hop_address = {
8869 ip6_address_t v6_next_hop_address = { {0} };
8873 u32 classify_table_index = ~0;
8875 u8 resolve_host = 0, resolve_attached = 0;
8876 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8877 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8878 mpls_label_t *next_hop_out_label_stack = NULL;
8879 mpls_label_t local_label = MPLS_LABEL_INVALID;
8881 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8883 /* Parse args required to build the message */
8884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8886 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8888 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8890 else if (unformat (i, "%d", &local_label))
8892 else if (unformat (i, "eos"))
8894 else if (unformat (i, "non-eos"))
8896 else if (unformat (i, "via %U", unformat_ip4_address,
8897 &v4_next_hop_address))
8900 next_hop_proto = DPO_PROTO_IP4;
8902 else if (unformat (i, "via %U", unformat_ip6_address,
8903 &v6_next_hop_address))
8906 next_hop_proto = DPO_PROTO_IP6;
8908 else if (unformat (i, "weight %d", &next_hop_weight))
8910 else if (unformat (i, "classify %d", &classify_table_index))
8914 else if (unformat (i, "del"))
8916 else if (unformat (i, "add"))
8918 else if (unformat (i, "resolve-via-host"))
8920 else if (unformat (i, "resolve-via-attached"))
8921 resolve_attached = 1;
8922 else if (unformat (i, "multipath"))
8924 else if (unformat (i, "count %d", &count))
8926 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8929 next_hop_proto = DPO_PROTO_IP4;
8931 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8934 next_hop_proto = DPO_PROTO_IP6;
8936 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8938 else if (unformat (i, "via-label %d", &next_hop_via_label))
8940 else if (unformat (i, "out-label %d", &next_hop_out_label))
8941 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8944 clib_warning ("parse error '%U'", format_unformat_error, i);
8949 if (!next_hop_set && !is_classify)
8951 errmsg ("next hop / classify not set");
8955 if (MPLS_LABEL_INVALID == local_label)
8957 errmsg ("missing label");
8963 /* Turn on async mode */
8964 vam->async_mode = 1;
8965 vam->async_errors = 0;
8966 before = vat_time_now (vam);
8969 for (j = 0; j < count; j++)
8971 /* Construct the API message */
8972 M2 (MPLS_ROUTE_ADD_DEL, mp,
8973 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8975 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8976 mp->mr_table_id = ntohl (table_id);
8978 mp->mr_is_add = is_add;
8979 mp->mr_next_hop_proto = next_hop_proto;
8980 mp->mr_is_classify = is_classify;
8981 mp->mr_is_multipath = is_multipath;
8982 mp->mr_is_resolve_host = resolve_host;
8983 mp->mr_is_resolve_attached = resolve_attached;
8984 mp->mr_next_hop_weight = next_hop_weight;
8985 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8986 mp->mr_classify_table_index = ntohl (classify_table_index);
8987 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8988 mp->mr_label = ntohl (local_label);
8989 mp->mr_eos = is_eos;
8991 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8992 if (0 != mp->mr_next_hop_n_out_labels)
8994 memcpy (mp->mr_next_hop_out_label_stack,
8995 next_hop_out_label_stack,
8996 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8997 vec_free (next_hop_out_label_stack);
9002 if (DPO_PROTO_IP4 == next_hop_proto)
9004 clib_memcpy (mp->mr_next_hop,
9005 &v4_next_hop_address,
9006 sizeof (v4_next_hop_address));
9008 else if (DPO_PROTO_IP6 == next_hop_proto)
9011 clib_memcpy (mp->mr_next_hop,
9012 &v6_next_hop_address,
9013 sizeof (v6_next_hop_address));
9020 /* If we receive SIGTERM, stop now... */
9025 /* When testing multiple add/del ops, use a control-ping to sync */
9028 vl_api_control_ping_t *mp_ping;
9032 /* Shut off async mode */
9033 vam->async_mode = 0;
9035 MPING (CONTROL_PING, mp_ping);
9038 timeout = vat_time_now (vam) + 1.0;
9039 while (vat_time_now (vam) < timeout)
9040 if (vam->result_ready == 1)
9045 if (vam->retval == -99)
9048 if (vam->async_errors > 0)
9050 errmsg ("%d asynchronous errors", vam->async_errors);
9053 vam->async_errors = 0;
9054 after = vat_time_now (vam);
9056 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9060 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9061 count, after - before, count / (after - before));
9067 /* Wait for a reply... */
9072 /* Return the good/bad news */
9073 return (vam->retval);
9077 api_mpls_ip_bind_unbind (vat_main_t * vam)
9079 unformat_input_t *i = vam->input;
9080 vl_api_mpls_ip_bind_unbind_t *mp;
9081 u32 ip_table_id = 0;
9084 ip4_address_t v4_address;
9085 ip6_address_t v6_address;
9088 mpls_label_t local_label = MPLS_LABEL_INVALID;
9091 /* Parse args required to build the message */
9092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9094 if (unformat (i, "%U/%d", unformat_ip4_address,
9095 &v4_address, &address_length))
9100 else if (unformat (i, "%U/%d", unformat_ip6_address,
9101 &v6_address, &address_length))
9106 else if (unformat (i, "%d", &local_label))
9108 else if (unformat (i, "table-id %d", &ip_table_id))
9110 else if (unformat (i, "unbind"))
9112 else if (unformat (i, "bind"))
9116 clib_warning ("parse error '%U'", format_unformat_error, i);
9123 errmsg ("IP addres not set");
9127 if (MPLS_LABEL_INVALID == local_label)
9129 errmsg ("missing label");
9133 /* Construct the API message */
9134 M (MPLS_IP_BIND_UNBIND, mp);
9136 mp->mb_is_bind = is_bind;
9137 mp->mb_is_ip4 = is_ip4;
9138 mp->mb_ip_table_id = ntohl (ip_table_id);
9139 mp->mb_mpls_table_id = 0;
9140 mp->mb_label = ntohl (local_label);
9141 mp->mb_address_length = address_length;
9144 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9146 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9151 /* Wait for a reply... */
9157 api_bier_table_add_del (vat_main_t * vam)
9159 unformat_input_t *i = vam->input;
9160 vl_api_bier_table_add_del_t *mp;
9162 u32 set = 0, sub_domain = 0, hdr_len = 3;
9163 mpls_label_t local_label = MPLS_LABEL_INVALID;
9166 /* Parse args required to build the message */
9167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9169 if (unformat (i, "sub-domain %d", &sub_domain))
9171 else if (unformat (i, "set %d", &set))
9173 else if (unformat (i, "label %d", &local_label))
9175 else if (unformat (i, "hdr-len %d", &hdr_len))
9177 else if (unformat (i, "add"))
9179 else if (unformat (i, "del"))
9183 clib_warning ("parse error '%U'", format_unformat_error, i);
9188 if (MPLS_LABEL_INVALID == local_label)
9190 errmsg ("missing label\n");
9194 /* Construct the API message */
9195 M (BIER_TABLE_ADD_DEL, mp);
9197 mp->bt_is_add = is_add;
9198 mp->bt_label = ntohl (local_label);
9199 mp->bt_tbl_id.bt_set = set;
9200 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9201 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9206 /* Wait for a reply... */
9213 api_bier_route_add_del (vat_main_t * vam)
9215 unformat_input_t *i = vam->input;
9216 vl_api_bier_route_add_del_t *mp;
9218 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9219 ip4_address_t v4_next_hop_address;
9220 ip6_address_t v6_next_hop_address;
9221 u8 next_hop_set = 0;
9222 u8 next_hop_proto_is_ip4 = 1;
9223 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9226 /* Parse args required to build the message */
9227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9229 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9231 next_hop_proto_is_ip4 = 1;
9234 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9236 next_hop_proto_is_ip4 = 0;
9239 if (unformat (i, "sub-domain %d", &sub_domain))
9241 else if (unformat (i, "set %d", &set))
9243 else if (unformat (i, "hdr-len %d", &hdr_len))
9245 else if (unformat (i, "bp %d", &bp))
9247 else if (unformat (i, "add"))
9249 else if (unformat (i, "del"))
9251 else if (unformat (i, "out-label %d", &next_hop_out_label))
9255 clib_warning ("parse error '%U'", format_unformat_error, i);
9260 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9262 errmsg ("next hop / label set\n");
9267 errmsg ("bit=position not set\n");
9271 /* Construct the API message */
9272 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9274 mp->br_is_add = is_add;
9275 mp->br_tbl_id.bt_set = set;
9276 mp->br_tbl_id.bt_sub_domain = sub_domain;
9277 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9278 mp->br_bp = ntohs (bp);
9280 mp->br_paths[0].n_labels = 1;
9281 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9282 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9284 if (next_hop_proto_is_ip4)
9286 clib_memcpy (mp->br_paths[0].next_hop,
9287 &v4_next_hop_address, sizeof (v4_next_hop_address));
9291 clib_memcpy (mp->br_paths[0].next_hop,
9292 &v6_next_hop_address, sizeof (v6_next_hop_address));
9298 /* Wait for a reply... */
9305 api_proxy_arp_add_del (vat_main_t * vam)
9307 unformat_input_t *i = vam->input;
9308 vl_api_proxy_arp_add_del_t *mp;
9311 ip4_address_t lo, hi;
9315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9317 if (unformat (i, "vrf %d", &vrf_id))
9319 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9320 unformat_ip4_address, &hi))
9322 else if (unformat (i, "del"))
9326 clib_warning ("parse error '%U'", format_unformat_error, i);
9333 errmsg ("address range not set");
9337 M (PROXY_ARP_ADD_DEL, mp);
9339 mp->proxy.vrf_id = ntohl (vrf_id);
9340 mp->is_add = is_add;
9341 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9342 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9350 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9352 unformat_input_t *i = vam->input;
9353 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9356 u8 sw_if_index_set = 0;
9359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9361 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9362 sw_if_index_set = 1;
9363 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9364 sw_if_index_set = 1;
9365 else if (unformat (i, "enable"))
9367 else if (unformat (i, "disable"))
9371 clib_warning ("parse error '%U'", format_unformat_error, i);
9376 if (sw_if_index_set == 0)
9378 errmsg ("missing interface name or sw_if_index");
9382 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9384 mp->sw_if_index = ntohl (sw_if_index);
9385 mp->enable_disable = enable;
9393 api_mpls_tunnel_add_del (vat_main_t * vam)
9395 unformat_input_t *i = vam->input;
9396 vl_api_mpls_tunnel_add_del_t *mp;
9400 u32 sw_if_index = ~0;
9401 u32 next_hop_sw_if_index = ~0;
9402 u32 next_hop_proto_is_ip4 = 1;
9404 u32 next_hop_table_id = 0;
9405 ip4_address_t v4_next_hop_address = {
9408 ip6_address_t v6_next_hop_address = { {0} };
9409 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9414 if (unformat (i, "add"))
9416 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9418 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9420 else if (unformat (i, "via %U",
9421 unformat_ip4_address, &v4_next_hop_address))
9423 next_hop_proto_is_ip4 = 1;
9425 else if (unformat (i, "via %U",
9426 unformat_ip6_address, &v6_next_hop_address))
9428 next_hop_proto_is_ip4 = 0;
9430 else if (unformat (i, "l2-only"))
9432 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9434 else if (unformat (i, "out-label %d", &next_hop_out_label))
9435 vec_add1 (labels, ntohl (next_hop_out_label));
9438 clib_warning ("parse error '%U'", format_unformat_error, i);
9443 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9445 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9446 mp->mt_sw_if_index = ntohl (sw_if_index);
9447 mp->mt_is_add = is_add;
9448 mp->mt_l2_only = l2_only;
9449 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9450 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9452 mp->mt_next_hop_n_out_labels = vec_len (labels);
9454 if (0 != mp->mt_next_hop_n_out_labels)
9456 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9457 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9461 if (next_hop_proto_is_ip4)
9463 clib_memcpy (mp->mt_next_hop,
9464 &v4_next_hop_address, sizeof (v4_next_hop_address));
9468 clib_memcpy (mp->mt_next_hop,
9469 &v6_next_hop_address, sizeof (v6_next_hop_address));
9478 api_sw_interface_set_unnumbered (vat_main_t * vam)
9480 unformat_input_t *i = vam->input;
9481 vl_api_sw_interface_set_unnumbered_t *mp;
9483 u32 unnum_sw_index = ~0;
9485 u8 sw_if_index_set = 0;
9488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9490 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9491 sw_if_index_set = 1;
9492 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9493 sw_if_index_set = 1;
9494 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9496 else if (unformat (i, "del"))
9500 clib_warning ("parse error '%U'", format_unformat_error, i);
9505 if (sw_if_index_set == 0)
9507 errmsg ("missing interface name or sw_if_index");
9511 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9513 mp->sw_if_index = ntohl (sw_if_index);
9514 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9515 mp->is_add = is_add;
9523 api_ip_neighbor_add_del (vat_main_t * vam)
9525 unformat_input_t *i = vam->input;
9526 vl_api_ip_neighbor_add_del_t *mp;
9528 u8 sw_if_index_set = 0;
9531 u8 is_no_fib_entry = 0;
9534 u8 v4_address_set = 0;
9535 u8 v6_address_set = 0;
9536 ip4_address_t v4address;
9537 ip6_address_t v6address;
9540 memset (mac_address, 0, sizeof (mac_address));
9542 /* Parse args required to build the message */
9543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9545 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9549 else if (unformat (i, "del"))
9552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9553 sw_if_index_set = 1;
9554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9555 sw_if_index_set = 1;
9556 else if (unformat (i, "is_static"))
9558 else if (unformat (i, "no-fib-entry"))
9559 is_no_fib_entry = 1;
9560 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9562 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9566 clib_warning ("parse error '%U'", format_unformat_error, i);
9571 if (sw_if_index_set == 0)
9573 errmsg ("missing interface name or sw_if_index");
9576 if (v4_address_set && v6_address_set)
9578 errmsg ("both v4 and v6 addresses set");
9581 if (!v4_address_set && !v6_address_set)
9583 errmsg ("no address set");
9587 /* Construct the API message */
9588 M (IP_NEIGHBOR_ADD_DEL, mp);
9590 mp->sw_if_index = ntohl (sw_if_index);
9591 mp->is_add = is_add;
9592 mp->is_static = is_static;
9593 mp->is_no_adj_fib = is_no_fib_entry;
9595 clib_memcpy (mp->mac_address, mac_address, 6);
9599 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9603 /* mp->is_ipv6 = 0; via memset in M macro above */
9604 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9610 /* Wait for a reply, return good/bad news */
9616 api_create_vlan_subif (vat_main_t * vam)
9618 unformat_input_t *i = vam->input;
9619 vl_api_create_vlan_subif_t *mp;
9621 u8 sw_if_index_set = 0;
9626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9628 if (unformat (i, "sw_if_index %d", &sw_if_index))
9629 sw_if_index_set = 1;
9631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9632 sw_if_index_set = 1;
9633 else if (unformat (i, "vlan %d", &vlan_id))
9637 clib_warning ("parse error '%U'", format_unformat_error, i);
9642 if (sw_if_index_set == 0)
9644 errmsg ("missing interface name or sw_if_index");
9648 if (vlan_id_set == 0)
9650 errmsg ("missing vlan_id");
9653 M (CREATE_VLAN_SUBIF, mp);
9655 mp->sw_if_index = ntohl (sw_if_index);
9656 mp->vlan_id = ntohl (vlan_id);
9663 #define foreach_create_subif_bit \
9670 _(outer_vlan_id_any) \
9671 _(inner_vlan_id_any)
9674 api_create_subif (vat_main_t * vam)
9676 unformat_input_t *i = vam->input;
9677 vl_api_create_subif_t *mp;
9679 u8 sw_if_index_set = 0;
9686 u32 exact_match = 0;
9687 u32 default_sub = 0;
9688 u32 outer_vlan_id_any = 0;
9689 u32 inner_vlan_id_any = 0;
9691 u16 outer_vlan_id = 0;
9692 u16 inner_vlan_id = 0;
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "sw_if_index %d", &sw_if_index))
9698 sw_if_index_set = 1;
9700 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9701 sw_if_index_set = 1;
9702 else if (unformat (i, "sub_id %d", &sub_id))
9704 else if (unformat (i, "outer_vlan_id %d", &tmp))
9705 outer_vlan_id = tmp;
9706 else if (unformat (i, "inner_vlan_id %d", &tmp))
9707 inner_vlan_id = tmp;
9709 #define _(a) else if (unformat (i, #a)) a = 1 ;
9710 foreach_create_subif_bit
9714 clib_warning ("parse error '%U'", format_unformat_error, i);
9719 if (sw_if_index_set == 0)
9721 errmsg ("missing interface name or sw_if_index");
9725 if (sub_id_set == 0)
9727 errmsg ("missing sub_id");
9730 M (CREATE_SUBIF, mp);
9732 mp->sw_if_index = ntohl (sw_if_index);
9733 mp->sub_id = ntohl (sub_id);
9735 #define _(a) mp->a = a;
9736 foreach_create_subif_bit;
9739 mp->outer_vlan_id = ntohs (outer_vlan_id);
9740 mp->inner_vlan_id = ntohs (inner_vlan_id);
9748 api_oam_add_del (vat_main_t * vam)
9750 unformat_input_t *i = vam->input;
9751 vl_api_oam_add_del_t *mp;
9754 ip4_address_t src, dst;
9759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9761 if (unformat (i, "vrf %d", &vrf_id))
9763 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9765 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9767 else if (unformat (i, "del"))
9771 clib_warning ("parse error '%U'", format_unformat_error, i);
9778 errmsg ("missing src addr");
9784 errmsg ("missing dst addr");
9788 M (OAM_ADD_DEL, mp);
9790 mp->vrf_id = ntohl (vrf_id);
9791 mp->is_add = is_add;
9792 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9793 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9801 api_reset_fib (vat_main_t * vam)
9803 unformat_input_t *i = vam->input;
9804 vl_api_reset_fib_t *mp;
9810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9812 if (unformat (i, "vrf %d", &vrf_id))
9814 else if (unformat (i, "ipv6"))
9818 clib_warning ("parse error '%U'", format_unformat_error, i);
9823 if (vrf_id_set == 0)
9825 errmsg ("missing vrf id");
9831 mp->vrf_id = ntohl (vrf_id);
9832 mp->is_ipv6 = is_ipv6;
9840 api_dhcp_proxy_config (vat_main_t * vam)
9842 unformat_input_t *i = vam->input;
9843 vl_api_dhcp_proxy_config_t *mp;
9845 u32 server_vrf_id = 0;
9847 u8 v4_address_set = 0;
9848 u8 v6_address_set = 0;
9849 ip4_address_t v4address;
9850 ip6_address_t v6address;
9851 u8 v4_src_address_set = 0;
9852 u8 v6_src_address_set = 0;
9853 ip4_address_t v4srcaddress;
9854 ip6_address_t v6srcaddress;
9857 /* Parse args required to build the message */
9858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9860 if (unformat (i, "del"))
9862 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9864 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9866 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9868 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9870 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9871 v4_src_address_set = 1;
9872 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9873 v6_src_address_set = 1;
9878 if (v4_address_set && v6_address_set)
9880 errmsg ("both v4 and v6 server addresses set");
9883 if (!v4_address_set && !v6_address_set)
9885 errmsg ("no server addresses set");
9889 if (v4_src_address_set && v6_src_address_set)
9891 errmsg ("both v4 and v6 src addresses set");
9894 if (!v4_src_address_set && !v6_src_address_set)
9896 errmsg ("no src addresses set");
9900 if (!(v4_src_address_set && v4_address_set) &&
9901 !(v6_src_address_set && v6_address_set))
9903 errmsg ("no matching server and src addresses set");
9907 /* Construct the API message */
9908 M (DHCP_PROXY_CONFIG, mp);
9910 mp->is_add = is_add;
9911 mp->rx_vrf_id = ntohl (rx_vrf_id);
9912 mp->server_vrf_id = ntohl (server_vrf_id);
9916 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9917 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9921 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9922 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9928 /* Wait for a reply, return good/bad news */
9933 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9934 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9937 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9939 vat_main_t *vam = &vat_main;
9940 u32 i, count = mp->count;
9941 vl_api_dhcp_server_t *s;
9945 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9946 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9947 ntohl (mp->rx_vrf_id),
9948 format_ip6_address, mp->dhcp_src_address,
9949 mp->vss_type, mp->vss_vpn_ascii_id,
9950 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9953 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9954 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9955 ntohl (mp->rx_vrf_id),
9956 format_ip4_address, mp->dhcp_src_address,
9957 mp->vss_type, mp->vss_vpn_ascii_id,
9958 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9960 for (i = 0; i < count; i++)
9962 s = &mp->servers[i];
9966 " Server Table-ID %d, Server Address %U",
9967 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9970 " Server Table-ID %d, Server Address %U",
9971 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9975 static void vl_api_dhcp_proxy_details_t_handler_json
9976 (vl_api_dhcp_proxy_details_t * mp)
9978 vat_main_t *vam = &vat_main;
9979 vat_json_node_t *node = NULL;
9980 u32 i, count = mp->count;
9982 struct in6_addr ip6;
9983 vl_api_dhcp_server_t *s;
9985 if (VAT_JSON_ARRAY != vam->json_tree.type)
9987 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9988 vat_json_init_array (&vam->json_tree);
9990 node = vat_json_array_add (&vam->json_tree);
9992 vat_json_init_object (node);
9993 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9994 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9995 sizeof (mp->vss_type));
9996 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9997 mp->vss_vpn_ascii_id);
9998 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9999 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10003 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10004 vat_json_object_add_ip6 (node, "src_address", ip6);
10008 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10009 vat_json_object_add_ip4 (node, "src_address", ip4);
10012 for (i = 0; i < count; i++)
10014 s = &mp->servers[i];
10016 vat_json_object_add_uint (node, "server-table-id",
10017 ntohl (s->server_vrf_id));
10021 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10022 vat_json_object_add_ip4 (node, "src_address", ip4);
10026 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10027 vat_json_object_add_ip6 (node, "server_address", ip6);
10033 api_dhcp_proxy_dump (vat_main_t * vam)
10035 unformat_input_t *i = vam->input;
10036 vl_api_control_ping_t *mp_ping;
10037 vl_api_dhcp_proxy_dump_t *mp;
10041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10043 if (unformat (i, "ipv6"))
10047 clib_warning ("parse error '%U'", format_unformat_error, i);
10052 M (DHCP_PROXY_DUMP, mp);
10054 mp->is_ip6 = is_ipv6;
10057 /* Use a control ping for synchronization */
10058 MPING (CONTROL_PING, mp_ping);
10066 api_dhcp_proxy_set_vss (vat_main_t * vam)
10068 unformat_input_t *i = vam->input;
10069 vl_api_dhcp_proxy_set_vss_t *mp;
10073 u8 vss_type = VSS_TYPE_DEFAULT;
10074 u8 *vpn_ascii_id = 0;
10079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10081 if (unformat (i, "tbl_id %d", &tbl_id))
10083 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10084 vss_type = VSS_TYPE_ASCII;
10085 else if (unformat (i, "fib_id %d", &fib_id))
10086 vss_type = VSS_TYPE_VPN_ID;
10087 else if (unformat (i, "oui %d", &oui))
10088 vss_type = VSS_TYPE_VPN_ID;
10089 else if (unformat (i, "ipv6"))
10091 else if (unformat (i, "del"))
10099 errmsg ("missing tbl_id ");
10100 vec_free (vpn_ascii_id);
10104 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10106 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10107 vec_free (vpn_ascii_id);
10111 M (DHCP_PROXY_SET_VSS, mp);
10112 mp->tbl_id = ntohl (tbl_id);
10113 mp->vss_type = vss_type;
10116 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10117 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10119 mp->vpn_index = ntohl (fib_id);
10120 mp->oui = ntohl (oui);
10121 mp->is_ipv6 = is_ipv6;
10122 mp->is_add = is_add;
10127 vec_free (vpn_ascii_id);
10132 api_dhcp_client_config (vat_main_t * vam)
10134 unformat_input_t *i = vam->input;
10135 vl_api_dhcp_client_config_t *mp;
10137 u8 sw_if_index_set = 0;
10140 u8 disable_event = 0;
10143 /* Parse args required to build the message */
10144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10146 if (unformat (i, "del"))
10149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10150 sw_if_index_set = 1;
10151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10152 sw_if_index_set = 1;
10153 else if (unformat (i, "hostname %s", &hostname))
10155 else if (unformat (i, "disable_event"))
10161 if (sw_if_index_set == 0)
10163 errmsg ("missing interface name or sw_if_index");
10167 if (vec_len (hostname) > 63)
10169 errmsg ("hostname too long");
10171 vec_add1 (hostname, 0);
10173 /* Construct the API message */
10174 M (DHCP_CLIENT_CONFIG, mp);
10176 mp->is_add = is_add;
10177 mp->client.sw_if_index = htonl (sw_if_index);
10178 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10179 vec_free (hostname);
10180 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10181 mp->client.pid = htonl (getpid ());
10186 /* Wait for a reply, return good/bad news */
10192 api_set_ip_flow_hash (vat_main_t * vam)
10194 unformat_input_t *i = vam->input;
10195 vl_api_set_ip_flow_hash_t *mp;
10207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10209 if (unformat (i, "vrf %d", &vrf_id))
10211 else if (unformat (i, "ipv6"))
10213 else if (unformat (i, "src"))
10215 else if (unformat (i, "dst"))
10217 else if (unformat (i, "sport"))
10219 else if (unformat (i, "dport"))
10221 else if (unformat (i, "proto"))
10223 else if (unformat (i, "reverse"))
10228 clib_warning ("parse error '%U'", format_unformat_error, i);
10233 if (vrf_id_set == 0)
10235 errmsg ("missing vrf id");
10239 M (SET_IP_FLOW_HASH, mp);
10245 mp->reverse = reverse;
10246 mp->vrf_id = ntohl (vrf_id);
10247 mp->is_ipv6 = is_ipv6;
10255 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10257 unformat_input_t *i = vam->input;
10258 vl_api_sw_interface_ip6_enable_disable_t *mp;
10260 u8 sw_if_index_set = 0;
10264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10266 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10267 sw_if_index_set = 1;
10268 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10269 sw_if_index_set = 1;
10270 else if (unformat (i, "enable"))
10272 else if (unformat (i, "disable"))
10276 clib_warning ("parse error '%U'", format_unformat_error, i);
10281 if (sw_if_index_set == 0)
10283 errmsg ("missing interface name or sw_if_index");
10287 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10289 mp->sw_if_index = ntohl (sw_if_index);
10290 mp->enable = enable;
10298 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10300 unformat_input_t *i = vam->input;
10301 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10303 u8 sw_if_index_set = 0;
10304 u8 v6_address_set = 0;
10305 ip6_address_t v6address;
10308 /* Parse args required to build the message */
10309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10312 sw_if_index_set = 1;
10313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10314 sw_if_index_set = 1;
10315 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10316 v6_address_set = 1;
10321 if (sw_if_index_set == 0)
10323 errmsg ("missing interface name or sw_if_index");
10326 if (!v6_address_set)
10328 errmsg ("no address set");
10332 /* Construct the API message */
10333 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10335 mp->sw_if_index = ntohl (sw_if_index);
10336 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10341 /* Wait for a reply, return good/bad news */
10347 api_ip6nd_proxy_add_del (vat_main_t * vam)
10349 unformat_input_t *i = vam->input;
10350 vl_api_ip6nd_proxy_add_del_t *mp;
10351 u32 sw_if_index = ~0;
10352 u8 v6_address_set = 0;
10353 ip6_address_t v6address;
10357 /* Parse args required to build the message */
10358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10364 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10365 v6_address_set = 1;
10366 if (unformat (i, "del"))
10370 clib_warning ("parse error '%U'", format_unformat_error, i);
10375 if (sw_if_index == ~0)
10377 errmsg ("missing interface name or sw_if_index");
10380 if (!v6_address_set)
10382 errmsg ("no address set");
10386 /* Construct the API message */
10387 M (IP6ND_PROXY_ADD_DEL, mp);
10389 mp->is_del = is_del;
10390 mp->sw_if_index = ntohl (sw_if_index);
10391 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10396 /* Wait for a reply, return good/bad news */
10402 api_ip6nd_proxy_dump (vat_main_t * vam)
10404 vl_api_ip6nd_proxy_dump_t *mp;
10405 vl_api_control_ping_t *mp_ping;
10408 M (IP6ND_PROXY_DUMP, mp);
10412 /* Use a control ping for synchronization */
10413 MPING (CONTROL_PING, mp_ping);
10420 static void vl_api_ip6nd_proxy_details_t_handler
10421 (vl_api_ip6nd_proxy_details_t * mp)
10423 vat_main_t *vam = &vat_main;
10425 print (vam->ofp, "host %U sw_if_index %d",
10426 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10429 static void vl_api_ip6nd_proxy_details_t_handler_json
10430 (vl_api_ip6nd_proxy_details_t * mp)
10432 vat_main_t *vam = &vat_main;
10433 struct in6_addr ip6;
10434 vat_json_node_t *node = NULL;
10436 if (VAT_JSON_ARRAY != vam->json_tree.type)
10438 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10439 vat_json_init_array (&vam->json_tree);
10441 node = vat_json_array_add (&vam->json_tree);
10443 vat_json_init_object (node);
10444 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10446 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10447 vat_json_object_add_ip6 (node, "host", ip6);
10451 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10453 unformat_input_t *i = vam->input;
10454 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10456 u8 sw_if_index_set = 0;
10457 u32 address_length = 0;
10458 u8 v6_address_set = 0;
10459 ip6_address_t v6address;
10460 u8 use_default = 0;
10461 u8 no_advertise = 0;
10463 u8 no_autoconfig = 0;
10466 u32 val_lifetime = 0;
10467 u32 pref_lifetime = 0;
10470 /* Parse args required to build the message */
10471 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10473 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10474 sw_if_index_set = 1;
10475 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10476 sw_if_index_set = 1;
10477 else if (unformat (i, "%U/%d",
10478 unformat_ip6_address, &v6address, &address_length))
10479 v6_address_set = 1;
10480 else if (unformat (i, "val_life %d", &val_lifetime))
10482 else if (unformat (i, "pref_life %d", &pref_lifetime))
10484 else if (unformat (i, "def"))
10486 else if (unformat (i, "noadv"))
10488 else if (unformat (i, "offl"))
10490 else if (unformat (i, "noauto"))
10492 else if (unformat (i, "nolink"))
10494 else if (unformat (i, "isno"))
10498 clib_warning ("parse error '%U'", format_unformat_error, i);
10503 if (sw_if_index_set == 0)
10505 errmsg ("missing interface name or sw_if_index");
10508 if (!v6_address_set)
10510 errmsg ("no address set");
10514 /* Construct the API message */
10515 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10517 mp->sw_if_index = ntohl (sw_if_index);
10518 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10519 mp->address_length = address_length;
10520 mp->use_default = use_default;
10521 mp->no_advertise = no_advertise;
10522 mp->off_link = off_link;
10523 mp->no_autoconfig = no_autoconfig;
10524 mp->no_onlink = no_onlink;
10526 mp->val_lifetime = ntohl (val_lifetime);
10527 mp->pref_lifetime = ntohl (pref_lifetime);
10532 /* Wait for a reply, return good/bad news */
10538 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10540 unformat_input_t *i = vam->input;
10541 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10543 u8 sw_if_index_set = 0;
10548 u8 send_unicast = 0;
10551 u8 default_router = 0;
10552 u32 max_interval = 0;
10553 u32 min_interval = 0;
10555 u32 initial_count = 0;
10556 u32 initial_interval = 0;
10560 /* Parse args required to build the message */
10561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10563 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10564 sw_if_index_set = 1;
10565 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10566 sw_if_index_set = 1;
10567 else if (unformat (i, "maxint %d", &max_interval))
10569 else if (unformat (i, "minint %d", &min_interval))
10571 else if (unformat (i, "life %d", &lifetime))
10573 else if (unformat (i, "count %d", &initial_count))
10575 else if (unformat (i, "interval %d", &initial_interval))
10577 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10579 else if (unformat (i, "managed"))
10581 else if (unformat (i, "other"))
10583 else if (unformat (i, "ll"))
10585 else if (unformat (i, "send"))
10587 else if (unformat (i, "cease"))
10589 else if (unformat (i, "isno"))
10591 else if (unformat (i, "def"))
10592 default_router = 1;
10595 clib_warning ("parse error '%U'", format_unformat_error, i);
10600 if (sw_if_index_set == 0)
10602 errmsg ("missing interface name or sw_if_index");
10606 /* Construct the API message */
10607 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10609 mp->sw_if_index = ntohl (sw_if_index);
10610 mp->max_interval = ntohl (max_interval);
10611 mp->min_interval = ntohl (min_interval);
10612 mp->lifetime = ntohl (lifetime);
10613 mp->initial_count = ntohl (initial_count);
10614 mp->initial_interval = ntohl (initial_interval);
10615 mp->suppress = suppress;
10616 mp->managed = managed;
10618 mp->ll_option = ll_option;
10619 mp->send_unicast = send_unicast;
10622 mp->default_router = default_router;
10627 /* Wait for a reply, return good/bad news */
10633 api_set_arp_neighbor_limit (vat_main_t * vam)
10635 unformat_input_t *i = vam->input;
10636 vl_api_set_arp_neighbor_limit_t *mp;
10642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10644 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10646 else if (unformat (i, "ipv6"))
10650 clib_warning ("parse error '%U'", format_unformat_error, i);
10655 if (limit_set == 0)
10657 errmsg ("missing limit value");
10661 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10663 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10664 mp->is_ipv6 = is_ipv6;
10672 api_l2_patch_add_del (vat_main_t * vam)
10674 unformat_input_t *i = vam->input;
10675 vl_api_l2_patch_add_del_t *mp;
10676 u32 rx_sw_if_index;
10677 u8 rx_sw_if_index_set = 0;
10678 u32 tx_sw_if_index;
10679 u8 tx_sw_if_index_set = 0;
10683 /* Parse args required to build the message */
10684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10686 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10687 rx_sw_if_index_set = 1;
10688 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10689 tx_sw_if_index_set = 1;
10690 else if (unformat (i, "rx"))
10692 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10694 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10696 rx_sw_if_index_set = 1;
10701 else if (unformat (i, "tx"))
10703 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10705 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10707 tx_sw_if_index_set = 1;
10712 else if (unformat (i, "del"))
10718 if (rx_sw_if_index_set == 0)
10720 errmsg ("missing rx interface name or rx_sw_if_index");
10724 if (tx_sw_if_index_set == 0)
10726 errmsg ("missing tx interface name or tx_sw_if_index");
10730 M (L2_PATCH_ADD_DEL, mp);
10732 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10733 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10734 mp->is_add = is_add;
10742 u8 localsid_addr[16];
10751 api_sr_localsid_add_del (vat_main_t * vam)
10753 unformat_input_t *i = vam->input;
10754 vl_api_sr_localsid_add_del_t *mp;
10757 ip6_address_t localsid;
10761 u32 fib_table = ~(u32) 0;
10762 ip6_address_t next_hop;
10764 bool nexthop_set = 0;
10768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10770 if (unformat (i, "del"))
10772 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10773 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10775 else if (unformat (i, "behavior %u", &behavior));
10776 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10777 else if (unformat (i, "fib-table %u", &fib_table));
10778 else if (unformat (i, "end.psp %u", &behavior));
10783 M (SR_LOCALSID_ADD_DEL, mp);
10785 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10787 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10788 mp->behavior = behavior;
10789 mp->sw_if_index = ntohl (sw_if_index);
10790 mp->fib_table = ntohl (fib_table);
10791 mp->end_psp = end_psp;
10792 mp->is_del = is_del;
10800 api_ioam_enable (vat_main_t * vam)
10802 unformat_input_t *input = vam->input;
10803 vl_api_ioam_enable_t *mp;
10805 int has_trace_option = 0;
10806 int has_pot_option = 0;
10807 int has_seqno_option = 0;
10808 int has_analyse_option = 0;
10811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10813 if (unformat (input, "trace"))
10814 has_trace_option = 1;
10815 else if (unformat (input, "pot"))
10816 has_pot_option = 1;
10817 else if (unformat (input, "seqno"))
10818 has_seqno_option = 1;
10819 else if (unformat (input, "analyse"))
10820 has_analyse_option = 1;
10824 M (IOAM_ENABLE, mp);
10825 mp->id = htons (id);
10826 mp->seqno = has_seqno_option;
10827 mp->analyse = has_analyse_option;
10828 mp->pot_enable = has_pot_option;
10829 mp->trace_enable = has_trace_option;
10838 api_ioam_disable (vat_main_t * vam)
10840 vl_api_ioam_disable_t *mp;
10843 M (IOAM_DISABLE, mp);
10849 #define foreach_tcp_proto_field \
10853 #define foreach_udp_proto_field \
10857 #define foreach_ip4_proto_field \
10869 u16 src_port, dst_port;
10872 #if VPP_API_TEST_BUILTIN == 0
10874 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10876 u8 **maskp = va_arg (*args, u8 **);
10878 u8 found_something = 0;
10881 #define _(a) u8 a=0;
10882 foreach_tcp_proto_field;
10885 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10888 #define _(a) else if (unformat (input, #a)) a=1;
10889 foreach_tcp_proto_field
10895 #define _(a) found_something += a;
10896 foreach_tcp_proto_field;
10899 if (found_something == 0)
10902 vec_validate (mask, sizeof (*tcp) - 1);
10904 tcp = (tcp_header_t *) mask;
10906 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10907 foreach_tcp_proto_field;
10915 unformat_udp_mask (unformat_input_t * input, va_list * args)
10917 u8 **maskp = va_arg (*args, u8 **);
10919 u8 found_something = 0;
10922 #define _(a) u8 a=0;
10923 foreach_udp_proto_field;
10926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10929 #define _(a) else if (unformat (input, #a)) a=1;
10930 foreach_udp_proto_field
10936 #define _(a) found_something += a;
10937 foreach_udp_proto_field;
10940 if (found_something == 0)
10943 vec_validate (mask, sizeof (*udp) - 1);
10945 udp = (udp_header_t *) mask;
10947 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10948 foreach_udp_proto_field;
10956 unformat_l4_mask (unformat_input_t * input, va_list * args)
10958 u8 **maskp = va_arg (*args, u8 **);
10959 u16 src_port = 0, dst_port = 0;
10960 tcpudp_header_t *tcpudp;
10962 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10964 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10966 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10968 else if (unformat (input, "src_port"))
10970 else if (unformat (input, "dst_port"))
10976 if (!src_port && !dst_port)
10980 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10982 tcpudp = (tcpudp_header_t *) mask;
10983 tcpudp->src_port = src_port;
10984 tcpudp->dst_port = dst_port;
10992 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10994 u8 **maskp = va_arg (*args, u8 **);
10996 u8 found_something = 0;
10999 #define _(a) u8 a=0;
11000 foreach_ip4_proto_field;
11006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11008 if (unformat (input, "version"))
11010 else if (unformat (input, "hdr_length"))
11012 else if (unformat (input, "src"))
11014 else if (unformat (input, "dst"))
11016 else if (unformat (input, "proto"))
11019 #define _(a) else if (unformat (input, #a)) a=1;
11020 foreach_ip4_proto_field
11026 #define _(a) found_something += a;
11027 foreach_ip4_proto_field;
11030 if (found_something == 0)
11033 vec_validate (mask, sizeof (*ip) - 1);
11035 ip = (ip4_header_t *) mask;
11037 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11038 foreach_ip4_proto_field;
11041 ip->ip_version_and_header_length = 0;
11044 ip->ip_version_and_header_length |= 0xF0;
11047 ip->ip_version_and_header_length |= 0x0F;
11053 #define foreach_ip6_proto_field \
11056 _(payload_length) \
11061 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11063 u8 **maskp = va_arg (*args, u8 **);
11065 u8 found_something = 0;
11067 u32 ip_version_traffic_class_and_flow_label;
11069 #define _(a) u8 a=0;
11070 foreach_ip6_proto_field;
11073 u8 traffic_class = 0;
11076 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11078 if (unformat (input, "version"))
11080 else if (unformat (input, "traffic-class"))
11082 else if (unformat (input, "flow-label"))
11084 else if (unformat (input, "src"))
11086 else if (unformat (input, "dst"))
11088 else if (unformat (input, "proto"))
11091 #define _(a) else if (unformat (input, #a)) a=1;
11092 foreach_ip6_proto_field
11098 #define _(a) found_something += a;
11099 foreach_ip6_proto_field;
11102 if (found_something == 0)
11105 vec_validate (mask, sizeof (*ip) - 1);
11107 ip = (ip6_header_t *) mask;
11109 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11110 foreach_ip6_proto_field;
11113 ip_version_traffic_class_and_flow_label = 0;
11116 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11119 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11122 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11124 ip->ip_version_traffic_class_and_flow_label =
11125 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11132 unformat_l3_mask (unformat_input_t * input, va_list * args)
11134 u8 **maskp = va_arg (*args, u8 **);
11136 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11138 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11140 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11149 unformat_l2_mask (unformat_input_t * input, va_list * args)
11151 u8 **maskp = va_arg (*args, u8 **);
11158 u8 ignore_tag1 = 0;
11159 u8 ignore_tag2 = 0;
11166 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11168 if (unformat (input, "src"))
11170 else if (unformat (input, "dst"))
11172 else if (unformat (input, "proto"))
11174 else if (unformat (input, "tag1"))
11176 else if (unformat (input, "tag2"))
11178 else if (unformat (input, "ignore-tag1"))
11180 else if (unformat (input, "ignore-tag2"))
11182 else if (unformat (input, "cos1"))
11184 else if (unformat (input, "cos2"))
11186 else if (unformat (input, "dot1q"))
11188 else if (unformat (input, "dot1ad"))
11193 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11194 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11197 if (tag1 || ignore_tag1 || cos1 || dot1q)
11199 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11202 vec_validate (mask, len - 1);
11205 memset (mask, 0xff, 6);
11208 memset (mask + 6, 0xff, 6);
11210 if (tag2 || dot1ad)
11212 /* inner vlan tag */
11221 mask[21] = mask[20] = 0xff;
11242 mask[16] = mask[17] = 0xff;
11252 mask[12] = mask[13] = 0xff;
11259 unformat_classify_mask (unformat_input_t * input, va_list * args)
11261 u8 **maskp = va_arg (*args, u8 **);
11262 u32 *skipp = va_arg (*args, u32 *);
11263 u32 *matchp = va_arg (*args, u32 *);
11271 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11273 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11275 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11277 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11279 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11293 if (mask || l2 || l3 || l4)
11295 if (l2 || l3 || l4)
11297 /* "With a free Ethernet header in every package" */
11299 vec_validate (l2, 13);
11303 vec_append (mask, l3);
11308 vec_append (mask, l4);
11313 /* Scan forward looking for the first significant mask octet */
11314 for (i = 0; i < vec_len (mask); i++)
11318 /* compute (skip, match) params */
11319 *skipp = i / sizeof (u32x4);
11320 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11322 /* Pad mask to an even multiple of the vector size */
11323 while (vec_len (mask) % sizeof (u32x4))
11324 vec_add1 (mask, 0);
11326 match = vec_len (mask) / sizeof (u32x4);
11328 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11330 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11331 if (*tmp || *(tmp + 1))
11336 clib_warning ("BUG: match 0");
11338 _vec_len (mask) = match * sizeof (u32x4);
11348 #endif /* VPP_API_TEST_BUILTIN */
11350 #define foreach_l2_next \
11352 _(ethernet, ETHERNET_INPUT) \
11353 _(ip4, IP4_INPUT) \
11357 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11359 u32 *miss_next_indexp = va_arg (*args, u32 *);
11360 u32 next_index = 0;
11364 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11368 if (unformat (input, "%d", &tmp))
11377 *miss_next_indexp = next_index;
11381 #define foreach_ip_next \
11384 _(rewrite, REWRITE)
11387 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11389 u32 *miss_next_indexp = va_arg (*args, u32 *);
11390 u32 next_index = 0;
11394 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11398 if (unformat (input, "%d", &tmp))
11407 *miss_next_indexp = next_index;
11411 #define foreach_acl_next \
11415 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11417 u32 *miss_next_indexp = va_arg (*args, u32 *);
11418 u32 next_index = 0;
11422 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11426 if (unformat (input, "permit"))
11431 else if (unformat (input, "%d", &tmp))
11440 *miss_next_indexp = next_index;
11445 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11447 u32 *r = va_arg (*args, u32 *);
11449 if (unformat (input, "conform-color"))
11450 *r = POLICE_CONFORM;
11451 else if (unformat (input, "exceed-color"))
11452 *r = POLICE_EXCEED;
11460 api_classify_add_del_table (vat_main_t * vam)
11462 unformat_input_t *i = vam->input;
11463 vl_api_classify_add_del_table_t *mp;
11470 u32 table_index = ~0;
11471 u32 next_table_index = ~0;
11472 u32 miss_next_index = ~0;
11473 u32 memory_size = 32 << 20;
11475 u32 current_data_flag = 0;
11476 int current_data_offset = 0;
11479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11481 if (unformat (i, "del"))
11483 else if (unformat (i, "del-chain"))
11488 else if (unformat (i, "buckets %d", &nbuckets))
11490 else if (unformat (i, "memory_size %d", &memory_size))
11492 else if (unformat (i, "skip %d", &skip))
11494 else if (unformat (i, "match %d", &match))
11496 else if (unformat (i, "table %d", &table_index))
11498 else if (unformat (i, "mask %U", unformat_classify_mask,
11499 &mask, &skip, &match))
11501 else if (unformat (i, "next-table %d", &next_table_index))
11503 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11506 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11509 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11512 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11514 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11520 if (is_add && mask == 0)
11522 errmsg ("Mask required");
11526 if (is_add && skip == ~0)
11528 errmsg ("skip count required");
11532 if (is_add && match == ~0)
11534 errmsg ("match count required");
11538 if (!is_add && table_index == ~0)
11540 errmsg ("table index required for delete");
11544 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11546 mp->is_add = is_add;
11547 mp->del_chain = del_chain;
11548 mp->table_index = ntohl (table_index);
11549 mp->nbuckets = ntohl (nbuckets);
11550 mp->memory_size = ntohl (memory_size);
11551 mp->skip_n_vectors = ntohl (skip);
11552 mp->match_n_vectors = ntohl (match);
11553 mp->next_table_index = ntohl (next_table_index);
11554 mp->miss_next_index = ntohl (miss_next_index);
11555 mp->current_data_flag = ntohl (current_data_flag);
11556 mp->current_data_offset = ntohl (current_data_offset);
11557 clib_memcpy (mp->mask, mask, vec_len (mask));
11566 #if VPP_API_TEST_BUILTIN == 0
11568 unformat_l4_match (unformat_input_t * input, va_list * args)
11570 u8 **matchp = va_arg (*args, u8 **);
11572 u8 *proto_header = 0;
11578 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11580 if (unformat (input, "src_port %d", &src_port))
11582 else if (unformat (input, "dst_port %d", &dst_port))
11588 h.src_port = clib_host_to_net_u16 (src_port);
11589 h.dst_port = clib_host_to_net_u16 (dst_port);
11590 vec_validate (proto_header, sizeof (h) - 1);
11591 memcpy (proto_header, &h, sizeof (h));
11593 *matchp = proto_header;
11599 unformat_ip4_match (unformat_input_t * input, va_list * args)
11601 u8 **matchp = va_arg (*args, u8 **);
11606 int hdr_length = 0;
11607 u32 hdr_length_val;
11608 int src = 0, dst = 0;
11609 ip4_address_t src_val, dst_val;
11616 int fragment_id = 0;
11617 u32 fragment_id_val;
11623 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11625 if (unformat (input, "version %d", &version_val))
11627 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11629 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11631 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11633 else if (unformat (input, "proto %d", &proto_val))
11635 else if (unformat (input, "tos %d", &tos_val))
11637 else if (unformat (input, "length %d", &length_val))
11639 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11641 else if (unformat (input, "ttl %d", &ttl_val))
11643 else if (unformat (input, "checksum %d", &checksum_val))
11649 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11650 + ttl + checksum == 0)
11654 * Aligned because we use the real comparison functions
11656 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11658 ip = (ip4_header_t *) match;
11660 /* These are realistically matched in practice */
11662 ip->src_address.as_u32 = src_val.as_u32;
11665 ip->dst_address.as_u32 = dst_val.as_u32;
11668 ip->protocol = proto_val;
11671 /* These are not, but they're included for completeness */
11673 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11676 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11682 ip->length = clib_host_to_net_u16 (length_val);
11688 ip->checksum = clib_host_to_net_u16 (checksum_val);
11695 unformat_ip6_match (unformat_input_t * input, va_list * args)
11697 u8 **matchp = va_arg (*args, u8 **);
11702 u8 traffic_class = 0;
11703 u32 traffic_class_val = 0;
11706 int src = 0, dst = 0;
11707 ip6_address_t src_val, dst_val;
11710 int payload_length = 0;
11711 u32 payload_length_val;
11714 u32 ip_version_traffic_class_and_flow_label;
11716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11718 if (unformat (input, "version %d", &version_val))
11720 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11722 else if (unformat (input, "flow_label %d", &flow_label_val))
11724 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11726 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11728 else if (unformat (input, "proto %d", &proto_val))
11730 else if (unformat (input, "payload_length %d", &payload_length_val))
11731 payload_length = 1;
11732 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11738 if (version + traffic_class + flow_label + src + dst + proto +
11739 payload_length + hop_limit == 0)
11743 * Aligned because we use the real comparison functions
11745 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11747 ip = (ip6_header_t *) match;
11750 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11753 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11756 ip->protocol = proto_val;
11758 ip_version_traffic_class_and_flow_label = 0;
11761 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11764 ip_version_traffic_class_and_flow_label |=
11765 (traffic_class_val & 0xFF) << 20;
11768 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11770 ip->ip_version_traffic_class_and_flow_label =
11771 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11773 if (payload_length)
11774 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11777 ip->hop_limit = hop_limit_val;
11784 unformat_l3_match (unformat_input_t * input, va_list * args)
11786 u8 **matchp = va_arg (*args, u8 **);
11788 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11790 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11792 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11801 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11803 u8 *tagp = va_arg (*args, u8 *);
11806 if (unformat (input, "%d", &tag))
11808 tagp[0] = (tag >> 8) & 0x0F;
11809 tagp[1] = tag & 0xFF;
11817 unformat_l2_match (unformat_input_t * input, va_list * args)
11819 u8 **matchp = va_arg (*args, u8 **);
11832 u8 ignore_tag1 = 0;
11833 u8 ignore_tag2 = 0;
11839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11841 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11844 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11846 else if (unformat (input, "proto %U",
11847 unformat_ethernet_type_host_byte_order, &proto_val))
11849 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11851 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11853 else if (unformat (input, "ignore-tag1"))
11855 else if (unformat (input, "ignore-tag2"))
11857 else if (unformat (input, "cos1 %d", &cos1_val))
11859 else if (unformat (input, "cos2 %d", &cos2_val))
11864 if ((src + dst + proto + tag1 + tag2 +
11865 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11868 if (tag1 || ignore_tag1 || cos1)
11870 if (tag2 || ignore_tag2 || cos2)
11873 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11876 clib_memcpy (match, dst_val, 6);
11879 clib_memcpy (match + 6, src_val, 6);
11883 /* inner vlan tag */
11884 match[19] = tag2_val[1];
11885 match[18] = tag2_val[0];
11887 match[18] |= (cos2_val & 0x7) << 5;
11890 match[21] = proto_val & 0xff;
11891 match[20] = proto_val >> 8;
11895 match[15] = tag1_val[1];
11896 match[14] = tag1_val[0];
11899 match[14] |= (cos1_val & 0x7) << 5;
11905 match[15] = tag1_val[1];
11906 match[14] = tag1_val[0];
11909 match[17] = proto_val & 0xff;
11910 match[16] = proto_val >> 8;
11913 match[14] |= (cos1_val & 0x7) << 5;
11919 match[18] |= (cos2_val & 0x7) << 5;
11921 match[14] |= (cos1_val & 0x7) << 5;
11924 match[13] = proto_val & 0xff;
11925 match[12] = proto_val >> 8;
11933 unformat_qos_source (unformat_input_t * input, va_list * args)
11935 int *qs = va_arg (*args, int *);
11937 if (unformat (input, "ip"))
11938 *qs = QOS_SOURCE_IP;
11939 else if (unformat (input, "mpls"))
11940 *qs = QOS_SOURCE_MPLS;
11941 else if (unformat (input, "ext"))
11942 *qs = QOS_SOURCE_EXT;
11943 else if (unformat (input, "vlan"))
11944 *qs = QOS_SOURCE_VLAN;
11953 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11955 u8 **matchp = va_arg (*args, u8 **);
11956 u32 skip_n_vectors = va_arg (*args, u32);
11957 u32 match_n_vectors = va_arg (*args, u32);
11964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11966 if (unformat (input, "hex %U", unformat_hex_string, &match))
11968 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11970 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11972 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11986 if (match || l2 || l3 || l4)
11988 if (l2 || l3 || l4)
11990 /* "Win a free Ethernet header in every packet" */
11992 vec_validate_aligned (l2, 13, sizeof (u32x4));
11996 vec_append_aligned (match, l3, sizeof (u32x4));
12001 vec_append_aligned (match, l4, sizeof (u32x4));
12006 /* Make sure the vector is big enough even if key is all 0's */
12007 vec_validate_aligned
12008 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12011 /* Set size, include skipped vectors */
12012 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12023 api_classify_add_del_session (vat_main_t * vam)
12025 unformat_input_t *i = vam->input;
12026 vl_api_classify_add_del_session_t *mp;
12028 u32 table_index = ~0;
12029 u32 hit_next_index = ~0;
12030 u32 opaque_index = ~0;
12033 u32 skip_n_vectors = 0;
12034 u32 match_n_vectors = 0;
12040 * Warning: you have to supply skip_n and match_n
12041 * because the API client cant simply look at the classify
12045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12047 if (unformat (i, "del"))
12049 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12052 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12055 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12058 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12060 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12062 else if (unformat (i, "opaque-index %d", &opaque_index))
12064 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12066 else if (unformat (i, "match_n %d", &match_n_vectors))
12068 else if (unformat (i, "match %U", api_unformat_classify_match,
12069 &match, skip_n_vectors, match_n_vectors))
12071 else if (unformat (i, "advance %d", &advance))
12073 else if (unformat (i, "table-index %d", &table_index))
12075 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12077 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12079 else if (unformat (i, "action %d", &action))
12081 else if (unformat (i, "metadata %d", &metadata))
12087 if (table_index == ~0)
12089 errmsg ("Table index required");
12093 if (is_add && match == 0)
12095 errmsg ("Match value required");
12099 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12101 mp->is_add = is_add;
12102 mp->table_index = ntohl (table_index);
12103 mp->hit_next_index = ntohl (hit_next_index);
12104 mp->opaque_index = ntohl (opaque_index);
12105 mp->advance = ntohl (advance);
12106 mp->action = action;
12107 mp->metadata = ntohl (metadata);
12108 clib_memcpy (mp->match, match, vec_len (match));
12117 api_classify_set_interface_ip_table (vat_main_t * vam)
12119 unformat_input_t *i = vam->input;
12120 vl_api_classify_set_interface_ip_table_t *mp;
12122 int sw_if_index_set;
12123 u32 table_index = ~0;
12127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12130 sw_if_index_set = 1;
12131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12132 sw_if_index_set = 1;
12133 else if (unformat (i, "table %d", &table_index))
12137 clib_warning ("parse error '%U'", format_unformat_error, i);
12142 if (sw_if_index_set == 0)
12144 errmsg ("missing interface name or sw_if_index");
12149 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12151 mp->sw_if_index = ntohl (sw_if_index);
12152 mp->table_index = ntohl (table_index);
12153 mp->is_ipv6 = is_ipv6;
12161 api_classify_set_interface_l2_tables (vat_main_t * vam)
12163 unformat_input_t *i = vam->input;
12164 vl_api_classify_set_interface_l2_tables_t *mp;
12166 int sw_if_index_set;
12167 u32 ip4_table_index = ~0;
12168 u32 ip6_table_index = ~0;
12169 u32 other_table_index = ~0;
12173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12175 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12176 sw_if_index_set = 1;
12177 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12178 sw_if_index_set = 1;
12179 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12181 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12183 else if (unformat (i, "other-table %d", &other_table_index))
12185 else if (unformat (i, "is-input %d", &is_input))
12189 clib_warning ("parse error '%U'", format_unformat_error, i);
12194 if (sw_if_index_set == 0)
12196 errmsg ("missing interface name or sw_if_index");
12201 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12203 mp->sw_if_index = ntohl (sw_if_index);
12204 mp->ip4_table_index = ntohl (ip4_table_index);
12205 mp->ip6_table_index = ntohl (ip6_table_index);
12206 mp->other_table_index = ntohl (other_table_index);
12207 mp->is_input = (u8) is_input;
12215 api_set_ipfix_exporter (vat_main_t * vam)
12217 unformat_input_t *i = vam->input;
12218 vl_api_set_ipfix_exporter_t *mp;
12219 ip4_address_t collector_address;
12220 u8 collector_address_set = 0;
12221 u32 collector_port = ~0;
12222 ip4_address_t src_address;
12223 u8 src_address_set = 0;
12226 u32 template_interval = ~0;
12227 u8 udp_checksum = 0;
12230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12232 if (unformat (i, "collector_address %U", unformat_ip4_address,
12233 &collector_address))
12234 collector_address_set = 1;
12235 else if (unformat (i, "collector_port %d", &collector_port))
12237 else if (unformat (i, "src_address %U", unformat_ip4_address,
12239 src_address_set = 1;
12240 else if (unformat (i, "vrf_id %d", &vrf_id))
12242 else if (unformat (i, "path_mtu %d", &path_mtu))
12244 else if (unformat (i, "template_interval %d", &template_interval))
12246 else if (unformat (i, "udp_checksum"))
12252 if (collector_address_set == 0)
12254 errmsg ("collector_address required");
12258 if (src_address_set == 0)
12260 errmsg ("src_address required");
12264 M (SET_IPFIX_EXPORTER, mp);
12266 memcpy (mp->collector_address, collector_address.data,
12267 sizeof (collector_address.data));
12268 mp->collector_port = htons ((u16) collector_port);
12269 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12270 mp->vrf_id = htonl (vrf_id);
12271 mp->path_mtu = htonl (path_mtu);
12272 mp->template_interval = htonl (template_interval);
12273 mp->udp_checksum = udp_checksum;
12281 api_set_ipfix_classify_stream (vat_main_t * vam)
12283 unformat_input_t *i = vam->input;
12284 vl_api_set_ipfix_classify_stream_t *mp;
12286 u32 src_port = UDP_DST_PORT_ipfix;
12289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12291 if (unformat (i, "domain %d", &domain_id))
12293 else if (unformat (i, "src_port %d", &src_port))
12297 errmsg ("unknown input `%U'", format_unformat_error, i);
12302 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12304 mp->domain_id = htonl (domain_id);
12305 mp->src_port = htons ((u16) src_port);
12313 api_ipfix_classify_table_add_del (vat_main_t * vam)
12315 unformat_input_t *i = vam->input;
12316 vl_api_ipfix_classify_table_add_del_t *mp;
12318 u32 classify_table_index = ~0;
12320 u8 transport_protocol = 255;
12323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12325 if (unformat (i, "add"))
12327 else if (unformat (i, "del"))
12329 else if (unformat (i, "table %d", &classify_table_index))
12331 else if (unformat (i, "ip4"))
12333 else if (unformat (i, "ip6"))
12335 else if (unformat (i, "tcp"))
12336 transport_protocol = 6;
12337 else if (unformat (i, "udp"))
12338 transport_protocol = 17;
12341 errmsg ("unknown input `%U'", format_unformat_error, i);
12348 errmsg ("expecting: add|del");
12351 if (classify_table_index == ~0)
12353 errmsg ("classifier table not specified");
12356 if (ip_version == 0)
12358 errmsg ("IP version not specified");
12362 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12364 mp->is_add = is_add;
12365 mp->table_id = htonl (classify_table_index);
12366 mp->ip_version = ip_version;
12367 mp->transport_protocol = transport_protocol;
12375 api_get_node_index (vat_main_t * vam)
12377 unformat_input_t *i = vam->input;
12378 vl_api_get_node_index_t *mp;
12382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12384 if (unformat (i, "node %s", &name))
12391 errmsg ("node name required");
12394 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12396 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12400 M (GET_NODE_INDEX, mp);
12401 clib_memcpy (mp->node_name, name, vec_len (name));
12410 api_get_next_index (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_get_next_index_t *mp;
12414 u8 *node_name = 0, *next_node_name = 0;
12417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12419 if (unformat (i, "node-name %s", &node_name))
12421 else if (unformat (i, "next-node-name %s", &next_node_name))
12425 if (node_name == 0)
12427 errmsg ("node name required");
12430 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12432 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12436 if (next_node_name == 0)
12438 errmsg ("next node name required");
12441 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12443 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12447 M (GET_NEXT_INDEX, mp);
12448 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12449 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12450 vec_free (node_name);
12451 vec_free (next_node_name);
12459 api_add_node_next (vat_main_t * vam)
12461 unformat_input_t *i = vam->input;
12462 vl_api_add_node_next_t *mp;
12467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12469 if (unformat (i, "node %s", &name))
12471 else if (unformat (i, "next %s", &next))
12478 errmsg ("node name required");
12481 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12483 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12488 errmsg ("next node required");
12491 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12493 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12497 M (ADD_NODE_NEXT, mp);
12498 clib_memcpy (mp->node_name, name, vec_len (name));
12499 clib_memcpy (mp->next_name, next, vec_len (next));
12509 api_l2tpv3_create_tunnel (vat_main_t * vam)
12511 unformat_input_t *i = vam->input;
12512 ip6_address_t client_address, our_address;
12513 int client_address_set = 0;
12514 int our_address_set = 0;
12515 u32 local_session_id = 0;
12516 u32 remote_session_id = 0;
12517 u64 local_cookie = 0;
12518 u64 remote_cookie = 0;
12519 u8 l2_sublayer_present = 0;
12520 vl_api_l2tpv3_create_tunnel_t *mp;
12523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12525 if (unformat (i, "client_address %U", unformat_ip6_address,
12527 client_address_set = 1;
12528 else if (unformat (i, "our_address %U", unformat_ip6_address,
12530 our_address_set = 1;
12531 else if (unformat (i, "local_session_id %d", &local_session_id))
12533 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12535 else if (unformat (i, "local_cookie %lld", &local_cookie))
12537 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12539 else if (unformat (i, "l2-sublayer-present"))
12540 l2_sublayer_present = 1;
12545 if (client_address_set == 0)
12547 errmsg ("client_address required");
12551 if (our_address_set == 0)
12553 errmsg ("our_address required");
12557 M (L2TPV3_CREATE_TUNNEL, mp);
12559 clib_memcpy (mp->client_address, client_address.as_u8,
12560 sizeof (mp->client_address));
12562 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12564 mp->local_session_id = ntohl (local_session_id);
12565 mp->remote_session_id = ntohl (remote_session_id);
12566 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12567 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12568 mp->l2_sublayer_present = l2_sublayer_present;
12577 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12579 unformat_input_t *i = vam->input;
12581 u8 sw_if_index_set = 0;
12582 u64 new_local_cookie = 0;
12583 u64 new_remote_cookie = 0;
12584 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12590 sw_if_index_set = 1;
12591 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12592 sw_if_index_set = 1;
12593 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12595 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12601 if (sw_if_index_set == 0)
12603 errmsg ("missing interface name or sw_if_index");
12607 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12609 mp->sw_if_index = ntohl (sw_if_index);
12610 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12611 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12619 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12621 unformat_input_t *i = vam->input;
12622 vl_api_l2tpv3_interface_enable_disable_t *mp;
12624 u8 sw_if_index_set = 0;
12625 u8 enable_disable = 1;
12628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12631 sw_if_index_set = 1;
12632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12633 sw_if_index_set = 1;
12634 else if (unformat (i, "enable"))
12635 enable_disable = 1;
12636 else if (unformat (i, "disable"))
12637 enable_disable = 0;
12642 if (sw_if_index_set == 0)
12644 errmsg ("missing interface name or sw_if_index");
12648 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12650 mp->sw_if_index = ntohl (sw_if_index);
12651 mp->enable_disable = enable_disable;
12659 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12661 unformat_input_t *i = vam->input;
12662 vl_api_l2tpv3_set_lookup_key_t *mp;
12666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12668 if (unformat (i, "lookup_v6_src"))
12669 key = L2T_LOOKUP_SRC_ADDRESS;
12670 else if (unformat (i, "lookup_v6_dst"))
12671 key = L2T_LOOKUP_DST_ADDRESS;
12672 else if (unformat (i, "lookup_session_id"))
12673 key = L2T_LOOKUP_SESSION_ID;
12678 if (key == (u8) ~ 0)
12680 errmsg ("l2tp session lookup key unset");
12684 M (L2TPV3_SET_LOOKUP_KEY, mp);
12693 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12694 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12696 vat_main_t *vam = &vat_main;
12698 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12699 format_ip6_address, mp->our_address,
12700 format_ip6_address, mp->client_address,
12701 clib_net_to_host_u32 (mp->sw_if_index));
12704 " local cookies %016llx %016llx remote cookie %016llx",
12705 clib_net_to_host_u64 (mp->local_cookie[0]),
12706 clib_net_to_host_u64 (mp->local_cookie[1]),
12707 clib_net_to_host_u64 (mp->remote_cookie));
12709 print (vam->ofp, " local session-id %d remote session-id %d",
12710 clib_net_to_host_u32 (mp->local_session_id),
12711 clib_net_to_host_u32 (mp->remote_session_id));
12713 print (vam->ofp, " l2 specific sublayer %s\n",
12714 mp->l2_sublayer_present ? "preset" : "absent");
12718 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12719 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12721 vat_main_t *vam = &vat_main;
12722 vat_json_node_t *node = NULL;
12723 struct in6_addr addr;
12725 if (VAT_JSON_ARRAY != vam->json_tree.type)
12727 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12728 vat_json_init_array (&vam->json_tree);
12730 node = vat_json_array_add (&vam->json_tree);
12732 vat_json_init_object (node);
12734 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12735 vat_json_object_add_ip6 (node, "our_address", addr);
12736 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12737 vat_json_object_add_ip6 (node, "client_address", addr);
12739 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12740 vat_json_init_array (lc);
12741 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12742 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12743 vat_json_object_add_uint (node, "remote_cookie",
12744 clib_net_to_host_u64 (mp->remote_cookie));
12746 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12747 vat_json_object_add_uint (node, "local_session_id",
12748 clib_net_to_host_u32 (mp->local_session_id));
12749 vat_json_object_add_uint (node, "remote_session_id",
12750 clib_net_to_host_u32 (mp->remote_session_id));
12751 vat_json_object_add_string_copy (node, "l2_sublayer",
12752 mp->l2_sublayer_present ? (u8 *) "present"
12753 : (u8 *) "absent");
12757 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12759 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12760 vl_api_control_ping_t *mp_ping;
12763 /* Get list of l2tpv3-tunnel interfaces */
12764 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12767 /* Use a control ping for synchronization */
12768 MPING (CONTROL_PING, mp_ping);
12776 static void vl_api_sw_interface_tap_details_t_handler
12777 (vl_api_sw_interface_tap_details_t * mp)
12779 vat_main_t *vam = &vat_main;
12781 print (vam->ofp, "%-16s %d",
12782 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12785 static void vl_api_sw_interface_tap_details_t_handler_json
12786 (vl_api_sw_interface_tap_details_t * mp)
12788 vat_main_t *vam = &vat_main;
12789 vat_json_node_t *node = NULL;
12791 if (VAT_JSON_ARRAY != vam->json_tree.type)
12793 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12794 vat_json_init_array (&vam->json_tree);
12796 node = vat_json_array_add (&vam->json_tree);
12798 vat_json_init_object (node);
12799 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12800 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12804 api_sw_interface_tap_dump (vat_main_t * vam)
12806 vl_api_sw_interface_tap_dump_t *mp;
12807 vl_api_control_ping_t *mp_ping;
12810 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12811 /* Get list of tap interfaces */
12812 M (SW_INTERFACE_TAP_DUMP, mp);
12815 /* Use a control ping for synchronization */
12816 MPING (CONTROL_PING, mp_ping);
12823 static void vl_api_sw_interface_tap_v2_details_t_handler
12824 (vl_api_sw_interface_tap_v2_details_t * mp)
12826 vat_main_t *vam = &vat_main;
12828 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12829 mp->host_ip4_prefix_len);
12830 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12831 mp->host_ip6_prefix_len);
12834 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12835 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12836 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12837 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12838 mp->host_bridge, ip4, ip6);
12844 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12845 (vl_api_sw_interface_tap_v2_details_t * mp)
12847 vat_main_t *vam = &vat_main;
12848 vat_json_node_t *node = NULL;
12850 if (VAT_JSON_ARRAY != vam->json_tree.type)
12852 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12853 vat_json_init_array (&vam->json_tree);
12855 node = vat_json_array_add (&vam->json_tree);
12857 vat_json_init_object (node);
12858 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12859 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12860 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12861 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12862 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12863 vat_json_object_add_string_copy (node, "host_mac_addr",
12864 format (0, "%U", format_ethernet_address,
12865 &mp->host_mac_addr));
12866 vat_json_object_add_string_copy (node, "host_namespace",
12867 mp->host_namespace);
12868 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12869 vat_json_object_add_string_copy (node, "host_ip4_addr",
12870 format (0, "%U/%d", format_ip4_address,
12872 mp->host_ip4_prefix_len));
12873 vat_json_object_add_string_copy (node, "host_ip6_addr",
12874 format (0, "%U/%d", format_ip6_address,
12876 mp->host_ip6_prefix_len));
12881 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12883 vl_api_sw_interface_tap_v2_dump_t *mp;
12884 vl_api_control_ping_t *mp_ping;
12888 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12889 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12890 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12893 /* Get list of tap interfaces */
12894 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12897 /* Use a control ping for synchronization */
12898 MPING (CONTROL_PING, mp_ping);
12906 api_vxlan_offload_rx (vat_main_t * vam)
12908 unformat_input_t *line_input = vam->input;
12909 vl_api_vxlan_offload_rx_t *mp;
12910 u32 hw_if_index = ~0, rx_if_index = ~0;
12914 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12916 if (unformat (line_input, "del"))
12918 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12921 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12923 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12926 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12930 errmsg ("parse error '%U'", format_unformat_error, line_input);
12935 if (hw_if_index == ~0)
12937 errmsg ("no hw interface");
12941 if (rx_if_index == ~0)
12943 errmsg ("no rx tunnel");
12947 M (VXLAN_OFFLOAD_RX, mp);
12949 mp->hw_if_index = ntohl (hw_if_index);
12950 mp->sw_if_index = ntohl (rx_if_index);
12951 mp->enable = is_add;
12958 static uword unformat_vxlan_decap_next
12959 (unformat_input_t * input, va_list * args)
12961 u32 *result = va_arg (*args, u32 *);
12964 if (unformat (input, "l2"))
12965 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12966 else if (unformat (input, "%d", &tmp))
12974 api_vxlan_add_del_tunnel (vat_main_t * vam)
12976 unformat_input_t *line_input = vam->input;
12977 vl_api_vxlan_add_del_tunnel_t *mp;
12978 ip46_address_t src, dst;
12980 u8 ipv4_set = 0, ipv6_set = 0;
12985 u32 mcast_sw_if_index = ~0;
12986 u32 encap_vrf_id = 0;
12987 u32 decap_next_index = ~0;
12991 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12992 memset (&src, 0, sizeof src);
12993 memset (&dst, 0, sizeof dst);
12995 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12997 if (unformat (line_input, "del"))
12999 else if (unformat (line_input, "instance %d", &instance))
13002 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13008 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13014 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13020 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13025 else if (unformat (line_input, "group %U %U",
13026 unformat_ip4_address, &dst.ip4,
13027 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13029 grp_set = dst_set = 1;
13032 else if (unformat (line_input, "group %U",
13033 unformat_ip4_address, &dst.ip4))
13035 grp_set = dst_set = 1;
13038 else if (unformat (line_input, "group %U %U",
13039 unformat_ip6_address, &dst.ip6,
13040 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13042 grp_set = dst_set = 1;
13045 else if (unformat (line_input, "group %U",
13046 unformat_ip6_address, &dst.ip6))
13048 grp_set = dst_set = 1;
13052 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13054 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13056 else if (unformat (line_input, "decap-next %U",
13057 unformat_vxlan_decap_next, &decap_next_index))
13059 else if (unformat (line_input, "vni %d", &vni))
13063 errmsg ("parse error '%U'", format_unformat_error, line_input);
13070 errmsg ("tunnel src address not specified");
13075 errmsg ("tunnel dst address not specified");
13079 if (grp_set && !ip46_address_is_multicast (&dst))
13081 errmsg ("tunnel group address not multicast");
13084 if (grp_set && mcast_sw_if_index == ~0)
13086 errmsg ("tunnel nonexistent multicast device");
13089 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13091 errmsg ("tunnel dst address must be unicast");
13096 if (ipv4_set && ipv6_set)
13098 errmsg ("both IPv4 and IPv6 addresses specified");
13102 if ((vni == 0) || (vni >> 24))
13104 errmsg ("vni not specified or out of range");
13108 M (VXLAN_ADD_DEL_TUNNEL, mp);
13112 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13113 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13117 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13118 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13121 mp->instance = htonl (instance);
13122 mp->encap_vrf_id = ntohl (encap_vrf_id);
13123 mp->decap_next_index = ntohl (decap_next_index);
13124 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13125 mp->vni = ntohl (vni);
13126 mp->is_add = is_add;
13127 mp->is_ipv6 = ipv6_set;
13134 static void vl_api_vxlan_tunnel_details_t_handler
13135 (vl_api_vxlan_tunnel_details_t * mp)
13137 vat_main_t *vam = &vat_main;
13138 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13139 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13141 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13142 ntohl (mp->sw_if_index),
13143 ntohl (mp->instance),
13144 format_ip46_address, &src, IP46_TYPE_ANY,
13145 format_ip46_address, &dst, IP46_TYPE_ANY,
13146 ntohl (mp->encap_vrf_id),
13147 ntohl (mp->decap_next_index), ntohl (mp->vni),
13148 ntohl (mp->mcast_sw_if_index));
13151 static void vl_api_vxlan_tunnel_details_t_handler_json
13152 (vl_api_vxlan_tunnel_details_t * mp)
13154 vat_main_t *vam = &vat_main;
13155 vat_json_node_t *node = NULL;
13157 if (VAT_JSON_ARRAY != vam->json_tree.type)
13159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13160 vat_json_init_array (&vam->json_tree);
13162 node = vat_json_array_add (&vam->json_tree);
13164 vat_json_init_object (node);
13165 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13167 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13171 struct in6_addr ip6;
13173 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13174 vat_json_object_add_ip6 (node, "src_address", ip6);
13175 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13176 vat_json_object_add_ip6 (node, "dst_address", ip6);
13180 struct in_addr ip4;
13182 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13183 vat_json_object_add_ip4 (node, "src_address", ip4);
13184 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13185 vat_json_object_add_ip4 (node, "dst_address", ip4);
13187 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13188 vat_json_object_add_uint (node, "decap_next_index",
13189 ntohl (mp->decap_next_index));
13190 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13191 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13192 vat_json_object_add_uint (node, "mcast_sw_if_index",
13193 ntohl (mp->mcast_sw_if_index));
13197 api_vxlan_tunnel_dump (vat_main_t * vam)
13199 unformat_input_t *i = vam->input;
13200 vl_api_vxlan_tunnel_dump_t *mp;
13201 vl_api_control_ping_t *mp_ping;
13203 u8 sw_if_index_set = 0;
13206 /* Parse args required to build the message */
13207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13209 if (unformat (i, "sw_if_index %d", &sw_if_index))
13210 sw_if_index_set = 1;
13215 if (sw_if_index_set == 0)
13220 if (!vam->json_output)
13222 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13223 "sw_if_index", "instance", "src_address", "dst_address",
13224 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13227 /* Get list of vxlan-tunnel interfaces */
13228 M (VXLAN_TUNNEL_DUMP, mp);
13230 mp->sw_if_index = htonl (sw_if_index);
13234 /* Use a control ping for synchronization */
13235 MPING (CONTROL_PING, mp_ping);
13242 static uword unformat_geneve_decap_next
13243 (unformat_input_t * input, va_list * args)
13245 u32 *result = va_arg (*args, u32 *);
13248 if (unformat (input, "l2"))
13249 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13250 else if (unformat (input, "%d", &tmp))
13258 api_geneve_add_del_tunnel (vat_main_t * vam)
13260 unformat_input_t *line_input = vam->input;
13261 vl_api_geneve_add_del_tunnel_t *mp;
13262 ip46_address_t src, dst;
13264 u8 ipv4_set = 0, ipv6_set = 0;
13268 u32 mcast_sw_if_index = ~0;
13269 u32 encap_vrf_id = 0;
13270 u32 decap_next_index = ~0;
13274 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13275 memset (&src, 0, sizeof src);
13276 memset (&dst, 0, sizeof dst);
13278 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13280 if (unformat (line_input, "del"))
13283 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13289 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13295 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13301 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13306 else if (unformat (line_input, "group %U %U",
13307 unformat_ip4_address, &dst.ip4,
13308 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13310 grp_set = dst_set = 1;
13313 else if (unformat (line_input, "group %U",
13314 unformat_ip4_address, &dst.ip4))
13316 grp_set = dst_set = 1;
13319 else if (unformat (line_input, "group %U %U",
13320 unformat_ip6_address, &dst.ip6,
13321 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13323 grp_set = dst_set = 1;
13326 else if (unformat (line_input, "group %U",
13327 unformat_ip6_address, &dst.ip6))
13329 grp_set = dst_set = 1;
13333 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13335 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13337 else if (unformat (line_input, "decap-next %U",
13338 unformat_geneve_decap_next, &decap_next_index))
13340 else if (unformat (line_input, "vni %d", &vni))
13344 errmsg ("parse error '%U'", format_unformat_error, line_input);
13351 errmsg ("tunnel src address not specified");
13356 errmsg ("tunnel dst address not specified");
13360 if (grp_set && !ip46_address_is_multicast (&dst))
13362 errmsg ("tunnel group address not multicast");
13365 if (grp_set && mcast_sw_if_index == ~0)
13367 errmsg ("tunnel nonexistent multicast device");
13370 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13372 errmsg ("tunnel dst address must be unicast");
13377 if (ipv4_set && ipv6_set)
13379 errmsg ("both IPv4 and IPv6 addresses specified");
13383 if ((vni == 0) || (vni >> 24))
13385 errmsg ("vni not specified or out of range");
13389 M (GENEVE_ADD_DEL_TUNNEL, mp);
13393 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13394 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13398 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13399 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13401 mp->encap_vrf_id = ntohl (encap_vrf_id);
13402 mp->decap_next_index = ntohl (decap_next_index);
13403 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13404 mp->vni = ntohl (vni);
13405 mp->is_add = is_add;
13406 mp->is_ipv6 = ipv6_set;
13413 static void vl_api_geneve_tunnel_details_t_handler
13414 (vl_api_geneve_tunnel_details_t * mp)
13416 vat_main_t *vam = &vat_main;
13417 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13418 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13420 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13421 ntohl (mp->sw_if_index),
13422 format_ip46_address, &src, IP46_TYPE_ANY,
13423 format_ip46_address, &dst, IP46_TYPE_ANY,
13424 ntohl (mp->encap_vrf_id),
13425 ntohl (mp->decap_next_index), ntohl (mp->vni),
13426 ntohl (mp->mcast_sw_if_index));
13429 static void vl_api_geneve_tunnel_details_t_handler_json
13430 (vl_api_geneve_tunnel_details_t * mp)
13432 vat_main_t *vam = &vat_main;
13433 vat_json_node_t *node = NULL;
13435 if (VAT_JSON_ARRAY != vam->json_tree.type)
13437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13438 vat_json_init_array (&vam->json_tree);
13440 node = vat_json_array_add (&vam->json_tree);
13442 vat_json_init_object (node);
13443 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13446 struct in6_addr ip6;
13448 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13449 vat_json_object_add_ip6 (node, "src_address", ip6);
13450 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13451 vat_json_object_add_ip6 (node, "dst_address", ip6);
13455 struct in_addr ip4;
13457 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13458 vat_json_object_add_ip4 (node, "src_address", ip4);
13459 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13460 vat_json_object_add_ip4 (node, "dst_address", ip4);
13462 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13463 vat_json_object_add_uint (node, "decap_next_index",
13464 ntohl (mp->decap_next_index));
13465 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13466 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13467 vat_json_object_add_uint (node, "mcast_sw_if_index",
13468 ntohl (mp->mcast_sw_if_index));
13472 api_geneve_tunnel_dump (vat_main_t * vam)
13474 unformat_input_t *i = vam->input;
13475 vl_api_geneve_tunnel_dump_t *mp;
13476 vl_api_control_ping_t *mp_ping;
13478 u8 sw_if_index_set = 0;
13481 /* Parse args required to build the message */
13482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13484 if (unformat (i, "sw_if_index %d", &sw_if_index))
13485 sw_if_index_set = 1;
13490 if (sw_if_index_set == 0)
13495 if (!vam->json_output)
13497 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13498 "sw_if_index", "local_address", "remote_address",
13499 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13502 /* Get list of geneve-tunnel interfaces */
13503 M (GENEVE_TUNNEL_DUMP, mp);
13505 mp->sw_if_index = htonl (sw_if_index);
13509 /* Use a control ping for synchronization */
13510 M (CONTROL_PING, mp_ping);
13518 api_gre_add_del_tunnel (vat_main_t * vam)
13520 unformat_input_t *line_input = vam->input;
13521 vl_api_gre_add_del_tunnel_t *mp;
13522 ip4_address_t src4, dst4;
13523 ip6_address_t src6, dst6;
13527 u8 t_type = GRE_TUNNEL_TYPE_L3;
13530 u32 outer_fib_id = 0;
13531 u32 session_id = 0;
13535 memset (&src4, 0, sizeof src4);
13536 memset (&dst4, 0, sizeof dst4);
13537 memset (&src6, 0, sizeof src6);
13538 memset (&dst6, 0, sizeof dst6);
13540 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13542 if (unformat (line_input, "del"))
13544 else if (unformat (line_input, "instance %d", &instance))
13546 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13551 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13556 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13561 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13566 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13568 else if (unformat (line_input, "teb"))
13569 t_type = GRE_TUNNEL_TYPE_TEB;
13570 else if (unformat (line_input, "erspan %d", &session_id))
13571 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13574 errmsg ("parse error '%U'", format_unformat_error, line_input);
13581 errmsg ("tunnel src address not specified");
13586 errmsg ("tunnel dst address not specified");
13589 if (ipv4_set && ipv6_set)
13591 errmsg ("both IPv4 and IPv6 addresses specified");
13596 M (GRE_ADD_DEL_TUNNEL, mp);
13600 clib_memcpy (&mp->src_address, &src4, 4);
13601 clib_memcpy (&mp->dst_address, &dst4, 4);
13605 clib_memcpy (&mp->src_address, &src6, 16);
13606 clib_memcpy (&mp->dst_address, &dst6, 16);
13608 mp->instance = htonl (instance);
13609 mp->outer_fib_id = htonl (outer_fib_id);
13610 mp->is_add = is_add;
13611 mp->session_id = htons ((u16) session_id);
13612 mp->tunnel_type = t_type;
13613 mp->is_ipv6 = ipv6_set;
13620 static void vl_api_gre_tunnel_details_t_handler
13621 (vl_api_gre_tunnel_details_t * mp)
13623 vat_main_t *vam = &vat_main;
13624 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13625 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13627 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13628 ntohl (mp->sw_if_index),
13629 ntohl (mp->instance),
13630 format_ip46_address, &src, IP46_TYPE_ANY,
13631 format_ip46_address, &dst, IP46_TYPE_ANY,
13632 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13635 static void vl_api_gre_tunnel_details_t_handler_json
13636 (vl_api_gre_tunnel_details_t * mp)
13638 vat_main_t *vam = &vat_main;
13639 vat_json_node_t *node = NULL;
13640 struct in_addr ip4;
13641 struct in6_addr ip6;
13643 if (VAT_JSON_ARRAY != vam->json_tree.type)
13645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13646 vat_json_init_array (&vam->json_tree);
13648 node = vat_json_array_add (&vam->json_tree);
13650 vat_json_init_object (node);
13651 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13652 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13655 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13656 vat_json_object_add_ip4 (node, "src_address", ip4);
13657 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13658 vat_json_object_add_ip4 (node, "dst_address", ip4);
13662 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13663 vat_json_object_add_ip6 (node, "src_address", ip6);
13664 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13665 vat_json_object_add_ip6 (node, "dst_address", ip6);
13667 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13668 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13669 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13670 vat_json_object_add_uint (node, "session_id", mp->session_id);
13674 api_gre_tunnel_dump (vat_main_t * vam)
13676 unformat_input_t *i = vam->input;
13677 vl_api_gre_tunnel_dump_t *mp;
13678 vl_api_control_ping_t *mp_ping;
13680 u8 sw_if_index_set = 0;
13683 /* Parse args required to build the message */
13684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13686 if (unformat (i, "sw_if_index %d", &sw_if_index))
13687 sw_if_index_set = 1;
13692 if (sw_if_index_set == 0)
13697 if (!vam->json_output)
13699 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13700 "sw_if_index", "instance", "src_address", "dst_address",
13701 "tunnel_type", "outer_fib_id", "session_id");
13704 /* Get list of gre-tunnel interfaces */
13705 M (GRE_TUNNEL_DUMP, mp);
13707 mp->sw_if_index = htonl (sw_if_index);
13711 /* Use a control ping for synchronization */
13712 MPING (CONTROL_PING, mp_ping);
13720 api_l2_fib_clear_table (vat_main_t * vam)
13722 // unformat_input_t * i = vam->input;
13723 vl_api_l2_fib_clear_table_t *mp;
13726 M (L2_FIB_CLEAR_TABLE, mp);
13734 api_l2_interface_efp_filter (vat_main_t * vam)
13736 unformat_input_t *i = vam->input;
13737 vl_api_l2_interface_efp_filter_t *mp;
13740 u8 sw_if_index_set = 0;
13743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13746 sw_if_index_set = 1;
13747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13748 sw_if_index_set = 1;
13749 else if (unformat (i, "enable"))
13751 else if (unformat (i, "disable"))
13755 clib_warning ("parse error '%U'", format_unformat_error, i);
13760 if (sw_if_index_set == 0)
13762 errmsg ("missing sw_if_index");
13766 M (L2_INTERFACE_EFP_FILTER, mp);
13768 mp->sw_if_index = ntohl (sw_if_index);
13769 mp->enable_disable = enable;
13776 #define foreach_vtr_op \
13777 _("disable", L2_VTR_DISABLED) \
13778 _("push-1", L2_VTR_PUSH_1) \
13779 _("push-2", L2_VTR_PUSH_2) \
13780 _("pop-1", L2_VTR_POP_1) \
13781 _("pop-2", L2_VTR_POP_2) \
13782 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13783 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13784 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13785 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13788 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13790 unformat_input_t *i = vam->input;
13791 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13793 u8 sw_if_index_set = 0;
13796 u32 push_dot1q = 1;
13801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13804 sw_if_index_set = 1;
13805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13806 sw_if_index_set = 1;
13807 else if (unformat (i, "vtr_op %d", &vtr_op))
13809 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13812 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13814 else if (unformat (i, "tag1 %d", &tag1))
13816 else if (unformat (i, "tag2 %d", &tag2))
13820 clib_warning ("parse error '%U'", format_unformat_error, i);
13825 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13827 errmsg ("missing vtr operation or sw_if_index");
13831 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13832 mp->sw_if_index = ntohl (sw_if_index);
13833 mp->vtr_op = ntohl (vtr_op);
13834 mp->push_dot1q = ntohl (push_dot1q);
13835 mp->tag1 = ntohl (tag1);
13836 mp->tag2 = ntohl (tag2);
13844 api_create_vhost_user_if (vat_main_t * vam)
13846 unformat_input_t *i = vam->input;
13847 vl_api_create_vhost_user_if_t *mp;
13850 u8 file_name_set = 0;
13851 u32 custom_dev_instance = ~0;
13853 u8 use_custom_mac = 0;
13857 /* Shut up coverity */
13858 memset (hwaddr, 0, sizeof (hwaddr));
13860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13862 if (unformat (i, "socket %s", &file_name))
13866 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13868 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13869 use_custom_mac = 1;
13870 else if (unformat (i, "server"))
13872 else if (unformat (i, "tag %s", &tag))
13878 if (file_name_set == 0)
13880 errmsg ("missing socket file name");
13884 if (vec_len (file_name) > 255)
13886 errmsg ("socket file name too long");
13889 vec_add1 (file_name, 0);
13891 M (CREATE_VHOST_USER_IF, mp);
13893 mp->is_server = is_server;
13894 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13895 vec_free (file_name);
13896 if (custom_dev_instance != ~0)
13899 mp->custom_dev_instance = ntohl (custom_dev_instance);
13901 mp->use_custom_mac = use_custom_mac;
13902 clib_memcpy (mp->mac_address, hwaddr, 6);
13904 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13913 api_modify_vhost_user_if (vat_main_t * vam)
13915 unformat_input_t *i = vam->input;
13916 vl_api_modify_vhost_user_if_t *mp;
13919 u8 file_name_set = 0;
13920 u32 custom_dev_instance = ~0;
13921 u8 sw_if_index_set = 0;
13922 u32 sw_if_index = (u32) ~ 0;
13925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13927 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13928 sw_if_index_set = 1;
13929 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13930 sw_if_index_set = 1;
13931 else if (unformat (i, "socket %s", &file_name))
13935 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13937 else if (unformat (i, "server"))
13943 if (sw_if_index_set == 0)
13945 errmsg ("missing sw_if_index or interface name");
13949 if (file_name_set == 0)
13951 errmsg ("missing socket file name");
13955 if (vec_len (file_name) > 255)
13957 errmsg ("socket file name too long");
13960 vec_add1 (file_name, 0);
13962 M (MODIFY_VHOST_USER_IF, mp);
13964 mp->sw_if_index = ntohl (sw_if_index);
13965 mp->is_server = is_server;
13966 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13967 vec_free (file_name);
13968 if (custom_dev_instance != ~0)
13971 mp->custom_dev_instance = ntohl (custom_dev_instance);
13980 api_delete_vhost_user_if (vat_main_t * vam)
13982 unformat_input_t *i = vam->input;
13983 vl_api_delete_vhost_user_if_t *mp;
13984 u32 sw_if_index = ~0;
13985 u8 sw_if_index_set = 0;
13988 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13990 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13991 sw_if_index_set = 1;
13992 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13993 sw_if_index_set = 1;
13998 if (sw_if_index_set == 0)
14000 errmsg ("missing sw_if_index or interface name");
14005 M (DELETE_VHOST_USER_IF, mp);
14007 mp->sw_if_index = ntohl (sw_if_index);
14014 static void vl_api_sw_interface_vhost_user_details_t_handler
14015 (vl_api_sw_interface_vhost_user_details_t * mp)
14017 vat_main_t *vam = &vat_main;
14019 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14020 (char *) mp->interface_name,
14021 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14022 clib_net_to_host_u64 (mp->features), mp->is_server,
14023 ntohl (mp->num_regions), (char *) mp->sock_filename);
14024 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14027 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14028 (vl_api_sw_interface_vhost_user_details_t * mp)
14030 vat_main_t *vam = &vat_main;
14031 vat_json_node_t *node = NULL;
14033 if (VAT_JSON_ARRAY != vam->json_tree.type)
14035 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14036 vat_json_init_array (&vam->json_tree);
14038 node = vat_json_array_add (&vam->json_tree);
14040 vat_json_init_object (node);
14041 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14042 vat_json_object_add_string_copy (node, "interface_name",
14043 mp->interface_name);
14044 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14045 ntohl (mp->virtio_net_hdr_sz));
14046 vat_json_object_add_uint (node, "features",
14047 clib_net_to_host_u64 (mp->features));
14048 vat_json_object_add_uint (node, "is_server", mp->is_server);
14049 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14050 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14051 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14055 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14057 vl_api_sw_interface_vhost_user_dump_t *mp;
14058 vl_api_control_ping_t *mp_ping;
14061 "Interface name idx hdr_sz features server regions filename");
14063 /* Get list of vhost-user interfaces */
14064 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14067 /* Use a control ping for synchronization */
14068 MPING (CONTROL_PING, mp_ping);
14076 api_show_version (vat_main_t * vam)
14078 vl_api_show_version_t *mp;
14081 M (SHOW_VERSION, mp);
14090 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14092 unformat_input_t *line_input = vam->input;
14093 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14094 ip4_address_t local4, remote4;
14095 ip6_address_t local6, remote6;
14097 u8 ipv4_set = 0, ipv6_set = 0;
14101 u32 mcast_sw_if_index = ~0;
14102 u32 encap_vrf_id = 0;
14103 u32 decap_vrf_id = 0;
14109 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14110 memset (&local4, 0, sizeof local4);
14111 memset (&remote4, 0, sizeof remote4);
14112 memset (&local6, 0, sizeof local6);
14113 memset (&remote6, 0, sizeof remote6);
14115 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14117 if (unformat (line_input, "del"))
14119 else if (unformat (line_input, "local %U",
14120 unformat_ip4_address, &local4))
14125 else if (unformat (line_input, "remote %U",
14126 unformat_ip4_address, &remote4))
14131 else if (unformat (line_input, "local %U",
14132 unformat_ip6_address, &local6))
14137 else if (unformat (line_input, "remote %U",
14138 unformat_ip6_address, &remote6))
14143 else if (unformat (line_input, "group %U %U",
14144 unformat_ip4_address, &remote4,
14145 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14147 grp_set = remote_set = 1;
14150 else if (unformat (line_input, "group %U",
14151 unformat_ip4_address, &remote4))
14153 grp_set = remote_set = 1;
14156 else if (unformat (line_input, "group %U %U",
14157 unformat_ip6_address, &remote6,
14158 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14160 grp_set = remote_set = 1;
14163 else if (unformat (line_input, "group %U",
14164 unformat_ip6_address, &remote6))
14166 grp_set = remote_set = 1;
14170 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14172 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14174 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14176 else if (unformat (line_input, "vni %d", &vni))
14178 else if (unformat (line_input, "next-ip4"))
14180 else if (unformat (line_input, "next-ip6"))
14182 else if (unformat (line_input, "next-ethernet"))
14184 else if (unformat (line_input, "next-nsh"))
14188 errmsg ("parse error '%U'", format_unformat_error, line_input);
14193 if (local_set == 0)
14195 errmsg ("tunnel local address not specified");
14198 if (remote_set == 0)
14200 errmsg ("tunnel remote address not specified");
14203 if (grp_set && mcast_sw_if_index == ~0)
14205 errmsg ("tunnel nonexistent multicast device");
14208 if (ipv4_set && ipv6_set)
14210 errmsg ("both IPv4 and IPv6 addresses specified");
14216 errmsg ("vni not specified");
14220 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14225 clib_memcpy (&mp->local, &local6, sizeof (local6));
14226 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14230 clib_memcpy (&mp->local, &local4, sizeof (local4));
14231 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14234 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14235 mp->encap_vrf_id = ntohl (encap_vrf_id);
14236 mp->decap_vrf_id = ntohl (decap_vrf_id);
14237 mp->protocol = protocol;
14238 mp->vni = ntohl (vni);
14239 mp->is_add = is_add;
14240 mp->is_ipv6 = ipv6_set;
14247 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14248 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14250 vat_main_t *vam = &vat_main;
14251 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14252 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14254 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14255 ntohl (mp->sw_if_index),
14256 format_ip46_address, &local, IP46_TYPE_ANY,
14257 format_ip46_address, &remote, IP46_TYPE_ANY,
14258 ntohl (mp->vni), mp->protocol,
14259 ntohl (mp->mcast_sw_if_index),
14260 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14264 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14265 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14267 vat_main_t *vam = &vat_main;
14268 vat_json_node_t *node = NULL;
14269 struct in_addr ip4;
14270 struct in6_addr ip6;
14272 if (VAT_JSON_ARRAY != vam->json_tree.type)
14274 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14275 vat_json_init_array (&vam->json_tree);
14277 node = vat_json_array_add (&vam->json_tree);
14279 vat_json_init_object (node);
14280 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14283 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14284 vat_json_object_add_ip6 (node, "local", ip6);
14285 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14286 vat_json_object_add_ip6 (node, "remote", ip6);
14290 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14291 vat_json_object_add_ip4 (node, "local", ip4);
14292 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14293 vat_json_object_add_ip4 (node, "remote", ip4);
14295 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14296 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14297 vat_json_object_add_uint (node, "mcast_sw_if_index",
14298 ntohl (mp->mcast_sw_if_index));
14299 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14300 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14301 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14305 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14307 unformat_input_t *i = vam->input;
14308 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14309 vl_api_control_ping_t *mp_ping;
14311 u8 sw_if_index_set = 0;
14314 /* Parse args required to build the message */
14315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14317 if (unformat (i, "sw_if_index %d", &sw_if_index))
14318 sw_if_index_set = 1;
14323 if (sw_if_index_set == 0)
14328 if (!vam->json_output)
14330 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14331 "sw_if_index", "local", "remote", "vni",
14332 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14335 /* Get list of vxlan-tunnel interfaces */
14336 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14338 mp->sw_if_index = htonl (sw_if_index);
14342 /* Use a control ping for synchronization */
14343 MPING (CONTROL_PING, mp_ping);
14350 static void vl_api_l2_fib_table_details_t_handler
14351 (vl_api_l2_fib_table_details_t * mp)
14353 vat_main_t *vam = &vat_main;
14355 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14357 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14358 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14362 static void vl_api_l2_fib_table_details_t_handler_json
14363 (vl_api_l2_fib_table_details_t * mp)
14365 vat_main_t *vam = &vat_main;
14366 vat_json_node_t *node = NULL;
14368 if (VAT_JSON_ARRAY != vam->json_tree.type)
14370 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14371 vat_json_init_array (&vam->json_tree);
14373 node = vat_json_array_add (&vam->json_tree);
14375 vat_json_init_object (node);
14376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14377 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14378 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14379 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14380 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14381 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14385 api_l2_fib_table_dump (vat_main_t * vam)
14387 unformat_input_t *i = vam->input;
14388 vl_api_l2_fib_table_dump_t *mp;
14389 vl_api_control_ping_t *mp_ping;
14394 /* Parse args required to build the message */
14395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14397 if (unformat (i, "bd_id %d", &bd_id))
14403 if (bd_id_set == 0)
14405 errmsg ("missing bridge domain");
14409 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14411 /* Get list of l2 fib entries */
14412 M (L2_FIB_TABLE_DUMP, mp);
14414 mp->bd_id = ntohl (bd_id);
14417 /* Use a control ping for synchronization */
14418 MPING (CONTROL_PING, mp_ping);
14427 api_interface_name_renumber (vat_main_t * vam)
14429 unformat_input_t *line_input = vam->input;
14430 vl_api_interface_name_renumber_t *mp;
14431 u32 sw_if_index = ~0;
14432 u32 new_show_dev_instance = ~0;
14435 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14437 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14440 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14442 else if (unformat (line_input, "new_show_dev_instance %d",
14443 &new_show_dev_instance))
14449 if (sw_if_index == ~0)
14451 errmsg ("missing interface name or sw_if_index");
14455 if (new_show_dev_instance == ~0)
14457 errmsg ("missing new_show_dev_instance");
14461 M (INTERFACE_NAME_RENUMBER, mp);
14463 mp->sw_if_index = ntohl (sw_if_index);
14464 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14472 api_ip_probe_neighbor (vat_main_t * vam)
14474 unformat_input_t *i = vam->input;
14475 vl_api_ip_probe_neighbor_t *mp;
14483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14489 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14491 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14502 errmsg ("missing interface");
14508 errmsg ("missing addresses");
14512 M (IP_PROBE_NEIGHBOR, mp);
14514 mp->sw_if_index = ntohl (sw_if_index);
14515 mp->is_ipv6 = is_ipv6;
14516 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14524 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14526 unformat_input_t *i = vam->input;
14527 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14528 u8 mode = IP_SCAN_V46_NEIGHBORS;
14529 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14532 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14534 if (unformat (i, "ip4"))
14535 mode = IP_SCAN_V4_NEIGHBORS;
14536 else if (unformat (i, "ip6"))
14537 mode = IP_SCAN_V6_NEIGHBORS;
14538 if (unformat (i, "both"))
14539 mode = IP_SCAN_V46_NEIGHBORS;
14540 else if (unformat (i, "disable"))
14541 mode = IP_SCAN_DISABLED;
14542 else if (unformat (i, "interval %d", &interval))
14544 else if (unformat (i, "max-time %d", &time))
14546 else if (unformat (i, "max-update %d", &update))
14548 else if (unformat (i, "delay %d", &delay))
14550 else if (unformat (i, "stale %d", &stale))
14556 if (interval > 255)
14558 errmsg ("interval cannot exceed 255 minutes.");
14563 errmsg ("max-time cannot exceed 255 usec.");
14568 errmsg ("max-update cannot exceed 255.");
14573 errmsg ("delay cannot exceed 255 msec.");
14578 errmsg ("stale cannot exceed 255 minutes.");
14582 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14584 mp->scan_interval = interval;
14585 mp->max_proc_time = time;
14586 mp->max_update = update;
14587 mp->scan_int_delay = delay;
14588 mp->stale_threshold = stale;
14596 api_want_ip4_arp_events (vat_main_t * vam)
14598 unformat_input_t *line_input = vam->input;
14599 vl_api_want_ip4_arp_events_t *mp;
14600 ip4_address_t address;
14601 int address_set = 0;
14602 u32 enable_disable = 1;
14605 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14607 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14609 else if (unformat (line_input, "del"))
14610 enable_disable = 0;
14615 if (address_set == 0)
14617 errmsg ("missing addresses");
14621 M (WANT_IP4_ARP_EVENTS, mp);
14622 mp->enable_disable = enable_disable;
14623 mp->pid = htonl (getpid ());
14624 mp->address = address.as_u32;
14632 api_want_ip6_nd_events (vat_main_t * vam)
14634 unformat_input_t *line_input = vam->input;
14635 vl_api_want_ip6_nd_events_t *mp;
14636 ip6_address_t address;
14637 int address_set = 0;
14638 u32 enable_disable = 1;
14641 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14643 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14645 else if (unformat (line_input, "del"))
14646 enable_disable = 0;
14651 if (address_set == 0)
14653 errmsg ("missing addresses");
14657 M (WANT_IP6_ND_EVENTS, mp);
14658 mp->enable_disable = enable_disable;
14659 mp->pid = htonl (getpid ());
14660 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14668 api_want_l2_macs_events (vat_main_t * vam)
14670 unformat_input_t *line_input = vam->input;
14671 vl_api_want_l2_macs_events_t *mp;
14672 u8 enable_disable = 1;
14673 u32 scan_delay = 0;
14674 u32 max_macs_in_event = 0;
14675 u32 learn_limit = 0;
14678 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (line_input, "learn-limit %d", &learn_limit))
14682 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14684 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14686 else if (unformat (line_input, "disable"))
14687 enable_disable = 0;
14692 M (WANT_L2_MACS_EVENTS, mp);
14693 mp->enable_disable = enable_disable;
14694 mp->pid = htonl (getpid ());
14695 mp->learn_limit = htonl (learn_limit);
14696 mp->scan_delay = (u8) scan_delay;
14697 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14704 api_input_acl_set_interface (vat_main_t * vam)
14706 unformat_input_t *i = vam->input;
14707 vl_api_input_acl_set_interface_t *mp;
14709 int sw_if_index_set;
14710 u32 ip4_table_index = ~0;
14711 u32 ip6_table_index = ~0;
14712 u32 l2_table_index = ~0;
14716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14719 sw_if_index_set = 1;
14720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14721 sw_if_index_set = 1;
14722 else if (unformat (i, "del"))
14724 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14726 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14728 else if (unformat (i, "l2-table %d", &l2_table_index))
14732 clib_warning ("parse error '%U'", format_unformat_error, i);
14737 if (sw_if_index_set == 0)
14739 errmsg ("missing interface name or sw_if_index");
14743 M (INPUT_ACL_SET_INTERFACE, mp);
14745 mp->sw_if_index = ntohl (sw_if_index);
14746 mp->ip4_table_index = ntohl (ip4_table_index);
14747 mp->ip6_table_index = ntohl (ip6_table_index);
14748 mp->l2_table_index = ntohl (l2_table_index);
14749 mp->is_add = is_add;
14757 api_output_acl_set_interface (vat_main_t * vam)
14759 unformat_input_t *i = vam->input;
14760 vl_api_output_acl_set_interface_t *mp;
14762 int sw_if_index_set;
14763 u32 ip4_table_index = ~0;
14764 u32 ip6_table_index = ~0;
14765 u32 l2_table_index = ~0;
14769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14771 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14772 sw_if_index_set = 1;
14773 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14774 sw_if_index_set = 1;
14775 else if (unformat (i, "del"))
14777 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14779 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14781 else if (unformat (i, "l2-table %d", &l2_table_index))
14785 clib_warning ("parse error '%U'", format_unformat_error, i);
14790 if (sw_if_index_set == 0)
14792 errmsg ("missing interface name or sw_if_index");
14796 M (OUTPUT_ACL_SET_INTERFACE, mp);
14798 mp->sw_if_index = ntohl (sw_if_index);
14799 mp->ip4_table_index = ntohl (ip4_table_index);
14800 mp->ip6_table_index = ntohl (ip6_table_index);
14801 mp->l2_table_index = ntohl (l2_table_index);
14802 mp->is_add = is_add;
14810 api_ip_address_dump (vat_main_t * vam)
14812 unformat_input_t *i = vam->input;
14813 vl_api_ip_address_dump_t *mp;
14814 vl_api_control_ping_t *mp_ping;
14815 u32 sw_if_index = ~0;
14816 u8 sw_if_index_set = 0;
14821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14823 if (unformat (i, "sw_if_index %d", &sw_if_index))
14824 sw_if_index_set = 1;
14826 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14827 sw_if_index_set = 1;
14828 else if (unformat (i, "ipv4"))
14830 else if (unformat (i, "ipv6"))
14836 if (ipv4_set && ipv6_set)
14838 errmsg ("ipv4 and ipv6 flags cannot be both set");
14842 if ((!ipv4_set) && (!ipv6_set))
14844 errmsg ("no ipv4 nor ipv6 flag set");
14848 if (sw_if_index_set == 0)
14850 errmsg ("missing interface name or sw_if_index");
14854 vam->current_sw_if_index = sw_if_index;
14855 vam->is_ipv6 = ipv6_set;
14857 M (IP_ADDRESS_DUMP, mp);
14858 mp->sw_if_index = ntohl (sw_if_index);
14859 mp->is_ipv6 = ipv6_set;
14862 /* Use a control ping for synchronization */
14863 MPING (CONTROL_PING, mp_ping);
14871 api_ip_dump (vat_main_t * vam)
14873 vl_api_ip_dump_t *mp;
14874 vl_api_control_ping_t *mp_ping;
14875 unformat_input_t *in = vam->input;
14882 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14884 if (unformat (in, "ipv4"))
14886 else if (unformat (in, "ipv6"))
14892 if (ipv4_set && ipv6_set)
14894 errmsg ("ipv4 and ipv6 flags cannot be both set");
14898 if ((!ipv4_set) && (!ipv6_set))
14900 errmsg ("no ipv4 nor ipv6 flag set");
14904 is_ipv6 = ipv6_set;
14905 vam->is_ipv6 = is_ipv6;
14907 /* free old data */
14908 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14910 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14912 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14915 mp->is_ipv6 = ipv6_set;
14918 /* Use a control ping for synchronization */
14919 MPING (CONTROL_PING, mp_ping);
14927 api_ipsec_spd_add_del (vat_main_t * vam)
14929 unformat_input_t *i = vam->input;
14930 vl_api_ipsec_spd_add_del_t *mp;
14935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14937 if (unformat (i, "spd_id %d", &spd_id))
14939 else if (unformat (i, "del"))
14943 clib_warning ("parse error '%U'", format_unformat_error, i);
14949 errmsg ("spd_id must be set");
14953 M (IPSEC_SPD_ADD_DEL, mp);
14955 mp->spd_id = ntohl (spd_id);
14956 mp->is_add = is_add;
14964 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14966 unformat_input_t *i = vam->input;
14967 vl_api_ipsec_interface_add_del_spd_t *mp;
14969 u8 sw_if_index_set = 0;
14970 u32 spd_id = (u32) ~ 0;
14974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14976 if (unformat (i, "del"))
14978 else if (unformat (i, "spd_id %d", &spd_id))
14981 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14982 sw_if_index_set = 1;
14983 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14984 sw_if_index_set = 1;
14987 clib_warning ("parse error '%U'", format_unformat_error, i);
14993 if (spd_id == (u32) ~ 0)
14995 errmsg ("spd_id must be set");
14999 if (sw_if_index_set == 0)
15001 errmsg ("missing interface name or sw_if_index");
15005 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15007 mp->spd_id = ntohl (spd_id);
15008 mp->sw_if_index = ntohl (sw_if_index);
15009 mp->is_add = is_add;
15017 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15019 unformat_input_t *i = vam->input;
15020 vl_api_ipsec_spd_add_del_entry_t *mp;
15021 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15022 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15024 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15025 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15026 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15027 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15030 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15031 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15032 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15033 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15034 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15035 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15039 if (unformat (i, "del"))
15041 if (unformat (i, "outbound"))
15043 if (unformat (i, "inbound"))
15045 else if (unformat (i, "spd_id %d", &spd_id))
15047 else if (unformat (i, "sa_id %d", &sa_id))
15049 else if (unformat (i, "priority %d", &priority))
15051 else if (unformat (i, "protocol %d", &protocol))
15053 else if (unformat (i, "lport_start %d", &lport_start))
15055 else if (unformat (i, "lport_stop %d", &lport_stop))
15057 else if (unformat (i, "rport_start %d", &rport_start))
15059 else if (unformat (i, "rport_stop %d", &rport_stop))
15063 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15069 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15076 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15082 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15089 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15095 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15102 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15108 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15114 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15116 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15118 clib_warning ("unsupported action: 'resolve'");
15124 clib_warning ("parse error '%U'", format_unformat_error, i);
15130 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15132 mp->spd_id = ntohl (spd_id);
15133 mp->priority = ntohl (priority);
15134 mp->is_outbound = is_outbound;
15136 mp->is_ipv6 = is_ipv6;
15137 if (is_ipv6 || is_ip_any)
15139 clib_memcpy (mp->remote_address_start, &raddr6_start,
15140 sizeof (ip6_address_t));
15141 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15142 sizeof (ip6_address_t));
15143 clib_memcpy (mp->local_address_start, &laddr6_start,
15144 sizeof (ip6_address_t));
15145 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15146 sizeof (ip6_address_t));
15150 clib_memcpy (mp->remote_address_start, &raddr4_start,
15151 sizeof (ip4_address_t));
15152 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15153 sizeof (ip4_address_t));
15154 clib_memcpy (mp->local_address_start, &laddr4_start,
15155 sizeof (ip4_address_t));
15156 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15157 sizeof (ip4_address_t));
15159 mp->protocol = (u8) protocol;
15160 mp->local_port_start = ntohs ((u16) lport_start);
15161 mp->local_port_stop = ntohs ((u16) lport_stop);
15162 mp->remote_port_start = ntohs ((u16) rport_start);
15163 mp->remote_port_stop = ntohs ((u16) rport_stop);
15164 mp->policy = (u8) policy;
15165 mp->sa_id = ntohl (sa_id);
15166 mp->is_add = is_add;
15167 mp->is_ip_any = is_ip_any;
15174 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15176 unformat_input_t *i = vam->input;
15177 vl_api_ipsec_sad_add_del_entry_t *mp;
15178 u32 sad_id = 0, spi = 0;
15179 u8 *ck = 0, *ik = 0;
15182 u8 protocol = IPSEC_PROTOCOL_AH;
15183 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15184 u32 crypto_alg = 0, integ_alg = 0;
15185 ip4_address_t tun_src4;
15186 ip4_address_t tun_dst4;
15187 ip6_address_t tun_src6;
15188 ip6_address_t tun_dst6;
15191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15193 if (unformat (i, "del"))
15195 else if (unformat (i, "sad_id %d", &sad_id))
15197 else if (unformat (i, "spi %d", &spi))
15199 else if (unformat (i, "esp"))
15200 protocol = IPSEC_PROTOCOL_ESP;
15201 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15204 is_tunnel_ipv6 = 0;
15206 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15209 is_tunnel_ipv6 = 0;
15211 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15214 is_tunnel_ipv6 = 1;
15216 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15219 is_tunnel_ipv6 = 1;
15223 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15225 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15226 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15228 clib_warning ("unsupported crypto-alg: '%U'",
15229 format_ipsec_crypto_alg, crypto_alg);
15233 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15237 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15239 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15240 integ_alg >= IPSEC_INTEG_N_ALG)
15242 clib_warning ("unsupported integ-alg: '%U'",
15243 format_ipsec_integ_alg, integ_alg);
15247 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15251 clib_warning ("parse error '%U'", format_unformat_error, i);
15257 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15259 mp->sad_id = ntohl (sad_id);
15260 mp->is_add = is_add;
15261 mp->protocol = protocol;
15262 mp->spi = ntohl (spi);
15263 mp->is_tunnel = is_tunnel;
15264 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15265 mp->crypto_algorithm = crypto_alg;
15266 mp->integrity_algorithm = integ_alg;
15267 mp->crypto_key_length = vec_len (ck);
15268 mp->integrity_key_length = vec_len (ik);
15270 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15271 mp->crypto_key_length = sizeof (mp->crypto_key);
15273 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15274 mp->integrity_key_length = sizeof (mp->integrity_key);
15277 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15279 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15283 if (is_tunnel_ipv6)
15285 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15286 sizeof (ip6_address_t));
15287 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15288 sizeof (ip6_address_t));
15292 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15293 sizeof (ip4_address_t));
15294 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15295 sizeof (ip4_address_t));
15305 api_ipsec_sa_set_key (vat_main_t * vam)
15307 unformat_input_t *i = vam->input;
15308 vl_api_ipsec_sa_set_key_t *mp;
15310 u8 *ck = 0, *ik = 0;
15313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15315 if (unformat (i, "sa_id %d", &sa_id))
15317 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15319 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15323 clib_warning ("parse error '%U'", format_unformat_error, i);
15328 M (IPSEC_SA_SET_KEY, mp);
15330 mp->sa_id = ntohl (sa_id);
15331 mp->crypto_key_length = vec_len (ck);
15332 mp->integrity_key_length = vec_len (ik);
15334 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15335 mp->crypto_key_length = sizeof (mp->crypto_key);
15337 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15338 mp->integrity_key_length = sizeof (mp->integrity_key);
15341 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15343 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15351 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15353 unformat_input_t *i = vam->input;
15354 vl_api_ipsec_tunnel_if_add_del_t *mp;
15355 u32 local_spi = 0, remote_spi = 0;
15356 u32 crypto_alg = 0, integ_alg = 0;
15357 u8 *lck = NULL, *rck = NULL;
15358 u8 *lik = NULL, *rik = NULL;
15359 ip4_address_t local_ip = { {0} };
15360 ip4_address_t remote_ip = { {0} };
15363 u8 anti_replay = 0;
15368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15370 if (unformat (i, "del"))
15372 else if (unformat (i, "esn"))
15374 else if (unformat (i, "anti_replay"))
15376 else if (unformat (i, "local_spi %d", &local_spi))
15378 else if (unformat (i, "remote_spi %d", &remote_spi))
15380 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15382 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15384 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15387 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15389 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15391 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15395 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15397 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15398 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15400 errmsg ("unsupported crypto-alg: '%U'\n",
15401 format_ipsec_crypto_alg, crypto_alg);
15407 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15409 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15410 integ_alg >= IPSEC_INTEG_N_ALG)
15412 errmsg ("unsupported integ-alg: '%U'\n",
15413 format_ipsec_integ_alg, integ_alg);
15417 else if (unformat (i, "instance %u", &instance))
15421 errmsg ("parse error '%U'\n", format_unformat_error, i);
15426 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15428 mp->is_add = is_add;
15430 mp->anti_replay = anti_replay;
15432 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15433 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15435 mp->local_spi = htonl (local_spi);
15436 mp->remote_spi = htonl (remote_spi);
15437 mp->crypto_alg = (u8) crypto_alg;
15439 mp->local_crypto_key_len = 0;
15442 mp->local_crypto_key_len = vec_len (lck);
15443 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15444 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15445 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15448 mp->remote_crypto_key_len = 0;
15451 mp->remote_crypto_key_len = vec_len (rck);
15452 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15453 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15454 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15457 mp->integ_alg = (u8) integ_alg;
15459 mp->local_integ_key_len = 0;
15462 mp->local_integ_key_len = vec_len (lik);
15463 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15464 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15465 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15468 mp->remote_integ_key_len = 0;
15471 mp->remote_integ_key_len = vec_len (rik);
15472 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15473 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15474 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15479 mp->renumber = renumber;
15480 mp->show_instance = ntohl (instance);
15489 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15491 vat_main_t *vam = &vat_main;
15493 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15494 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15495 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15496 "tunnel_src_addr %U tunnel_dst_addr %U "
15497 "salt %u seq_outbound %lu last_seq_inbound %lu "
15498 "replay_window %lu total_data_size %lu\n",
15499 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15501 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15502 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15503 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15504 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15505 mp->tunnel_src_addr,
15506 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15507 mp->tunnel_dst_addr,
15509 clib_net_to_host_u64 (mp->seq_outbound),
15510 clib_net_to_host_u64 (mp->last_seq_inbound),
15511 clib_net_to_host_u64 (mp->replay_window),
15512 clib_net_to_host_u64 (mp->total_data_size));
15515 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15516 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15518 static void vl_api_ipsec_sa_details_t_handler_json
15519 (vl_api_ipsec_sa_details_t * mp)
15521 vat_main_t *vam = &vat_main;
15522 vat_json_node_t *node = NULL;
15523 struct in_addr src_ip4, dst_ip4;
15524 struct in6_addr src_ip6, dst_ip6;
15526 if (VAT_JSON_ARRAY != vam->json_tree.type)
15528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15529 vat_json_init_array (&vam->json_tree);
15531 node = vat_json_array_add (&vam->json_tree);
15533 vat_json_init_object (node);
15534 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15535 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15536 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15537 vat_json_object_add_uint (node, "proto", mp->protocol);
15538 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15539 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15540 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15541 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15542 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15543 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15544 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15545 mp->crypto_key_len);
15546 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15547 mp->integ_key_len);
15548 if (mp->is_tunnel_ip6)
15550 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15551 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15552 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15553 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15557 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15558 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15559 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15560 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15562 vat_json_object_add_uint (node, "replay_window",
15563 clib_net_to_host_u64 (mp->replay_window));
15564 vat_json_object_add_uint (node, "total_data_size",
15565 clib_net_to_host_u64 (mp->total_data_size));
15570 api_ipsec_sa_dump (vat_main_t * vam)
15572 unformat_input_t *i = vam->input;
15573 vl_api_ipsec_sa_dump_t *mp;
15574 vl_api_control_ping_t *mp_ping;
15578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15580 if (unformat (i, "sa_id %d", &sa_id))
15584 clib_warning ("parse error '%U'", format_unformat_error, i);
15589 M (IPSEC_SA_DUMP, mp);
15591 mp->sa_id = ntohl (sa_id);
15595 /* Use a control ping for synchronization */
15596 M (CONTROL_PING, mp_ping);
15604 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15606 unformat_input_t *i = vam->input;
15607 vl_api_ipsec_tunnel_if_set_key_t *mp;
15608 u32 sw_if_index = ~0;
15609 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15619 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15620 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15622 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15623 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15624 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15625 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15627 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15628 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15629 else if (unformat (i, "%U", unformat_hex_string, &key))
15633 clib_warning ("parse error '%U'", format_unformat_error, i);
15638 if (sw_if_index == ~0)
15640 errmsg ("interface must be specified");
15644 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15646 errmsg ("key type must be specified");
15652 errmsg ("algorithm must be specified");
15656 if (vec_len (key) == 0)
15658 errmsg ("key must be specified");
15662 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15664 mp->sw_if_index = htonl (sw_if_index);
15666 mp->key_type = key_type;
15667 mp->key_len = vec_len (key);
15668 clib_memcpy (mp->key, key, vec_len (key));
15677 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15679 unformat_input_t *i = vam->input;
15680 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15681 u32 sw_if_index = ~0;
15683 u8 is_outbound = (u8) ~ 0;
15686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15688 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15690 else if (unformat (i, "sa_id %d", &sa_id))
15692 else if (unformat (i, "outbound"))
15694 else if (unformat (i, "inbound"))
15698 clib_warning ("parse error '%U'", format_unformat_error, i);
15703 if (sw_if_index == ~0)
15705 errmsg ("interface must be specified");
15711 errmsg ("SA ID must be specified");
15715 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15717 mp->sw_if_index = htonl (sw_if_index);
15718 mp->sa_id = htonl (sa_id);
15719 mp->is_outbound = is_outbound;
15728 api_ikev2_profile_add_del (vat_main_t * vam)
15730 unformat_input_t *i = vam->input;
15731 vl_api_ikev2_profile_add_del_t *mp;
15736 const char *valid_chars = "a-zA-Z0-9_";
15738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15740 if (unformat (i, "del"))
15742 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15743 vec_add1 (name, 0);
15746 errmsg ("parse error '%U'", format_unformat_error, i);
15751 if (!vec_len (name))
15753 errmsg ("profile name must be specified");
15757 if (vec_len (name) > 64)
15759 errmsg ("profile name too long");
15763 M (IKEV2_PROFILE_ADD_DEL, mp);
15765 clib_memcpy (mp->name, name, vec_len (name));
15766 mp->is_add = is_add;
15775 api_ikev2_profile_set_auth (vat_main_t * vam)
15777 unformat_input_t *i = vam->input;
15778 vl_api_ikev2_profile_set_auth_t *mp;
15781 u32 auth_method = 0;
15785 const char *valid_chars = "a-zA-Z0-9_";
15787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15789 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15790 vec_add1 (name, 0);
15791 else if (unformat (i, "auth_method %U",
15792 unformat_ikev2_auth_method, &auth_method))
15794 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15796 else if (unformat (i, "auth_data %v", &data))
15800 errmsg ("parse error '%U'", format_unformat_error, i);
15805 if (!vec_len (name))
15807 errmsg ("profile name must be specified");
15811 if (vec_len (name) > 64)
15813 errmsg ("profile name too long");
15817 if (!vec_len (data))
15819 errmsg ("auth_data must be specified");
15825 errmsg ("auth_method must be specified");
15829 M (IKEV2_PROFILE_SET_AUTH, mp);
15831 mp->is_hex = is_hex;
15832 mp->auth_method = (u8) auth_method;
15833 mp->data_len = vec_len (data);
15834 clib_memcpy (mp->name, name, vec_len (name));
15835 clib_memcpy (mp->data, data, vec_len (data));
15845 api_ikev2_profile_set_id (vat_main_t * vam)
15847 unformat_input_t *i = vam->input;
15848 vl_api_ikev2_profile_set_id_t *mp;
15856 const char *valid_chars = "a-zA-Z0-9_";
15858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15860 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15861 vec_add1 (name, 0);
15862 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15864 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15866 data = vec_new (u8, 4);
15867 clib_memcpy (data, ip4.as_u8, 4);
15869 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15871 else if (unformat (i, "id_data %v", &data))
15873 else if (unformat (i, "local"))
15875 else if (unformat (i, "remote"))
15879 errmsg ("parse error '%U'", format_unformat_error, i);
15884 if (!vec_len (name))
15886 errmsg ("profile name must be specified");
15890 if (vec_len (name) > 64)
15892 errmsg ("profile name too long");
15896 if (!vec_len (data))
15898 errmsg ("id_data must be specified");
15904 errmsg ("id_type must be specified");
15908 M (IKEV2_PROFILE_SET_ID, mp);
15910 mp->is_local = is_local;
15911 mp->id_type = (u8) id_type;
15912 mp->data_len = vec_len (data);
15913 clib_memcpy (mp->name, name, vec_len (name));
15914 clib_memcpy (mp->data, data, vec_len (data));
15924 api_ikev2_profile_set_ts (vat_main_t * vam)
15926 unformat_input_t *i = vam->input;
15927 vl_api_ikev2_profile_set_ts_t *mp;
15930 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15931 ip4_address_t start_addr, end_addr;
15933 const char *valid_chars = "a-zA-Z0-9_";
15936 start_addr.as_u32 = 0;
15937 end_addr.as_u32 = (u32) ~ 0;
15939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15941 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15942 vec_add1 (name, 0);
15943 else if (unformat (i, "protocol %d", &proto))
15945 else if (unformat (i, "start_port %d", &start_port))
15947 else if (unformat (i, "end_port %d", &end_port))
15950 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15952 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15954 else if (unformat (i, "local"))
15956 else if (unformat (i, "remote"))
15960 errmsg ("parse error '%U'", format_unformat_error, i);
15965 if (!vec_len (name))
15967 errmsg ("profile name must be specified");
15971 if (vec_len (name) > 64)
15973 errmsg ("profile name too long");
15977 M (IKEV2_PROFILE_SET_TS, mp);
15979 mp->is_local = is_local;
15980 mp->proto = (u8) proto;
15981 mp->start_port = (u16) start_port;
15982 mp->end_port = (u16) end_port;
15983 mp->start_addr = start_addr.as_u32;
15984 mp->end_addr = end_addr.as_u32;
15985 clib_memcpy (mp->name, name, vec_len (name));
15994 api_ikev2_set_local_key (vat_main_t * vam)
15996 unformat_input_t *i = vam->input;
15997 vl_api_ikev2_set_local_key_t *mp;
16001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16003 if (unformat (i, "file %v", &file))
16004 vec_add1 (file, 0);
16007 errmsg ("parse error '%U'", format_unformat_error, i);
16012 if (!vec_len (file))
16014 errmsg ("RSA key file must be specified");
16018 if (vec_len (file) > 256)
16020 errmsg ("file name too long");
16024 M (IKEV2_SET_LOCAL_KEY, mp);
16026 clib_memcpy (mp->key_file, file, vec_len (file));
16035 api_ikev2_set_responder (vat_main_t * vam)
16037 unformat_input_t *i = vam->input;
16038 vl_api_ikev2_set_responder_t *mp;
16041 u32 sw_if_index = ~0;
16042 ip4_address_t address;
16044 const char *valid_chars = "a-zA-Z0-9_";
16046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16049 (i, "%U interface %d address %U", unformat_token, valid_chars,
16050 &name, &sw_if_index, unformat_ip4_address, &address))
16051 vec_add1 (name, 0);
16054 errmsg ("parse error '%U'", format_unformat_error, i);
16059 if (!vec_len (name))
16061 errmsg ("profile name must be specified");
16065 if (vec_len (name) > 64)
16067 errmsg ("profile name too long");
16071 M (IKEV2_SET_RESPONDER, mp);
16073 clib_memcpy (mp->name, name, vec_len (name));
16076 mp->sw_if_index = sw_if_index;
16077 clib_memcpy (mp->address, &address, sizeof (address));
16085 api_ikev2_set_ike_transforms (vat_main_t * vam)
16087 unformat_input_t *i = vam->input;
16088 vl_api_ikev2_set_ike_transforms_t *mp;
16091 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16093 const char *valid_chars = "a-zA-Z0-9_";
16095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16097 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16098 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16099 vec_add1 (name, 0);
16102 errmsg ("parse error '%U'", format_unformat_error, i);
16107 if (!vec_len (name))
16109 errmsg ("profile name must be specified");
16113 if (vec_len (name) > 64)
16115 errmsg ("profile name too long");
16119 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16121 clib_memcpy (mp->name, name, vec_len (name));
16123 mp->crypto_alg = crypto_alg;
16124 mp->crypto_key_size = crypto_key_size;
16125 mp->integ_alg = integ_alg;
16126 mp->dh_group = dh_group;
16135 api_ikev2_set_esp_transforms (vat_main_t * vam)
16137 unformat_input_t *i = vam->input;
16138 vl_api_ikev2_set_esp_transforms_t *mp;
16141 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16143 const char *valid_chars = "a-zA-Z0-9_";
16145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16147 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16148 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16149 vec_add1 (name, 0);
16152 errmsg ("parse error '%U'", format_unformat_error, i);
16157 if (!vec_len (name))
16159 errmsg ("profile name must be specified");
16163 if (vec_len (name) > 64)
16165 errmsg ("profile name too long");
16169 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16171 clib_memcpy (mp->name, name, vec_len (name));
16173 mp->crypto_alg = crypto_alg;
16174 mp->crypto_key_size = crypto_key_size;
16175 mp->integ_alg = integ_alg;
16176 mp->dh_group = dh_group;
16184 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16186 unformat_input_t *i = vam->input;
16187 vl_api_ikev2_set_sa_lifetime_t *mp;
16190 u64 lifetime, lifetime_maxdata;
16191 u32 lifetime_jitter, handover;
16193 const char *valid_chars = "a-zA-Z0-9_";
16195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16197 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16198 &lifetime, &lifetime_jitter, &handover,
16199 &lifetime_maxdata))
16200 vec_add1 (name, 0);
16203 errmsg ("parse error '%U'", format_unformat_error, i);
16208 if (!vec_len (name))
16210 errmsg ("profile name must be specified");
16214 if (vec_len (name) > 64)
16216 errmsg ("profile name too long");
16220 M (IKEV2_SET_SA_LIFETIME, mp);
16222 clib_memcpy (mp->name, name, vec_len (name));
16224 mp->lifetime = lifetime;
16225 mp->lifetime_jitter = lifetime_jitter;
16226 mp->handover = handover;
16227 mp->lifetime_maxdata = lifetime_maxdata;
16235 api_ikev2_initiate_sa_init (vat_main_t * vam)
16237 unformat_input_t *i = vam->input;
16238 vl_api_ikev2_initiate_sa_init_t *mp;
16242 const char *valid_chars = "a-zA-Z0-9_";
16244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16246 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16247 vec_add1 (name, 0);
16250 errmsg ("parse error '%U'", format_unformat_error, i);
16255 if (!vec_len (name))
16257 errmsg ("profile name must be specified");
16261 if (vec_len (name) > 64)
16263 errmsg ("profile name too long");
16267 M (IKEV2_INITIATE_SA_INIT, mp);
16269 clib_memcpy (mp->name, name, vec_len (name));
16278 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16280 unformat_input_t *i = vam->input;
16281 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16288 if (unformat (i, "%lx", &ispi))
16292 errmsg ("parse error '%U'", format_unformat_error, i);
16297 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16307 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16309 unformat_input_t *i = vam->input;
16310 vl_api_ikev2_initiate_del_child_sa_t *mp;
16315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16317 if (unformat (i, "%x", &ispi))
16321 errmsg ("parse error '%U'", format_unformat_error, i);
16326 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16336 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16338 unformat_input_t *i = vam->input;
16339 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16346 if (unformat (i, "%x", &ispi))
16350 errmsg ("parse error '%U'", format_unformat_error, i);
16355 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16368 api_map_add_domain (vat_main_t * vam)
16370 unformat_input_t *i = vam->input;
16371 vl_api_map_add_domain_t *mp;
16373 ip4_address_t ip4_prefix;
16374 ip6_address_t ip6_prefix;
16375 ip6_address_t ip6_src;
16376 u32 num_m_args = 0;
16377 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16378 0, psid_length = 0;
16379 u8 is_translation = 0;
16381 u32 ip6_src_len = 128;
16384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16386 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16387 &ip4_prefix, &ip4_prefix_len))
16389 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16390 &ip6_prefix, &ip6_prefix_len))
16394 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16397 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16399 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16401 else if (unformat (i, "psid-offset %d", &psid_offset))
16403 else if (unformat (i, "psid-len %d", &psid_length))
16405 else if (unformat (i, "mtu %d", &mtu))
16407 else if (unformat (i, "map-t"))
16408 is_translation = 1;
16411 clib_warning ("parse error '%U'", format_unformat_error, i);
16416 if (num_m_args < 3)
16418 errmsg ("mandatory argument(s) missing");
16422 /* Construct the API message */
16423 M (MAP_ADD_DOMAIN, mp);
16425 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16426 mp->ip4_prefix_len = ip4_prefix_len;
16428 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16429 mp->ip6_prefix_len = ip6_prefix_len;
16431 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16432 mp->ip6_src_prefix_len = ip6_src_len;
16434 mp->ea_bits_len = ea_bits_len;
16435 mp->psid_offset = psid_offset;
16436 mp->psid_length = psid_length;
16437 mp->is_translation = is_translation;
16438 mp->mtu = htons (mtu);
16443 /* Wait for a reply, return good/bad news */
16449 api_map_del_domain (vat_main_t * vam)
16451 unformat_input_t *i = vam->input;
16452 vl_api_map_del_domain_t *mp;
16454 u32 num_m_args = 0;
16458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16460 if (unformat (i, "index %d", &index))
16464 clib_warning ("parse error '%U'", format_unformat_error, i);
16469 if (num_m_args != 1)
16471 errmsg ("mandatory argument(s) missing");
16475 /* Construct the API message */
16476 M (MAP_DEL_DOMAIN, mp);
16478 mp->index = ntohl (index);
16483 /* Wait for a reply, return good/bad news */
16489 api_map_add_del_rule (vat_main_t * vam)
16491 unformat_input_t *i = vam->input;
16492 vl_api_map_add_del_rule_t *mp;
16494 ip6_address_t ip6_dst;
16495 u32 num_m_args = 0, index, psid = 0;
16498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16500 if (unformat (i, "index %d", &index))
16502 else if (unformat (i, "psid %d", &psid))
16504 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16506 else if (unformat (i, "del"))
16512 clib_warning ("parse error '%U'", format_unformat_error, i);
16517 /* Construct the API message */
16518 M (MAP_ADD_DEL_RULE, mp);
16520 mp->index = ntohl (index);
16521 mp->is_add = is_add;
16522 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16523 mp->psid = ntohs (psid);
16528 /* Wait for a reply, return good/bad news */
16534 api_map_domain_dump (vat_main_t * vam)
16536 vl_api_map_domain_dump_t *mp;
16537 vl_api_control_ping_t *mp_ping;
16540 /* Construct the API message */
16541 M (MAP_DOMAIN_DUMP, mp);
16546 /* Use a control ping for synchronization */
16547 MPING (CONTROL_PING, mp_ping);
16555 api_map_rule_dump (vat_main_t * vam)
16557 unformat_input_t *i = vam->input;
16558 vl_api_map_rule_dump_t *mp;
16559 vl_api_control_ping_t *mp_ping;
16560 u32 domain_index = ~0;
16563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16565 if (unformat (i, "index %u", &domain_index))
16571 if (domain_index == ~0)
16573 clib_warning ("parse error: domain index expected");
16577 /* Construct the API message */
16578 M (MAP_RULE_DUMP, mp);
16580 mp->domain_index = htonl (domain_index);
16585 /* Use a control ping for synchronization */
16586 MPING (CONTROL_PING, mp_ping);
16593 static void vl_api_map_add_domain_reply_t_handler
16594 (vl_api_map_add_domain_reply_t * mp)
16596 vat_main_t *vam = &vat_main;
16597 i32 retval = ntohl (mp->retval);
16599 if (vam->async_mode)
16601 vam->async_errors += (retval < 0);
16605 vam->retval = retval;
16606 vam->result_ready = 1;
16610 static void vl_api_map_add_domain_reply_t_handler_json
16611 (vl_api_map_add_domain_reply_t * mp)
16613 vat_main_t *vam = &vat_main;
16614 vat_json_node_t node;
16616 vat_json_init_object (&node);
16617 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16618 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16620 vat_json_print (vam->ofp, &node);
16621 vat_json_free (&node);
16623 vam->retval = ntohl (mp->retval);
16624 vam->result_ready = 1;
16628 api_get_first_msg_id (vat_main_t * vam)
16630 vl_api_get_first_msg_id_t *mp;
16631 unformat_input_t *i = vam->input;
16636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16638 if (unformat (i, "client %s", &name))
16646 errmsg ("missing client name");
16649 vec_add1 (name, 0);
16651 if (vec_len (name) > 63)
16653 errmsg ("client name too long");
16657 M (GET_FIRST_MSG_ID, mp);
16658 clib_memcpy (mp->name, name, vec_len (name));
16665 api_cop_interface_enable_disable (vat_main_t * vam)
16667 unformat_input_t *line_input = vam->input;
16668 vl_api_cop_interface_enable_disable_t *mp;
16669 u32 sw_if_index = ~0;
16670 u8 enable_disable = 1;
16673 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16675 if (unformat (line_input, "disable"))
16676 enable_disable = 0;
16677 if (unformat (line_input, "enable"))
16678 enable_disable = 1;
16679 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16680 vam, &sw_if_index))
16682 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16688 if (sw_if_index == ~0)
16690 errmsg ("missing interface name or sw_if_index");
16694 /* Construct the API message */
16695 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16696 mp->sw_if_index = ntohl (sw_if_index);
16697 mp->enable_disable = enable_disable;
16701 /* Wait for the reply */
16707 api_cop_whitelist_enable_disable (vat_main_t * vam)
16709 unformat_input_t *line_input = vam->input;
16710 vl_api_cop_whitelist_enable_disable_t *mp;
16711 u32 sw_if_index = ~0;
16712 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16716 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16718 if (unformat (line_input, "ip4"))
16720 else if (unformat (line_input, "ip6"))
16722 else if (unformat (line_input, "default"))
16724 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16725 vam, &sw_if_index))
16727 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16729 else if (unformat (line_input, "fib-id %d", &fib_id))
16735 if (sw_if_index == ~0)
16737 errmsg ("missing interface name or sw_if_index");
16741 /* Construct the API message */
16742 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16743 mp->sw_if_index = ntohl (sw_if_index);
16744 mp->fib_id = ntohl (fib_id);
16747 mp->default_cop = default_cop;
16751 /* Wait for the reply */
16757 api_get_node_graph (vat_main_t * vam)
16759 vl_api_get_node_graph_t *mp;
16762 M (GET_NODE_GRAPH, mp);
16766 /* Wait for the reply */
16772 /** Used for parsing LISP eids */
16773 typedef CLIB_PACKED(struct{
16774 u8 addr[16]; /**< eid address */
16775 u32 len; /**< prefix length if IP */
16776 u8 type; /**< type of eid */
16781 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16783 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16785 memset (a, 0, sizeof (a[0]));
16787 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16789 a->type = 0; /* ipv4 type */
16791 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16793 a->type = 1; /* ipv6 type */
16795 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16797 a->type = 2; /* mac type */
16799 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16801 a->type = 3; /* NSH type */
16802 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16803 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16810 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16819 lisp_eid_size_vat (u8 type)
16836 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16838 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16842 api_one_add_del_locator_set (vat_main_t * vam)
16844 unformat_input_t *input = vam->input;
16845 vl_api_one_add_del_locator_set_t *mp;
16847 u8 *locator_set_name = NULL;
16848 u8 locator_set_name_set = 0;
16849 vl_api_local_locator_t locator, *locators = 0;
16850 u32 sw_if_index, priority, weight;
16854 /* Parse args required to build the message */
16855 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16857 if (unformat (input, "del"))
16861 else if (unformat (input, "locator-set %s", &locator_set_name))
16863 locator_set_name_set = 1;
16865 else if (unformat (input, "sw_if_index %u p %u w %u",
16866 &sw_if_index, &priority, &weight))
16868 locator.sw_if_index = htonl (sw_if_index);
16869 locator.priority = priority;
16870 locator.weight = weight;
16871 vec_add1 (locators, locator);
16875 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16876 &sw_if_index, &priority, &weight))
16878 locator.sw_if_index = htonl (sw_if_index);
16879 locator.priority = priority;
16880 locator.weight = weight;
16881 vec_add1 (locators, locator);
16887 if (locator_set_name_set == 0)
16889 errmsg ("missing locator-set name");
16890 vec_free (locators);
16894 if (vec_len (locator_set_name) > 64)
16896 errmsg ("locator-set name too long");
16897 vec_free (locator_set_name);
16898 vec_free (locators);
16901 vec_add1 (locator_set_name, 0);
16903 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16905 /* Construct the API message */
16906 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16908 mp->is_add = is_add;
16909 clib_memcpy (mp->locator_set_name, locator_set_name,
16910 vec_len (locator_set_name));
16911 vec_free (locator_set_name);
16913 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16915 clib_memcpy (mp->locators, locators, data_len);
16916 vec_free (locators);
16921 /* Wait for a reply... */
16926 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16929 api_one_add_del_locator (vat_main_t * vam)
16931 unformat_input_t *input = vam->input;
16932 vl_api_one_add_del_locator_t *mp;
16933 u32 tmp_if_index = ~0;
16934 u32 sw_if_index = ~0;
16935 u8 sw_if_index_set = 0;
16936 u8 sw_if_index_if_name_set = 0;
16938 u8 priority_set = 0;
16942 u8 *locator_set_name = NULL;
16943 u8 locator_set_name_set = 0;
16946 /* Parse args required to build the message */
16947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16949 if (unformat (input, "del"))
16953 else if (unformat (input, "locator-set %s", &locator_set_name))
16955 locator_set_name_set = 1;
16957 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16960 sw_if_index_if_name_set = 1;
16961 sw_if_index = tmp_if_index;
16963 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16965 sw_if_index_set = 1;
16966 sw_if_index = tmp_if_index;
16968 else if (unformat (input, "p %d", &priority))
16972 else if (unformat (input, "w %d", &weight))
16980 if (locator_set_name_set == 0)
16982 errmsg ("missing locator-set name");
16986 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16988 errmsg ("missing sw_if_index");
16989 vec_free (locator_set_name);
16993 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16995 errmsg ("cannot use both params interface name and sw_if_index");
16996 vec_free (locator_set_name);
17000 if (priority_set == 0)
17002 errmsg ("missing locator-set priority");
17003 vec_free (locator_set_name);
17007 if (weight_set == 0)
17009 errmsg ("missing locator-set weight");
17010 vec_free (locator_set_name);
17014 if (vec_len (locator_set_name) > 64)
17016 errmsg ("locator-set name too long");
17017 vec_free (locator_set_name);
17020 vec_add1 (locator_set_name, 0);
17022 /* Construct the API message */
17023 M (ONE_ADD_DEL_LOCATOR, mp);
17025 mp->is_add = is_add;
17026 mp->sw_if_index = ntohl (sw_if_index);
17027 mp->priority = priority;
17028 mp->weight = weight;
17029 clib_memcpy (mp->locator_set_name, locator_set_name,
17030 vec_len (locator_set_name));
17031 vec_free (locator_set_name);
17036 /* Wait for a reply... */
17041 #define api_lisp_add_del_locator api_one_add_del_locator
17044 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17046 u32 *key_id = va_arg (*args, u32 *);
17049 if (unformat (input, "%s", &s))
17051 if (!strcmp ((char *) s, "sha1"))
17052 key_id[0] = HMAC_SHA_1_96;
17053 else if (!strcmp ((char *) s, "sha256"))
17054 key_id[0] = HMAC_SHA_256_128;
17057 clib_warning ("invalid key_id: '%s'", s);
17058 key_id[0] = HMAC_NO_KEY;
17069 api_one_add_del_local_eid (vat_main_t * vam)
17071 unformat_input_t *input = vam->input;
17072 vl_api_one_add_del_local_eid_t *mp;
17075 lisp_eid_vat_t _eid, *eid = &_eid;
17076 u8 *locator_set_name = 0;
17077 u8 locator_set_name_set = 0;
17083 /* Parse args required to build the message */
17084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17086 if (unformat (input, "del"))
17090 else if (unformat (input, "vni %d", &vni))
17094 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17098 else if (unformat (input, "locator-set %s", &locator_set_name))
17100 locator_set_name_set = 1;
17102 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17104 else if (unformat (input, "secret-key %_%v%_", &key))
17110 if (locator_set_name_set == 0)
17112 errmsg ("missing locator-set name");
17118 errmsg ("EID address not set!");
17119 vec_free (locator_set_name);
17123 if (key && (0 == key_id))
17125 errmsg ("invalid key_id!");
17129 if (vec_len (key) > 64)
17131 errmsg ("key too long");
17136 if (vec_len (locator_set_name) > 64)
17138 errmsg ("locator-set name too long");
17139 vec_free (locator_set_name);
17142 vec_add1 (locator_set_name, 0);
17144 /* Construct the API message */
17145 M (ONE_ADD_DEL_LOCAL_EID, mp);
17147 mp->is_add = is_add;
17148 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17149 mp->eid_type = eid->type;
17150 mp->prefix_len = eid->len;
17151 mp->vni = clib_host_to_net_u32 (vni);
17152 mp->key_id = clib_host_to_net_u16 (key_id);
17153 clib_memcpy (mp->locator_set_name, locator_set_name,
17154 vec_len (locator_set_name));
17155 clib_memcpy (mp->key, key, vec_len (key));
17157 vec_free (locator_set_name);
17163 /* Wait for a reply... */
17168 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17171 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17173 u32 dp_table = 0, vni = 0;;
17174 unformat_input_t *input = vam->input;
17175 vl_api_gpe_add_del_fwd_entry_t *mp;
17177 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17178 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17179 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17180 u32 action = ~0, w;
17181 ip4_address_t rmt_rloc4, lcl_rloc4;
17182 ip6_address_t rmt_rloc6, lcl_rloc6;
17183 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17186 memset (&rloc, 0, sizeof (rloc));
17188 /* Parse args required to build the message */
17189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17191 if (unformat (input, "del"))
17193 else if (unformat (input, "add"))
17195 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17199 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17203 else if (unformat (input, "vrf %d", &dp_table))
17205 else if (unformat (input, "bd %d", &dp_table))
17207 else if (unformat (input, "vni %d", &vni))
17209 else if (unformat (input, "w %d", &w))
17213 errmsg ("No RLOC configured for setting priority/weight!");
17216 curr_rloc->weight = w;
17218 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17219 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17223 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17225 vec_add1 (lcl_locs, rloc);
17227 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17228 vec_add1 (rmt_locs, rloc);
17229 /* weight saved in rmt loc */
17230 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17232 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17233 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17236 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17238 vec_add1 (lcl_locs, rloc);
17240 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17241 vec_add1 (rmt_locs, rloc);
17242 /* weight saved in rmt loc */
17243 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17245 else if (unformat (input, "action %d", &action))
17251 clib_warning ("parse error '%U'", format_unformat_error, input);
17258 errmsg ("remote eid addresses not set");
17262 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17264 errmsg ("eid types don't match");
17268 if (0 == rmt_locs && (u32) ~ 0 == action)
17270 errmsg ("action not set for negative mapping");
17274 /* Construct the API message */
17275 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17276 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17278 mp->is_add = is_add;
17279 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17280 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17281 mp->eid_type = rmt_eid->type;
17282 mp->dp_table = clib_host_to_net_u32 (dp_table);
17283 mp->vni = clib_host_to_net_u32 (vni);
17284 mp->rmt_len = rmt_eid->len;
17285 mp->lcl_len = lcl_eid->len;
17286 mp->action = action;
17288 if (0 != rmt_locs && 0 != lcl_locs)
17290 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17291 clib_memcpy (mp->locs, lcl_locs,
17292 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17294 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17295 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17296 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17298 vec_free (lcl_locs);
17299 vec_free (rmt_locs);
17304 /* Wait for a reply... */
17310 api_one_add_del_map_server (vat_main_t * vam)
17312 unformat_input_t *input = vam->input;
17313 vl_api_one_add_del_map_server_t *mp;
17317 ip4_address_t ipv4;
17318 ip6_address_t ipv6;
17321 /* Parse args required to build the message */
17322 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17324 if (unformat (input, "del"))
17328 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17332 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17340 if (ipv4_set && ipv6_set)
17342 errmsg ("both eid v4 and v6 addresses set");
17346 if (!ipv4_set && !ipv6_set)
17348 errmsg ("eid addresses not set");
17352 /* Construct the API message */
17353 M (ONE_ADD_DEL_MAP_SERVER, mp);
17355 mp->is_add = is_add;
17359 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17364 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17370 /* Wait for a reply... */
17375 #define api_lisp_add_del_map_server api_one_add_del_map_server
17378 api_one_add_del_map_resolver (vat_main_t * vam)
17380 unformat_input_t *input = vam->input;
17381 vl_api_one_add_del_map_resolver_t *mp;
17385 ip4_address_t ipv4;
17386 ip6_address_t ipv6;
17389 /* Parse args required to build the message */
17390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17392 if (unformat (input, "del"))
17396 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17400 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17408 if (ipv4_set && ipv6_set)
17410 errmsg ("both eid v4 and v6 addresses set");
17414 if (!ipv4_set && !ipv6_set)
17416 errmsg ("eid addresses not set");
17420 /* Construct the API message */
17421 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17423 mp->is_add = is_add;
17427 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17432 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17438 /* Wait for a reply... */
17443 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17446 api_lisp_gpe_enable_disable (vat_main_t * vam)
17448 unformat_input_t *input = vam->input;
17449 vl_api_gpe_enable_disable_t *mp;
17454 /* Parse args required to build the message */
17455 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17457 if (unformat (input, "enable"))
17462 else if (unformat (input, "disable"))
17473 errmsg ("Value not set");
17477 /* Construct the API message */
17478 M (GPE_ENABLE_DISABLE, mp);
17485 /* Wait for a reply... */
17491 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17493 unformat_input_t *input = vam->input;
17494 vl_api_one_rloc_probe_enable_disable_t *mp;
17499 /* Parse args required to build the message */
17500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17502 if (unformat (input, "enable"))
17507 else if (unformat (input, "disable"))
17515 errmsg ("Value not set");
17519 /* Construct the API message */
17520 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17522 mp->is_enabled = is_en;
17527 /* Wait for a reply... */
17532 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17535 api_one_map_register_enable_disable (vat_main_t * vam)
17537 unformat_input_t *input = vam->input;
17538 vl_api_one_map_register_enable_disable_t *mp;
17543 /* Parse args required to build the message */
17544 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17546 if (unformat (input, "enable"))
17551 else if (unformat (input, "disable"))
17559 errmsg ("Value not set");
17563 /* Construct the API message */
17564 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17566 mp->is_enabled = is_en;
17571 /* Wait for a reply... */
17576 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17579 api_one_enable_disable (vat_main_t * vam)
17581 unformat_input_t *input = vam->input;
17582 vl_api_one_enable_disable_t *mp;
17587 /* Parse args required to build the message */
17588 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17590 if (unformat (input, "enable"))
17595 else if (unformat (input, "disable"))
17605 errmsg ("Value not set");
17609 /* Construct the API message */
17610 M (ONE_ENABLE_DISABLE, mp);
17617 /* Wait for a reply... */
17622 #define api_lisp_enable_disable api_one_enable_disable
17625 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17627 unformat_input_t *input = vam->input;
17628 vl_api_one_enable_disable_xtr_mode_t *mp;
17633 /* Parse args required to build the message */
17634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17636 if (unformat (input, "enable"))
17641 else if (unformat (input, "disable"))
17651 errmsg ("Value not set");
17655 /* Construct the API message */
17656 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17663 /* Wait for a reply... */
17669 api_one_show_xtr_mode (vat_main_t * vam)
17671 vl_api_one_show_xtr_mode_t *mp;
17674 /* Construct the API message */
17675 M (ONE_SHOW_XTR_MODE, mp);
17680 /* Wait for a reply... */
17686 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17688 unformat_input_t *input = vam->input;
17689 vl_api_one_enable_disable_pitr_mode_t *mp;
17694 /* Parse args required to build the message */
17695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17697 if (unformat (input, "enable"))
17702 else if (unformat (input, "disable"))
17712 errmsg ("Value not set");
17716 /* Construct the API message */
17717 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17724 /* Wait for a reply... */
17730 api_one_show_pitr_mode (vat_main_t * vam)
17732 vl_api_one_show_pitr_mode_t *mp;
17735 /* Construct the API message */
17736 M (ONE_SHOW_PITR_MODE, mp);
17741 /* Wait for a reply... */
17747 api_one_enable_disable_petr_mode (vat_main_t * vam)
17749 unformat_input_t *input = vam->input;
17750 vl_api_one_enable_disable_petr_mode_t *mp;
17755 /* Parse args required to build the message */
17756 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17758 if (unformat (input, "enable"))
17763 else if (unformat (input, "disable"))
17773 errmsg ("Value not set");
17777 /* Construct the API message */
17778 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17785 /* Wait for a reply... */
17791 api_one_show_petr_mode (vat_main_t * vam)
17793 vl_api_one_show_petr_mode_t *mp;
17796 /* Construct the API message */
17797 M (ONE_SHOW_PETR_MODE, mp);
17802 /* Wait for a reply... */
17808 api_show_one_map_register_state (vat_main_t * vam)
17810 vl_api_show_one_map_register_state_t *mp;
17813 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17818 /* wait for reply */
17823 #define api_show_lisp_map_register_state api_show_one_map_register_state
17826 api_show_one_rloc_probe_state (vat_main_t * vam)
17828 vl_api_show_one_rloc_probe_state_t *mp;
17831 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17836 /* wait for reply */
17841 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17844 api_one_add_del_ndp_entry (vat_main_t * vam)
17846 vl_api_one_add_del_ndp_entry_t *mp;
17847 unformat_input_t *input = vam->input;
17852 u8 mac[6] = { 0, };
17853 u8 ip6[16] = { 0, };
17857 /* Parse args required to build the message */
17858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17860 if (unformat (input, "del"))
17862 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17864 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17866 else if (unformat (input, "bd %d", &bd))
17870 errmsg ("parse error '%U'", format_unformat_error, input);
17875 if (!bd_set || !ip_set || (!mac_set && is_add))
17877 errmsg ("Missing BD, IP or MAC!");
17881 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17882 mp->is_add = is_add;
17883 clib_memcpy (mp->mac, mac, 6);
17884 mp->bd = clib_host_to_net_u32 (bd);
17885 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17890 /* wait for reply */
17896 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17898 vl_api_one_add_del_l2_arp_entry_t *mp;
17899 unformat_input_t *input = vam->input;
17904 u8 mac[6] = { 0, };
17905 u32 ip4 = 0, bd = ~0;
17908 /* Parse args required to build the message */
17909 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17911 if (unformat (input, "del"))
17913 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17915 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17917 else if (unformat (input, "bd %d", &bd))
17921 errmsg ("parse error '%U'", format_unformat_error, input);
17926 if (!bd_set || !ip_set || (!mac_set && is_add))
17928 errmsg ("Missing BD, IP or MAC!");
17932 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17933 mp->is_add = is_add;
17934 clib_memcpy (mp->mac, mac, 6);
17935 mp->bd = clib_host_to_net_u32 (bd);
17941 /* wait for reply */
17947 api_one_ndp_bd_get (vat_main_t * vam)
17949 vl_api_one_ndp_bd_get_t *mp;
17952 M (ONE_NDP_BD_GET, mp);
17957 /* wait for reply */
17963 api_one_ndp_entries_get (vat_main_t * vam)
17965 vl_api_one_ndp_entries_get_t *mp;
17966 unformat_input_t *input = vam->input;
17971 /* Parse args required to build the message */
17972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17974 if (unformat (input, "bd %d", &bd))
17978 errmsg ("parse error '%U'", format_unformat_error, input);
17985 errmsg ("Expected bridge domain!");
17989 M (ONE_NDP_ENTRIES_GET, mp);
17990 mp->bd = clib_host_to_net_u32 (bd);
17995 /* wait for reply */
18001 api_one_l2_arp_bd_get (vat_main_t * vam)
18003 vl_api_one_l2_arp_bd_get_t *mp;
18006 M (ONE_L2_ARP_BD_GET, mp);
18011 /* wait for reply */
18017 api_one_l2_arp_entries_get (vat_main_t * vam)
18019 vl_api_one_l2_arp_entries_get_t *mp;
18020 unformat_input_t *input = vam->input;
18025 /* Parse args required to build the message */
18026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18028 if (unformat (input, "bd %d", &bd))
18032 errmsg ("parse error '%U'", format_unformat_error, input);
18039 errmsg ("Expected bridge domain!");
18043 M (ONE_L2_ARP_ENTRIES_GET, mp);
18044 mp->bd = clib_host_to_net_u32 (bd);
18049 /* wait for reply */
18055 api_one_stats_enable_disable (vat_main_t * vam)
18057 vl_api_one_stats_enable_disable_t *mp;
18058 unformat_input_t *input = vam->input;
18063 /* Parse args required to build the message */
18064 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18066 if (unformat (input, "enable"))
18071 else if (unformat (input, "disable"))
18081 errmsg ("Value not set");
18085 M (ONE_STATS_ENABLE_DISABLE, mp);
18091 /* wait for reply */
18097 api_show_one_stats_enable_disable (vat_main_t * vam)
18099 vl_api_show_one_stats_enable_disable_t *mp;
18102 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18107 /* wait for reply */
18113 api_show_one_map_request_mode (vat_main_t * vam)
18115 vl_api_show_one_map_request_mode_t *mp;
18118 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18123 /* wait for reply */
18128 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18131 api_one_map_request_mode (vat_main_t * vam)
18133 unformat_input_t *input = vam->input;
18134 vl_api_one_map_request_mode_t *mp;
18138 /* Parse args required to build the message */
18139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18141 if (unformat (input, "dst-only"))
18143 else if (unformat (input, "src-dst"))
18147 errmsg ("parse error '%U'", format_unformat_error, input);
18152 M (ONE_MAP_REQUEST_MODE, mp);
18159 /* wait for reply */
18164 #define api_lisp_map_request_mode api_one_map_request_mode
18167 * Enable/disable ONE proxy ITR.
18169 * @param vam vpp API test context
18170 * @return return code
18173 api_one_pitr_set_locator_set (vat_main_t * vam)
18175 u8 ls_name_set = 0;
18176 unformat_input_t *input = vam->input;
18177 vl_api_one_pitr_set_locator_set_t *mp;
18182 /* Parse args required to build the message */
18183 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18185 if (unformat (input, "del"))
18187 else if (unformat (input, "locator-set %s", &ls_name))
18191 errmsg ("parse error '%U'", format_unformat_error, input);
18198 errmsg ("locator-set name not set!");
18202 M (ONE_PITR_SET_LOCATOR_SET, mp);
18204 mp->is_add = is_add;
18205 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18206 vec_free (ls_name);
18211 /* wait for reply */
18216 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18219 api_one_nsh_set_locator_set (vat_main_t * vam)
18221 u8 ls_name_set = 0;
18222 unformat_input_t *input = vam->input;
18223 vl_api_one_nsh_set_locator_set_t *mp;
18228 /* Parse args required to build the message */
18229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18231 if (unformat (input, "del"))
18233 else if (unformat (input, "ls %s", &ls_name))
18237 errmsg ("parse error '%U'", format_unformat_error, input);
18242 if (!ls_name_set && is_add)
18244 errmsg ("locator-set name not set!");
18248 M (ONE_NSH_SET_LOCATOR_SET, mp);
18250 mp->is_add = is_add;
18251 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18252 vec_free (ls_name);
18257 /* wait for reply */
18263 api_show_one_pitr (vat_main_t * vam)
18265 vl_api_show_one_pitr_t *mp;
18268 if (!vam->json_output)
18270 print (vam->ofp, "%=20s", "lisp status:");
18273 M (SHOW_ONE_PITR, mp);
18277 /* Wait for a reply... */
18282 #define api_show_lisp_pitr api_show_one_pitr
18285 api_one_use_petr (vat_main_t * vam)
18287 unformat_input_t *input = vam->input;
18288 vl_api_one_use_petr_t *mp;
18293 memset (&ip, 0, sizeof (ip));
18295 /* Parse args required to build the message */
18296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18298 if (unformat (input, "disable"))
18301 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18304 ip_addr_version (&ip) = IP4;
18307 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18310 ip_addr_version (&ip) = IP6;
18314 errmsg ("parse error '%U'", format_unformat_error, input);
18319 M (ONE_USE_PETR, mp);
18321 mp->is_add = is_add;
18324 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18326 clib_memcpy (mp->address, &ip, 4);
18328 clib_memcpy (mp->address, &ip, 16);
18334 /* wait for reply */
18339 #define api_lisp_use_petr api_one_use_petr
18342 api_show_one_nsh_mapping (vat_main_t * vam)
18344 vl_api_show_one_use_petr_t *mp;
18347 if (!vam->json_output)
18349 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18352 M (SHOW_ONE_NSH_MAPPING, mp);
18356 /* Wait for a reply... */
18362 api_show_one_use_petr (vat_main_t * vam)
18364 vl_api_show_one_use_petr_t *mp;
18367 if (!vam->json_output)
18369 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18372 M (SHOW_ONE_USE_PETR, mp);
18376 /* Wait for a reply... */
18381 #define api_show_lisp_use_petr api_show_one_use_petr
18384 * Add/delete mapping between vni and vrf
18387 api_one_eid_table_add_del_map (vat_main_t * vam)
18389 unformat_input_t *input = vam->input;
18390 vl_api_one_eid_table_add_del_map_t *mp;
18391 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18392 u32 vni, vrf, bd_index;
18395 /* Parse args required to build the message */
18396 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18398 if (unformat (input, "del"))
18400 else if (unformat (input, "vrf %d", &vrf))
18402 else if (unformat (input, "bd_index %d", &bd_index))
18404 else if (unformat (input, "vni %d", &vni))
18410 if (!vni_set || (!vrf_set && !bd_index_set))
18412 errmsg ("missing arguments!");
18416 if (vrf_set && bd_index_set)
18418 errmsg ("error: both vrf and bd entered!");
18422 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18424 mp->is_add = is_add;
18425 mp->vni = htonl (vni);
18426 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18427 mp->is_l2 = bd_index_set;
18432 /* wait for reply */
18437 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18440 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18442 u32 *action = va_arg (*args, u32 *);
18445 if (unformat (input, "%s", &s))
18447 if (!strcmp ((char *) s, "no-action"))
18449 else if (!strcmp ((char *) s, "natively-forward"))
18451 else if (!strcmp ((char *) s, "send-map-request"))
18453 else if (!strcmp ((char *) s, "drop"))
18457 clib_warning ("invalid action: '%s'", s);
18469 * Add/del remote mapping to/from ONE control plane
18471 * @param vam vpp API test context
18472 * @return return code
18475 api_one_add_del_remote_mapping (vat_main_t * vam)
18477 unformat_input_t *input = vam->input;
18478 vl_api_one_add_del_remote_mapping_t *mp;
18480 lisp_eid_vat_t _eid, *eid = &_eid;
18481 lisp_eid_vat_t _seid, *seid = &_seid;
18482 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18483 u32 action = ~0, p, w, data_len;
18484 ip4_address_t rloc4;
18485 ip6_address_t rloc6;
18486 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18489 memset (&rloc, 0, sizeof (rloc));
18491 /* Parse args required to build the message */
18492 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18494 if (unformat (input, "del-all"))
18498 else if (unformat (input, "del"))
18502 else if (unformat (input, "add"))
18506 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18510 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18514 else if (unformat (input, "vni %d", &vni))
18518 else if (unformat (input, "p %d w %d", &p, &w))
18522 errmsg ("No RLOC configured for setting priority/weight!");
18525 curr_rloc->priority = p;
18526 curr_rloc->weight = w;
18528 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18531 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18532 vec_add1 (rlocs, rloc);
18533 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18535 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18538 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18539 vec_add1 (rlocs, rloc);
18540 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18542 else if (unformat (input, "action %U",
18543 unformat_negative_mapping_action, &action))
18549 clib_warning ("parse error '%U'", format_unformat_error, input);
18556 errmsg ("missing params!");
18560 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18562 errmsg ("no action set for negative map-reply!");
18566 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18568 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18569 mp->is_add = is_add;
18570 mp->vni = htonl (vni);
18571 mp->action = (u8) action;
18572 mp->is_src_dst = seid_set;
18573 mp->eid_len = eid->len;
18574 mp->seid_len = seid->len;
18575 mp->del_all = del_all;
18576 mp->eid_type = eid->type;
18577 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18578 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18580 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18581 clib_memcpy (mp->rlocs, rlocs, data_len);
18587 /* Wait for a reply... */
18592 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18595 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18596 * forwarding entries in data-plane accordingly.
18598 * @param vam vpp API test context
18599 * @return return code
18602 api_one_add_del_adjacency (vat_main_t * vam)
18604 unformat_input_t *input = vam->input;
18605 vl_api_one_add_del_adjacency_t *mp;
18607 ip4_address_t leid4, reid4;
18608 ip6_address_t leid6, reid6;
18609 u8 reid_mac[6] = { 0 };
18610 u8 leid_mac[6] = { 0 };
18611 u8 reid_type, leid_type;
18612 u32 leid_len = 0, reid_len = 0, len;
18616 leid_type = reid_type = (u8) ~ 0;
18618 /* Parse args required to build the message */
18619 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18621 if (unformat (input, "del"))
18625 else if (unformat (input, "add"))
18629 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18632 reid_type = 0; /* ipv4 */
18635 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18638 reid_type = 1; /* ipv6 */
18641 else if (unformat (input, "reid %U", unformat_ethernet_address,
18644 reid_type = 2; /* mac */
18646 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18649 leid_type = 0; /* ipv4 */
18652 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18655 leid_type = 1; /* ipv6 */
18658 else if (unformat (input, "leid %U", unformat_ethernet_address,
18661 leid_type = 2; /* mac */
18663 else if (unformat (input, "vni %d", &vni))
18669 errmsg ("parse error '%U'", format_unformat_error, input);
18674 if ((u8) ~ 0 == reid_type)
18676 errmsg ("missing params!");
18680 if (leid_type != reid_type)
18682 errmsg ("remote and local EIDs are of different types!");
18686 M (ONE_ADD_DEL_ADJACENCY, mp);
18687 mp->is_add = is_add;
18688 mp->vni = htonl (vni);
18689 mp->leid_len = leid_len;
18690 mp->reid_len = reid_len;
18691 mp->eid_type = reid_type;
18693 switch (mp->eid_type)
18696 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18697 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18700 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18701 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18704 clib_memcpy (mp->leid, leid_mac, 6);
18705 clib_memcpy (mp->reid, reid_mac, 6);
18708 errmsg ("unknown EID type %d!", mp->eid_type);
18715 /* Wait for a reply... */
18720 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18723 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18725 u32 *mode = va_arg (*args, u32 *);
18727 if (unformat (input, "lisp"))
18729 else if (unformat (input, "vxlan"))
18738 api_gpe_get_encap_mode (vat_main_t * vam)
18740 vl_api_gpe_get_encap_mode_t *mp;
18743 /* Construct the API message */
18744 M (GPE_GET_ENCAP_MODE, mp);
18749 /* Wait for a reply... */
18755 api_gpe_set_encap_mode (vat_main_t * vam)
18757 unformat_input_t *input = vam->input;
18758 vl_api_gpe_set_encap_mode_t *mp;
18762 /* Parse args required to build the message */
18763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18765 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18771 /* Construct the API message */
18772 M (GPE_SET_ENCAP_MODE, mp);
18779 /* Wait for a reply... */
18785 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18787 unformat_input_t *input = vam->input;
18788 vl_api_gpe_add_del_iface_t *mp;
18789 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18790 u32 dp_table = 0, vni = 0;
18793 /* Parse args required to build the message */
18794 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18796 if (unformat (input, "up"))
18801 else if (unformat (input, "down"))
18806 else if (unformat (input, "table_id %d", &dp_table))
18810 else if (unformat (input, "bd_id %d", &dp_table))
18815 else if (unformat (input, "vni %d", &vni))
18823 if (action_set == 0)
18825 errmsg ("Action not set");
18828 if (dp_table_set == 0 || vni_set == 0)
18830 errmsg ("vni and dp_table must be set");
18834 /* Construct the API message */
18835 M (GPE_ADD_DEL_IFACE, mp);
18837 mp->is_add = is_add;
18838 mp->dp_table = clib_host_to_net_u32 (dp_table);
18840 mp->vni = clib_host_to_net_u32 (vni);
18845 /* Wait for a reply... */
18851 api_one_map_register_fallback_threshold (vat_main_t * vam)
18853 unformat_input_t *input = vam->input;
18854 vl_api_one_map_register_fallback_threshold_t *mp;
18859 /* Parse args required to build the message */
18860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18862 if (unformat (input, "%u", &value))
18866 clib_warning ("parse error '%U'", format_unformat_error, input);
18873 errmsg ("fallback threshold value is missing!");
18877 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18878 mp->value = clib_host_to_net_u32 (value);
18883 /* Wait for a reply... */
18889 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18891 vl_api_show_one_map_register_fallback_threshold_t *mp;
18894 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18899 /* Wait for a reply... */
18905 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18907 u32 *proto = va_arg (*args, u32 *);
18909 if (unformat (input, "udp"))
18911 else if (unformat (input, "api"))
18920 api_one_set_transport_protocol (vat_main_t * vam)
18922 unformat_input_t *input = vam->input;
18923 vl_api_one_set_transport_protocol_t *mp;
18928 /* Parse args required to build the message */
18929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18931 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18935 clib_warning ("parse error '%U'", format_unformat_error, input);
18942 errmsg ("Transport protocol missing!");
18946 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18947 mp->protocol = (u8) protocol;
18952 /* Wait for a reply... */
18958 api_one_get_transport_protocol (vat_main_t * vam)
18960 vl_api_one_get_transport_protocol_t *mp;
18963 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18968 /* Wait for a reply... */
18974 api_one_map_register_set_ttl (vat_main_t * vam)
18976 unformat_input_t *input = vam->input;
18977 vl_api_one_map_register_set_ttl_t *mp;
18982 /* Parse args required to build the message */
18983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18985 if (unformat (input, "%u", &ttl))
18989 clib_warning ("parse error '%U'", format_unformat_error, input);
18996 errmsg ("TTL value missing!");
19000 M (ONE_MAP_REGISTER_SET_TTL, mp);
19001 mp->ttl = clib_host_to_net_u32 (ttl);
19006 /* Wait for a reply... */
19012 api_show_one_map_register_ttl (vat_main_t * vam)
19014 vl_api_show_one_map_register_ttl_t *mp;
19017 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19022 /* Wait for a reply... */
19028 * Add/del map request itr rlocs from ONE control plane and updates
19030 * @param vam vpp API test context
19031 * @return return code
19034 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19036 unformat_input_t *input = vam->input;
19037 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19038 u8 *locator_set_name = 0;
19039 u8 locator_set_name_set = 0;
19043 /* Parse args required to build the message */
19044 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19046 if (unformat (input, "del"))
19050 else if (unformat (input, "%_%v%_", &locator_set_name))
19052 locator_set_name_set = 1;
19056 clib_warning ("parse error '%U'", format_unformat_error, input);
19061 if (is_add && !locator_set_name_set)
19063 errmsg ("itr-rloc is not set!");
19067 if (is_add && vec_len (locator_set_name) > 64)
19069 errmsg ("itr-rloc locator-set name too long");
19070 vec_free (locator_set_name);
19074 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19075 mp->is_add = is_add;
19078 clib_memcpy (mp->locator_set_name, locator_set_name,
19079 vec_len (locator_set_name));
19083 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19085 vec_free (locator_set_name);
19090 /* Wait for a reply... */
19095 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19098 api_one_locator_dump (vat_main_t * vam)
19100 unformat_input_t *input = vam->input;
19101 vl_api_one_locator_dump_t *mp;
19102 vl_api_control_ping_t *mp_ping;
19103 u8 is_index_set = 0, is_name_set = 0;
19108 /* Parse args required to build the message */
19109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19111 if (unformat (input, "ls_name %_%v%_", &ls_name))
19115 else if (unformat (input, "ls_index %d", &ls_index))
19121 errmsg ("parse error '%U'", format_unformat_error, input);
19126 if (!is_index_set && !is_name_set)
19128 errmsg ("error: expected one of index or name!");
19132 if (is_index_set && is_name_set)
19134 errmsg ("error: only one param expected!");
19138 if (vec_len (ls_name) > 62)
19140 errmsg ("error: locator set name too long!");
19144 if (!vam->json_output)
19146 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19149 M (ONE_LOCATOR_DUMP, mp);
19150 mp->is_index_set = is_index_set;
19153 mp->ls_index = clib_host_to_net_u32 (ls_index);
19156 vec_add1 (ls_name, 0);
19157 strncpy ((char *) mp->ls_name, (char *) ls_name,
19158 sizeof (mp->ls_name) - 1);
19164 /* Use a control ping for synchronization */
19165 MPING (CONTROL_PING, mp_ping);
19168 /* Wait for a reply... */
19173 #define api_lisp_locator_dump api_one_locator_dump
19176 api_one_locator_set_dump (vat_main_t * vam)
19178 vl_api_one_locator_set_dump_t *mp;
19179 vl_api_control_ping_t *mp_ping;
19180 unformat_input_t *input = vam->input;
19184 /* Parse args required to build the message */
19185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19187 if (unformat (input, "local"))
19191 else if (unformat (input, "remote"))
19197 errmsg ("parse error '%U'", format_unformat_error, input);
19202 if (!vam->json_output)
19204 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19207 M (ONE_LOCATOR_SET_DUMP, mp);
19209 mp->filter = filter;
19214 /* Use a control ping for synchronization */
19215 MPING (CONTROL_PING, mp_ping);
19218 /* Wait for a reply... */
19223 #define api_lisp_locator_set_dump api_one_locator_set_dump
19226 api_one_eid_table_map_dump (vat_main_t * vam)
19230 unformat_input_t *input = vam->input;
19231 vl_api_one_eid_table_map_dump_t *mp;
19232 vl_api_control_ping_t *mp_ping;
19235 /* Parse args required to build the message */
19236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19238 if (unformat (input, "l2"))
19243 else if (unformat (input, "l3"))
19250 errmsg ("parse error '%U'", format_unformat_error, input);
19257 errmsg ("expected one of 'l2' or 'l3' parameter!");
19261 if (!vam->json_output)
19263 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19266 M (ONE_EID_TABLE_MAP_DUMP, mp);
19272 /* Use a control ping for synchronization */
19273 MPING (CONTROL_PING, mp_ping);
19276 /* Wait for a reply... */
19281 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19284 api_one_eid_table_vni_dump (vat_main_t * vam)
19286 vl_api_one_eid_table_vni_dump_t *mp;
19287 vl_api_control_ping_t *mp_ping;
19290 if (!vam->json_output)
19292 print (vam->ofp, "VNI");
19295 M (ONE_EID_TABLE_VNI_DUMP, mp);
19300 /* Use a control ping for synchronization */
19301 MPING (CONTROL_PING, mp_ping);
19304 /* Wait for a reply... */
19309 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19312 api_one_eid_table_dump (vat_main_t * vam)
19314 unformat_input_t *i = vam->input;
19315 vl_api_one_eid_table_dump_t *mp;
19316 vl_api_control_ping_t *mp_ping;
19317 struct in_addr ip4;
19318 struct in6_addr ip6;
19320 u8 eid_type = ~0, eid_set = 0;
19321 u32 prefix_length = ~0, t, vni = 0;
19324 lisp_nsh_api_t nsh;
19326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19328 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19334 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19340 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19345 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19350 else if (unformat (i, "vni %d", &t))
19354 else if (unformat (i, "local"))
19358 else if (unformat (i, "remote"))
19364 errmsg ("parse error '%U'", format_unformat_error, i);
19369 if (!vam->json_output)
19371 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19372 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19375 M (ONE_EID_TABLE_DUMP, mp);
19377 mp->filter = filter;
19381 mp->vni = htonl (vni);
19382 mp->eid_type = eid_type;
19386 mp->prefix_length = prefix_length;
19387 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19390 mp->prefix_length = prefix_length;
19391 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19394 clib_memcpy (mp->eid, mac, sizeof (mac));
19397 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19400 errmsg ("unknown EID type %d!", eid_type);
19408 /* Use a control ping for synchronization */
19409 MPING (CONTROL_PING, mp_ping);
19412 /* Wait for a reply... */
19417 #define api_lisp_eid_table_dump api_one_eid_table_dump
19420 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19422 unformat_input_t *i = vam->input;
19423 vl_api_gpe_fwd_entries_get_t *mp;
19428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19430 if (unformat (i, "vni %d", &vni))
19436 errmsg ("parse error '%U'", format_unformat_error, i);
19443 errmsg ("vni not set!");
19447 if (!vam->json_output)
19449 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19453 M (GPE_FWD_ENTRIES_GET, mp);
19454 mp->vni = clib_host_to_net_u32 (vni);
19459 /* Wait for a reply... */
19464 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19465 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19466 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19467 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19468 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19469 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19470 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19471 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19474 api_one_adjacencies_get (vat_main_t * vam)
19476 unformat_input_t *i = vam->input;
19477 vl_api_one_adjacencies_get_t *mp;
19482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19484 if (unformat (i, "vni %d", &vni))
19490 errmsg ("parse error '%U'", format_unformat_error, i);
19497 errmsg ("vni not set!");
19501 if (!vam->json_output)
19503 print (vam->ofp, "%s %40s", "leid", "reid");
19506 M (ONE_ADJACENCIES_GET, mp);
19507 mp->vni = clib_host_to_net_u32 (vni);
19512 /* Wait for a reply... */
19517 #define api_lisp_adjacencies_get api_one_adjacencies_get
19520 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19522 unformat_input_t *i = vam->input;
19523 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19525 u8 ip_family_set = 0, is_ip4 = 1;
19527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19529 if (unformat (i, "ip4"))
19534 else if (unformat (i, "ip6"))
19541 errmsg ("parse error '%U'", format_unformat_error, i);
19546 if (!ip_family_set)
19548 errmsg ("ip family not set!");
19552 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19553 mp->is_ip4 = is_ip4;
19558 /* Wait for a reply... */
19564 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19566 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19569 if (!vam->json_output)
19571 print (vam->ofp, "VNIs");
19574 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19579 /* Wait for a reply... */
19585 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19587 unformat_input_t *i = vam->input;
19588 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19590 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19591 struct in_addr ip4;
19592 struct in6_addr ip6;
19593 u32 table_id = 0, nh_sw_if_index = ~0;
19595 memset (&ip4, 0, sizeof (ip4));
19596 memset (&ip6, 0, sizeof (ip6));
19598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19600 if (unformat (i, "del"))
19602 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19603 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19608 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19609 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19614 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19618 nh_sw_if_index = ~0;
19620 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19624 nh_sw_if_index = ~0;
19626 else if (unformat (i, "table %d", &table_id))
19630 errmsg ("parse error '%U'", format_unformat_error, i);
19637 errmsg ("nh addr not set!");
19641 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19642 mp->is_add = is_add;
19643 mp->table_id = clib_host_to_net_u32 (table_id);
19644 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19645 mp->is_ip4 = is_ip4;
19647 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19649 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19654 /* Wait for a reply... */
19660 api_one_map_server_dump (vat_main_t * vam)
19662 vl_api_one_map_server_dump_t *mp;
19663 vl_api_control_ping_t *mp_ping;
19666 if (!vam->json_output)
19668 print (vam->ofp, "%=20s", "Map server");
19671 M (ONE_MAP_SERVER_DUMP, mp);
19675 /* Use a control ping for synchronization */
19676 MPING (CONTROL_PING, mp_ping);
19679 /* Wait for a reply... */
19684 #define api_lisp_map_server_dump api_one_map_server_dump
19687 api_one_map_resolver_dump (vat_main_t * vam)
19689 vl_api_one_map_resolver_dump_t *mp;
19690 vl_api_control_ping_t *mp_ping;
19693 if (!vam->json_output)
19695 print (vam->ofp, "%=20s", "Map resolver");
19698 M (ONE_MAP_RESOLVER_DUMP, mp);
19702 /* Use a control ping for synchronization */
19703 MPING (CONTROL_PING, mp_ping);
19706 /* Wait for a reply... */
19711 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19714 api_one_stats_flush (vat_main_t * vam)
19716 vl_api_one_stats_flush_t *mp;
19719 M (ONE_STATS_FLUSH, mp);
19726 api_one_stats_dump (vat_main_t * vam)
19728 vl_api_one_stats_dump_t *mp;
19729 vl_api_control_ping_t *mp_ping;
19732 M (ONE_STATS_DUMP, mp);
19736 /* Use a control ping for synchronization */
19737 MPING (CONTROL_PING, mp_ping);
19740 /* Wait for a reply... */
19746 api_show_one_status (vat_main_t * vam)
19748 vl_api_show_one_status_t *mp;
19751 if (!vam->json_output)
19753 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19756 M (SHOW_ONE_STATUS, mp);
19759 /* Wait for a reply... */
19764 #define api_show_lisp_status api_show_one_status
19767 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19769 vl_api_gpe_fwd_entry_path_dump_t *mp;
19770 vl_api_control_ping_t *mp_ping;
19771 unformat_input_t *i = vam->input;
19772 u32 fwd_entry_index = ~0;
19775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19777 if (unformat (i, "index %d", &fwd_entry_index))
19783 if (~0 == fwd_entry_index)
19785 errmsg ("no index specified!");
19789 if (!vam->json_output)
19791 print (vam->ofp, "first line");
19794 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19798 /* Use a control ping for synchronization */
19799 MPING (CONTROL_PING, mp_ping);
19802 /* Wait for a reply... */
19808 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19810 vl_api_one_get_map_request_itr_rlocs_t *mp;
19813 if (!vam->json_output)
19815 print (vam->ofp, "%=20s", "itr-rlocs:");
19818 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19821 /* Wait for a reply... */
19826 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19829 api_af_packet_create (vat_main_t * vam)
19831 unformat_input_t *i = vam->input;
19832 vl_api_af_packet_create_t *mp;
19833 u8 *host_if_name = 0;
19835 u8 random_hw_addr = 1;
19838 memset (hw_addr, 0, sizeof (hw_addr));
19840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19842 if (unformat (i, "name %s", &host_if_name))
19843 vec_add1 (host_if_name, 0);
19844 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19845 random_hw_addr = 0;
19850 if (!vec_len (host_if_name))
19852 errmsg ("host-interface name must be specified");
19856 if (vec_len (host_if_name) > 64)
19858 errmsg ("host-interface name too long");
19862 M (AF_PACKET_CREATE, mp);
19864 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19865 clib_memcpy (mp->hw_addr, hw_addr, 6);
19866 mp->use_random_hw_addr = random_hw_addr;
19867 vec_free (host_if_name);
19875 fprintf (vam->ofp ? vam->ofp : stderr,
19876 " new sw_if_index = %d\n", vam->sw_if_index);
19883 api_af_packet_delete (vat_main_t * vam)
19885 unformat_input_t *i = vam->input;
19886 vl_api_af_packet_delete_t *mp;
19887 u8 *host_if_name = 0;
19890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19892 if (unformat (i, "name %s", &host_if_name))
19893 vec_add1 (host_if_name, 0);
19898 if (!vec_len (host_if_name))
19900 errmsg ("host-interface name must be specified");
19904 if (vec_len (host_if_name) > 64)
19906 errmsg ("host-interface name too long");
19910 M (AF_PACKET_DELETE, mp);
19912 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19913 vec_free (host_if_name);
19920 static void vl_api_af_packet_details_t_handler
19921 (vl_api_af_packet_details_t * mp)
19923 vat_main_t *vam = &vat_main;
19925 print (vam->ofp, "%-16s %d",
19926 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19929 static void vl_api_af_packet_details_t_handler_json
19930 (vl_api_af_packet_details_t * mp)
19932 vat_main_t *vam = &vat_main;
19933 vat_json_node_t *node = NULL;
19935 if (VAT_JSON_ARRAY != vam->json_tree.type)
19937 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19938 vat_json_init_array (&vam->json_tree);
19940 node = vat_json_array_add (&vam->json_tree);
19942 vat_json_init_object (node);
19943 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19944 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19948 api_af_packet_dump (vat_main_t * vam)
19950 vl_api_af_packet_dump_t *mp;
19951 vl_api_control_ping_t *mp_ping;
19954 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19955 /* Get list of tap interfaces */
19956 M (AF_PACKET_DUMP, mp);
19959 /* Use a control ping for synchronization */
19960 MPING (CONTROL_PING, mp_ping);
19968 api_policer_add_del (vat_main_t * vam)
19970 unformat_input_t *i = vam->input;
19971 vl_api_policer_add_del_t *mp;
19981 u8 color_aware = 0;
19982 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19985 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19986 conform_action.dscp = 0;
19987 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19988 exceed_action.dscp = 0;
19989 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19990 violate_action.dscp = 0;
19992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19994 if (unformat (i, "del"))
19996 else if (unformat (i, "name %s", &name))
19997 vec_add1 (name, 0);
19998 else if (unformat (i, "cir %u", &cir))
20000 else if (unformat (i, "eir %u", &eir))
20002 else if (unformat (i, "cb %u", &cb))
20004 else if (unformat (i, "eb %u", &eb))
20006 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20009 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20012 else if (unformat (i, "type %U", unformat_policer_type, &type))
20014 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20017 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20020 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20023 else if (unformat (i, "color-aware"))
20029 if (!vec_len (name))
20031 errmsg ("policer name must be specified");
20035 if (vec_len (name) > 64)
20037 errmsg ("policer name too long");
20041 M (POLICER_ADD_DEL, mp);
20043 clib_memcpy (mp->name, name, vec_len (name));
20045 mp->is_add = is_add;
20046 mp->cir = ntohl (cir);
20047 mp->eir = ntohl (eir);
20048 mp->cb = clib_net_to_host_u64 (cb);
20049 mp->eb = clib_net_to_host_u64 (eb);
20050 mp->rate_type = rate_type;
20051 mp->round_type = round_type;
20053 mp->conform_action_type = conform_action.action_type;
20054 mp->conform_dscp = conform_action.dscp;
20055 mp->exceed_action_type = exceed_action.action_type;
20056 mp->exceed_dscp = exceed_action.dscp;
20057 mp->violate_action_type = violate_action.action_type;
20058 mp->violate_dscp = violate_action.dscp;
20059 mp->color_aware = color_aware;
20067 api_policer_dump (vat_main_t * vam)
20069 unformat_input_t *i = vam->input;
20070 vl_api_policer_dump_t *mp;
20071 vl_api_control_ping_t *mp_ping;
20072 u8 *match_name = 0;
20073 u8 match_name_valid = 0;
20076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20078 if (unformat (i, "name %s", &match_name))
20080 vec_add1 (match_name, 0);
20081 match_name_valid = 1;
20087 M (POLICER_DUMP, mp);
20088 mp->match_name_valid = match_name_valid;
20089 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20090 vec_free (match_name);
20094 /* Use a control ping for synchronization */
20095 MPING (CONTROL_PING, mp_ping);
20098 /* Wait for a reply... */
20104 api_policer_classify_set_interface (vat_main_t * vam)
20106 unformat_input_t *i = vam->input;
20107 vl_api_policer_classify_set_interface_t *mp;
20109 int sw_if_index_set;
20110 u32 ip4_table_index = ~0;
20111 u32 ip6_table_index = ~0;
20112 u32 l2_table_index = ~0;
20116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20119 sw_if_index_set = 1;
20120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20121 sw_if_index_set = 1;
20122 else if (unformat (i, "del"))
20124 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20126 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20128 else if (unformat (i, "l2-table %d", &l2_table_index))
20132 clib_warning ("parse error '%U'", format_unformat_error, i);
20137 if (sw_if_index_set == 0)
20139 errmsg ("missing interface name or sw_if_index");
20143 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20145 mp->sw_if_index = ntohl (sw_if_index);
20146 mp->ip4_table_index = ntohl (ip4_table_index);
20147 mp->ip6_table_index = ntohl (ip6_table_index);
20148 mp->l2_table_index = ntohl (l2_table_index);
20149 mp->is_add = is_add;
20157 api_policer_classify_dump (vat_main_t * vam)
20159 unformat_input_t *i = vam->input;
20160 vl_api_policer_classify_dump_t *mp;
20161 vl_api_control_ping_t *mp_ping;
20162 u8 type = POLICER_CLASSIFY_N_TABLES;
20165 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20169 errmsg ("classify table type must be specified");
20173 if (!vam->json_output)
20175 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20178 M (POLICER_CLASSIFY_DUMP, mp);
20183 /* Use a control ping for synchronization */
20184 MPING (CONTROL_PING, mp_ping);
20187 /* Wait for a reply... */
20193 api_netmap_create (vat_main_t * vam)
20195 unformat_input_t *i = vam->input;
20196 vl_api_netmap_create_t *mp;
20199 u8 random_hw_addr = 1;
20204 memset (hw_addr, 0, sizeof (hw_addr));
20206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20208 if (unformat (i, "name %s", &if_name))
20209 vec_add1 (if_name, 0);
20210 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20211 random_hw_addr = 0;
20212 else if (unformat (i, "pipe"))
20214 else if (unformat (i, "master"))
20216 else if (unformat (i, "slave"))
20222 if (!vec_len (if_name))
20224 errmsg ("interface name must be specified");
20228 if (vec_len (if_name) > 64)
20230 errmsg ("interface name too long");
20234 M (NETMAP_CREATE, mp);
20236 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20237 clib_memcpy (mp->hw_addr, hw_addr, 6);
20238 mp->use_random_hw_addr = random_hw_addr;
20239 mp->is_pipe = is_pipe;
20240 mp->is_master = is_master;
20241 vec_free (if_name);
20249 api_netmap_delete (vat_main_t * vam)
20251 unformat_input_t *i = vam->input;
20252 vl_api_netmap_delete_t *mp;
20256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20258 if (unformat (i, "name %s", &if_name))
20259 vec_add1 (if_name, 0);
20264 if (!vec_len (if_name))
20266 errmsg ("interface name must be specified");
20270 if (vec_len (if_name) > 64)
20272 errmsg ("interface name too long");
20276 M (NETMAP_DELETE, mp);
20278 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20279 vec_free (if_name);
20287 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20289 if (fp->afi == IP46_TYPE_IP6)
20291 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20292 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20293 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20294 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20295 format_ip6_address, fp->next_hop);
20296 else if (fp->afi == IP46_TYPE_IP4)
20298 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20299 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20300 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20301 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20302 format_ip4_address, fp->next_hop);
20306 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20307 vl_api_fib_path_t * fp)
20309 struct in_addr ip4;
20310 struct in6_addr ip6;
20312 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20313 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20314 vat_json_object_add_uint (node, "is_local", fp->is_local);
20315 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20316 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20317 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20318 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20319 if (fp->afi == IP46_TYPE_IP4)
20321 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20322 vat_json_object_add_ip4 (node, "next_hop", ip4);
20324 else if (fp->afi == IP46_TYPE_IP6)
20326 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20327 vat_json_object_add_ip6 (node, "next_hop", ip6);
20332 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20334 vat_main_t *vam = &vat_main;
20335 int count = ntohl (mp->mt_count);
20336 vl_api_fib_path_t *fp;
20339 print (vam->ofp, "[%d]: sw_if_index %d via:",
20340 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20342 for (i = 0; i < count; i++)
20344 vl_api_mpls_fib_path_print (vam, fp);
20348 print (vam->ofp, "");
20351 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20352 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20355 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20357 vat_main_t *vam = &vat_main;
20358 vat_json_node_t *node = NULL;
20359 int count = ntohl (mp->mt_count);
20360 vl_api_fib_path_t *fp;
20363 if (VAT_JSON_ARRAY != vam->json_tree.type)
20365 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20366 vat_json_init_array (&vam->json_tree);
20368 node = vat_json_array_add (&vam->json_tree);
20370 vat_json_init_object (node);
20371 vat_json_object_add_uint (node, "tunnel_index",
20372 ntohl (mp->mt_tunnel_index));
20373 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20375 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20378 for (i = 0; i < count; i++)
20380 vl_api_mpls_fib_path_json_print (node, fp);
20386 api_mpls_tunnel_dump (vat_main_t * vam)
20388 vl_api_mpls_tunnel_dump_t *mp;
20389 vl_api_control_ping_t *mp_ping;
20393 /* Parse args required to build the message */
20394 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20396 if (!unformat (vam->input, "tunnel_index %d", &index))
20403 print (vam->ofp, " tunnel_index %d", index);
20405 M (MPLS_TUNNEL_DUMP, mp);
20406 mp->tunnel_index = htonl (index);
20409 /* Use a control ping for synchronization */
20410 MPING (CONTROL_PING, mp_ping);
20417 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20418 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20422 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20424 vat_main_t *vam = &vat_main;
20425 int count = ntohl (mp->count);
20426 vl_api_fib_path_t *fp;
20430 "table-id %d, label %u, ess_bit %u",
20431 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20433 for (i = 0; i < count; i++)
20435 vl_api_mpls_fib_path_print (vam, fp);
20440 static void vl_api_mpls_fib_details_t_handler_json
20441 (vl_api_mpls_fib_details_t * mp)
20443 vat_main_t *vam = &vat_main;
20444 int count = ntohl (mp->count);
20445 vat_json_node_t *node = NULL;
20446 vl_api_fib_path_t *fp;
20449 if (VAT_JSON_ARRAY != vam->json_tree.type)
20451 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20452 vat_json_init_array (&vam->json_tree);
20454 node = vat_json_array_add (&vam->json_tree);
20456 vat_json_init_object (node);
20457 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20458 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20459 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20460 vat_json_object_add_uint (node, "path_count", count);
20462 for (i = 0; i < count; i++)
20464 vl_api_mpls_fib_path_json_print (node, fp);
20470 api_mpls_fib_dump (vat_main_t * vam)
20472 vl_api_mpls_fib_dump_t *mp;
20473 vl_api_control_ping_t *mp_ping;
20476 M (MPLS_FIB_DUMP, mp);
20479 /* Use a control ping for synchronization */
20480 MPING (CONTROL_PING, mp_ping);
20487 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20488 #define vl_api_ip_fib_details_t_print vl_noop_handler
20491 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20493 vat_main_t *vam = &vat_main;
20494 int count = ntohl (mp->count);
20495 vl_api_fib_path_t *fp;
20499 "table-id %d, prefix %U/%d",
20500 ntohl (mp->table_id), format_ip4_address, mp->address,
20501 mp->address_length);
20503 for (i = 0; i < count; i++)
20505 if (fp->afi == IP46_TYPE_IP6)
20507 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20508 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20509 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20510 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20511 format_ip6_address, fp->next_hop);
20512 else if (fp->afi == IP46_TYPE_IP4)
20514 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20515 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20516 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20517 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20518 format_ip4_address, fp->next_hop);
20523 static void vl_api_ip_fib_details_t_handler_json
20524 (vl_api_ip_fib_details_t * mp)
20526 vat_main_t *vam = &vat_main;
20527 int count = ntohl (mp->count);
20528 vat_json_node_t *node = NULL;
20529 struct in_addr ip4;
20530 struct in6_addr ip6;
20531 vl_api_fib_path_t *fp;
20534 if (VAT_JSON_ARRAY != vam->json_tree.type)
20536 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20537 vat_json_init_array (&vam->json_tree);
20539 node = vat_json_array_add (&vam->json_tree);
20541 vat_json_init_object (node);
20542 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20543 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20544 vat_json_object_add_ip4 (node, "prefix", ip4);
20545 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20546 vat_json_object_add_uint (node, "path_count", count);
20548 for (i = 0; i < count; i++)
20550 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20551 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20552 vat_json_object_add_uint (node, "is_local", fp->is_local);
20553 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20554 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20555 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20556 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20557 if (fp->afi == IP46_TYPE_IP4)
20559 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20560 vat_json_object_add_ip4 (node, "next_hop", ip4);
20562 else if (fp->afi == IP46_TYPE_IP6)
20564 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20565 vat_json_object_add_ip6 (node, "next_hop", ip6);
20571 api_ip_fib_dump (vat_main_t * vam)
20573 vl_api_ip_fib_dump_t *mp;
20574 vl_api_control_ping_t *mp_ping;
20577 M (IP_FIB_DUMP, mp);
20580 /* Use a control ping for synchronization */
20581 MPING (CONTROL_PING, mp_ping);
20589 api_ip_mfib_dump (vat_main_t * vam)
20591 vl_api_ip_mfib_dump_t *mp;
20592 vl_api_control_ping_t *mp_ping;
20595 M (IP_MFIB_DUMP, mp);
20598 /* Use a control ping for synchronization */
20599 MPING (CONTROL_PING, mp_ping);
20606 static void vl_api_ip_neighbor_details_t_handler
20607 (vl_api_ip_neighbor_details_t * mp)
20609 vat_main_t *vam = &vat_main;
20611 print (vam->ofp, "%c %U %U",
20612 (mp->is_static) ? 'S' : 'D',
20613 format_ethernet_address, &mp->mac_address,
20614 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20618 static void vl_api_ip_neighbor_details_t_handler_json
20619 (vl_api_ip_neighbor_details_t * mp)
20622 vat_main_t *vam = &vat_main;
20623 vat_json_node_t *node;
20624 struct in_addr ip4;
20625 struct in6_addr ip6;
20627 if (VAT_JSON_ARRAY != vam->json_tree.type)
20629 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20630 vat_json_init_array (&vam->json_tree);
20632 node = vat_json_array_add (&vam->json_tree);
20634 vat_json_init_object (node);
20635 vat_json_object_add_string_copy (node, "flag",
20636 (mp->is_static) ? (u8 *) "static" : (u8 *)
20639 vat_json_object_add_string_copy (node, "link_layer",
20640 format (0, "%U", format_ethernet_address,
20641 &mp->mac_address));
20645 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20646 vat_json_object_add_ip6 (node, "ip_address", ip6);
20650 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20651 vat_json_object_add_ip4 (node, "ip_address", ip4);
20656 api_ip_neighbor_dump (vat_main_t * vam)
20658 unformat_input_t *i = vam->input;
20659 vl_api_ip_neighbor_dump_t *mp;
20660 vl_api_control_ping_t *mp_ping;
20662 u32 sw_if_index = ~0;
20665 /* Parse args required to build the message */
20666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20670 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20672 else if (unformat (i, "ip6"))
20678 if (sw_if_index == ~0)
20680 errmsg ("missing interface name or sw_if_index");
20684 M (IP_NEIGHBOR_DUMP, mp);
20685 mp->is_ipv6 = (u8) is_ipv6;
20686 mp->sw_if_index = ntohl (sw_if_index);
20689 /* Use a control ping for synchronization */
20690 MPING (CONTROL_PING, mp_ping);
20697 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20698 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20701 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20703 vat_main_t *vam = &vat_main;
20704 int count = ntohl (mp->count);
20705 vl_api_fib_path_t *fp;
20709 "table-id %d, prefix %U/%d",
20710 ntohl (mp->table_id), format_ip6_address, mp->address,
20711 mp->address_length);
20713 for (i = 0; i < count; i++)
20715 if (fp->afi == IP46_TYPE_IP6)
20717 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20718 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20719 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20720 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20721 format_ip6_address, fp->next_hop);
20722 else if (fp->afi == IP46_TYPE_IP4)
20724 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20725 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20726 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20727 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20728 format_ip4_address, fp->next_hop);
20733 static void vl_api_ip6_fib_details_t_handler_json
20734 (vl_api_ip6_fib_details_t * mp)
20736 vat_main_t *vam = &vat_main;
20737 int count = ntohl (mp->count);
20738 vat_json_node_t *node = NULL;
20739 struct in_addr ip4;
20740 struct in6_addr ip6;
20741 vl_api_fib_path_t *fp;
20744 if (VAT_JSON_ARRAY != vam->json_tree.type)
20746 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20747 vat_json_init_array (&vam->json_tree);
20749 node = vat_json_array_add (&vam->json_tree);
20751 vat_json_init_object (node);
20752 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20753 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20754 vat_json_object_add_ip6 (node, "prefix", ip6);
20755 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20756 vat_json_object_add_uint (node, "path_count", count);
20758 for (i = 0; i < count; i++)
20760 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20761 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20762 vat_json_object_add_uint (node, "is_local", fp->is_local);
20763 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20764 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20765 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20766 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20767 if (fp->afi == IP46_TYPE_IP4)
20769 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20770 vat_json_object_add_ip4 (node, "next_hop", ip4);
20772 else if (fp->afi == IP46_TYPE_IP6)
20774 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20775 vat_json_object_add_ip6 (node, "next_hop", ip6);
20781 api_ip6_fib_dump (vat_main_t * vam)
20783 vl_api_ip6_fib_dump_t *mp;
20784 vl_api_control_ping_t *mp_ping;
20787 M (IP6_FIB_DUMP, mp);
20790 /* Use a control ping for synchronization */
20791 MPING (CONTROL_PING, mp_ping);
20799 api_ip6_mfib_dump (vat_main_t * vam)
20801 vl_api_ip6_mfib_dump_t *mp;
20802 vl_api_control_ping_t *mp_ping;
20805 M (IP6_MFIB_DUMP, mp);
20808 /* Use a control ping for synchronization */
20809 MPING (CONTROL_PING, mp_ping);
20817 api_classify_table_ids (vat_main_t * vam)
20819 vl_api_classify_table_ids_t *mp;
20822 /* Construct the API message */
20823 M (CLASSIFY_TABLE_IDS, mp);
20832 api_classify_table_by_interface (vat_main_t * vam)
20834 unformat_input_t *input = vam->input;
20835 vl_api_classify_table_by_interface_t *mp;
20837 u32 sw_if_index = ~0;
20839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20841 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20843 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20848 if (sw_if_index == ~0)
20850 errmsg ("missing interface name or sw_if_index");
20854 /* Construct the API message */
20855 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20857 mp->sw_if_index = ntohl (sw_if_index);
20865 api_classify_table_info (vat_main_t * vam)
20867 unformat_input_t *input = vam->input;
20868 vl_api_classify_table_info_t *mp;
20872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20874 if (unformat (input, "table_id %d", &table_id))
20879 if (table_id == ~0)
20881 errmsg ("missing table id");
20885 /* Construct the API message */
20886 M (CLASSIFY_TABLE_INFO, mp);
20888 mp->table_id = ntohl (table_id);
20896 api_classify_session_dump (vat_main_t * vam)
20898 unformat_input_t *input = vam->input;
20899 vl_api_classify_session_dump_t *mp;
20900 vl_api_control_ping_t *mp_ping;
20904 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20906 if (unformat (input, "table_id %d", &table_id))
20911 if (table_id == ~0)
20913 errmsg ("missing table id");
20917 /* Construct the API message */
20918 M (CLASSIFY_SESSION_DUMP, mp);
20920 mp->table_id = ntohl (table_id);
20923 /* Use a control ping for synchronization */
20924 MPING (CONTROL_PING, mp_ping);
20932 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20934 vat_main_t *vam = &vat_main;
20936 print (vam->ofp, "collector_address %U, collector_port %d, "
20937 "src_address %U, vrf_id %d, path_mtu %u, "
20938 "template_interval %u, udp_checksum %d",
20939 format_ip4_address, mp->collector_address,
20940 ntohs (mp->collector_port),
20941 format_ip4_address, mp->src_address,
20942 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20943 ntohl (mp->template_interval), mp->udp_checksum);
20946 vam->result_ready = 1;
20950 vl_api_ipfix_exporter_details_t_handler_json
20951 (vl_api_ipfix_exporter_details_t * mp)
20953 vat_main_t *vam = &vat_main;
20954 vat_json_node_t node;
20955 struct in_addr collector_address;
20956 struct in_addr src_address;
20958 vat_json_init_object (&node);
20959 clib_memcpy (&collector_address, &mp->collector_address,
20960 sizeof (collector_address));
20961 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20962 vat_json_object_add_uint (&node, "collector_port",
20963 ntohs (mp->collector_port));
20964 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20965 vat_json_object_add_ip4 (&node, "src_address", src_address);
20966 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20967 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20968 vat_json_object_add_uint (&node, "template_interval",
20969 ntohl (mp->template_interval));
20970 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20972 vat_json_print (vam->ofp, &node);
20973 vat_json_free (&node);
20975 vam->result_ready = 1;
20979 api_ipfix_exporter_dump (vat_main_t * vam)
20981 vl_api_ipfix_exporter_dump_t *mp;
20984 /* Construct the API message */
20985 M (IPFIX_EXPORTER_DUMP, mp);
20994 api_ipfix_classify_stream_dump (vat_main_t * vam)
20996 vl_api_ipfix_classify_stream_dump_t *mp;
20999 /* Construct the API message */
21000 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21011 vl_api_ipfix_classify_stream_details_t_handler
21012 (vl_api_ipfix_classify_stream_details_t * mp)
21014 vat_main_t *vam = &vat_main;
21015 print (vam->ofp, "domain_id %d, src_port %d",
21016 ntohl (mp->domain_id), ntohs (mp->src_port));
21018 vam->result_ready = 1;
21022 vl_api_ipfix_classify_stream_details_t_handler_json
21023 (vl_api_ipfix_classify_stream_details_t * mp)
21025 vat_main_t *vam = &vat_main;
21026 vat_json_node_t node;
21028 vat_json_init_object (&node);
21029 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21030 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21032 vat_json_print (vam->ofp, &node);
21033 vat_json_free (&node);
21035 vam->result_ready = 1;
21039 api_ipfix_classify_table_dump (vat_main_t * vam)
21041 vl_api_ipfix_classify_table_dump_t *mp;
21042 vl_api_control_ping_t *mp_ping;
21045 if (!vam->json_output)
21047 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21048 "transport_protocol");
21051 /* Construct the API message */
21052 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21057 /* Use a control ping for synchronization */
21058 MPING (CONTROL_PING, mp_ping);
21066 vl_api_ipfix_classify_table_details_t_handler
21067 (vl_api_ipfix_classify_table_details_t * mp)
21069 vat_main_t *vam = &vat_main;
21070 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21071 mp->transport_protocol);
21075 vl_api_ipfix_classify_table_details_t_handler_json
21076 (vl_api_ipfix_classify_table_details_t * mp)
21078 vat_json_node_t *node = NULL;
21079 vat_main_t *vam = &vat_main;
21081 if (VAT_JSON_ARRAY != vam->json_tree.type)
21083 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21084 vat_json_init_array (&vam->json_tree);
21087 node = vat_json_array_add (&vam->json_tree);
21088 vat_json_init_object (node);
21090 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21091 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21092 vat_json_object_add_uint (node, "transport_protocol",
21093 mp->transport_protocol);
21097 api_sw_interface_span_enable_disable (vat_main_t * vam)
21099 unformat_input_t *i = vam->input;
21100 vl_api_sw_interface_span_enable_disable_t *mp;
21101 u32 src_sw_if_index = ~0;
21102 u32 dst_sw_if_index = ~0;
21107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21110 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21112 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21116 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21118 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21120 else if (unformat (i, "disable"))
21122 else if (unformat (i, "rx"))
21124 else if (unformat (i, "tx"))
21126 else if (unformat (i, "both"))
21128 else if (unformat (i, "l2"))
21134 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21136 mp->sw_if_index_from = htonl (src_sw_if_index);
21137 mp->sw_if_index_to = htonl (dst_sw_if_index);
21147 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21150 vat_main_t *vam = &vat_main;
21151 u8 *sw_if_from_name = 0;
21152 u8 *sw_if_to_name = 0;
21153 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21154 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21155 char *states[] = { "none", "rx", "tx", "both" };
21159 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21161 if ((u32) p->value[0] == sw_if_index_from)
21163 sw_if_from_name = (u8 *)(p->key);
21167 if ((u32) p->value[0] == sw_if_index_to)
21169 sw_if_to_name = (u8 *)(p->key);
21170 if (sw_if_from_name)
21175 print (vam->ofp, "%20s => %20s (%s) %s",
21176 sw_if_from_name, sw_if_to_name, states[mp->state],
21177 mp->is_l2 ? "l2" : "device");
21181 vl_api_sw_interface_span_details_t_handler_json
21182 (vl_api_sw_interface_span_details_t * mp)
21184 vat_main_t *vam = &vat_main;
21185 vat_json_node_t *node = NULL;
21186 u8 *sw_if_from_name = 0;
21187 u8 *sw_if_to_name = 0;
21188 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21189 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21193 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21195 if ((u32) p->value[0] == sw_if_index_from)
21197 sw_if_from_name = (u8 *)(p->key);
21201 if ((u32) p->value[0] == sw_if_index_to)
21203 sw_if_to_name = (u8 *)(p->key);
21204 if (sw_if_from_name)
21210 if (VAT_JSON_ARRAY != vam->json_tree.type)
21212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21213 vat_json_init_array (&vam->json_tree);
21215 node = vat_json_array_add (&vam->json_tree);
21217 vat_json_init_object (node);
21218 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21219 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21220 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21221 if (0 != sw_if_to_name)
21223 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21225 vat_json_object_add_uint (node, "state", mp->state);
21226 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21230 api_sw_interface_span_dump (vat_main_t * vam)
21232 unformat_input_t *input = vam->input;
21233 vl_api_sw_interface_span_dump_t *mp;
21234 vl_api_control_ping_t *mp_ping;
21238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21240 if (unformat (input, "l2"))
21246 M (SW_INTERFACE_SPAN_DUMP, mp);
21250 /* Use a control ping for synchronization */
21251 MPING (CONTROL_PING, mp_ping);
21259 api_pg_create_interface (vat_main_t * vam)
21261 unformat_input_t *input = vam->input;
21262 vl_api_pg_create_interface_t *mp;
21266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21268 if (unformat (input, "if_id %d", &if_id))
21275 errmsg ("missing pg interface index");
21279 /* Construct the API message */
21280 M (PG_CREATE_INTERFACE, mp);
21282 mp->interface_id = ntohl (if_id);
21290 api_pg_capture (vat_main_t * vam)
21292 unformat_input_t *input = vam->input;
21293 vl_api_pg_capture_t *mp;
21298 u8 pcap_file_set = 0;
21301 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21303 if (unformat (input, "if_id %d", &if_id))
21305 else if (unformat (input, "pcap %s", &pcap_file))
21307 else if (unformat (input, "count %d", &count))
21309 else if (unformat (input, "disable"))
21316 errmsg ("missing pg interface index");
21319 if (pcap_file_set > 0)
21321 if (vec_len (pcap_file) > 255)
21323 errmsg ("pcap file name is too long");
21328 u32 name_len = vec_len (pcap_file);
21329 /* Construct the API message */
21330 M (PG_CAPTURE, mp);
21332 mp->interface_id = ntohl (if_id);
21333 mp->is_enabled = enable;
21334 mp->count = ntohl (count);
21335 mp->pcap_name_length = ntohl (name_len);
21336 if (pcap_file_set != 0)
21338 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21340 vec_free (pcap_file);
21348 api_pg_enable_disable (vat_main_t * vam)
21350 unformat_input_t *input = vam->input;
21351 vl_api_pg_enable_disable_t *mp;
21354 u8 stream_name_set = 0;
21355 u8 *stream_name = 0;
21357 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21359 if (unformat (input, "stream %s", &stream_name))
21360 stream_name_set = 1;
21361 else if (unformat (input, "disable"))
21367 if (stream_name_set > 0)
21369 if (vec_len (stream_name) > 255)
21371 errmsg ("stream name too long");
21376 u32 name_len = vec_len (stream_name);
21377 /* Construct the API message */
21378 M (PG_ENABLE_DISABLE, mp);
21380 mp->is_enabled = enable;
21381 if (stream_name_set != 0)
21383 mp->stream_name_length = ntohl (name_len);
21384 clib_memcpy (mp->stream_name, stream_name, name_len);
21386 vec_free (stream_name);
21394 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21396 unformat_input_t *input = vam->input;
21397 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21399 u16 *low_ports = 0;
21400 u16 *high_ports = 0;
21403 ip4_address_t ip4_addr;
21404 ip6_address_t ip6_addr;
21413 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21415 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21421 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21426 else if (unformat (input, "vrf %d", &vrf_id))
21428 else if (unformat (input, "del"))
21430 else if (unformat (input, "port %d", &tmp))
21432 if (tmp == 0 || tmp > 65535)
21434 errmsg ("port %d out of range", tmp);
21438 this_hi = this_low + 1;
21439 vec_add1 (low_ports, this_low);
21440 vec_add1 (high_ports, this_hi);
21442 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21444 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21446 errmsg ("incorrect range parameters");
21450 /* Note: in debug CLI +1 is added to high before
21451 passing to real fn that does "the work"
21452 (ip_source_and_port_range_check_add_del).
21453 This fn is a wrapper around the binary API fn a
21454 control plane will call, which expects this increment
21455 to have occurred. Hence letting the binary API control
21456 plane fn do the increment for consistency between VAT
21457 and other control planes.
21460 vec_add1 (low_ports, this_low);
21461 vec_add1 (high_ports, this_hi);
21467 if (prefix_set == 0)
21469 errmsg ("<address>/<mask> not specified");
21475 errmsg ("VRF ID required, not specified");
21482 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21486 if (vec_len (low_ports) == 0)
21488 errmsg ("At least one port or port range required");
21492 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21494 mp->is_add = is_add;
21499 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21504 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21507 mp->mask_length = length;
21508 mp->number_of_ranges = vec_len (low_ports);
21510 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21511 vec_free (low_ports);
21513 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21514 vec_free (high_ports);
21516 mp->vrf_id = ntohl (vrf_id);
21524 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21526 unformat_input_t *input = vam->input;
21527 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21528 u32 sw_if_index = ~0;
21530 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21531 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21537 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21539 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21541 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21543 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21545 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21547 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21549 else if (unformat (input, "del"))
21555 if (sw_if_index == ~0)
21557 errmsg ("Interface required but not specified");
21563 errmsg ("VRF ID required but not specified");
21567 if (tcp_out_vrf_id == 0
21568 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21571 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21575 /* Construct the API message */
21576 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21578 mp->sw_if_index = ntohl (sw_if_index);
21579 mp->is_add = is_add;
21580 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21581 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21582 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21583 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21588 /* Wait for a reply... */
21594 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21596 unformat_input_t *i = vam->input;
21597 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21598 u32 local_sa_id = 0;
21599 u32 remote_sa_id = 0;
21600 ip4_address_t src_address;
21601 ip4_address_t dst_address;
21605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21607 if (unformat (i, "local_sa %d", &local_sa_id))
21609 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21611 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21613 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21615 else if (unformat (i, "del"))
21619 clib_warning ("parse error '%U'", format_unformat_error, i);
21624 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21626 mp->local_sa_id = ntohl (local_sa_id);
21627 mp->remote_sa_id = ntohl (remote_sa_id);
21628 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21629 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21630 mp->is_add = is_add;
21638 api_punt (vat_main_t * vam)
21640 unformat_input_t *i = vam->input;
21648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21650 if (unformat (i, "ip %d", &ipv))
21652 else if (unformat (i, "protocol %d", &protocol))
21654 else if (unformat (i, "port %d", &port))
21656 else if (unformat (i, "del"))
21660 clib_warning ("parse error '%U'", format_unformat_error, i);
21667 mp->is_add = (u8) is_add;
21668 mp->ipv = (u8) ipv;
21669 mp->l4_protocol = (u8) protocol;
21670 mp->l4_port = htons ((u16) port);
21677 static void vl_api_ipsec_gre_tunnel_details_t_handler
21678 (vl_api_ipsec_gre_tunnel_details_t * mp)
21680 vat_main_t *vam = &vat_main;
21682 print (vam->ofp, "%11d%15U%15U%14d%14d",
21683 ntohl (mp->sw_if_index),
21684 format_ip4_address, &mp->src_address,
21685 format_ip4_address, &mp->dst_address,
21686 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21689 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21690 (vl_api_ipsec_gre_tunnel_details_t * mp)
21692 vat_main_t *vam = &vat_main;
21693 vat_json_node_t *node = NULL;
21694 struct in_addr ip4;
21696 if (VAT_JSON_ARRAY != vam->json_tree.type)
21698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21699 vat_json_init_array (&vam->json_tree);
21701 node = vat_json_array_add (&vam->json_tree);
21703 vat_json_init_object (node);
21704 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21705 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21706 vat_json_object_add_ip4 (node, "src_address", ip4);
21707 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21708 vat_json_object_add_ip4 (node, "dst_address", ip4);
21709 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21710 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21714 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21716 unformat_input_t *i = vam->input;
21717 vl_api_ipsec_gre_tunnel_dump_t *mp;
21718 vl_api_control_ping_t *mp_ping;
21720 u8 sw_if_index_set = 0;
21723 /* Parse args required to build the message */
21724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21726 if (unformat (i, "sw_if_index %d", &sw_if_index))
21727 sw_if_index_set = 1;
21732 if (sw_if_index_set == 0)
21737 if (!vam->json_output)
21739 print (vam->ofp, "%11s%15s%15s%14s%14s",
21740 "sw_if_index", "src_address", "dst_address",
21741 "local_sa_id", "remote_sa_id");
21744 /* Get list of gre-tunnel interfaces */
21745 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21747 mp->sw_if_index = htonl (sw_if_index);
21751 /* Use a control ping for synchronization */
21752 MPING (CONTROL_PING, mp_ping);
21760 api_delete_subif (vat_main_t * vam)
21762 unformat_input_t *i = vam->input;
21763 vl_api_delete_subif_t *mp;
21764 u32 sw_if_index = ~0;
21767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21769 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21771 if (unformat (i, "sw_if_index %d", &sw_if_index))
21777 if (sw_if_index == ~0)
21779 errmsg ("missing sw_if_index");
21783 /* Construct the API message */
21784 M (DELETE_SUBIF, mp);
21785 mp->sw_if_index = ntohl (sw_if_index);
21792 #define foreach_pbb_vtr_op \
21793 _("disable", L2_VTR_DISABLED) \
21794 _("pop", L2_VTR_POP_2) \
21795 _("push", L2_VTR_PUSH_2)
21798 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21800 unformat_input_t *i = vam->input;
21801 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21802 u32 sw_if_index = ~0, vtr_op = ~0;
21803 u16 outer_tag = ~0;
21804 u8 dmac[6], smac[6];
21805 u8 dmac_set = 0, smac_set = 0;
21811 /* Shut up coverity */
21812 memset (dmac, 0, sizeof (dmac));
21813 memset (smac, 0, sizeof (smac));
21815 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21817 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21819 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21821 else if (unformat (i, "vtr_op %d", &vtr_op))
21823 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21826 else if (unformat (i, "translate_pbb_stag"))
21828 if (unformat (i, "%d", &tmp))
21830 vtr_op = L2_VTR_TRANSLATE_2_1;
21836 ("translate_pbb_stag operation requires outer tag definition");
21840 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21842 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21844 else if (unformat (i, "sid %d", &sid))
21846 else if (unformat (i, "vlanid %d", &tmp))
21850 clib_warning ("parse error '%U'", format_unformat_error, i);
21855 if ((sw_if_index == ~0) || (vtr_op == ~0))
21857 errmsg ("missing sw_if_index or vtr operation");
21860 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21861 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21864 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21868 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21869 mp->sw_if_index = ntohl (sw_if_index);
21870 mp->vtr_op = ntohl (vtr_op);
21871 mp->outer_tag = ntohs (outer_tag);
21872 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21873 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21874 mp->b_vlanid = ntohs (vlanid);
21875 mp->i_sid = ntohl (sid);
21883 api_flow_classify_set_interface (vat_main_t * vam)
21885 unformat_input_t *i = vam->input;
21886 vl_api_flow_classify_set_interface_t *mp;
21888 int sw_if_index_set;
21889 u32 ip4_table_index = ~0;
21890 u32 ip6_table_index = ~0;
21894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21896 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21897 sw_if_index_set = 1;
21898 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21899 sw_if_index_set = 1;
21900 else if (unformat (i, "del"))
21902 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21904 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21908 clib_warning ("parse error '%U'", format_unformat_error, i);
21913 if (sw_if_index_set == 0)
21915 errmsg ("missing interface name or sw_if_index");
21919 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21921 mp->sw_if_index = ntohl (sw_if_index);
21922 mp->ip4_table_index = ntohl (ip4_table_index);
21923 mp->ip6_table_index = ntohl (ip6_table_index);
21924 mp->is_add = is_add;
21932 api_flow_classify_dump (vat_main_t * vam)
21934 unformat_input_t *i = vam->input;
21935 vl_api_flow_classify_dump_t *mp;
21936 vl_api_control_ping_t *mp_ping;
21937 u8 type = FLOW_CLASSIFY_N_TABLES;
21940 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21944 errmsg ("classify table type must be specified");
21948 if (!vam->json_output)
21950 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21953 M (FLOW_CLASSIFY_DUMP, mp);
21958 /* Use a control ping for synchronization */
21959 MPING (CONTROL_PING, mp_ping);
21962 /* Wait for a reply... */
21968 api_feature_enable_disable (vat_main_t * vam)
21970 unformat_input_t *i = vam->input;
21971 vl_api_feature_enable_disable_t *mp;
21973 u8 *feature_name = 0;
21974 u32 sw_if_index = ~0;
21978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21980 if (unformat (i, "arc_name %s", &arc_name))
21982 else if (unformat (i, "feature_name %s", &feature_name))
21985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21989 else if (unformat (i, "disable"))
21997 errmsg ("missing arc name");
22000 if (vec_len (arc_name) > 63)
22002 errmsg ("arc name too long");
22005 if (feature_name == 0)
22007 errmsg ("missing feature name");
22010 if (vec_len (feature_name) > 63)
22012 errmsg ("feature name too long");
22015 if (sw_if_index == ~0)
22017 errmsg ("missing interface name or sw_if_index");
22021 /* Construct the API message */
22022 M (FEATURE_ENABLE_DISABLE, mp);
22023 mp->sw_if_index = ntohl (sw_if_index);
22024 mp->enable = enable;
22025 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22026 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22027 vec_free (arc_name);
22028 vec_free (feature_name);
22036 api_sw_interface_tag_add_del (vat_main_t * vam)
22038 unformat_input_t *i = vam->input;
22039 vl_api_sw_interface_tag_add_del_t *mp;
22040 u32 sw_if_index = ~0;
22045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22047 if (unformat (i, "tag %s", &tag))
22049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22053 else if (unformat (i, "del"))
22059 if (sw_if_index == ~0)
22061 errmsg ("missing interface name or sw_if_index");
22065 if (enable && (tag == 0))
22067 errmsg ("no tag specified");
22071 /* Construct the API message */
22072 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22073 mp->sw_if_index = ntohl (sw_if_index);
22074 mp->is_add = enable;
22076 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22084 static void vl_api_l2_xconnect_details_t_handler
22085 (vl_api_l2_xconnect_details_t * mp)
22087 vat_main_t *vam = &vat_main;
22089 print (vam->ofp, "%15d%15d",
22090 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22093 static void vl_api_l2_xconnect_details_t_handler_json
22094 (vl_api_l2_xconnect_details_t * mp)
22096 vat_main_t *vam = &vat_main;
22097 vat_json_node_t *node = NULL;
22099 if (VAT_JSON_ARRAY != vam->json_tree.type)
22101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22102 vat_json_init_array (&vam->json_tree);
22104 node = vat_json_array_add (&vam->json_tree);
22106 vat_json_init_object (node);
22107 vat_json_object_add_uint (node, "rx_sw_if_index",
22108 ntohl (mp->rx_sw_if_index));
22109 vat_json_object_add_uint (node, "tx_sw_if_index",
22110 ntohl (mp->tx_sw_if_index));
22114 api_l2_xconnect_dump (vat_main_t * vam)
22116 vl_api_l2_xconnect_dump_t *mp;
22117 vl_api_control_ping_t *mp_ping;
22120 if (!vam->json_output)
22122 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22125 M (L2_XCONNECT_DUMP, mp);
22129 /* Use a control ping for synchronization */
22130 MPING (CONTROL_PING, mp_ping);
22138 api_hw_interface_set_mtu (vat_main_t * vam)
22140 unformat_input_t *i = vam->input;
22141 vl_api_hw_interface_set_mtu_t *mp;
22142 u32 sw_if_index = ~0;
22146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22148 if (unformat (i, "mtu %d", &mtu))
22150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22158 if (sw_if_index == ~0)
22160 errmsg ("missing interface name or sw_if_index");
22166 errmsg ("no mtu specified");
22170 /* Construct the API message */
22171 M (HW_INTERFACE_SET_MTU, mp);
22172 mp->sw_if_index = ntohl (sw_if_index);
22173 mp->mtu = ntohs ((u16) mtu);
22181 api_p2p_ethernet_add (vat_main_t * vam)
22183 unformat_input_t *i = vam->input;
22184 vl_api_p2p_ethernet_add_t *mp;
22185 u32 parent_if_index = ~0;
22191 memset (remote_mac, 0, sizeof (remote_mac));
22192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22196 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22200 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22202 else if (unformat (i, "sub_id %d", &sub_id))
22206 clib_warning ("parse error '%U'", format_unformat_error, i);
22211 if (parent_if_index == ~0)
22213 errmsg ("missing interface name or sw_if_index");
22218 errmsg ("missing remote mac address");
22223 errmsg ("missing sub-interface id");
22227 M (P2P_ETHERNET_ADD, mp);
22228 mp->parent_if_index = ntohl (parent_if_index);
22229 mp->subif_id = ntohl (sub_id);
22230 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22238 api_p2p_ethernet_del (vat_main_t * vam)
22240 unformat_input_t *i = vam->input;
22241 vl_api_p2p_ethernet_del_t *mp;
22242 u32 parent_if_index = ~0;
22247 memset (remote_mac, 0, sizeof (remote_mac));
22248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22250 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22252 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22256 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22260 clib_warning ("parse error '%U'", format_unformat_error, i);
22265 if (parent_if_index == ~0)
22267 errmsg ("missing interface name or sw_if_index");
22272 errmsg ("missing remote mac address");
22276 M (P2P_ETHERNET_DEL, mp);
22277 mp->parent_if_index = ntohl (parent_if_index);
22278 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22286 api_lldp_config (vat_main_t * vam)
22288 unformat_input_t *i = vam->input;
22289 vl_api_lldp_config_t *mp;
22291 int tx_interval = 0;
22292 u8 *sys_name = NULL;
22295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22297 if (unformat (i, "system-name %s", &sys_name))
22299 else if (unformat (i, "tx-hold %d", &tx_hold))
22301 else if (unformat (i, "tx-interval %d", &tx_interval))
22305 clib_warning ("parse error '%U'", format_unformat_error, i);
22310 vec_add1 (sys_name, 0);
22312 M (LLDP_CONFIG, mp);
22313 mp->tx_hold = htonl (tx_hold);
22314 mp->tx_interval = htonl (tx_interval);
22315 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22316 vec_free (sys_name);
22324 api_sw_interface_set_lldp (vat_main_t * vam)
22326 unformat_input_t *i = vam->input;
22327 vl_api_sw_interface_set_lldp_t *mp;
22328 u32 sw_if_index = ~0;
22330 u8 *port_desc = NULL, *mgmt_oid = NULL;
22331 ip4_address_t ip4_addr;
22332 ip6_address_t ip6_addr;
22335 memset (&ip4_addr, 0, sizeof (ip4_addr));
22336 memset (&ip6_addr, 0, sizeof (ip6_addr));
22338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22340 if (unformat (i, "disable"))
22343 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22345 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22347 else if (unformat (i, "port-desc %s", &port_desc))
22349 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22351 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22353 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22359 if (sw_if_index == ~0)
22361 errmsg ("missing interface name or sw_if_index");
22365 /* Construct the API message */
22366 vec_add1 (port_desc, 0);
22367 vec_add1 (mgmt_oid, 0);
22368 M (SW_INTERFACE_SET_LLDP, mp);
22369 mp->sw_if_index = ntohl (sw_if_index);
22370 mp->enable = enable;
22371 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22372 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22373 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22374 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22375 vec_free (port_desc);
22376 vec_free (mgmt_oid);
22384 api_tcp_configure_src_addresses (vat_main_t * vam)
22386 vl_api_tcp_configure_src_addresses_t *mp;
22387 unformat_input_t *i = vam->input;
22388 ip4_address_t v4first, v4last;
22389 ip6_address_t v6first, v6last;
22394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22396 if (unformat (i, "%U - %U",
22397 unformat_ip4_address, &v4first,
22398 unformat_ip4_address, &v4last))
22402 errmsg ("one range per message (range already set)");
22407 else if (unformat (i, "%U - %U",
22408 unformat_ip6_address, &v6first,
22409 unformat_ip6_address, &v6last))
22413 errmsg ("one range per message (range already set)");
22418 else if (unformat (i, "vrf %d", &vrf_id))
22424 if (range_set == 0)
22426 errmsg ("address range not set");
22430 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22431 mp->vrf_id = ntohl (vrf_id);
22433 if (range_set == 2)
22436 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22437 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22442 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22443 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22450 static void vl_api_app_namespace_add_del_reply_t_handler
22451 (vl_api_app_namespace_add_del_reply_t * mp)
22453 vat_main_t *vam = &vat_main;
22454 i32 retval = ntohl (mp->retval);
22455 if (vam->async_mode)
22457 vam->async_errors += (retval < 0);
22461 vam->retval = retval;
22463 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22464 vam->result_ready = 1;
22468 static void vl_api_app_namespace_add_del_reply_t_handler_json
22469 (vl_api_app_namespace_add_del_reply_t * mp)
22471 vat_main_t *vam = &vat_main;
22472 vat_json_node_t node;
22474 vat_json_init_object (&node);
22475 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22476 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22478 vat_json_print (vam->ofp, &node);
22479 vat_json_free (&node);
22481 vam->retval = ntohl (mp->retval);
22482 vam->result_ready = 1;
22486 api_app_namespace_add_del (vat_main_t * vam)
22488 vl_api_app_namespace_add_del_t *mp;
22489 unformat_input_t *i = vam->input;
22490 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22491 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22497 if (unformat (i, "id %_%v%_", &ns_id))
22499 else if (unformat (i, "secret %lu", &secret))
22501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22502 sw_if_index_set = 1;
22503 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22505 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22510 if (!ns_id || !secret_set || !sw_if_index_set)
22512 errmsg ("namespace id, secret and sw_if_index must be set");
22515 if (vec_len (ns_id) > 64)
22517 errmsg ("namespace id too long");
22520 M (APP_NAMESPACE_ADD_DEL, mp);
22522 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22523 mp->namespace_id_len = vec_len (ns_id);
22524 mp->secret = clib_host_to_net_u64 (secret);
22525 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22526 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22527 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22534 static void vl_api_map_stats_segment_reply_t_handler
22535 (vl_api_map_stats_segment_reply_t * mp)
22537 #if VPP_API_TEST_BUILTIN == 0
22538 vat_main_t *vam = &vat_main;
22539 ssvm_private_t *ssvmp = &vam->stat_segment;
22540 ssvm_shared_header_t *shared_header;
22541 socket_client_main_t *scm = vam->socket_client_main;
22542 int rv = ntohl (mp->retval);
22544 clib_error_t *error;
22550 vam->result_ready = 1;
22555 * Check the socket for the magic fd
22557 error = vl_sock_api_recv_fd_msg (scm->socket_fd, &my_fd, 5);
22560 clib_error_report (error);
22562 vam->result_ready = 1;
22566 memset (ssvmp, 0, sizeof (*ssvmp));
22569 /* Note: this closes memfd.fd */
22570 retval = ssvm_slave_init_memfd (ssvmp);
22573 clib_warning ("WARNING: segment map returned %d", retval);
22575 vam->result_ready = 1;
22579 errmsg ("stat segment mapped OK...");
22581 ASSERT (ssvmp && ssvmp->sh);
22583 /* Pick up the segment lock from the shared memory header */
22584 shared_header = ssvmp->sh;
22585 vam->stat_segment_lockp = (clib_spinlock_t *) (shared_header->opaque[0]);
22587 vam->result_ready = 1;
22591 static void vl_api_map_stats_segment_reply_t_handler_json
22592 (vl_api_map_stats_segment_reply_t * mp)
22594 #if VPP_API_TEST_BUILTIN == 0
22595 vat_main_t *vam = &vat_main;
22596 clib_warning ("not implemented");
22598 vam->result_ready = 1;
22603 api_map_stats_segment (vat_main_t * vam)
22605 #if VPP_API_TEST_BUILTIN == 0
22606 vl_api_map_stats_segment_t *mp;
22609 M (MAP_STATS_SEGMENT, mp);
22615 errmsg ("api unavailable");
22621 api_sock_init_shm (vat_main_t * vam)
22623 #if VPP_API_TEST_BUILTIN == 0
22624 unformat_input_t *i = vam->input;
22625 vl_api_shm_elem_config_t *config = 0;
22626 u64 size = 64 << 20;
22629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22631 if (unformat (i, "size %U", unformat_memory_size, &size))
22638 * Canned custom ring allocator config.
22639 * Should probably parse all of this
22641 vec_validate (config, 6);
22642 config[0].type = VL_API_VLIB_RING;
22643 config[0].size = 256;
22644 config[0].count = 32;
22646 config[1].type = VL_API_VLIB_RING;
22647 config[1].size = 1024;
22648 config[1].count = 16;
22650 config[2].type = VL_API_VLIB_RING;
22651 config[2].size = 4096;
22652 config[2].count = 2;
22654 config[3].type = VL_API_CLIENT_RING;
22655 config[3].size = 256;
22656 config[3].count = 32;
22658 config[4].type = VL_API_CLIENT_RING;
22659 config[4].size = 1024;
22660 config[4].count = 16;
22662 config[5].type = VL_API_CLIENT_RING;
22663 config[5].size = 4096;
22664 config[5].count = 2;
22666 config[6].type = VL_API_QUEUE;
22667 config[6].count = 128;
22668 config[6].size = sizeof (uword);
22670 rv = vl_socket_client_init_shm (config);
22672 vam->client_index_invalid = 1;
22680 api_dns_enable_disable (vat_main_t * vam)
22682 unformat_input_t *line_input = vam->input;
22683 vl_api_dns_enable_disable_t *mp;
22684 u8 enable_disable = 1;
22687 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22689 if (unformat (line_input, "disable"))
22690 enable_disable = 0;
22691 if (unformat (line_input, "enable"))
22692 enable_disable = 1;
22697 /* Construct the API message */
22698 M (DNS_ENABLE_DISABLE, mp);
22699 mp->enable = enable_disable;
22703 /* Wait for the reply */
22709 api_dns_resolve_name (vat_main_t * vam)
22711 unformat_input_t *line_input = vam->input;
22712 vl_api_dns_resolve_name_t *mp;
22716 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22718 if (unformat (line_input, "%s", &name))
22724 if (vec_len (name) > 127)
22726 errmsg ("name too long");
22730 /* Construct the API message */
22731 M (DNS_RESOLVE_NAME, mp);
22732 memcpy (mp->name, name, vec_len (name));
22737 /* Wait for the reply */
22743 api_dns_resolve_ip (vat_main_t * vam)
22745 unformat_input_t *line_input = vam->input;
22746 vl_api_dns_resolve_ip_t *mp;
22748 ip4_address_t addr4;
22749 ip6_address_t addr6;
22752 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22754 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22756 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22764 errmsg ("missing address");
22768 /* Construct the API message */
22769 M (DNS_RESOLVE_IP, mp);
22770 mp->is_ip6 = is_ip6;
22772 memcpy (mp->address, &addr6, sizeof (addr6));
22774 memcpy (mp->address, &addr4, sizeof (addr4));
22778 /* Wait for the reply */
22784 api_dns_name_server_add_del (vat_main_t * vam)
22786 unformat_input_t *i = vam->input;
22787 vl_api_dns_name_server_add_del_t *mp;
22789 ip6_address_t ip6_server;
22790 ip4_address_t ip4_server;
22795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22797 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22799 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22801 else if (unformat (i, "del"))
22805 clib_warning ("parse error '%U'", format_unformat_error, i);
22810 if (ip4_set && ip6_set)
22812 errmsg ("Only one server address allowed per message");
22815 if ((ip4_set + ip6_set) == 0)
22817 errmsg ("Server address required");
22821 /* Construct the API message */
22822 M (DNS_NAME_SERVER_ADD_DEL, mp);
22826 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22831 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22835 mp->is_add = is_add;
22840 /* Wait for a reply, return good/bad news */
22846 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22848 vat_main_t *vam = &vat_main;
22853 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22854 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22855 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22856 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22857 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22858 clib_net_to_host_u32 (mp->action_index), mp->tag);
22863 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22864 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22865 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22866 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22867 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22868 clib_net_to_host_u32 (mp->action_index), mp->tag);
22873 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22876 vat_main_t *vam = &vat_main;
22877 vat_json_node_t *node = NULL;
22878 struct in6_addr ip6;
22879 struct in_addr ip4;
22881 if (VAT_JSON_ARRAY != vam->json_tree.type)
22883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22884 vat_json_init_array (&vam->json_tree);
22886 node = vat_json_array_add (&vam->json_tree);
22887 vat_json_init_object (node);
22889 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22890 vat_json_object_add_uint (node, "appns_index",
22891 clib_net_to_host_u32 (mp->appns_index));
22892 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22893 vat_json_object_add_uint (node, "scope", mp->scope);
22894 vat_json_object_add_uint (node, "action_index",
22895 clib_net_to_host_u32 (mp->action_index));
22896 vat_json_object_add_uint (node, "lcl_port",
22897 clib_net_to_host_u16 (mp->lcl_port));
22898 vat_json_object_add_uint (node, "rmt_port",
22899 clib_net_to_host_u16 (mp->rmt_port));
22900 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22901 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22902 vat_json_object_add_string_copy (node, "tag", mp->tag);
22905 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22906 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22907 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22908 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22912 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22913 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22914 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22915 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22920 api_session_rule_add_del (vat_main_t * vam)
22922 vl_api_session_rule_add_del_t *mp;
22923 unformat_input_t *i = vam->input;
22924 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22925 u32 appns_index = 0, scope = 0;
22926 ip4_address_t lcl_ip4, rmt_ip4;
22927 ip6_address_t lcl_ip6, rmt_ip6;
22928 u8 is_ip4 = 1, conn_set = 0;
22929 u8 is_add = 1, *tag = 0;
22932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22934 if (unformat (i, "del"))
22936 else if (unformat (i, "add"))
22938 else if (unformat (i, "proto tcp"))
22940 else if (unformat (i, "proto udp"))
22942 else if (unformat (i, "appns %d", &appns_index))
22944 else if (unformat (i, "scope %d", &scope))
22946 else if (unformat (i, "tag %_%v%_", &tag))
22950 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22951 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22959 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22960 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22966 else if (unformat (i, "action %d", &action))
22971 if (proto == ~0 || !conn_set || action == ~0)
22973 errmsg ("transport proto, connection and action must be set");
22979 errmsg ("scope should be 0-3");
22983 M (SESSION_RULE_ADD_DEL, mp);
22985 mp->is_ip4 = is_ip4;
22986 mp->transport_proto = proto;
22987 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22988 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22989 mp->lcl_plen = lcl_plen;
22990 mp->rmt_plen = rmt_plen;
22991 mp->action_index = clib_host_to_net_u32 (action);
22992 mp->appns_index = clib_host_to_net_u32 (appns_index);
22994 mp->is_add = is_add;
22997 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22998 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23002 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23003 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23007 clib_memcpy (mp->tag, tag, vec_len (tag));
23017 api_session_rules_dump (vat_main_t * vam)
23019 vl_api_session_rules_dump_t *mp;
23020 vl_api_control_ping_t *mp_ping;
23023 if (!vam->json_output)
23025 print (vam->ofp, "%=20s", "Session Rules");
23028 M (SESSION_RULES_DUMP, mp);
23032 /* Use a control ping for synchronization */
23033 MPING (CONTROL_PING, mp_ping);
23036 /* Wait for a reply... */
23042 api_ip_container_proxy_add_del (vat_main_t * vam)
23044 vl_api_ip_container_proxy_add_del_t *mp;
23045 unformat_input_t *i = vam->input;
23046 u32 plen = ~0, sw_if_index = ~0;
23053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23055 if (unformat (i, "del"))
23057 else if (unformat (i, "add"))
23059 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23064 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23069 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23074 if (sw_if_index == ~0 || plen == ~0)
23076 errmsg ("address and sw_if_index must be set");
23080 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23082 mp->is_ip4 = is_ip4;
23083 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23085 mp->is_add = is_add;
23087 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23089 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23097 api_qos_record_enable_disable (vat_main_t * vam)
23099 unformat_input_t *i = vam->input;
23100 vl_api_qos_record_enable_disable_t *mp;
23101 u32 sw_if_index, qs = 0xff;
23102 u8 sw_if_index_set = 0;
23106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23108 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23109 sw_if_index_set = 1;
23110 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23111 sw_if_index_set = 1;
23112 else if (unformat (i, "%U", unformat_qos_source, &qs))
23114 else if (unformat (i, "disable"))
23118 clib_warning ("parse error '%U'", format_unformat_error, i);
23123 if (sw_if_index_set == 0)
23125 errmsg ("missing interface name or sw_if_index");
23130 errmsg ("input location must be specified");
23134 M (QOS_RECORD_ENABLE_DISABLE, mp);
23136 mp->sw_if_index = ntohl (sw_if_index);
23137 mp->input_source = qs;
23138 mp->enable = enable;
23147 q_or_quit (vat_main_t * vam)
23149 #if VPP_API_TEST_BUILTIN == 0
23150 longjmp (vam->jump_buf, 1);
23152 return 0; /* not so much */
23156 q (vat_main_t * vam)
23158 return q_or_quit (vam);
23162 quit (vat_main_t * vam)
23164 return q_or_quit (vam);
23168 comment (vat_main_t * vam)
23174 statseg (vat_main_t * vam)
23176 ssvm_private_t *ssvmp = &vam->stat_segment;
23177 ssvm_shared_header_t *shared_header = ssvmp->sh;
23178 vlib_counter_t **counters;
23179 u64 thread0_index1_packets;
23180 u64 thread0_index1_bytes;
23181 f64 vector_rate, input_rate;
23184 uword *counter_vector_by_name;
23185 if (vam->stat_segment_lockp == 0)
23187 errmsg ("Stat segment not mapped...");
23191 /* look up "/if/rx for sw_if_index 1 as a test */
23193 clib_spinlock_lock (vam->stat_segment_lockp);
23195 counter_vector_by_name = (uword *) shared_header->opaque[1];
23197 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23200 clib_spinlock_unlock (vam->stat_segment_lockp);
23201 errmsg ("/if/tx not found?");
23205 /* Fish per-thread vector of combined counters from shared memory */
23206 counters = (vlib_counter_t **) p[0];
23208 if (vec_len (counters[0]) < 2)
23210 clib_spinlock_unlock (vam->stat_segment_lockp);
23211 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23215 /* Read thread 0 sw_if_index 1 counter */
23216 thread0_index1_packets = counters[0][1].packets;
23217 thread0_index1_bytes = counters[0][1].bytes;
23219 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23222 clib_spinlock_unlock (vam->stat_segment_lockp);
23223 errmsg ("vector_rate not found?");
23227 vector_rate = *(f64 *) (p[0]);
23228 p = hash_get_mem (counter_vector_by_name, "input_rate");
23231 clib_spinlock_unlock (vam->stat_segment_lockp);
23232 errmsg ("input_rate not found?");
23235 input_rate = *(f64 *) (p[0]);
23237 clib_spinlock_unlock (vam->stat_segment_lockp);
23239 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23240 vector_rate, input_rate);
23241 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23242 thread0_index1_packets, thread0_index1_bytes);
23248 cmd_cmp (void *a1, void *a2)
23253 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23257 help (vat_main_t * vam)
23262 unformat_input_t *i = vam->input;
23265 if (unformat (i, "%s", &name))
23269 vec_add1 (name, 0);
23271 hs = hash_get_mem (vam->help_by_name, name);
23273 print (vam->ofp, "usage: %s %s", name, hs[0]);
23275 print (vam->ofp, "No such msg / command '%s'", name);
23280 print (vam->ofp, "Help is available for the following:");
23283 hash_foreach_pair (p, vam->function_by_name,
23285 vec_add1 (cmds, (u8 *)(p->key));
23289 vec_sort_with_function (cmds, cmd_cmp);
23291 for (j = 0; j < vec_len (cmds); j++)
23292 print (vam->ofp, "%s", cmds[j]);
23299 set (vat_main_t * vam)
23301 u8 *name = 0, *value = 0;
23302 unformat_input_t *i = vam->input;
23304 if (unformat (i, "%s", &name))
23306 /* The input buffer is a vector, not a string. */
23307 value = vec_dup (i->buffer);
23308 vec_delete (value, i->index, 0);
23309 /* Almost certainly has a trailing newline */
23310 if (value[vec_len (value) - 1] == '\n')
23311 value[vec_len (value) - 1] = 0;
23312 /* Make sure it's a proper string, one way or the other */
23313 vec_add1 (value, 0);
23314 (void) clib_macro_set_value (&vam->macro_main,
23315 (char *) name, (char *) value);
23318 errmsg ("usage: set <name> <value>");
23326 unset (vat_main_t * vam)
23330 if (unformat (vam->input, "%s", &name))
23331 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23332 errmsg ("unset: %s wasn't set", name);
23345 macro_sort_cmp (void *a1, void *a2)
23347 macro_sort_t *s1 = a1;
23348 macro_sort_t *s2 = a2;
23350 return strcmp ((char *) (s1->name), (char *) (s2->name));
23354 dump_macro_table (vat_main_t * vam)
23356 macro_sort_t *sort_me = 0, *sm;
23361 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23363 vec_add2 (sort_me, sm, 1);
23364 sm->name = (u8 *)(p->key);
23365 sm->value = (u8 *) (p->value[0]);
23369 vec_sort_with_function (sort_me, macro_sort_cmp);
23371 if (vec_len (sort_me))
23372 print (vam->ofp, "%-15s%s", "Name", "Value");
23374 print (vam->ofp, "The macro table is empty...");
23376 for (i = 0; i < vec_len (sort_me); i++)
23377 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23382 dump_node_table (vat_main_t * vam)
23385 vlib_node_t *node, *next_node;
23387 if (vec_len (vam->graph_nodes) == 0)
23389 print (vam->ofp, "Node table empty, issue get_node_graph...");
23393 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23395 node = vam->graph_nodes[0][i];
23396 print (vam->ofp, "[%d] %s", i, node->name);
23397 for (j = 0; j < vec_len (node->next_nodes); j++)
23399 if (node->next_nodes[j] != ~0)
23401 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23402 print (vam->ofp, " [%d] %s", j, next_node->name);
23410 value_sort_cmp (void *a1, void *a2)
23412 name_sort_t *n1 = a1;
23413 name_sort_t *n2 = a2;
23415 if (n1->value < n2->value)
23417 if (n1->value > n2->value)
23424 dump_msg_api_table (vat_main_t * vam)
23426 api_main_t *am = &api_main;
23427 name_sort_t *nses = 0, *ns;
23432 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23434 vec_add2 (nses, ns, 1);
23435 ns->name = (u8 *)(hp->key);
23436 ns->value = (u32) hp->value[0];
23440 vec_sort_with_function (nses, value_sort_cmp);
23442 for (i = 0; i < vec_len (nses); i++)
23443 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23449 get_msg_id (vat_main_t * vam)
23454 if (unformat (vam->input, "%s", &name_and_crc))
23456 message_index = vl_msg_api_get_msg_index (name_and_crc);
23457 if (message_index == ~0)
23459 print (vam->ofp, " '%s' not found", name_and_crc);
23462 print (vam->ofp, " '%s' has message index %d",
23463 name_and_crc, message_index);
23466 errmsg ("name_and_crc required...");
23471 search_node_table (vat_main_t * vam)
23473 unformat_input_t *line_input = vam->input;
23476 vlib_node_t *node, *next_node;
23479 if (vam->graph_node_index_by_name == 0)
23481 print (vam->ofp, "Node table empty, issue get_node_graph...");
23485 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23487 if (unformat (line_input, "%s", &node_to_find))
23489 vec_add1 (node_to_find, 0);
23490 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23493 print (vam->ofp, "%s not found...", node_to_find);
23496 node = vam->graph_nodes[0][p[0]];
23497 print (vam->ofp, "[%d] %s", p[0], node->name);
23498 for (j = 0; j < vec_len (node->next_nodes); j++)
23500 if (node->next_nodes[j] != ~0)
23502 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23503 print (vam->ofp, " [%d] %s", j, next_node->name);
23510 clib_warning ("parse error '%U'", format_unformat_error,
23516 vec_free (node_to_find);
23525 script (vat_main_t * vam)
23527 #if (VPP_API_TEST_BUILTIN==0)
23529 char *save_current_file;
23530 unformat_input_t save_input;
23531 jmp_buf save_jump_buf;
23532 u32 save_line_number;
23534 FILE *new_fp, *save_ifp;
23536 if (unformat (vam->input, "%s", &s))
23538 new_fp = fopen ((char *) s, "r");
23541 errmsg ("Couldn't open script file %s", s);
23548 errmsg ("Missing script name");
23552 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23553 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23554 save_ifp = vam->ifp;
23555 save_line_number = vam->input_line_number;
23556 save_current_file = (char *) vam->current_file;
23558 vam->input_line_number = 0;
23560 vam->current_file = s;
23563 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23564 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23565 vam->ifp = save_ifp;
23566 vam->input_line_number = save_line_number;
23567 vam->current_file = (u8 *) save_current_file;
23572 clib_warning ("use the exec command...");
23578 echo (vat_main_t * vam)
23580 print (vam->ofp, "%v", vam->input->buffer);
23584 /* List of API message constructors, CLI names map to api_xxx */
23585 #define foreach_vpe_api_msg \
23586 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23587 _(sw_interface_dump,"") \
23588 _(sw_interface_set_flags, \
23589 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23590 _(sw_interface_add_del_address, \
23591 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23592 _(sw_interface_set_rx_mode, \
23593 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23594 _(sw_interface_set_table, \
23595 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23596 _(sw_interface_set_mpls_enable, \
23597 "<intfc> | sw_if_index [disable | dis]") \
23598 _(sw_interface_set_vpath, \
23599 "<intfc> | sw_if_index <id> enable | disable") \
23600 _(sw_interface_set_vxlan_bypass, \
23601 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23602 _(sw_interface_set_geneve_bypass, \
23603 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23604 _(sw_interface_set_l2_xconnect, \
23605 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23606 "enable | disable") \
23607 _(sw_interface_set_l2_bridge, \
23608 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23609 "[shg <split-horizon-group>] [bvi]\n" \
23610 "enable | disable") \
23611 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23612 _(bridge_domain_add_del, \
23613 "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") \
23614 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23616 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23617 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23618 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23620 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23622 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23624 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23626 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23628 "<vpp-if-name> | sw_if_index <id>") \
23629 _(sw_interface_tap_dump, "") \
23631 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23633 "<vpp-if-name> | sw_if_index <id>") \
23634 _(sw_interface_tap_v2_dump, "") \
23636 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23637 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23639 "<vpp-if-name> | sw_if_index <id>") \
23641 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23642 _(bond_detach_slave, \
23643 "sw_if_index <n>") \
23644 _(sw_interface_bond_dump, "") \
23645 _(sw_interface_slave_dump, \
23646 "<vpp-if-name> | sw_if_index <id>") \
23647 _(ip_table_add_del, \
23648 "table-id <n> [ipv6]\n") \
23649 _(ip_add_del_route, \
23650 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23651 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23652 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23653 "[multipath] [count <n>]") \
23654 _(ip_mroute_add_del, \
23655 "<src> <grp>/<mask> [table-id <n>]\n" \
23656 "[<intfc> | sw_if_index <id>] [local] [del]") \
23657 _(mpls_table_add_del, \
23658 "table-id <n>\n") \
23659 _(mpls_route_add_del, \
23660 "<label> <eos> via <addr> [table-id <n>]\n" \
23661 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23662 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23663 "[multipath] [count <n>]") \
23664 _(mpls_ip_bind_unbind, \
23665 "<label> <addr/len>") \
23666 _(mpls_tunnel_add_del, \
23667 " via <addr> [table-id <n>]\n" \
23668 "sw_if_index <id>] [l2] [del]") \
23669 _(bier_table_add_del, \
23670 "<label> <sub-domain> <set> <bsl> [del]") \
23671 _(bier_route_add_del, \
23672 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23673 "[<intfc> | sw_if_index <id>]" \
23674 "[weight <n>] [del] [multipath]") \
23675 _(proxy_arp_add_del, \
23676 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23677 _(proxy_arp_intfc_enable_disable, \
23678 "<intfc> | sw_if_index <id> enable | disable") \
23679 _(sw_interface_set_unnumbered, \
23680 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23681 _(ip_neighbor_add_del, \
23682 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23683 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23684 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23685 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23686 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23687 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23688 "[outer_vlan_id_any][inner_vlan_id_any]") \
23689 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23690 _(reset_fib, "vrf <n> [ipv6]") \
23691 _(dhcp_proxy_config, \
23692 "svr <v46-address> src <v46-address>\n" \
23693 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23694 _(dhcp_proxy_set_vss, \
23695 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23696 _(dhcp_proxy_dump, "ip6") \
23697 _(dhcp_client_config, \
23698 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23699 _(set_ip_flow_hash, \
23700 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23701 _(sw_interface_ip6_enable_disable, \
23702 "<intfc> | sw_if_index <id> enable | disable") \
23703 _(sw_interface_ip6_set_link_local_address, \
23704 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23705 _(ip6nd_proxy_add_del, \
23706 "<intfc> | sw_if_index <id> <ip6-address>") \
23707 _(ip6nd_proxy_dump, "") \
23708 _(sw_interface_ip6nd_ra_prefix, \
23709 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23710 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23711 "[nolink] [isno]") \
23712 _(sw_interface_ip6nd_ra_config, \
23713 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23714 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23715 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23716 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23717 _(l2_patch_add_del, \
23718 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23719 "enable | disable") \
23720 _(sr_localsid_add_del, \
23721 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23722 "fib-table <num> (end.psp) sw_if_index <num>") \
23723 _(classify_add_del_table, \
23724 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23725 " [del] [del-chain] mask <mask-value>\n" \
23726 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23727 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23728 _(classify_add_del_session, \
23729 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23730 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23731 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23732 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23733 _(classify_set_interface_ip_table, \
23734 "<intfc> | sw_if_index <nn> table <nn>") \
23735 _(classify_set_interface_l2_tables, \
23736 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23737 " [other-table <nn>]") \
23738 _(get_node_index, "node <node-name") \
23739 _(add_node_next, "node <node-name> next <next-node-name>") \
23740 _(l2tpv3_create_tunnel, \
23741 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23742 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23743 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23744 _(l2tpv3_set_tunnel_cookies, \
23745 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23746 "[new_remote_cookie <nn>]\n") \
23747 _(l2tpv3_interface_enable_disable, \
23748 "<intfc> | sw_if_index <nn> enable | disable") \
23749 _(l2tpv3_set_lookup_key, \
23750 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23751 _(sw_if_l2tpv3_tunnel_dump, "") \
23752 _(vxlan_offload_rx, \
23753 "hw { <interface name> | hw_if_index <nn>} " \
23754 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23755 _(vxlan_add_del_tunnel, \
23756 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23757 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23758 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23759 _(geneve_add_del_tunnel, \
23760 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23761 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23762 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23763 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23764 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23765 _(gre_add_del_tunnel, \
23766 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23767 "[teb | erspan <session-id>] [del]") \
23768 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23769 _(l2_fib_clear_table, "") \
23770 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23771 _(l2_interface_vlan_tag_rewrite, \
23772 "<intfc> | sw_if_index <nn> \n" \
23773 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23774 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23775 _(create_vhost_user_if, \
23776 "socket <filename> [server] [renumber <dev_instance>] " \
23777 "[mac <mac_address>]") \
23778 _(modify_vhost_user_if, \
23779 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23780 "[server] [renumber <dev_instance>]") \
23781 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23782 _(sw_interface_vhost_user_dump, "") \
23783 _(show_version, "") \
23784 _(vxlan_gpe_add_del_tunnel, \
23785 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23786 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23787 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23788 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23789 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23790 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23791 _(interface_name_renumber, \
23792 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23793 _(input_acl_set_interface, \
23794 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23795 " [l2-table <nn>] [del]") \
23796 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23797 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23798 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23799 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23800 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23801 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23802 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23803 _(ip_dump, "ipv4 | ipv6") \
23804 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23805 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23807 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23808 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23809 " integ_alg <alg> integ_key <hex>") \
23810 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23811 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23812 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23813 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23814 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23815 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23816 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23817 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23818 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23819 " [instance <n>]") \
23820 _(ipsec_sa_dump, "[sa_id <n>]") \
23821 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23822 " <alg> <hex>\n") \
23823 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23824 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23825 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23826 "(auth_data 0x<data> | auth_data <data>)") \
23827 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23828 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23829 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23830 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23831 "(local|remote)") \
23832 _(ikev2_set_local_key, "file <absolute_file_path>") \
23833 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23834 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23835 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23836 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23837 _(ikev2_initiate_sa_init, "<profile_name>") \
23838 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23839 _(ikev2_initiate_del_child_sa, "<ispi>") \
23840 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23841 _(delete_loopback,"sw_if_index <nn>") \
23842 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23843 _(map_add_domain, \
23844 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23845 "ip6-src <ip6addr> " \
23846 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23847 _(map_del_domain, "index <n>") \
23848 _(map_add_del_rule, \
23849 "index <n> psid <n> dst <ip6addr> [del]") \
23850 _(map_domain_dump, "") \
23851 _(map_rule_dump, "index <map-domain>") \
23852 _(want_interface_events, "enable|disable") \
23853 _(want_stats,"enable|disable") \
23854 _(get_first_msg_id, "client <name>") \
23855 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23856 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23857 "fib-id <nn> [ip4][ip6][default]") \
23858 _(get_node_graph, " ") \
23859 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23860 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23861 _(ioam_disable, "") \
23862 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23863 " sw_if_index <sw_if_index> p <priority> " \
23864 "w <weight>] [del]") \
23865 _(one_add_del_locator, "locator-set <locator_name> " \
23866 "iface <intf> | sw_if_index <sw_if_index> " \
23867 "p <priority> w <weight> [del]") \
23868 _(one_add_del_local_eid,"vni <vni> eid " \
23869 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23870 "locator-set <locator_name> [del]" \
23871 "[key-id sha1|sha256 secret-key <secret-key>]")\
23872 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23873 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23874 _(one_enable_disable, "enable|disable") \
23875 _(one_map_register_enable_disable, "enable|disable") \
23876 _(one_map_register_fallback_threshold, "<value>") \
23877 _(one_rloc_probe_enable_disable, "enable|disable") \
23878 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23880 "rloc <locator> p <prio> " \
23881 "w <weight> [rloc <loc> ... ] " \
23882 "action <action> [del-all]") \
23883 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23885 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23886 _(one_use_petr, "ip-address> | disable") \
23887 _(one_map_request_mode, "src-dst|dst-only") \
23888 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23889 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23890 _(one_locator_set_dump, "[local | remote]") \
23891 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23892 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23893 "[local] | [remote]") \
23894 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23895 _(one_ndp_bd_get, "") \
23896 _(one_ndp_entries_get, "bd <bridge-domain>") \
23897 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23898 _(one_l2_arp_bd_get, "") \
23899 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23900 _(one_stats_enable_disable, "enable|disalbe") \
23901 _(show_one_stats_enable_disable, "") \
23902 _(one_eid_table_vni_dump, "") \
23903 _(one_eid_table_map_dump, "l2|l3") \
23904 _(one_map_resolver_dump, "") \
23905 _(one_map_server_dump, "") \
23906 _(one_adjacencies_get, "vni <vni>") \
23907 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23908 _(show_one_rloc_probe_state, "") \
23909 _(show_one_map_register_state, "") \
23910 _(show_one_status, "") \
23911 _(one_stats_dump, "") \
23912 _(one_stats_flush, "") \
23913 _(one_get_map_request_itr_rlocs, "") \
23914 _(one_map_register_set_ttl, "<ttl>") \
23915 _(one_set_transport_protocol, "udp|api") \
23916 _(one_get_transport_protocol, "") \
23917 _(one_enable_disable_xtr_mode, "enable|disable") \
23918 _(one_show_xtr_mode, "") \
23919 _(one_enable_disable_pitr_mode, "enable|disable") \
23920 _(one_show_pitr_mode, "") \
23921 _(one_enable_disable_petr_mode, "enable|disable") \
23922 _(one_show_petr_mode, "") \
23923 _(show_one_nsh_mapping, "") \
23924 _(show_one_pitr, "") \
23925 _(show_one_use_petr, "") \
23926 _(show_one_map_request_mode, "") \
23927 _(show_one_map_register_ttl, "") \
23928 _(show_one_map_register_fallback_threshold, "") \
23929 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23930 " sw_if_index <sw_if_index> p <priority> " \
23931 "w <weight>] [del]") \
23932 _(lisp_add_del_locator, "locator-set <locator_name> " \
23933 "iface <intf> | sw_if_index <sw_if_index> " \
23934 "p <priority> w <weight> [del]") \
23935 _(lisp_add_del_local_eid,"vni <vni> eid " \
23936 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23937 "locator-set <locator_name> [del]" \
23938 "[key-id sha1|sha256 secret-key <secret-key>]") \
23939 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23940 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23941 _(lisp_enable_disable, "enable|disable") \
23942 _(lisp_map_register_enable_disable, "enable|disable") \
23943 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23944 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23946 "rloc <locator> p <prio> " \
23947 "w <weight> [rloc <loc> ... ] " \
23948 "action <action> [del-all]") \
23949 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23951 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23952 _(lisp_use_petr, "<ip-address> | disable") \
23953 _(lisp_map_request_mode, "src-dst|dst-only") \
23954 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23955 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23956 _(lisp_locator_set_dump, "[local | remote]") \
23957 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23958 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23959 "[local] | [remote]") \
23960 _(lisp_eid_table_vni_dump, "") \
23961 _(lisp_eid_table_map_dump, "l2|l3") \
23962 _(lisp_map_resolver_dump, "") \
23963 _(lisp_map_server_dump, "") \
23964 _(lisp_adjacencies_get, "vni <vni>") \
23965 _(gpe_fwd_entry_vnis_get, "") \
23966 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23967 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23968 "[table <table-id>]") \
23969 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23970 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23971 _(gpe_set_encap_mode, "lisp|vxlan") \
23972 _(gpe_get_encap_mode, "") \
23973 _(lisp_gpe_add_del_iface, "up|down") \
23974 _(lisp_gpe_enable_disable, "enable|disable") \
23975 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23976 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23977 _(show_lisp_rloc_probe_state, "") \
23978 _(show_lisp_map_register_state, "") \
23979 _(show_lisp_status, "") \
23980 _(lisp_get_map_request_itr_rlocs, "") \
23981 _(show_lisp_pitr, "") \
23982 _(show_lisp_use_petr, "") \
23983 _(show_lisp_map_request_mode, "") \
23984 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23985 _(af_packet_delete, "name <host interface name>") \
23986 _(af_packet_dump, "") \
23987 _(policer_add_del, "name <policer name> <params> [del]") \
23988 _(policer_dump, "[name <policer name>]") \
23989 _(policer_classify_set_interface, \
23990 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23991 " [l2-table <nn>] [del]") \
23992 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23993 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23994 "[master|slave]") \
23995 _(netmap_delete, "name <interface name>") \
23996 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23997 _(mpls_fib_dump, "") \
23998 _(classify_table_ids, "") \
23999 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
24000 _(classify_table_info, "table_id <nn>") \
24001 _(classify_session_dump, "table_id <nn>") \
24002 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24003 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24004 "[template_interval <nn>] [udp_checksum]") \
24005 _(ipfix_exporter_dump, "") \
24006 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24007 _(ipfix_classify_stream_dump, "") \
24008 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24009 _(ipfix_classify_table_dump, "") \
24010 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24011 _(sw_interface_span_dump, "[l2]") \
24012 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24013 _(pg_create_interface, "if_id <nn>") \
24014 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24015 _(pg_enable_disable, "[stream <id>] disable") \
24016 _(ip_source_and_port_range_check_add_del, \
24017 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24018 _(ip_source_and_port_range_check_interface_add_del, \
24019 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24020 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24021 _(ipsec_gre_add_del_tunnel, \
24022 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24023 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24024 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24025 _(l2_interface_pbb_tag_rewrite, \
24026 "<intfc> | sw_if_index <nn> \n" \
24027 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24028 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24029 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24030 _(flow_classify_set_interface, \
24031 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24032 _(flow_classify_dump, "type [ip4|ip6]") \
24033 _(ip_fib_dump, "") \
24034 _(ip_mfib_dump, "") \
24035 _(ip6_fib_dump, "") \
24036 _(ip6_mfib_dump, "") \
24037 _(feature_enable_disable, "arc_name <arc_name> " \
24038 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24039 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24041 _(l2_xconnect_dump, "") \
24042 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24043 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24044 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24045 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24046 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24047 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24048 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24049 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24050 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24051 _(sock_init_shm, "size <nnn>") \
24052 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24053 _(dns_enable_disable, "[enable][disable]") \
24054 _(dns_name_server_add_del, "<ip-address> [del]") \
24055 _(dns_resolve_name, "<hostname>") \
24056 _(dns_resolve_ip, "<ip4|ip6>") \
24057 _(dns_name_server_add_del, "<ip-address> [del]") \
24058 _(dns_resolve_name, "<hostname>") \
24059 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24060 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24061 _(session_rules_dump, "") \
24062 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24063 _(output_acl_set_interface, \
24064 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24065 " [l2-table <nn>] [del]") \
24066 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]") \
24067 _(map_stats_segment, "<no-args>")
24069 /* List of command functions, CLI names map directly to functions */
24070 #define foreach_cli_function \
24071 _(comment, "usage: comment <ignore-rest-of-line>") \
24072 _(dump_interface_table, "usage: dump_interface_table") \
24073 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24074 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24075 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24076 _(dump_stats_table, "usage: dump_stats_table") \
24077 _(dump_macro_table, "usage: dump_macro_table ") \
24078 _(dump_node_table, "usage: dump_node_table") \
24079 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24080 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24081 _(echo, "usage: echo <message>") \
24082 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24083 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24084 _(help, "usage: help") \
24085 _(q, "usage: quit") \
24086 _(quit, "usage: quit") \
24087 _(search_node_table, "usage: search_node_table <name>...") \
24088 _(set, "usage: set <variable-name> <value>") \
24089 _(script, "usage: script <file-name>") \
24090 _(statseg, "usage: statseg"); \
24091 _(unset, "usage: unset <variable-name>")
24094 static void vl_api_##n##_t_handler_uni \
24095 (vl_api_##n##_t * mp) \
24097 vat_main_t * vam = &vat_main; \
24098 if (vam->json_output) { \
24099 vl_api_##n##_t_handler_json(mp); \
24101 vl_api_##n##_t_handler(mp); \
24104 foreach_vpe_api_reply_msg;
24105 #if VPP_API_TEST_BUILTIN == 0
24106 foreach_standalone_reply_msg;
24111 vat_api_hookup (vat_main_t * vam)
24114 vl_msg_api_set_handlers(VL_API_##N, #n, \
24115 vl_api_##n##_t_handler_uni, \
24117 vl_api_##n##_t_endian, \
24118 vl_api_##n##_t_print, \
24119 sizeof(vl_api_##n##_t), 1);
24120 foreach_vpe_api_reply_msg;
24121 #if VPP_API_TEST_BUILTIN == 0
24122 foreach_standalone_reply_msg;
24126 #if (VPP_API_TEST_BUILTIN==0)
24127 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24129 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24131 vam->function_by_name = hash_create_string (0, sizeof (uword));
24133 vam->help_by_name = hash_create_string (0, sizeof (uword));
24136 /* API messages we can send */
24137 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24138 foreach_vpe_api_msg;
24142 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24143 foreach_vpe_api_msg;
24146 /* CLI functions */
24147 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24148 foreach_cli_function;
24152 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24153 foreach_cli_function;
24157 #if VPP_API_TEST_BUILTIN
24158 static clib_error_t *
24159 vat_api_hookup_shim (vlib_main_t * vm)
24161 vat_api_hookup (&vat_main);
24165 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24169 * fd.io coding-style-patch-verification: ON
24172 * eval: (c-set-style "gnu")