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); i++)
3093 node = vam->graph_nodes[i];
3094 vec_free (node->name);
3095 vec_free (node->next_nodes);
3098 vec_free (vam->graph_nodes);
3101 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3102 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3103 vec_free (pvt_copy);
3105 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3107 node = vam->graph_nodes[i];
3108 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3112 static void vl_api_get_node_graph_reply_t_handler_json
3113 (vl_api_get_node_graph_reply_t * mp)
3115 vat_main_t *vam = &vat_main;
3116 api_main_t *am = &api_main;
3118 vat_json_node_t node;
3121 /* $$$$ make this real? */
3122 vat_json_init_object (&node);
3123 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3124 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3126 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3128 /* Toss the shared-memory original... */
3129 pthread_mutex_lock (&am->vlib_rp->mutex);
3130 oldheap = svm_push_data_heap (am->vlib_rp);
3134 svm_pop_heap (oldheap);
3135 pthread_mutex_unlock (&am->vlib_rp->mutex);
3137 vat_json_print (vam->ofp, &node);
3138 vat_json_free (&node);
3140 vam->retval = ntohl (mp->retval);
3141 vam->result_ready = 1;
3145 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3147 vat_main_t *vam = &vat_main;
3152 s = format (s, "%=16d%=16d%=16d",
3153 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3157 s = format (s, "%=16U%=16d%=16d",
3158 mp->is_ipv6 ? format_ip6_address :
3160 mp->ip_address, mp->priority, mp->weight);
3163 print (vam->ofp, "%v", s);
3168 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3170 vat_main_t *vam = &vat_main;
3171 vat_json_node_t *node = NULL;
3172 struct in6_addr ip6;
3175 if (VAT_JSON_ARRAY != vam->json_tree.type)
3177 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3178 vat_json_init_array (&vam->json_tree);
3180 node = vat_json_array_add (&vam->json_tree);
3181 vat_json_init_object (node);
3183 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3184 vat_json_object_add_uint (node, "priority", mp->priority);
3185 vat_json_object_add_uint (node, "weight", mp->weight);
3188 vat_json_object_add_uint (node, "sw_if_index",
3189 clib_net_to_host_u32 (mp->sw_if_index));
3194 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3195 vat_json_object_add_ip6 (node, "address", ip6);
3199 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3200 vat_json_object_add_ip4 (node, "address", ip4);
3206 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3209 vat_main_t *vam = &vat_main;
3212 ls_name = format (0, "%s", mp->ls_name);
3214 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3220 vl_api_one_locator_set_details_t_handler_json
3221 (vl_api_one_locator_set_details_t * mp)
3223 vat_main_t *vam = &vat_main;
3224 vat_json_node_t *node = 0;
3227 ls_name = format (0, "%s", mp->ls_name);
3228 vec_add1 (ls_name, 0);
3230 if (VAT_JSON_ARRAY != vam->json_tree.type)
3232 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3233 vat_json_init_array (&vam->json_tree);
3235 node = vat_json_array_add (&vam->json_tree);
3237 vat_json_init_object (node);
3238 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3239 vat_json_object_add_uint (node, "ls_index",
3240 clib_net_to_host_u32 (mp->ls_index));
3248 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3251 unformat_nsh_address (unformat_input_t * input, va_list * args)
3253 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3254 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3258 format_nsh_address_vat (u8 * s, va_list * args)
3260 nsh_t *a = va_arg (*args, nsh_t *);
3261 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3265 format_lisp_flat_eid (u8 * s, va_list * args)
3267 u32 type = va_arg (*args, u32);
3268 u8 *eid = va_arg (*args, u8 *);
3269 u32 eid_len = va_arg (*args, u32);
3274 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3276 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3278 return format (s, "%U", format_ethernet_address, eid);
3280 return format (s, "%U", format_nsh_address_vat, eid);
3286 format_lisp_eid_vat (u8 * s, va_list * args)
3288 u32 type = va_arg (*args, u32);
3289 u8 *eid = va_arg (*args, u8 *);
3290 u32 eid_len = va_arg (*args, u32);
3291 u8 *seid = va_arg (*args, u8 *);
3292 u32 seid_len = va_arg (*args, u32);
3293 u32 is_src_dst = va_arg (*args, u32);
3296 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3298 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3304 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3306 vat_main_t *vam = &vat_main;
3307 u8 *s = 0, *eid = 0;
3309 if (~0 == mp->locator_set_index)
3310 s = format (0, "action: %d", mp->action);
3312 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3314 eid = format (0, "%U", format_lisp_eid_vat,
3318 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3321 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3322 clib_net_to_host_u32 (mp->vni),
3324 mp->is_local ? "local" : "remote",
3325 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3326 clib_net_to_host_u16 (mp->key_id), mp->key);
3333 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3336 vat_main_t *vam = &vat_main;
3337 vat_json_node_t *node = 0;
3340 if (VAT_JSON_ARRAY != vam->json_tree.type)
3342 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3343 vat_json_init_array (&vam->json_tree);
3345 node = vat_json_array_add (&vam->json_tree);
3347 vat_json_init_object (node);
3348 if (~0 == mp->locator_set_index)
3349 vat_json_object_add_uint (node, "action", mp->action);
3351 vat_json_object_add_uint (node, "locator_set_index",
3352 clib_net_to_host_u32 (mp->locator_set_index));
3354 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3355 if (mp->eid_type == 3)
3357 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3358 vat_json_init_object (nsh_json);
3359 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3360 vat_json_object_add_uint (nsh_json, "spi",
3361 clib_net_to_host_u32 (nsh->spi));
3362 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3366 eid = format (0, "%U", format_lisp_eid_vat,
3370 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3372 vat_json_object_add_string_copy (node, "eid", eid);
3375 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3376 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3377 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3381 vat_json_object_add_uint (node, "key_id",
3382 clib_net_to_host_u16 (mp->key_id));
3383 vat_json_object_add_string_copy (node, "key", mp->key);
3388 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3390 vat_main_t *vam = &vat_main;
3391 u8 *seid = 0, *deid = 0;
3392 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3394 deid = format (0, "%U", format_lisp_eid_vat,
3395 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3397 seid = format (0, "%U", format_lisp_eid_vat,
3398 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3404 format_ip_address_fcn = format_ip4_address;
3406 format_ip_address_fcn = format_ip6_address;
3409 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3410 clib_net_to_host_u32 (mp->vni),
3412 format_ip_address_fcn, mp->lloc,
3413 format_ip_address_fcn, mp->rloc,
3414 clib_net_to_host_u32 (mp->pkt_count),
3415 clib_net_to_host_u32 (mp->bytes));
3422 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3424 struct in6_addr ip6;
3426 vat_main_t *vam = &vat_main;
3427 vat_json_node_t *node = 0;
3428 u8 *deid = 0, *seid = 0;
3430 if (VAT_JSON_ARRAY != vam->json_tree.type)
3432 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3433 vat_json_init_array (&vam->json_tree);
3435 node = vat_json_array_add (&vam->json_tree);
3437 vat_json_init_object (node);
3438 deid = format (0, "%U", format_lisp_eid_vat,
3439 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3441 seid = format (0, "%U", format_lisp_eid_vat,
3442 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3447 vat_json_object_add_string_copy (node, "seid", seid);
3448 vat_json_object_add_string_copy (node, "deid", deid);
3449 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3453 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3454 vat_json_object_add_ip4 (node, "lloc", ip4);
3455 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3456 vat_json_object_add_ip4 (node, "rloc", ip4);
3460 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3461 vat_json_object_add_ip6 (node, "lloc", ip6);
3462 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3463 vat_json_object_add_ip6 (node, "rloc", ip6);
3465 vat_json_object_add_uint (node, "pkt_count",
3466 clib_net_to_host_u32 (mp->pkt_count));
3467 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3474 vl_api_one_eid_table_map_details_t_handler
3475 (vl_api_one_eid_table_map_details_t * mp)
3477 vat_main_t *vam = &vat_main;
3479 u8 *line = format (0, "%=10d%=10d",
3480 clib_net_to_host_u32 (mp->vni),
3481 clib_net_to_host_u32 (mp->dp_table));
3482 print (vam->ofp, "%v", line);
3487 vl_api_one_eid_table_map_details_t_handler_json
3488 (vl_api_one_eid_table_map_details_t * mp)
3490 vat_main_t *vam = &vat_main;
3491 vat_json_node_t *node = NULL;
3493 if (VAT_JSON_ARRAY != vam->json_tree.type)
3495 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3496 vat_json_init_array (&vam->json_tree);
3498 node = vat_json_array_add (&vam->json_tree);
3499 vat_json_init_object (node);
3500 vat_json_object_add_uint (node, "dp_table",
3501 clib_net_to_host_u32 (mp->dp_table));
3502 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3506 vl_api_one_eid_table_vni_details_t_handler
3507 (vl_api_one_eid_table_vni_details_t * mp)
3509 vat_main_t *vam = &vat_main;
3511 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3512 print (vam->ofp, "%v", line);
3517 vl_api_one_eid_table_vni_details_t_handler_json
3518 (vl_api_one_eid_table_vni_details_t * mp)
3520 vat_main_t *vam = &vat_main;
3521 vat_json_node_t *node = NULL;
3523 if (VAT_JSON_ARRAY != vam->json_tree.type)
3525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3526 vat_json_init_array (&vam->json_tree);
3528 node = vat_json_array_add (&vam->json_tree);
3529 vat_json_init_object (node);
3530 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3534 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3535 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3537 vat_main_t *vam = &vat_main;
3538 int retval = clib_net_to_host_u32 (mp->retval);
3540 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3541 print (vam->ofp, "fallback threshold value: %d", mp->value);
3543 vam->retval = retval;
3544 vam->result_ready = 1;
3548 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3549 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3551 vat_main_t *vam = &vat_main;
3552 vat_json_node_t _node, *node = &_node;
3553 int retval = clib_net_to_host_u32 (mp->retval);
3555 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3556 vat_json_init_object (node);
3557 vat_json_object_add_uint (node, "value", mp->value);
3559 vat_json_print (vam->ofp, node);
3560 vat_json_free (node);
3562 vam->retval = retval;
3563 vam->result_ready = 1;
3567 vl_api_show_one_map_register_state_reply_t_handler
3568 (vl_api_show_one_map_register_state_reply_t * mp)
3570 vat_main_t *vam = &vat_main;
3571 int retval = clib_net_to_host_u32 (mp->retval);
3573 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3575 vam->retval = retval;
3576 vam->result_ready = 1;
3580 vl_api_show_one_map_register_state_reply_t_handler_json
3581 (vl_api_show_one_map_register_state_reply_t * mp)
3583 vat_main_t *vam = &vat_main;
3584 vat_json_node_t _node, *node = &_node;
3585 int retval = clib_net_to_host_u32 (mp->retval);
3587 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3589 vat_json_init_object (node);
3590 vat_json_object_add_string_copy (node, "state", s);
3592 vat_json_print (vam->ofp, node);
3593 vat_json_free (node);
3595 vam->retval = retval;
3596 vam->result_ready = 1;
3601 vl_api_show_one_rloc_probe_state_reply_t_handler
3602 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3604 vat_main_t *vam = &vat_main;
3605 int retval = clib_net_to_host_u32 (mp->retval);
3610 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3612 vam->retval = retval;
3613 vam->result_ready = 1;
3617 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3618 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3620 vat_main_t *vam = &vat_main;
3621 vat_json_node_t _node, *node = &_node;
3622 int retval = clib_net_to_host_u32 (mp->retval);
3624 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3625 vat_json_init_object (node);
3626 vat_json_object_add_string_copy (node, "state", s);
3628 vat_json_print (vam->ofp, node);
3629 vat_json_free (node);
3631 vam->retval = retval;
3632 vam->result_ready = 1;
3637 vl_api_show_one_stats_enable_disable_reply_t_handler
3638 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3640 vat_main_t *vam = &vat_main;
3641 int retval = clib_net_to_host_u32 (mp->retval);
3646 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3648 vam->retval = retval;
3649 vam->result_ready = 1;
3653 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3654 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3656 vat_main_t *vam = &vat_main;
3657 vat_json_node_t _node, *node = &_node;
3658 int retval = clib_net_to_host_u32 (mp->retval);
3660 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3661 vat_json_init_object (node);
3662 vat_json_object_add_string_copy (node, "state", s);
3664 vat_json_print (vam->ofp, node);
3665 vat_json_free (node);
3667 vam->retval = retval;
3668 vam->result_ready = 1;
3673 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3675 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3676 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3677 e->vni = clib_net_to_host_u32 (e->vni);
3681 gpe_fwd_entries_get_reply_t_net_to_host
3682 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3686 mp->count = clib_net_to_host_u32 (mp->count);
3687 for (i = 0; i < mp->count; i++)
3689 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3694 format_gpe_encap_mode (u8 * s, va_list * args)
3696 u32 mode = va_arg (*args, u32);
3701 return format (s, "lisp");
3703 return format (s, "vxlan");
3709 vl_api_gpe_get_encap_mode_reply_t_handler
3710 (vl_api_gpe_get_encap_mode_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3714 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3715 vam->retval = ntohl (mp->retval);
3716 vam->result_ready = 1;
3720 vl_api_gpe_get_encap_mode_reply_t_handler_json
3721 (vl_api_gpe_get_encap_mode_reply_t * mp)
3723 vat_main_t *vam = &vat_main;
3724 vat_json_node_t node;
3726 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3727 vec_add1 (encap_mode, 0);
3729 vat_json_init_object (&node);
3730 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3732 vec_free (encap_mode);
3733 vat_json_print (vam->ofp, &node);
3734 vat_json_free (&node);
3736 vam->retval = ntohl (mp->retval);
3737 vam->result_ready = 1;
3741 vl_api_gpe_fwd_entry_path_details_t_handler
3742 (vl_api_gpe_fwd_entry_path_details_t * mp)
3744 vat_main_t *vam = &vat_main;
3745 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3747 if (mp->lcl_loc.is_ip4)
3748 format_ip_address_fcn = format_ip4_address;
3750 format_ip_address_fcn = format_ip6_address;
3752 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3753 format_ip_address_fcn, &mp->lcl_loc,
3754 format_ip_address_fcn, &mp->rmt_loc);
3758 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3760 struct in6_addr ip6;
3765 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3766 vat_json_object_add_ip4 (n, "address", ip4);
3770 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3771 vat_json_object_add_ip6 (n, "address", ip6);
3773 vat_json_object_add_uint (n, "weight", loc->weight);
3777 vl_api_gpe_fwd_entry_path_details_t_handler_json
3778 (vl_api_gpe_fwd_entry_path_details_t * mp)
3780 vat_main_t *vam = &vat_main;
3781 vat_json_node_t *node = NULL;
3782 vat_json_node_t *loc_node;
3784 if (VAT_JSON_ARRAY != vam->json_tree.type)
3786 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3787 vat_json_init_array (&vam->json_tree);
3789 node = vat_json_array_add (&vam->json_tree);
3790 vat_json_init_object (node);
3792 loc_node = vat_json_object_add (node, "local_locator");
3793 vat_json_init_object (loc_node);
3794 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3796 loc_node = vat_json_object_add (node, "remote_locator");
3797 vat_json_init_object (loc_node);
3798 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3802 vl_api_gpe_fwd_entries_get_reply_t_handler
3803 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3805 vat_main_t *vam = &vat_main;
3807 int retval = clib_net_to_host_u32 (mp->retval);
3808 vl_api_gpe_fwd_entry_t *e;
3813 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3815 for (i = 0; i < mp->count; i++)
3817 e = &mp->entries[i];
3818 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3819 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3820 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3824 vam->retval = retval;
3825 vam->result_ready = 1;
3829 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3830 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3833 vat_main_t *vam = &vat_main;
3834 vat_json_node_t *e = 0, root;
3836 int retval = clib_net_to_host_u32 (mp->retval);
3837 vl_api_gpe_fwd_entry_t *fwd;
3842 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3843 vat_json_init_array (&root);
3845 for (i = 0; i < mp->count; i++)
3847 e = vat_json_array_add (&root);
3848 fwd = &mp->entries[i];
3850 vat_json_init_object (e);
3851 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3852 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3853 vat_json_object_add_int (e, "vni", fwd->vni);
3854 vat_json_object_add_int (e, "action", fwd->action);
3856 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3857 fwd->leid_prefix_len);
3859 vat_json_object_add_string_copy (e, "leid", s);
3862 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3863 fwd->reid_prefix_len);
3865 vat_json_object_add_string_copy (e, "reid", s);
3869 vat_json_print (vam->ofp, &root);
3870 vat_json_free (&root);
3873 vam->retval = retval;
3874 vam->result_ready = 1;
3878 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3879 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3881 vat_main_t *vam = &vat_main;
3883 int retval = clib_net_to_host_u32 (mp->retval);
3884 vl_api_gpe_native_fwd_rpath_t *r;
3889 n = clib_net_to_host_u32 (mp->count);
3891 for (i = 0; i < n; i++)
3893 r = &mp->entries[i];
3894 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3895 clib_net_to_host_u32 (r->fib_index),
3896 clib_net_to_host_u32 (r->nh_sw_if_index),
3897 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3901 vam->retval = retval;
3902 vam->result_ready = 1;
3906 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3907 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3909 vat_main_t *vam = &vat_main;
3910 vat_json_node_t root, *e;
3912 int retval = clib_net_to_host_u32 (mp->retval);
3913 vl_api_gpe_native_fwd_rpath_t *r;
3919 n = clib_net_to_host_u32 (mp->count);
3920 vat_json_init_array (&root);
3922 for (i = 0; i < n; i++)
3924 e = vat_json_array_add (&root);
3925 vat_json_init_object (e);
3926 r = &mp->entries[i];
3928 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3931 vat_json_object_add_string_copy (e, "ip4", s);
3934 vat_json_object_add_uint (e, "fib_index",
3935 clib_net_to_host_u32 (r->fib_index));
3936 vat_json_object_add_uint (e, "nh_sw_if_index",
3937 clib_net_to_host_u32 (r->nh_sw_if_index));
3940 vat_json_print (vam->ofp, &root);
3941 vat_json_free (&root);
3944 vam->retval = retval;
3945 vam->result_ready = 1;
3949 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3950 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3952 vat_main_t *vam = &vat_main;
3954 int retval = clib_net_to_host_u32 (mp->retval);
3959 n = clib_net_to_host_u32 (mp->count);
3961 for (i = 0; i < n; i++)
3962 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3965 vam->retval = retval;
3966 vam->result_ready = 1;
3970 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3971 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3973 vat_main_t *vam = &vat_main;
3974 vat_json_node_t root;
3976 int retval = clib_net_to_host_u32 (mp->retval);
3981 n = clib_net_to_host_u32 (mp->count);
3982 vat_json_init_array (&root);
3984 for (i = 0; i < n; i++)
3985 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3987 vat_json_print (vam->ofp, &root);
3988 vat_json_free (&root);
3991 vam->retval = retval;
3992 vam->result_ready = 1;
3996 vl_api_one_ndp_entries_get_reply_t_handler
3997 (vl_api_one_ndp_entries_get_reply_t * mp)
3999 vat_main_t *vam = &vat_main;
4001 int retval = clib_net_to_host_u32 (mp->retval);
4006 n = clib_net_to_host_u32 (mp->count);
4008 for (i = 0; i < n; i++)
4009 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4010 format_ethernet_address, mp->entries[i].mac);
4013 vam->retval = retval;
4014 vam->result_ready = 1;
4018 vl_api_one_ndp_entries_get_reply_t_handler_json
4019 (vl_api_one_ndp_entries_get_reply_t * mp)
4022 vat_main_t *vam = &vat_main;
4023 vat_json_node_t *e = 0, root;
4025 int retval = clib_net_to_host_u32 (mp->retval);
4026 vl_api_one_ndp_entry_t *arp_entry;
4031 n = clib_net_to_host_u32 (mp->count);
4032 vat_json_init_array (&root);
4034 for (i = 0; i < n; i++)
4036 e = vat_json_array_add (&root);
4037 arp_entry = &mp->entries[i];
4039 vat_json_init_object (e);
4040 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4043 vat_json_object_add_string_copy (e, "mac", s);
4046 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4048 vat_json_object_add_string_copy (e, "ip6", s);
4052 vat_json_print (vam->ofp, &root);
4053 vat_json_free (&root);
4056 vam->retval = retval;
4057 vam->result_ready = 1;
4061 vl_api_one_l2_arp_entries_get_reply_t_handler
4062 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4064 vat_main_t *vam = &vat_main;
4066 int retval = clib_net_to_host_u32 (mp->retval);
4071 n = clib_net_to_host_u32 (mp->count);
4073 for (i = 0; i < n; i++)
4074 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4075 format_ethernet_address, mp->entries[i].mac);
4078 vam->retval = retval;
4079 vam->result_ready = 1;
4083 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4084 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4087 vat_main_t *vam = &vat_main;
4088 vat_json_node_t *e = 0, root;
4090 int retval = clib_net_to_host_u32 (mp->retval);
4091 vl_api_one_l2_arp_entry_t *arp_entry;
4096 n = clib_net_to_host_u32 (mp->count);
4097 vat_json_init_array (&root);
4099 for (i = 0; i < n; i++)
4101 e = vat_json_array_add (&root);
4102 arp_entry = &mp->entries[i];
4104 vat_json_init_object (e);
4105 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4108 vat_json_object_add_string_copy (e, "mac", s);
4111 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4113 vat_json_object_add_string_copy (e, "ip4", s);
4117 vat_json_print (vam->ofp, &root);
4118 vat_json_free (&root);
4121 vam->retval = retval;
4122 vam->result_ready = 1;
4126 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4128 vat_main_t *vam = &vat_main;
4130 int retval = clib_net_to_host_u32 (mp->retval);
4135 n = clib_net_to_host_u32 (mp->count);
4137 for (i = 0; i < n; i++)
4139 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4143 vam->retval = retval;
4144 vam->result_ready = 1;
4148 vl_api_one_ndp_bd_get_reply_t_handler_json
4149 (vl_api_one_ndp_bd_get_reply_t * mp)
4151 vat_main_t *vam = &vat_main;
4152 vat_json_node_t root;
4154 int retval = clib_net_to_host_u32 (mp->retval);
4159 n = clib_net_to_host_u32 (mp->count);
4160 vat_json_init_array (&root);
4162 for (i = 0; i < n; i++)
4164 vat_json_array_add_uint (&root,
4165 clib_net_to_host_u32 (mp->bridge_domains[i]));
4168 vat_json_print (vam->ofp, &root);
4169 vat_json_free (&root);
4172 vam->retval = retval;
4173 vam->result_ready = 1;
4177 vl_api_one_l2_arp_bd_get_reply_t_handler
4178 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4180 vat_main_t *vam = &vat_main;
4182 int retval = clib_net_to_host_u32 (mp->retval);
4187 n = clib_net_to_host_u32 (mp->count);
4189 for (i = 0; i < n; i++)
4191 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4195 vam->retval = retval;
4196 vam->result_ready = 1;
4200 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4201 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4203 vat_main_t *vam = &vat_main;
4204 vat_json_node_t root;
4206 int retval = clib_net_to_host_u32 (mp->retval);
4211 n = clib_net_to_host_u32 (mp->count);
4212 vat_json_init_array (&root);
4214 for (i = 0; i < n; i++)
4216 vat_json_array_add_uint (&root,
4217 clib_net_to_host_u32 (mp->bridge_domains[i]));
4220 vat_json_print (vam->ofp, &root);
4221 vat_json_free (&root);
4224 vam->retval = retval;
4225 vam->result_ready = 1;
4229 vl_api_one_adjacencies_get_reply_t_handler
4230 (vl_api_one_adjacencies_get_reply_t * mp)
4232 vat_main_t *vam = &vat_main;
4234 int retval = clib_net_to_host_u32 (mp->retval);
4235 vl_api_one_adjacency_t *a;
4240 n = clib_net_to_host_u32 (mp->count);
4242 for (i = 0; i < n; i++)
4244 a = &mp->adjacencies[i];
4245 print (vam->ofp, "%U %40U",
4246 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4247 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4251 vam->retval = retval;
4252 vam->result_ready = 1;
4256 vl_api_one_adjacencies_get_reply_t_handler_json
4257 (vl_api_one_adjacencies_get_reply_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 vat_json_node_t *e = 0, root;
4263 int retval = clib_net_to_host_u32 (mp->retval);
4264 vl_api_one_adjacency_t *a;
4269 n = clib_net_to_host_u32 (mp->count);
4270 vat_json_init_array (&root);
4272 for (i = 0; i < n; i++)
4274 e = vat_json_array_add (&root);
4275 a = &mp->adjacencies[i];
4277 vat_json_init_object (e);
4278 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4279 a->leid_prefix_len);
4281 vat_json_object_add_string_copy (e, "leid", s);
4284 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4285 a->reid_prefix_len);
4287 vat_json_object_add_string_copy (e, "reid", s);
4291 vat_json_print (vam->ofp, &root);
4292 vat_json_free (&root);
4295 vam->retval = retval;
4296 vam->result_ready = 1;
4300 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4302 vat_main_t *vam = &vat_main;
4304 print (vam->ofp, "%=20U",
4305 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4310 vl_api_one_map_server_details_t_handler_json
4311 (vl_api_one_map_server_details_t * mp)
4313 vat_main_t *vam = &vat_main;
4314 vat_json_node_t *node = NULL;
4315 struct in6_addr ip6;
4318 if (VAT_JSON_ARRAY != vam->json_tree.type)
4320 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4321 vat_json_init_array (&vam->json_tree);
4323 node = vat_json_array_add (&vam->json_tree);
4325 vat_json_init_object (node);
4328 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4329 vat_json_object_add_ip6 (node, "map-server", ip6);
4333 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4334 vat_json_object_add_ip4 (node, "map-server", ip4);
4339 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4342 vat_main_t *vam = &vat_main;
4344 print (vam->ofp, "%=20U",
4345 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4350 vl_api_one_map_resolver_details_t_handler_json
4351 (vl_api_one_map_resolver_details_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 vat_json_node_t *node = NULL;
4355 struct in6_addr ip6;
4358 if (VAT_JSON_ARRAY != vam->json_tree.type)
4360 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4361 vat_json_init_array (&vam->json_tree);
4363 node = vat_json_array_add (&vam->json_tree);
4365 vat_json_init_object (node);
4368 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4369 vat_json_object_add_ip6 (node, "map resolver", ip6);
4373 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4374 vat_json_object_add_ip4 (node, "map resolver", ip4);
4379 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4381 vat_main_t *vam = &vat_main;
4382 i32 retval = ntohl (mp->retval);
4386 print (vam->ofp, "feature: %s\ngpe: %s",
4387 mp->feature_status ? "enabled" : "disabled",
4388 mp->gpe_status ? "enabled" : "disabled");
4391 vam->retval = retval;
4392 vam->result_ready = 1;
4396 vl_api_show_one_status_reply_t_handler_json
4397 (vl_api_show_one_status_reply_t * mp)
4399 vat_main_t *vam = &vat_main;
4400 vat_json_node_t node;
4401 u8 *gpe_status = NULL;
4402 u8 *feature_status = NULL;
4404 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4405 feature_status = format (0, "%s",
4406 mp->feature_status ? "enabled" : "disabled");
4407 vec_add1 (gpe_status, 0);
4408 vec_add1 (feature_status, 0);
4410 vat_json_init_object (&node);
4411 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4412 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4414 vec_free (gpe_status);
4415 vec_free (feature_status);
4417 vat_json_print (vam->ofp, &node);
4418 vat_json_free (&node);
4420 vam->retval = ntohl (mp->retval);
4421 vam->result_ready = 1;
4425 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4426 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4428 vat_main_t *vam = &vat_main;
4429 i32 retval = ntohl (mp->retval);
4433 print (vam->ofp, "%=20s", mp->locator_set_name);
4436 vam->retval = retval;
4437 vam->result_ready = 1;
4441 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4442 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4444 vat_main_t *vam = &vat_main;
4445 vat_json_node_t *node = NULL;
4447 if (VAT_JSON_ARRAY != vam->json_tree.type)
4449 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4450 vat_json_init_array (&vam->json_tree);
4452 node = vat_json_array_add (&vam->json_tree);
4454 vat_json_init_object (node);
4455 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4457 vat_json_print (vam->ofp, node);
4458 vat_json_free (node);
4460 vam->retval = ntohl (mp->retval);
4461 vam->result_ready = 1;
4465 format_lisp_map_request_mode (u8 * s, va_list * args)
4467 u32 mode = va_arg (*args, u32);
4472 return format (0, "dst-only");
4474 return format (0, "src-dst");
4480 vl_api_show_one_map_request_mode_reply_t_handler
4481 (vl_api_show_one_map_request_mode_reply_t * mp)
4483 vat_main_t *vam = &vat_main;
4484 i32 retval = ntohl (mp->retval);
4488 u32 mode = mp->mode;
4489 print (vam->ofp, "map_request_mode: %U",
4490 format_lisp_map_request_mode, mode);
4493 vam->retval = retval;
4494 vam->result_ready = 1;
4498 vl_api_show_one_map_request_mode_reply_t_handler_json
4499 (vl_api_show_one_map_request_mode_reply_t * mp)
4501 vat_main_t *vam = &vat_main;
4502 vat_json_node_t node;
4507 s = format (0, "%U", format_lisp_map_request_mode, mode);
4510 vat_json_init_object (&node);
4511 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4512 vat_json_print (vam->ofp, &node);
4513 vat_json_free (&node);
4516 vam->retval = ntohl (mp->retval);
4517 vam->result_ready = 1;
4521 vl_api_one_show_xtr_mode_reply_t_handler
4522 (vl_api_one_show_xtr_mode_reply_t * mp)
4524 vat_main_t *vam = &vat_main;
4525 i32 retval = ntohl (mp->retval);
4529 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4532 vam->retval = retval;
4533 vam->result_ready = 1;
4537 vl_api_one_show_xtr_mode_reply_t_handler_json
4538 (vl_api_one_show_xtr_mode_reply_t * mp)
4540 vat_main_t *vam = &vat_main;
4541 vat_json_node_t node;
4544 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4545 vec_add1 (status, 0);
4547 vat_json_init_object (&node);
4548 vat_json_object_add_string_copy (&node, "status", status);
4552 vat_json_print (vam->ofp, &node);
4553 vat_json_free (&node);
4555 vam->retval = ntohl (mp->retval);
4556 vam->result_ready = 1;
4560 vl_api_one_show_pitr_mode_reply_t_handler
4561 (vl_api_one_show_pitr_mode_reply_t * mp)
4563 vat_main_t *vam = &vat_main;
4564 i32 retval = ntohl (mp->retval);
4568 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4571 vam->retval = retval;
4572 vam->result_ready = 1;
4576 vl_api_one_show_pitr_mode_reply_t_handler_json
4577 (vl_api_one_show_pitr_mode_reply_t * mp)
4579 vat_main_t *vam = &vat_main;
4580 vat_json_node_t node;
4583 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4584 vec_add1 (status, 0);
4586 vat_json_init_object (&node);
4587 vat_json_object_add_string_copy (&node, "status", status);
4591 vat_json_print (vam->ofp, &node);
4592 vat_json_free (&node);
4594 vam->retval = ntohl (mp->retval);
4595 vam->result_ready = 1;
4599 vl_api_one_show_petr_mode_reply_t_handler
4600 (vl_api_one_show_petr_mode_reply_t * mp)
4602 vat_main_t *vam = &vat_main;
4603 i32 retval = ntohl (mp->retval);
4607 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4610 vam->retval = retval;
4611 vam->result_ready = 1;
4615 vl_api_one_show_petr_mode_reply_t_handler_json
4616 (vl_api_one_show_petr_mode_reply_t * mp)
4618 vat_main_t *vam = &vat_main;
4619 vat_json_node_t node;
4622 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4623 vec_add1 (status, 0);
4625 vat_json_init_object (&node);
4626 vat_json_object_add_string_copy (&node, "status", status);
4630 vat_json_print (vam->ofp, &node);
4631 vat_json_free (&node);
4633 vam->retval = ntohl (mp->retval);
4634 vam->result_ready = 1;
4638 vl_api_show_one_use_petr_reply_t_handler
4639 (vl_api_show_one_use_petr_reply_t * mp)
4641 vat_main_t *vam = &vat_main;
4642 i32 retval = ntohl (mp->retval);
4646 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4649 print (vam->ofp, "Proxy-ETR address; %U",
4650 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4655 vam->retval = retval;
4656 vam->result_ready = 1;
4660 vl_api_show_one_use_petr_reply_t_handler_json
4661 (vl_api_show_one_use_petr_reply_t * mp)
4663 vat_main_t *vam = &vat_main;
4664 vat_json_node_t node;
4667 struct in6_addr ip6;
4669 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4670 vec_add1 (status, 0);
4672 vat_json_init_object (&node);
4673 vat_json_object_add_string_copy (&node, "status", status);
4678 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4679 vat_json_object_add_ip6 (&node, "address", ip6);
4683 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4684 vat_json_object_add_ip4 (&node, "address", ip4);
4690 vat_json_print (vam->ofp, &node);
4691 vat_json_free (&node);
4693 vam->retval = ntohl (mp->retval);
4694 vam->result_ready = 1;
4698 vl_api_show_one_nsh_mapping_reply_t_handler
4699 (vl_api_show_one_nsh_mapping_reply_t * mp)
4701 vat_main_t *vam = &vat_main;
4702 i32 retval = ntohl (mp->retval);
4706 print (vam->ofp, "%-20s%-16s",
4707 mp->is_set ? "set" : "not-set",
4708 mp->is_set ? (char *) mp->locator_set_name : "");
4711 vam->retval = retval;
4712 vam->result_ready = 1;
4716 vl_api_show_one_nsh_mapping_reply_t_handler_json
4717 (vl_api_show_one_nsh_mapping_reply_t * mp)
4719 vat_main_t *vam = &vat_main;
4720 vat_json_node_t node;
4723 status = format (0, "%s", mp->is_set ? "yes" : "no");
4724 vec_add1 (status, 0);
4726 vat_json_init_object (&node);
4727 vat_json_object_add_string_copy (&node, "is_set", status);
4730 vat_json_object_add_string_copy (&node, "locator_set",
4731 mp->locator_set_name);
4736 vat_json_print (vam->ofp, &node);
4737 vat_json_free (&node);
4739 vam->retval = ntohl (mp->retval);
4740 vam->result_ready = 1;
4744 vl_api_show_one_map_register_ttl_reply_t_handler
4745 (vl_api_show_one_map_register_ttl_reply_t * mp)
4747 vat_main_t *vam = &vat_main;
4748 i32 retval = ntohl (mp->retval);
4750 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4754 print (vam->ofp, "ttl: %u", mp->ttl);
4757 vam->retval = retval;
4758 vam->result_ready = 1;
4762 vl_api_show_one_map_register_ttl_reply_t_handler_json
4763 (vl_api_show_one_map_register_ttl_reply_t * mp)
4765 vat_main_t *vam = &vat_main;
4766 vat_json_node_t node;
4768 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4769 vat_json_init_object (&node);
4770 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4772 vat_json_print (vam->ofp, &node);
4773 vat_json_free (&node);
4775 vam->retval = ntohl (mp->retval);
4776 vam->result_ready = 1;
4780 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4782 vat_main_t *vam = &vat_main;
4783 i32 retval = ntohl (mp->retval);
4787 print (vam->ofp, "%-20s%-16s",
4788 mp->status ? "enabled" : "disabled",
4789 mp->status ? (char *) mp->locator_set_name : "");
4792 vam->retval = retval;
4793 vam->result_ready = 1;
4797 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4799 vat_main_t *vam = &vat_main;
4800 vat_json_node_t node;
4803 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4804 vec_add1 (status, 0);
4806 vat_json_init_object (&node);
4807 vat_json_object_add_string_copy (&node, "status", status);
4810 vat_json_object_add_string_copy (&node, "locator_set",
4811 mp->locator_set_name);
4816 vat_json_print (vam->ofp, &node);
4817 vat_json_free (&node);
4819 vam->retval = ntohl (mp->retval);
4820 vam->result_ready = 1;
4824 format_policer_type (u8 * s, va_list * va)
4826 u32 i = va_arg (*va, u32);
4828 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4829 s = format (s, "1r2c");
4830 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4831 s = format (s, "1r3c");
4832 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4833 s = format (s, "2r3c-2698");
4834 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4835 s = format (s, "2r3c-4115");
4836 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4837 s = format (s, "2r3c-mef5cf1");
4839 s = format (s, "ILLEGAL");
4844 format_policer_rate_type (u8 * s, va_list * va)
4846 u32 i = va_arg (*va, u32);
4848 if (i == SSE2_QOS_RATE_KBPS)
4849 s = format (s, "kbps");
4850 else if (i == SSE2_QOS_RATE_PPS)
4851 s = format (s, "pps");
4853 s = format (s, "ILLEGAL");
4858 format_policer_round_type (u8 * s, va_list * va)
4860 u32 i = va_arg (*va, u32);
4862 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4863 s = format (s, "closest");
4864 else if (i == SSE2_QOS_ROUND_TO_UP)
4865 s = format (s, "up");
4866 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4867 s = format (s, "down");
4869 s = format (s, "ILLEGAL");
4874 format_policer_action_type (u8 * s, va_list * va)
4876 u32 i = va_arg (*va, u32);
4878 if (i == SSE2_QOS_ACTION_DROP)
4879 s = format (s, "drop");
4880 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4881 s = format (s, "transmit");
4882 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4883 s = format (s, "mark-and-transmit");
4885 s = format (s, "ILLEGAL");
4890 format_dscp (u8 * s, va_list * va)
4892 u32 i = va_arg (*va, u32);
4897 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4901 return format (s, "ILLEGAL");
4903 s = format (s, "%s", t);
4908 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4910 vat_main_t *vam = &vat_main;
4911 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4913 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4914 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4916 conform_dscp_str = format (0, "");
4918 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4919 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4921 exceed_dscp_str = format (0, "");
4923 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4924 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4926 violate_dscp_str = format (0, "");
4928 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4929 "rate type %U, round type %U, %s rate, %s color-aware, "
4930 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4931 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4932 "conform action %U%s, exceed action %U%s, violate action %U%s",
4934 format_policer_type, mp->type,
4937 clib_net_to_host_u64 (mp->cb),
4938 clib_net_to_host_u64 (mp->eb),
4939 format_policer_rate_type, mp->rate_type,
4940 format_policer_round_type, mp->round_type,
4941 mp->single_rate ? "single" : "dual",
4942 mp->color_aware ? "is" : "not",
4943 ntohl (mp->cir_tokens_per_period),
4944 ntohl (mp->pir_tokens_per_period),
4946 ntohl (mp->current_limit),
4947 ntohl (mp->current_bucket),
4948 ntohl (mp->extended_limit),
4949 ntohl (mp->extended_bucket),
4950 clib_net_to_host_u64 (mp->last_update_time),
4951 format_policer_action_type, mp->conform_action_type,
4953 format_policer_action_type, mp->exceed_action_type,
4955 format_policer_action_type, mp->violate_action_type,
4958 vec_free (conform_dscp_str);
4959 vec_free (exceed_dscp_str);
4960 vec_free (violate_dscp_str);
4963 static void vl_api_policer_details_t_handler_json
4964 (vl_api_policer_details_t * mp)
4966 vat_main_t *vam = &vat_main;
4967 vat_json_node_t *node;
4968 u8 *rate_type_str, *round_type_str, *type_str;
4969 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4971 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4973 format (0, "%U", format_policer_round_type, mp->round_type);
4974 type_str = format (0, "%U", format_policer_type, mp->type);
4975 conform_action_str = format (0, "%U", format_policer_action_type,
4976 mp->conform_action_type);
4977 exceed_action_str = format (0, "%U", format_policer_action_type,
4978 mp->exceed_action_type);
4979 violate_action_str = format (0, "%U", format_policer_action_type,
4980 mp->violate_action_type);
4982 if (VAT_JSON_ARRAY != vam->json_tree.type)
4984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4985 vat_json_init_array (&vam->json_tree);
4987 node = vat_json_array_add (&vam->json_tree);
4989 vat_json_init_object (node);
4990 vat_json_object_add_string_copy (node, "name", mp->name);
4991 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4992 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4993 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4994 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4995 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4996 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4997 vat_json_object_add_string_copy (node, "type", type_str);
4998 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4999 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5000 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5001 vat_json_object_add_uint (node, "cir_tokens_per_period",
5002 ntohl (mp->cir_tokens_per_period));
5003 vat_json_object_add_uint (node, "eir_tokens_per_period",
5004 ntohl (mp->pir_tokens_per_period));
5005 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5006 vat_json_object_add_uint (node, "current_bucket",
5007 ntohl (mp->current_bucket));
5008 vat_json_object_add_uint (node, "extended_limit",
5009 ntohl (mp->extended_limit));
5010 vat_json_object_add_uint (node, "extended_bucket",
5011 ntohl (mp->extended_bucket));
5012 vat_json_object_add_uint (node, "last_update_time",
5013 ntohl (mp->last_update_time));
5014 vat_json_object_add_string_copy (node, "conform_action",
5015 conform_action_str);
5016 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5018 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5019 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5020 vec_free (dscp_str);
5022 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5023 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5025 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5026 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5027 vec_free (dscp_str);
5029 vat_json_object_add_string_copy (node, "violate_action",
5030 violate_action_str);
5031 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5033 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5034 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5035 vec_free (dscp_str);
5038 vec_free (rate_type_str);
5039 vec_free (round_type_str);
5040 vec_free (type_str);
5041 vec_free (conform_action_str);
5042 vec_free (exceed_action_str);
5043 vec_free (violate_action_str);
5047 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5050 vat_main_t *vam = &vat_main;
5051 int i, count = ntohl (mp->count);
5054 print (vam->ofp, "classify table ids (%d) : ", count);
5055 for (i = 0; i < count; i++)
5057 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5058 print (vam->ofp, (i < count - 1) ? "," : "");
5060 vam->retval = ntohl (mp->retval);
5061 vam->result_ready = 1;
5065 vl_api_classify_table_ids_reply_t_handler_json
5066 (vl_api_classify_table_ids_reply_t * mp)
5068 vat_main_t *vam = &vat_main;
5069 int i, count = ntohl (mp->count);
5073 vat_json_node_t node;
5075 vat_json_init_object (&node);
5076 for (i = 0; i < count; i++)
5078 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5080 vat_json_print (vam->ofp, &node);
5081 vat_json_free (&node);
5083 vam->retval = ntohl (mp->retval);
5084 vam->result_ready = 1;
5088 vl_api_classify_table_by_interface_reply_t_handler
5089 (vl_api_classify_table_by_interface_reply_t * mp)
5091 vat_main_t *vam = &vat_main;
5094 table_id = ntohl (mp->l2_table_id);
5096 print (vam->ofp, "l2 table id : %d", table_id);
5098 print (vam->ofp, "l2 table id : No input ACL tables configured");
5099 table_id = ntohl (mp->ip4_table_id);
5101 print (vam->ofp, "ip4 table id : %d", table_id);
5103 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5104 table_id = ntohl (mp->ip6_table_id);
5106 print (vam->ofp, "ip6 table id : %d", table_id);
5108 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5109 vam->retval = ntohl (mp->retval);
5110 vam->result_ready = 1;
5114 vl_api_classify_table_by_interface_reply_t_handler_json
5115 (vl_api_classify_table_by_interface_reply_t * mp)
5117 vat_main_t *vam = &vat_main;
5118 vat_json_node_t node;
5120 vat_json_init_object (&node);
5122 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5123 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5124 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5126 vat_json_print (vam->ofp, &node);
5127 vat_json_free (&node);
5129 vam->retval = ntohl (mp->retval);
5130 vam->result_ready = 1;
5133 static void vl_api_policer_add_del_reply_t_handler
5134 (vl_api_policer_add_del_reply_t * mp)
5136 vat_main_t *vam = &vat_main;
5137 i32 retval = ntohl (mp->retval);
5138 if (vam->async_mode)
5140 vam->async_errors += (retval < 0);
5144 vam->retval = retval;
5145 vam->result_ready = 1;
5146 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5148 * Note: this is just barely thread-safe, depends on
5149 * the main thread spinning waiting for an answer...
5151 errmsg ("policer index %d", ntohl (mp->policer_index));
5155 static void vl_api_policer_add_del_reply_t_handler_json
5156 (vl_api_policer_add_del_reply_t * mp)
5158 vat_main_t *vam = &vat_main;
5159 vat_json_node_t node;
5161 vat_json_init_object (&node);
5162 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5163 vat_json_object_add_uint (&node, "policer_index",
5164 ntohl (mp->policer_index));
5166 vat_json_print (vam->ofp, &node);
5167 vat_json_free (&node);
5169 vam->retval = ntohl (mp->retval);
5170 vam->result_ready = 1;
5173 /* Format hex dump. */
5175 format_hex_bytes (u8 * s, va_list * va)
5177 u8 *bytes = va_arg (*va, u8 *);
5178 int n_bytes = va_arg (*va, int);
5181 /* Print short or long form depending on byte count. */
5182 uword short_form = n_bytes <= 32;
5183 u32 indent = format_get_indent (s);
5188 for (i = 0; i < n_bytes; i++)
5190 if (!short_form && (i % 32) == 0)
5191 s = format (s, "%08x: ", i);
5192 s = format (s, "%02x", bytes[i]);
5193 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5194 s = format (s, "\n%U", format_white_space, indent);
5201 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5204 vat_main_t *vam = &vat_main;
5205 i32 retval = ntohl (mp->retval);
5208 print (vam->ofp, "classify table info :");
5209 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5210 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5211 ntohl (mp->miss_next_index));
5212 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5213 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5214 ntohl (mp->match_n_vectors));
5215 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5216 ntohl (mp->mask_length));
5218 vam->retval = retval;
5219 vam->result_ready = 1;
5223 vl_api_classify_table_info_reply_t_handler_json
5224 (vl_api_classify_table_info_reply_t * mp)
5226 vat_main_t *vam = &vat_main;
5227 vat_json_node_t node;
5229 i32 retval = ntohl (mp->retval);
5232 vat_json_init_object (&node);
5234 vat_json_object_add_int (&node, "sessions",
5235 ntohl (mp->active_sessions));
5236 vat_json_object_add_int (&node, "nexttbl",
5237 ntohl (mp->next_table_index));
5238 vat_json_object_add_int (&node, "nextnode",
5239 ntohl (mp->miss_next_index));
5240 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5241 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5242 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5243 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5244 ntohl (mp->mask_length), 0);
5245 vat_json_object_add_string_copy (&node, "mask", s);
5247 vat_json_print (vam->ofp, &node);
5248 vat_json_free (&node);
5250 vam->retval = ntohl (mp->retval);
5251 vam->result_ready = 1;
5255 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5258 vat_main_t *vam = &vat_main;
5260 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5261 ntohl (mp->hit_next_index), ntohl (mp->advance),
5262 ntohl (mp->opaque_index));
5263 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5264 ntohl (mp->match_length));
5268 vl_api_classify_session_details_t_handler_json
5269 (vl_api_classify_session_details_t * mp)
5271 vat_main_t *vam = &vat_main;
5272 vat_json_node_t *node = NULL;
5274 if (VAT_JSON_ARRAY != vam->json_tree.type)
5276 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5277 vat_json_init_array (&vam->json_tree);
5279 node = vat_json_array_add (&vam->json_tree);
5281 vat_json_init_object (node);
5282 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5283 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5284 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5286 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5288 vat_json_object_add_string_copy (node, "match", s);
5291 static void vl_api_pg_create_interface_reply_t_handler
5292 (vl_api_pg_create_interface_reply_t * mp)
5294 vat_main_t *vam = &vat_main;
5296 vam->retval = ntohl (mp->retval);
5297 vam->result_ready = 1;
5300 static void vl_api_pg_create_interface_reply_t_handler_json
5301 (vl_api_pg_create_interface_reply_t * mp)
5303 vat_main_t *vam = &vat_main;
5304 vat_json_node_t node;
5306 i32 retval = ntohl (mp->retval);
5309 vat_json_init_object (&node);
5311 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5313 vat_json_print (vam->ofp, &node);
5314 vat_json_free (&node);
5316 vam->retval = ntohl (mp->retval);
5317 vam->result_ready = 1;
5320 static void vl_api_policer_classify_details_t_handler
5321 (vl_api_policer_classify_details_t * mp)
5323 vat_main_t *vam = &vat_main;
5325 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5326 ntohl (mp->table_index));
5329 static void vl_api_policer_classify_details_t_handler_json
5330 (vl_api_policer_classify_details_t * mp)
5332 vat_main_t *vam = &vat_main;
5333 vat_json_node_t *node;
5335 if (VAT_JSON_ARRAY != vam->json_tree.type)
5337 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5338 vat_json_init_array (&vam->json_tree);
5340 node = vat_json_array_add (&vam->json_tree);
5342 vat_json_init_object (node);
5343 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5344 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5347 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5348 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5350 vat_main_t *vam = &vat_main;
5351 i32 retval = ntohl (mp->retval);
5352 if (vam->async_mode)
5354 vam->async_errors += (retval < 0);
5358 vam->retval = retval;
5359 vam->sw_if_index = ntohl (mp->sw_if_index);
5360 vam->result_ready = 1;
5362 vam->regenerate_interface_table = 1;
5365 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5366 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5368 vat_main_t *vam = &vat_main;
5369 vat_json_node_t node;
5371 vat_json_init_object (&node);
5372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5373 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5375 vat_json_print (vam->ofp, &node);
5376 vat_json_free (&node);
5378 vam->retval = ntohl (mp->retval);
5379 vam->result_ready = 1;
5382 static void vl_api_flow_classify_details_t_handler
5383 (vl_api_flow_classify_details_t * mp)
5385 vat_main_t *vam = &vat_main;
5387 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5388 ntohl (mp->table_index));
5391 static void vl_api_flow_classify_details_t_handler_json
5392 (vl_api_flow_classify_details_t * mp)
5394 vat_main_t *vam = &vat_main;
5395 vat_json_node_t *node;
5397 if (VAT_JSON_ARRAY != vam->json_tree.type)
5399 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5400 vat_json_init_array (&vam->json_tree);
5402 node = vat_json_array_add (&vam->json_tree);
5404 vat_json_init_object (node);
5405 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5406 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5409 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5410 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5411 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5412 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5413 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5414 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5415 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5416 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5417 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5418 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5419 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5420 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5421 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5422 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5423 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5424 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5425 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5426 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5427 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5428 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5429 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5430 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5433 * Generate boilerplate reply handlers, which
5434 * dig the return value out of the xxx_reply_t API message,
5435 * stick it into vam->retval, and set vam->result_ready
5437 * Could also do this by pointing N message decode slots at
5438 * a single function, but that could break in subtle ways.
5441 #define foreach_standard_reply_retval_handler \
5442 _(sw_interface_set_flags_reply) \
5443 _(sw_interface_add_del_address_reply) \
5444 _(sw_interface_set_rx_mode_reply) \
5445 _(sw_interface_set_table_reply) \
5446 _(sw_interface_set_mpls_enable_reply) \
5447 _(sw_interface_set_vpath_reply) \
5448 _(sw_interface_set_vxlan_bypass_reply) \
5449 _(sw_interface_set_geneve_bypass_reply) \
5450 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5451 _(sw_interface_set_l2_bridge_reply) \
5452 _(bridge_domain_add_del_reply) \
5453 _(sw_interface_set_l2_xconnect_reply) \
5454 _(l2fib_add_del_reply) \
5455 _(l2fib_flush_int_reply) \
5456 _(l2fib_flush_bd_reply) \
5457 _(ip_add_del_route_reply) \
5458 _(ip_table_add_del_reply) \
5459 _(ip_mroute_add_del_reply) \
5460 _(mpls_route_add_del_reply) \
5461 _(mpls_table_add_del_reply) \
5462 _(mpls_ip_bind_unbind_reply) \
5463 _(bier_route_add_del_reply) \
5464 _(bier_table_add_del_reply) \
5465 _(proxy_arp_add_del_reply) \
5466 _(proxy_arp_intfc_enable_disable_reply) \
5467 _(sw_interface_set_unnumbered_reply) \
5468 _(ip_neighbor_add_del_reply) \
5469 _(oam_add_del_reply) \
5470 _(reset_fib_reply) \
5471 _(dhcp_proxy_config_reply) \
5472 _(dhcp_proxy_set_vss_reply) \
5473 _(dhcp_client_config_reply) \
5474 _(set_ip_flow_hash_reply) \
5475 _(sw_interface_ip6_enable_disable_reply) \
5476 _(sw_interface_ip6_set_link_local_address_reply) \
5477 _(ip6nd_proxy_add_del_reply) \
5478 _(sw_interface_ip6nd_ra_prefix_reply) \
5479 _(sw_interface_ip6nd_ra_config_reply) \
5480 _(set_arp_neighbor_limit_reply) \
5481 _(l2_patch_add_del_reply) \
5482 _(sr_policy_add_reply) \
5483 _(sr_policy_mod_reply) \
5484 _(sr_policy_del_reply) \
5485 _(sr_localsid_add_del_reply) \
5486 _(sr_steering_add_del_reply) \
5487 _(classify_add_del_session_reply) \
5488 _(classify_set_interface_ip_table_reply) \
5489 _(classify_set_interface_l2_tables_reply) \
5490 _(l2tpv3_set_tunnel_cookies_reply) \
5491 _(l2tpv3_interface_enable_disable_reply) \
5492 _(l2tpv3_set_lookup_key_reply) \
5493 _(l2_fib_clear_table_reply) \
5494 _(l2_interface_efp_filter_reply) \
5495 _(l2_interface_vlan_tag_rewrite_reply) \
5496 _(modify_vhost_user_if_reply) \
5497 _(delete_vhost_user_if_reply) \
5498 _(ip_probe_neighbor_reply) \
5499 _(ip_scan_neighbor_enable_disable_reply) \
5500 _(want_ip4_arp_events_reply) \
5501 _(want_ip6_nd_events_reply) \
5502 _(want_l2_macs_events_reply) \
5503 _(input_acl_set_interface_reply) \
5504 _(ipsec_spd_add_del_reply) \
5505 _(ipsec_interface_add_del_spd_reply) \
5506 _(ipsec_spd_add_del_entry_reply) \
5507 _(ipsec_sad_add_del_entry_reply) \
5508 _(ipsec_sa_set_key_reply) \
5509 _(ipsec_tunnel_if_add_del_reply) \
5510 _(ipsec_tunnel_if_set_key_reply) \
5511 _(ipsec_tunnel_if_set_sa_reply) \
5512 _(ikev2_profile_add_del_reply) \
5513 _(ikev2_profile_set_auth_reply) \
5514 _(ikev2_profile_set_id_reply) \
5515 _(ikev2_profile_set_ts_reply) \
5516 _(ikev2_set_local_key_reply) \
5517 _(ikev2_set_responder_reply) \
5518 _(ikev2_set_ike_transforms_reply) \
5519 _(ikev2_set_esp_transforms_reply) \
5520 _(ikev2_set_sa_lifetime_reply) \
5521 _(ikev2_initiate_sa_init_reply) \
5522 _(ikev2_initiate_del_ike_sa_reply) \
5523 _(ikev2_initiate_del_child_sa_reply) \
5524 _(ikev2_initiate_rekey_child_sa_reply) \
5525 _(delete_loopback_reply) \
5526 _(bd_ip_mac_add_del_reply) \
5527 _(map_del_domain_reply) \
5528 _(map_add_del_rule_reply) \
5529 _(want_interface_events_reply) \
5530 _(want_stats_reply) \
5531 _(cop_interface_enable_disable_reply) \
5532 _(cop_whitelist_enable_disable_reply) \
5533 _(sw_interface_clear_stats_reply) \
5534 _(ioam_enable_reply) \
5535 _(ioam_disable_reply) \
5536 _(one_add_del_locator_reply) \
5537 _(one_add_del_local_eid_reply) \
5538 _(one_add_del_remote_mapping_reply) \
5539 _(one_add_del_adjacency_reply) \
5540 _(one_add_del_map_resolver_reply) \
5541 _(one_add_del_map_server_reply) \
5542 _(one_enable_disable_reply) \
5543 _(one_rloc_probe_enable_disable_reply) \
5544 _(one_map_register_enable_disable_reply) \
5545 _(one_map_register_set_ttl_reply) \
5546 _(one_set_transport_protocol_reply) \
5547 _(one_map_register_fallback_threshold_reply) \
5548 _(one_pitr_set_locator_set_reply) \
5549 _(one_map_request_mode_reply) \
5550 _(one_add_del_map_request_itr_rlocs_reply) \
5551 _(one_eid_table_add_del_map_reply) \
5552 _(one_use_petr_reply) \
5553 _(one_stats_enable_disable_reply) \
5554 _(one_add_del_l2_arp_entry_reply) \
5555 _(one_add_del_ndp_entry_reply) \
5556 _(one_stats_flush_reply) \
5557 _(one_enable_disable_xtr_mode_reply) \
5558 _(one_enable_disable_pitr_mode_reply) \
5559 _(one_enable_disable_petr_mode_reply) \
5560 _(gpe_enable_disable_reply) \
5561 _(gpe_set_encap_mode_reply) \
5562 _(gpe_add_del_iface_reply) \
5563 _(gpe_add_del_native_fwd_rpath_reply) \
5564 _(af_packet_delete_reply) \
5565 _(policer_classify_set_interface_reply) \
5566 _(netmap_create_reply) \
5567 _(netmap_delete_reply) \
5568 _(set_ipfix_exporter_reply) \
5569 _(set_ipfix_classify_stream_reply) \
5570 _(ipfix_classify_table_add_del_reply) \
5571 _(flow_classify_set_interface_reply) \
5572 _(sw_interface_span_enable_disable_reply) \
5573 _(pg_capture_reply) \
5574 _(pg_enable_disable_reply) \
5575 _(ip_source_and_port_range_check_add_del_reply) \
5576 _(ip_source_and_port_range_check_interface_add_del_reply)\
5577 _(delete_subif_reply) \
5578 _(l2_interface_pbb_tag_rewrite_reply) \
5580 _(feature_enable_disable_reply) \
5581 _(sw_interface_tag_add_del_reply) \
5582 _(hw_interface_set_mtu_reply) \
5583 _(p2p_ethernet_add_reply) \
5584 _(p2p_ethernet_del_reply) \
5585 _(lldp_config_reply) \
5586 _(sw_interface_set_lldp_reply) \
5587 _(tcp_configure_src_addresses_reply) \
5588 _(dns_enable_disable_reply) \
5589 _(dns_name_server_add_del_reply) \
5590 _(session_rule_add_del_reply) \
5591 _(ip_container_proxy_add_del_reply) \
5592 _(output_acl_set_interface_reply) \
5593 _(qos_record_enable_disable_reply)
5596 static void vl_api_##n##_t_handler \
5597 (vl_api_##n##_t * mp) \
5599 vat_main_t * vam = &vat_main; \
5600 i32 retval = ntohl(mp->retval); \
5601 if (vam->async_mode) { \
5602 vam->async_errors += (retval < 0); \
5604 vam->retval = retval; \
5605 vam->result_ready = 1; \
5608 foreach_standard_reply_retval_handler;
5612 static void vl_api_##n##_t_handler_json \
5613 (vl_api_##n##_t * mp) \
5615 vat_main_t * vam = &vat_main; \
5616 vat_json_node_t node; \
5617 vat_json_init_object(&node); \
5618 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5619 vat_json_print(vam->ofp, &node); \
5620 vam->retval = ntohl(mp->retval); \
5621 vam->result_ready = 1; \
5623 foreach_standard_reply_retval_handler;
5627 * Table of message reply handlers, must include boilerplate handlers
5631 #define foreach_vpe_api_reply_msg \
5632 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5633 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5634 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5635 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5636 _(CONTROL_PING_REPLY, control_ping_reply) \
5637 _(CLI_REPLY, cli_reply) \
5638 _(CLI_INBAND_REPLY, cli_inband_reply) \
5639 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5640 sw_interface_add_del_address_reply) \
5641 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5642 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5643 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5644 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5645 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5646 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5647 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5648 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5649 sw_interface_set_l2_xconnect_reply) \
5650 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5651 sw_interface_set_l2_bridge_reply) \
5652 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5653 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5654 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5655 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5656 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5657 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5658 _(L2_FLAGS_REPLY, l2_flags_reply) \
5659 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5660 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5661 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5662 _(TAP_DELETE_REPLY, tap_delete_reply) \
5663 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5664 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5665 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5666 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5667 _(BOND_CREATE_REPLY, bond_create_reply) \
5668 _(BOND_DELETE_REPLY, bond_delete_reply) \
5669 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5670 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5671 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5672 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5673 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5674 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5675 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5676 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5677 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5678 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5679 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5680 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5681 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5682 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5683 proxy_arp_intfc_enable_disable_reply) \
5684 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5685 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5686 sw_interface_set_unnumbered_reply) \
5687 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5688 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5689 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5690 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5691 _(RESET_FIB_REPLY, reset_fib_reply) \
5692 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5693 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5694 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5695 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5696 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5697 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5698 sw_interface_ip6_enable_disable_reply) \
5699 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5700 sw_interface_ip6_set_link_local_address_reply) \
5701 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5702 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5703 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5704 sw_interface_ip6nd_ra_prefix_reply) \
5705 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5706 sw_interface_ip6nd_ra_config_reply) \
5707 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5708 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5709 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5710 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5711 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5712 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5713 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5714 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5715 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5716 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5717 classify_set_interface_ip_table_reply) \
5718 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5719 classify_set_interface_l2_tables_reply) \
5720 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5721 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5722 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5723 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5724 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5725 l2tpv3_interface_enable_disable_reply) \
5726 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5727 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5728 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5729 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5730 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5731 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5732 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5733 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5734 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5735 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5736 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5737 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5738 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5739 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5740 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5741 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5742 _(SHOW_VERSION_REPLY, show_version_reply) \
5743 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5744 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5745 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5746 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5747 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5748 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5749 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5750 _(IP4_ARP_EVENT, ip4_arp_event) \
5751 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5752 _(IP6_ND_EVENT, ip6_nd_event) \
5753 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5754 _(L2_MACS_EVENT, l2_macs_event) \
5755 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5756 _(IP_ADDRESS_DETAILS, ip_address_details) \
5757 _(IP_DETAILS, ip_details) \
5758 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5759 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5760 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5761 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5762 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5763 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5764 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5765 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5766 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5767 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5768 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5769 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5770 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5771 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5772 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5773 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5774 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5775 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5776 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5777 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5778 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5779 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5780 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5781 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5782 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5783 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5784 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5785 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5786 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5787 _(MAP_RULE_DETAILS, map_rule_details) \
5788 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5789 _(WANT_STATS_REPLY, want_stats_reply) \
5790 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5791 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5792 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5793 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5794 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5795 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5796 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5797 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5798 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5799 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5800 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5801 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5802 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5803 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5804 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5805 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5806 one_map_register_enable_disable_reply) \
5807 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5808 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5809 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5810 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5811 one_map_register_fallback_threshold_reply) \
5812 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5813 one_rloc_probe_enable_disable_reply) \
5814 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5815 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5816 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5817 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5818 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5819 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5820 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5821 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5822 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5823 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5824 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5825 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5826 _(ONE_STATS_DETAILS, one_stats_details) \
5827 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5828 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5829 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5830 show_one_stats_enable_disable_reply) \
5831 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5832 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5833 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5834 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5835 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5836 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5837 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5838 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5839 one_enable_disable_pitr_mode_reply) \
5840 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5841 one_enable_disable_petr_mode_reply) \
5842 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5843 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5844 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5845 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5846 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5847 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5848 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5849 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5850 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5851 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5852 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5853 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5854 gpe_add_del_native_fwd_rpath_reply) \
5855 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5856 gpe_fwd_entry_path_details) \
5857 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5858 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5859 one_add_del_map_request_itr_rlocs_reply) \
5860 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5861 one_get_map_request_itr_rlocs_reply) \
5862 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5863 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5864 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5865 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5866 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5867 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5868 show_one_map_register_state_reply) \
5869 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5870 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5871 show_one_map_register_fallback_threshold_reply) \
5872 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5873 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5874 _(AF_PACKET_DETAILS, af_packet_details) \
5875 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5876 _(POLICER_DETAILS, policer_details) \
5877 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5878 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5879 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5880 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5881 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5882 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5883 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5884 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5885 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5886 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5887 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5888 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5889 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5890 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5891 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5892 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5893 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5894 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5895 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5896 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5897 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5898 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5899 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5900 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5901 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5902 ip_source_and_port_range_check_add_del_reply) \
5903 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5904 ip_source_and_port_range_check_interface_add_del_reply) \
5905 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5906 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5907 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5908 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5909 _(PUNT_REPLY, punt_reply) \
5910 _(IP_FIB_DETAILS, ip_fib_details) \
5911 _(IP6_FIB_DETAILS, ip6_fib_details) \
5912 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5913 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5914 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5915 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5916 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5917 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5918 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5919 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5920 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5921 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5922 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5923 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5924 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5925 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5926 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5927 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5928 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5929 _(SESSION_RULES_DETAILS, session_rules_details) \
5930 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5931 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5932 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5933 _(MAP_STATS_SEGMENT_REPLY, map_stats_segment_reply)
5935 #define foreach_standalone_reply_msg \
5936 _(SW_INTERFACE_EVENT, sw_interface_event) \
5937 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5938 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5939 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5940 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5941 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5942 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5950 #define STR_VTR_OP_CASE(op) \
5951 case L2_VTR_ ## op: \
5955 str_vtr_op (u32 vtr_op)
5959 STR_VTR_OP_CASE (DISABLED);
5960 STR_VTR_OP_CASE (PUSH_1);
5961 STR_VTR_OP_CASE (PUSH_2);
5962 STR_VTR_OP_CASE (POP_1);
5963 STR_VTR_OP_CASE (POP_2);
5964 STR_VTR_OP_CASE (TRANSLATE_1_1);
5965 STR_VTR_OP_CASE (TRANSLATE_1_2);
5966 STR_VTR_OP_CASE (TRANSLATE_2_1);
5967 STR_VTR_OP_CASE (TRANSLATE_2_2);
5974 dump_sub_interface_table (vat_main_t * vam)
5976 const sw_interface_subif_t *sub = NULL;
5978 if (vam->json_output)
5981 ("JSON output supported only for VPE API calls and dump_stats_table");
5986 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5987 "Interface", "sw_if_index",
5988 "sub id", "dot1ad", "tags", "outer id",
5989 "inner id", "exact", "default", "outer any", "inner any");
5991 vec_foreach (sub, vam->sw_if_subif_table)
5994 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5995 sub->interface_name,
5997 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5998 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5999 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
6000 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
6001 if (sub->vtr_op != L2_VTR_DISABLED)
6004 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
6005 "tag1: %d tag2: %d ]",
6006 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
6007 sub->vtr_tag1, sub->vtr_tag2);
6015 name_sort_cmp (void *a1, void *a2)
6017 name_sort_t *n1 = a1;
6018 name_sort_t *n2 = a2;
6020 return strcmp ((char *) n1->name, (char *) n2->name);
6024 dump_interface_table (vat_main_t * vam)
6027 name_sort_t *nses = 0, *ns;
6029 if (vam->json_output)
6032 ("JSON output supported only for VPE API calls and dump_stats_table");
6037 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6039 vec_add2 (nses, ns, 1);
6040 ns->name = (u8 *)(p->key);
6041 ns->value = (u32) p->value[0];
6045 vec_sort_with_function (nses, name_sort_cmp);
6047 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6048 vec_foreach (ns, nses)
6050 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6057 dump_ip_table (vat_main_t * vam, int is_ipv6)
6059 const ip_details_t *det = NULL;
6060 const ip_address_details_t *address = NULL;
6063 print (vam->ofp, "%-12s", "sw_if_index");
6065 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6072 print (vam->ofp, "%-12d", i);
6073 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6078 vec_foreach (address, det->addr)
6082 is_ipv6 ? format_ip6_address : format_ip4_address,
6083 address->ip, address->prefix_length);
6091 dump_ipv4_table (vat_main_t * vam)
6093 if (vam->json_output)
6096 ("JSON output supported only for VPE API calls and dump_stats_table");
6100 return dump_ip_table (vam, 0);
6104 dump_ipv6_table (vat_main_t * vam)
6106 if (vam->json_output)
6109 ("JSON output supported only for VPE API calls and dump_stats_table");
6113 return dump_ip_table (vam, 1);
6117 counter_type_to_str (u8 counter_type, u8 is_combined)
6121 switch (counter_type)
6123 case VNET_INTERFACE_COUNTER_DROP:
6125 case VNET_INTERFACE_COUNTER_PUNT:
6127 case VNET_INTERFACE_COUNTER_IP4:
6129 case VNET_INTERFACE_COUNTER_IP6:
6131 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6133 case VNET_INTERFACE_COUNTER_RX_MISS:
6135 case VNET_INTERFACE_COUNTER_RX_ERROR:
6137 case VNET_INTERFACE_COUNTER_TX_ERROR:
6140 return "INVALID-COUNTER-TYPE";
6145 switch (counter_type)
6147 case VNET_INTERFACE_COUNTER_RX:
6149 case VNET_INTERFACE_COUNTER_TX:
6152 return "INVALID-COUNTER-TYPE";
6158 dump_stats_table (vat_main_t * vam)
6160 vat_json_node_t node;
6161 vat_json_node_t *msg_array;
6162 vat_json_node_t *msg;
6163 vat_json_node_t *counter_array;
6164 vat_json_node_t *counter;
6165 interface_counter_t c;
6167 ip4_fib_counter_t *c4;
6168 ip6_fib_counter_t *c6;
6169 ip4_nbr_counter_t *n4;
6170 ip6_nbr_counter_t *n6;
6173 if (!vam->json_output)
6175 clib_warning ("dump_stats_table supported only in JSON format");
6179 vat_json_init_object (&node);
6181 /* interface counters */
6182 msg_array = vat_json_object_add (&node, "interface_counters");
6183 vat_json_init_array (msg_array);
6184 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6186 msg = vat_json_array_add (msg_array);
6187 vat_json_init_object (msg);
6188 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6189 (u8 *) counter_type_to_str (i, 0));
6190 vat_json_object_add_int (msg, "is_combined", 0);
6191 counter_array = vat_json_object_add (msg, "data");
6192 vat_json_init_array (counter_array);
6193 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6195 packets = vam->simple_interface_counters[i][j];
6196 vat_json_array_add_uint (counter_array, packets);
6199 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6201 msg = vat_json_array_add (msg_array);
6202 vat_json_init_object (msg);
6203 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6204 (u8 *) counter_type_to_str (i, 1));
6205 vat_json_object_add_int (msg, "is_combined", 1);
6206 counter_array = vat_json_object_add (msg, "data");
6207 vat_json_init_array (counter_array);
6208 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6210 c = vam->combined_interface_counters[i][j];
6211 counter = vat_json_array_add (counter_array);
6212 vat_json_init_object (counter);
6213 vat_json_object_add_uint (counter, "packets", c.packets);
6214 vat_json_object_add_uint (counter, "bytes", c.bytes);
6218 /* ip4 fib counters */
6219 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6220 vat_json_init_array (msg_array);
6221 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6223 msg = vat_json_array_add (msg_array);
6224 vat_json_init_object (msg);
6225 vat_json_object_add_uint (msg, "vrf_id",
6226 vam->ip4_fib_counters_vrf_id_by_index[i]);
6227 counter_array = vat_json_object_add (msg, "c");
6228 vat_json_init_array (counter_array);
6229 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6231 counter = vat_json_array_add (counter_array);
6232 vat_json_init_object (counter);
6233 c4 = &vam->ip4_fib_counters[i][j];
6234 vat_json_object_add_ip4 (counter, "address", c4->address);
6235 vat_json_object_add_uint (counter, "address_length",
6236 c4->address_length);
6237 vat_json_object_add_uint (counter, "packets", c4->packets);
6238 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6242 /* ip6 fib counters */
6243 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6244 vat_json_init_array (msg_array);
6245 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6247 msg = vat_json_array_add (msg_array);
6248 vat_json_init_object (msg);
6249 vat_json_object_add_uint (msg, "vrf_id",
6250 vam->ip6_fib_counters_vrf_id_by_index[i]);
6251 counter_array = vat_json_object_add (msg, "c");
6252 vat_json_init_array (counter_array);
6253 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6255 counter = vat_json_array_add (counter_array);
6256 vat_json_init_object (counter);
6257 c6 = &vam->ip6_fib_counters[i][j];
6258 vat_json_object_add_ip6 (counter, "address", c6->address);
6259 vat_json_object_add_uint (counter, "address_length",
6260 c6->address_length);
6261 vat_json_object_add_uint (counter, "packets", c6->packets);
6262 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6266 /* ip4 nbr counters */
6267 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6268 vat_json_init_array (msg_array);
6269 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6271 msg = vat_json_array_add (msg_array);
6272 vat_json_init_object (msg);
6273 vat_json_object_add_uint (msg, "sw_if_index", i);
6274 counter_array = vat_json_object_add (msg, "c");
6275 vat_json_init_array (counter_array);
6276 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6278 counter = vat_json_array_add (counter_array);
6279 vat_json_init_object (counter);
6280 n4 = &vam->ip4_nbr_counters[i][j];
6281 vat_json_object_add_ip4 (counter, "address", n4->address);
6282 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6283 vat_json_object_add_uint (counter, "packets", n4->packets);
6284 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6288 /* ip6 nbr counters */
6289 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6290 vat_json_init_array (msg_array);
6291 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6293 msg = vat_json_array_add (msg_array);
6294 vat_json_init_object (msg);
6295 vat_json_object_add_uint (msg, "sw_if_index", i);
6296 counter_array = vat_json_object_add (msg, "c");
6297 vat_json_init_array (counter_array);
6298 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6300 counter = vat_json_array_add (counter_array);
6301 vat_json_init_object (counter);
6302 n6 = &vam->ip6_nbr_counters[i][j];
6303 vat_json_object_add_ip6 (counter, "address", n6->address);
6304 vat_json_object_add_uint (counter, "packets", n6->packets);
6305 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6309 vat_json_print (vam->ofp, &node);
6310 vat_json_free (&node);
6316 * Pass CLI buffers directly in the CLI_INBAND API message,
6317 * instead of an additional shared memory area.
6320 exec_inband (vat_main_t * vam)
6322 vl_api_cli_inband_t *mp;
6323 unformat_input_t *i = vam->input;
6326 if (vec_len (i->buffer) == 0)
6329 if (vam->exec_mode == 0 && unformat (i, "mode"))
6334 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6341 * In order for the CLI command to work, it
6342 * must be a vector ending in \n, not a C-string ending
6345 u32 len = vec_len (vam->input->buffer);
6346 M2 (CLI_INBAND, mp, len);
6347 clib_memcpy (mp->cmd, vam->input->buffer, len);
6348 mp->length = htonl (len);
6352 /* json responses may or may not include a useful reply... */
6353 if (vec_len (vam->cmd_reply))
6354 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6359 exec (vat_main_t * vam)
6361 return exec_inband (vam);
6365 api_create_loopback (vat_main_t * vam)
6367 unformat_input_t *i = vam->input;
6368 vl_api_create_loopback_t *mp;
6369 vl_api_create_loopback_instance_t *mp_lbi;
6372 u8 is_specified = 0;
6373 u32 user_instance = 0;
6376 memset (mac_address, 0, sizeof (mac_address));
6378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6380 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6382 if (unformat (i, "instance %d", &user_instance))
6390 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6391 mp_lbi->is_specified = is_specified;
6393 mp_lbi->user_instance = htonl (user_instance);
6395 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6400 /* Construct the API message */
6401 M (CREATE_LOOPBACK, mp);
6403 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6412 api_delete_loopback (vat_main_t * vam)
6414 unformat_input_t *i = vam->input;
6415 vl_api_delete_loopback_t *mp;
6416 u32 sw_if_index = ~0;
6419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6421 if (unformat (i, "sw_if_index %d", &sw_if_index))
6427 if (sw_if_index == ~0)
6429 errmsg ("missing sw_if_index");
6433 /* Construct the API message */
6434 M (DELETE_LOOPBACK, mp);
6435 mp->sw_if_index = ntohl (sw_if_index);
6443 api_want_stats (vat_main_t * vam)
6445 unformat_input_t *i = vam->input;
6446 vl_api_want_stats_t *mp;
6450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6452 if (unformat (i, "enable"))
6454 else if (unformat (i, "disable"))
6462 errmsg ("missing enable|disable");
6467 mp->enable_disable = enable;
6475 api_want_interface_events (vat_main_t * vam)
6477 unformat_input_t *i = vam->input;
6478 vl_api_want_interface_events_t *mp;
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "enable"))
6486 else if (unformat (i, "disable"))
6494 errmsg ("missing enable|disable");
6498 M (WANT_INTERFACE_EVENTS, mp);
6499 mp->enable_disable = enable;
6501 vam->interface_event_display = enable;
6509 /* Note: non-static, called once to set up the initial intfc table */
6511 api_sw_interface_dump (vat_main_t * vam)
6513 vl_api_sw_interface_dump_t *mp;
6514 vl_api_control_ping_t *mp_ping;
6516 name_sort_t *nses = 0, *ns;
6517 sw_interface_subif_t *sub = NULL;
6520 /* Toss the old name table */
6522 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6524 vec_add2 (nses, ns, 1);
6525 ns->name = (u8 *)(p->key);
6526 ns->value = (u32) p->value[0];
6530 hash_free (vam->sw_if_index_by_interface_name);
6532 vec_foreach (ns, nses) vec_free (ns->name);
6536 vec_foreach (sub, vam->sw_if_subif_table)
6538 vec_free (sub->interface_name);
6540 vec_free (vam->sw_if_subif_table);
6542 /* recreate the interface name hash table */
6543 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6546 * Ask for all interface names. Otherwise, the epic catalog of
6547 * name filters becomes ridiculously long, and vat ends up needing
6548 * to be taught about new interface types.
6550 M (SW_INTERFACE_DUMP, mp);
6553 /* Use a control ping for synchronization */
6554 MPING (CONTROL_PING, mp_ping);
6562 api_sw_interface_set_flags (vat_main_t * vam)
6564 unformat_input_t *i = vam->input;
6565 vl_api_sw_interface_set_flags_t *mp;
6567 u8 sw_if_index_set = 0;
6571 /* Parse args required to build the message */
6572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6574 if (unformat (i, "admin-up"))
6576 else if (unformat (i, "admin-down"))
6579 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6580 sw_if_index_set = 1;
6581 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6582 sw_if_index_set = 1;
6587 if (sw_if_index_set == 0)
6589 errmsg ("missing interface name or sw_if_index");
6593 /* Construct the API message */
6594 M (SW_INTERFACE_SET_FLAGS, mp);
6595 mp->sw_if_index = ntohl (sw_if_index);
6596 mp->admin_up_down = admin_up;
6601 /* Wait for a reply, return the good/bad news... */
6607 api_sw_interface_set_rx_mode (vat_main_t * vam)
6609 unformat_input_t *i = vam->input;
6610 vl_api_sw_interface_set_rx_mode_t *mp;
6612 u8 sw_if_index_set = 0;
6614 u8 queue_id_valid = 0;
6616 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6618 /* Parse args required to build the message */
6619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6621 if (unformat (i, "queue %d", &queue_id))
6623 else if (unformat (i, "polling"))
6624 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6625 else if (unformat (i, "interrupt"))
6626 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6627 else if (unformat (i, "adaptive"))
6628 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6631 sw_if_index_set = 1;
6632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6633 sw_if_index_set = 1;
6638 if (sw_if_index_set == 0)
6640 errmsg ("missing interface name or sw_if_index");
6643 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6645 errmsg ("missing rx-mode");
6649 /* Construct the API message */
6650 M (SW_INTERFACE_SET_RX_MODE, mp);
6651 mp->sw_if_index = ntohl (sw_if_index);
6653 mp->queue_id_valid = queue_id_valid;
6654 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6659 /* Wait for a reply, return the good/bad news... */
6665 api_sw_interface_clear_stats (vat_main_t * vam)
6667 unformat_input_t *i = vam->input;
6668 vl_api_sw_interface_clear_stats_t *mp;
6670 u8 sw_if_index_set = 0;
6673 /* Parse args required to build the message */
6674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6677 sw_if_index_set = 1;
6678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6679 sw_if_index_set = 1;
6684 /* Construct the API message */
6685 M (SW_INTERFACE_CLEAR_STATS, mp);
6687 if (sw_if_index_set == 1)
6688 mp->sw_if_index = ntohl (sw_if_index);
6690 mp->sw_if_index = ~0;
6695 /* Wait for a reply, return the good/bad news... */
6701 api_sw_interface_add_del_address (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_sw_interface_add_del_address_t *mp;
6706 u8 sw_if_index_set = 0;
6707 u8 is_add = 1, del_all = 0;
6708 u32 address_length = 0;
6709 u8 v4_address_set = 0;
6710 u8 v6_address_set = 0;
6711 ip4_address_t v4address;
6712 ip6_address_t v6address;
6715 /* Parse args required to build the message */
6716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6718 if (unformat (i, "del-all"))
6720 else if (unformat (i, "del"))
6723 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6724 sw_if_index_set = 1;
6725 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6726 sw_if_index_set = 1;
6727 else if (unformat (i, "%U/%d",
6728 unformat_ip4_address, &v4address, &address_length))
6730 else if (unformat (i, "%U/%d",
6731 unformat_ip6_address, &v6address, &address_length))
6737 if (sw_if_index_set == 0)
6739 errmsg ("missing interface name or sw_if_index");
6742 if (v4_address_set && v6_address_set)
6744 errmsg ("both v4 and v6 addresses set");
6747 if (!v4_address_set && !v6_address_set && !del_all)
6749 errmsg ("no addresses set");
6753 /* Construct the API message */
6754 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6756 mp->sw_if_index = ntohl (sw_if_index);
6757 mp->is_add = is_add;
6758 mp->del_all = del_all;
6762 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6766 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6768 mp->address_length = address_length;
6773 /* Wait for a reply, return good/bad news */
6779 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6781 unformat_input_t *i = vam->input;
6782 vl_api_sw_interface_set_mpls_enable_t *mp;
6784 u8 sw_if_index_set = 0;
6788 /* Parse args required to build the message */
6789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6791 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6792 sw_if_index_set = 1;
6793 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6794 sw_if_index_set = 1;
6795 else if (unformat (i, "disable"))
6797 else if (unformat (i, "dis"))
6803 if (sw_if_index_set == 0)
6805 errmsg ("missing interface name or sw_if_index");
6809 /* Construct the API message */
6810 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6812 mp->sw_if_index = ntohl (sw_if_index);
6813 mp->enable = enable;
6818 /* Wait for a reply... */
6824 api_sw_interface_set_table (vat_main_t * vam)
6826 unformat_input_t *i = vam->input;
6827 vl_api_sw_interface_set_table_t *mp;
6828 u32 sw_if_index, vrf_id = 0;
6829 u8 sw_if_index_set = 0;
6833 /* Parse args required to build the message */
6834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6836 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6837 sw_if_index_set = 1;
6838 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6839 sw_if_index_set = 1;
6840 else if (unformat (i, "vrf %d", &vrf_id))
6842 else if (unformat (i, "ipv6"))
6848 if (sw_if_index_set == 0)
6850 errmsg ("missing interface name or sw_if_index");
6854 /* Construct the API message */
6855 M (SW_INTERFACE_SET_TABLE, mp);
6857 mp->sw_if_index = ntohl (sw_if_index);
6858 mp->is_ipv6 = is_ipv6;
6859 mp->vrf_id = ntohl (vrf_id);
6864 /* Wait for a reply... */
6869 static void vl_api_sw_interface_get_table_reply_t_handler
6870 (vl_api_sw_interface_get_table_reply_t * mp)
6872 vat_main_t *vam = &vat_main;
6874 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6876 vam->retval = ntohl (mp->retval);
6877 vam->result_ready = 1;
6881 static void vl_api_sw_interface_get_table_reply_t_handler_json
6882 (vl_api_sw_interface_get_table_reply_t * mp)
6884 vat_main_t *vam = &vat_main;
6885 vat_json_node_t node;
6887 vat_json_init_object (&node);
6888 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6889 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6891 vat_json_print (vam->ofp, &node);
6892 vat_json_free (&node);
6894 vam->retval = ntohl (mp->retval);
6895 vam->result_ready = 1;
6899 api_sw_interface_get_table (vat_main_t * vam)
6901 unformat_input_t *i = vam->input;
6902 vl_api_sw_interface_get_table_t *mp;
6904 u8 sw_if_index_set = 0;
6908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6910 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6911 sw_if_index_set = 1;
6912 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6913 sw_if_index_set = 1;
6914 else if (unformat (i, "ipv6"))
6920 if (sw_if_index_set == 0)
6922 errmsg ("missing interface name or sw_if_index");
6926 M (SW_INTERFACE_GET_TABLE, mp);
6927 mp->sw_if_index = htonl (sw_if_index);
6928 mp->is_ipv6 = is_ipv6;
6936 api_sw_interface_set_vpath (vat_main_t * vam)
6938 unformat_input_t *i = vam->input;
6939 vl_api_sw_interface_set_vpath_t *mp;
6940 u32 sw_if_index = 0;
6941 u8 sw_if_index_set = 0;
6945 /* Parse args required to build the message */
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6949 sw_if_index_set = 1;
6950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6951 sw_if_index_set = 1;
6952 else if (unformat (i, "enable"))
6954 else if (unformat (i, "disable"))
6960 if (sw_if_index_set == 0)
6962 errmsg ("missing interface name or sw_if_index");
6966 /* Construct the API message */
6967 M (SW_INTERFACE_SET_VPATH, mp);
6969 mp->sw_if_index = ntohl (sw_if_index);
6970 mp->enable = is_enable;
6975 /* Wait for a reply... */
6981 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6983 unformat_input_t *i = vam->input;
6984 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6985 u32 sw_if_index = 0;
6986 u8 sw_if_index_set = 0;
6991 /* Parse args required to build the message */
6992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6995 sw_if_index_set = 1;
6996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6997 sw_if_index_set = 1;
6998 else if (unformat (i, "enable"))
7000 else if (unformat (i, "disable"))
7002 else if (unformat (i, "ip4"))
7004 else if (unformat (i, "ip6"))
7010 if (sw_if_index_set == 0)
7012 errmsg ("missing interface name or sw_if_index");
7016 /* Construct the API message */
7017 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
7019 mp->sw_if_index = ntohl (sw_if_index);
7020 mp->enable = is_enable;
7021 mp->is_ipv6 = is_ipv6;
7026 /* Wait for a reply... */
7032 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
7034 unformat_input_t *i = vam->input;
7035 vl_api_sw_interface_set_geneve_bypass_t *mp;
7036 u32 sw_if_index = 0;
7037 u8 sw_if_index_set = 0;
7042 /* Parse args required to build the message */
7043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7045 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7046 sw_if_index_set = 1;
7047 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7048 sw_if_index_set = 1;
7049 else if (unformat (i, "enable"))
7051 else if (unformat (i, "disable"))
7053 else if (unformat (i, "ip4"))
7055 else if (unformat (i, "ip6"))
7061 if (sw_if_index_set == 0)
7063 errmsg ("missing interface name or sw_if_index");
7067 /* Construct the API message */
7068 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7070 mp->sw_if_index = ntohl (sw_if_index);
7071 mp->enable = is_enable;
7072 mp->is_ipv6 = is_ipv6;
7077 /* Wait for a reply... */
7083 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7085 unformat_input_t *i = vam->input;
7086 vl_api_sw_interface_set_l2_xconnect_t *mp;
7088 u8 rx_sw_if_index_set = 0;
7090 u8 tx_sw_if_index_set = 0;
7094 /* Parse args required to build the message */
7095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7097 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7098 rx_sw_if_index_set = 1;
7099 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7100 tx_sw_if_index_set = 1;
7101 else if (unformat (i, "rx"))
7103 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7105 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7107 rx_sw_if_index_set = 1;
7112 else if (unformat (i, "tx"))
7114 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7116 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7118 tx_sw_if_index_set = 1;
7123 else if (unformat (i, "enable"))
7125 else if (unformat (i, "disable"))
7131 if (rx_sw_if_index_set == 0)
7133 errmsg ("missing rx interface name or rx_sw_if_index");
7137 if (enable && (tx_sw_if_index_set == 0))
7139 errmsg ("missing tx interface name or tx_sw_if_index");
7143 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7145 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7146 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7147 mp->enable = enable;
7155 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7157 unformat_input_t *i = vam->input;
7158 vl_api_sw_interface_set_l2_bridge_t *mp;
7160 u8 rx_sw_if_index_set = 0;
7168 /* Parse args required to build the message */
7169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7171 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7172 rx_sw_if_index_set = 1;
7173 else if (unformat (i, "bd_id %d", &bd_id))
7177 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7178 rx_sw_if_index_set = 1;
7179 else if (unformat (i, "shg %d", &shg))
7181 else if (unformat (i, "bvi"))
7183 else if (unformat (i, "enable"))
7185 else if (unformat (i, "disable"))
7191 if (rx_sw_if_index_set == 0)
7193 errmsg ("missing rx interface name or sw_if_index");
7197 if (enable && (bd_id_set == 0))
7199 errmsg ("missing bridge domain");
7203 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7205 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7206 mp->bd_id = ntohl (bd_id);
7209 mp->enable = enable;
7217 api_bridge_domain_dump (vat_main_t * vam)
7219 unformat_input_t *i = vam->input;
7220 vl_api_bridge_domain_dump_t *mp;
7221 vl_api_control_ping_t *mp_ping;
7225 /* Parse args required to build the message */
7226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7228 if (unformat (i, "bd_id %d", &bd_id))
7234 M (BRIDGE_DOMAIN_DUMP, mp);
7235 mp->bd_id = ntohl (bd_id);
7238 /* Use a control ping for synchronization */
7239 MPING (CONTROL_PING, mp_ping);
7247 api_bridge_domain_add_del (vat_main_t * vam)
7249 unformat_input_t *i = vam->input;
7250 vl_api_bridge_domain_add_del_t *mp;
7253 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7258 /* Parse args required to build the message */
7259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7261 if (unformat (i, "bd_id %d", &bd_id))
7263 else if (unformat (i, "flood %d", &flood))
7265 else if (unformat (i, "uu-flood %d", &uu_flood))
7267 else if (unformat (i, "forward %d", &forward))
7269 else if (unformat (i, "learn %d", &learn))
7271 else if (unformat (i, "arp-term %d", &arp_term))
7273 else if (unformat (i, "mac-age %d", &mac_age))
7275 else if (unformat (i, "bd-tag %s", &bd_tag))
7277 else if (unformat (i, "del"))
7280 flood = uu_flood = forward = learn = 0;
7288 errmsg ("missing bridge domain");
7295 errmsg ("mac age must be less than 256 ");
7300 if ((bd_tag) && (vec_len (bd_tag) > 63))
7302 errmsg ("bd-tag cannot be longer than 63");
7307 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7309 mp->bd_id = ntohl (bd_id);
7311 mp->uu_flood = uu_flood;
7312 mp->forward = forward;
7314 mp->arp_term = arp_term;
7315 mp->is_add = is_add;
7316 mp->mac_age = (u8) mac_age;
7319 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7320 mp->bd_tag[vec_len (bd_tag)] = 0;
7331 api_l2fib_flush_bd (vat_main_t * vam)
7333 unformat_input_t *i = vam->input;
7334 vl_api_l2fib_flush_bd_t *mp;
7338 /* Parse args required to build the message */
7339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7341 if (unformat (i, "bd_id %d", &bd_id));
7348 errmsg ("missing bridge domain");
7352 M (L2FIB_FLUSH_BD, mp);
7354 mp->bd_id = htonl (bd_id);
7362 api_l2fib_flush_int (vat_main_t * vam)
7364 unformat_input_t *i = vam->input;
7365 vl_api_l2fib_flush_int_t *mp;
7366 u32 sw_if_index = ~0;
7369 /* Parse args required to build the message */
7370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7372 if (unformat (i, "sw_if_index %d", &sw_if_index));
7374 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7379 if (sw_if_index == ~0)
7381 errmsg ("missing interface name or sw_if_index");
7385 M (L2FIB_FLUSH_INT, mp);
7387 mp->sw_if_index = ntohl (sw_if_index);
7395 api_l2fib_add_del (vat_main_t * vam)
7397 unformat_input_t *i = vam->input;
7398 vl_api_l2fib_add_del_t *mp;
7404 u32 sw_if_index = 0;
7405 u8 sw_if_index_set = 0;
7414 /* Parse args required to build the message */
7415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7417 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7419 else if (unformat (i, "bd_id %d", &bd_id))
7421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7422 sw_if_index_set = 1;
7423 else if (unformat (i, "sw_if"))
7425 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7428 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7429 sw_if_index_set = 1;
7434 else if (unformat (i, "static"))
7436 else if (unformat (i, "filter"))
7441 else if (unformat (i, "bvi"))
7446 else if (unformat (i, "del"))
7448 else if (unformat (i, "count %d", &count))
7456 errmsg ("missing mac address");
7462 errmsg ("missing bridge domain");
7466 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7468 errmsg ("missing interface name or sw_if_index");
7474 /* Turn on async mode */
7475 vam->async_mode = 1;
7476 vam->async_errors = 0;
7477 before = vat_time_now (vam);
7480 for (j = 0; j < count; j++)
7482 M (L2FIB_ADD_DEL, mp);
7484 clib_memcpy (mp->mac, mac, 6);
7485 mp->bd_id = ntohl (bd_id);
7486 mp->is_add = is_add;
7487 mp->sw_if_index = ntohl (sw_if_index);
7491 mp->static_mac = static_mac;
7492 mp->filter_mac = filter_mac;
7493 mp->bvi_mac = bvi_mac;
7495 increment_mac_address (mac);
7502 vl_api_control_ping_t *mp_ping;
7505 /* Shut off async mode */
7506 vam->async_mode = 0;
7508 MPING (CONTROL_PING, mp_ping);
7511 timeout = vat_time_now (vam) + 1.0;
7512 while (vat_time_now (vam) < timeout)
7513 if (vam->result_ready == 1)
7518 if (vam->retval == -99)
7521 if (vam->async_errors > 0)
7523 errmsg ("%d asynchronous errors", vam->async_errors);
7526 vam->async_errors = 0;
7527 after = vat_time_now (vam);
7529 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7530 count, after - before, count / (after - before));
7536 /* Wait for a reply... */
7540 /* Return the good/bad news */
7541 return (vam->retval);
7545 api_bridge_domain_set_mac_age (vat_main_t * vam)
7547 unformat_input_t *i = vam->input;
7548 vl_api_bridge_domain_set_mac_age_t *mp;
7553 /* Parse args required to build the message */
7554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7556 if (unformat (i, "bd_id %d", &bd_id));
7557 else if (unformat (i, "mac-age %d", &mac_age));
7564 errmsg ("missing bridge domain");
7570 errmsg ("mac age must be less than 256 ");
7574 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7576 mp->bd_id = htonl (bd_id);
7577 mp->mac_age = (u8) mac_age;
7585 api_l2_flags (vat_main_t * vam)
7587 unformat_input_t *i = vam->input;
7588 vl_api_l2_flags_t *mp;
7591 u8 sw_if_index_set = 0;
7595 /* Parse args required to build the message */
7596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7598 if (unformat (i, "sw_if_index %d", &sw_if_index))
7599 sw_if_index_set = 1;
7600 else if (unformat (i, "sw_if"))
7602 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7605 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7606 sw_if_index_set = 1;
7611 else if (unformat (i, "learn"))
7613 else if (unformat (i, "forward"))
7615 else if (unformat (i, "flood"))
7617 else if (unformat (i, "uu-flood"))
7618 flags |= L2_UU_FLOOD;
7619 else if (unformat (i, "arp-term"))
7620 flags |= L2_ARP_TERM;
7621 else if (unformat (i, "off"))
7623 else if (unformat (i, "disable"))
7629 if (sw_if_index_set == 0)
7631 errmsg ("missing interface name or sw_if_index");
7637 mp->sw_if_index = ntohl (sw_if_index);
7638 mp->feature_bitmap = ntohl (flags);
7639 mp->is_set = is_set;
7647 api_bridge_flags (vat_main_t * vam)
7649 unformat_input_t *i = vam->input;
7650 vl_api_bridge_flags_t *mp;
7657 /* Parse args required to build the message */
7658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7660 if (unformat (i, "bd_id %d", &bd_id))
7662 else if (unformat (i, "learn"))
7664 else if (unformat (i, "forward"))
7666 else if (unformat (i, "flood"))
7668 else if (unformat (i, "uu-flood"))
7669 flags |= L2_UU_FLOOD;
7670 else if (unformat (i, "arp-term"))
7671 flags |= L2_ARP_TERM;
7672 else if (unformat (i, "off"))
7674 else if (unformat (i, "disable"))
7682 errmsg ("missing bridge domain");
7686 M (BRIDGE_FLAGS, mp);
7688 mp->bd_id = ntohl (bd_id);
7689 mp->feature_bitmap = ntohl (flags);
7690 mp->is_set = is_set;
7698 api_bd_ip_mac_add_del (vat_main_t * vam)
7700 unformat_input_t *i = vam->input;
7701 vl_api_bd_ip_mac_add_del_t *mp;
7708 ip4_address_t v4addr;
7709 ip6_address_t v6addr;
7714 /* Parse args required to build the message */
7715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7717 if (unformat (i, "bd_id %d", &bd_id))
7721 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7725 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7730 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7734 else if (unformat (i, "del"))
7742 errmsg ("missing bridge domain");
7745 else if (ip_set == 0)
7747 errmsg ("missing IP address");
7750 else if (mac_set == 0)
7752 errmsg ("missing MAC address");
7756 M (BD_IP_MAC_ADD_DEL, mp);
7758 mp->bd_id = ntohl (bd_id);
7759 mp->is_ipv6 = is_ipv6;
7760 mp->is_add = is_add;
7762 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7764 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7765 clib_memcpy (mp->mac_address, macaddr, 6);
7772 api_tap_connect (vat_main_t * vam)
7774 unformat_input_t *i = vam->input;
7775 vl_api_tap_connect_t *mp;
7781 ip4_address_t ip4_address;
7783 int ip4_address_set = 0;
7784 ip6_address_t ip6_address;
7786 int ip6_address_set = 0;
7789 memset (mac_address, 0, sizeof (mac_address));
7791 /* Parse args required to build the message */
7792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7794 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7798 else if (unformat (i, "random-mac"))
7800 else if (unformat (i, "tapname %s", &tap_name))
7802 else if (unformat (i, "tag %s", &tag))
7804 else if (unformat (i, "address %U/%d",
7805 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7806 ip4_address_set = 1;
7807 else if (unformat (i, "address %U/%d",
7808 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7809 ip6_address_set = 1;
7816 errmsg ("missing tap name");
7819 if (vec_len (tap_name) > 63)
7821 errmsg ("tap name too long");
7824 vec_add1 (tap_name, 0);
7826 if (vec_len (tag) > 63)
7828 errmsg ("tag too long");
7832 /* Construct the API message */
7833 M (TAP_CONNECT, mp);
7835 mp->use_random_mac = random_mac;
7836 clib_memcpy (mp->mac_address, mac_address, 6);
7837 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7839 clib_memcpy (mp->tag, tag, vec_len (tag));
7841 if (ip4_address_set)
7843 mp->ip4_address_set = 1;
7844 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7845 mp->ip4_mask_width = ip4_mask_width;
7847 if (ip6_address_set)
7849 mp->ip6_address_set = 1;
7850 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7851 mp->ip6_mask_width = ip6_mask_width;
7854 vec_free (tap_name);
7860 /* Wait for a reply... */
7866 api_tap_modify (vat_main_t * vam)
7868 unformat_input_t *i = vam->input;
7869 vl_api_tap_modify_t *mp;
7874 u32 sw_if_index = ~0;
7875 u8 sw_if_index_set = 0;
7878 memset (mac_address, 0, sizeof (mac_address));
7880 /* Parse args required to build the message */
7881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7883 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7884 sw_if_index_set = 1;
7885 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7886 sw_if_index_set = 1;
7887 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7891 else if (unformat (i, "random-mac"))
7893 else if (unformat (i, "tapname %s", &tap_name))
7899 if (sw_if_index_set == 0)
7901 errmsg ("missing vpp interface name");
7906 errmsg ("missing tap name");
7909 if (vec_len (tap_name) > 63)
7911 errmsg ("tap name too long");
7913 vec_add1 (tap_name, 0);
7915 /* Construct the API message */
7918 mp->use_random_mac = random_mac;
7919 mp->sw_if_index = ntohl (sw_if_index);
7920 clib_memcpy (mp->mac_address, mac_address, 6);
7921 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7922 vec_free (tap_name);
7927 /* Wait for a reply... */
7933 api_tap_delete (vat_main_t * vam)
7935 unformat_input_t *i = vam->input;
7936 vl_api_tap_delete_t *mp;
7937 u32 sw_if_index = ~0;
7938 u8 sw_if_index_set = 0;
7941 /* Parse args required to build the message */
7942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7944 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7945 sw_if_index_set = 1;
7946 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7947 sw_if_index_set = 1;
7952 if (sw_if_index_set == 0)
7954 errmsg ("missing vpp interface name");
7958 /* Construct the API message */
7961 mp->sw_if_index = ntohl (sw_if_index);
7966 /* Wait for a reply... */
7972 api_tap_create_v2 (vat_main_t * vam)
7974 unformat_input_t *i = vam->input;
7975 vl_api_tap_create_v2_t *mp;
7979 u8 *host_if_name = 0;
7981 u8 host_mac_addr[6];
7982 u8 host_mac_addr_set = 0;
7983 u8 *host_bridge = 0;
7984 ip4_address_t host_ip4_addr;
7985 ip4_address_t host_ip4_gw;
7986 u8 host_ip4_gw_set = 0;
7987 u32 host_ip4_prefix_len = 0;
7988 ip6_address_t host_ip6_addr;
7989 ip6_address_t host_ip6_gw;
7990 u8 host_ip6_gw_set = 0;
7991 u32 host_ip6_prefix_len = 0;
7993 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7995 memset (mac_address, 0, sizeof (mac_address));
7997 /* Parse args required to build the message */
7998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8000 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
8004 else if (unformat (i, "id %u", &id))
8006 else if (unformat (i, "host-if-name %s", &host_if_name))
8008 else if (unformat (i, "host-ns %s", &host_ns))
8010 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
8012 host_mac_addr_set = 1;
8013 else if (unformat (i, "host-bridge %s", &host_bridge))
8015 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
8016 &host_ip4_addr, &host_ip4_prefix_len))
8018 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
8019 &host_ip6_addr, &host_ip6_prefix_len))
8021 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
8023 host_ip4_gw_set = 1;
8024 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
8026 host_ip6_gw_set = 1;
8027 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
8029 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
8035 if (vec_len (host_if_name) > 63)
8037 errmsg ("tap name too long. ");
8040 if (vec_len (host_ns) > 63)
8042 errmsg ("host name space too long. ");
8045 if (vec_len (host_bridge) > 63)
8047 errmsg ("host bridge name too long. ");
8050 if (host_ip4_prefix_len > 32)
8052 errmsg ("host ip4 prefix length not valid. ");
8055 if (host_ip6_prefix_len > 128)
8057 errmsg ("host ip6 prefix length not valid. ");
8060 if (!is_pow2 (rx_ring_sz))
8062 errmsg ("rx ring size must be power of 2. ");
8065 if (rx_ring_sz > 32768)
8067 errmsg ("rx ring size must be 32768 or lower. ");
8070 if (!is_pow2 (tx_ring_sz))
8072 errmsg ("tx ring size must be power of 2. ");
8075 if (tx_ring_sz > 32768)
8077 errmsg ("tx ring size must be 32768 or lower. ");
8081 /* Construct the API message */
8082 M (TAP_CREATE_V2, mp);
8084 mp->use_random_mac = random_mac;
8086 mp->id = ntohl (id);
8087 mp->host_namespace_set = host_ns != 0;
8088 mp->host_bridge_set = host_bridge != 0;
8089 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8090 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8091 mp->rx_ring_sz = ntohs (rx_ring_sz);
8092 mp->tx_ring_sz = ntohs (tx_ring_sz);
8094 if (random_mac == 0)
8095 clib_memcpy (mp->mac_address, mac_address, 6);
8096 if (host_mac_addr_set)
8097 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8099 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8101 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8103 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8104 if (host_ip4_prefix_len)
8105 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8106 if (host_ip4_prefix_len)
8107 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8108 if (host_ip4_gw_set)
8109 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8110 if (host_ip6_gw_set)
8111 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8114 vec_free (host_if_name);
8115 vec_free (host_bridge);
8120 /* Wait for a reply... */
8126 api_tap_delete_v2 (vat_main_t * vam)
8128 unformat_input_t *i = vam->input;
8129 vl_api_tap_delete_v2_t *mp;
8130 u32 sw_if_index = ~0;
8131 u8 sw_if_index_set = 0;
8134 /* Parse args required to build the message */
8135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8138 sw_if_index_set = 1;
8139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8140 sw_if_index_set = 1;
8145 if (sw_if_index_set == 0)
8147 errmsg ("missing vpp interface name. ");
8151 /* Construct the API message */
8152 M (TAP_DELETE_V2, mp);
8154 mp->sw_if_index = ntohl (sw_if_index);
8159 /* Wait for a reply... */
8165 api_bond_create (vat_main_t * vam)
8167 unformat_input_t *i = vam->input;
8168 vl_api_bond_create_t *mp;
8176 memset (mac_address, 0, sizeof (mac_address));
8179 /* Parse args required to build the message */
8180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8182 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8184 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8185 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8187 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8194 if (mode_is_set == 0)
8196 errmsg ("Missing bond mode. ");
8200 /* Construct the API message */
8201 M (BOND_CREATE, mp);
8203 mp->use_custom_mac = custom_mac;
8209 clib_memcpy (mp->mac_address, mac_address, 6);
8214 /* Wait for a reply... */
8220 api_bond_delete (vat_main_t * vam)
8222 unformat_input_t *i = vam->input;
8223 vl_api_bond_delete_t *mp;
8224 u32 sw_if_index = ~0;
8225 u8 sw_if_index_set = 0;
8228 /* Parse args required to build the message */
8229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8232 sw_if_index_set = 1;
8233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8234 sw_if_index_set = 1;
8239 if (sw_if_index_set == 0)
8241 errmsg ("missing vpp interface name. ");
8245 /* Construct the API message */
8246 M (BOND_DELETE, mp);
8248 mp->sw_if_index = ntohl (sw_if_index);
8253 /* Wait for a reply... */
8259 api_bond_enslave (vat_main_t * vam)
8261 unformat_input_t *i = vam->input;
8262 vl_api_bond_enslave_t *mp;
8263 u32 bond_sw_if_index;
8267 u32 bond_sw_if_index_is_set = 0;
8269 u8 sw_if_index_is_set = 0;
8271 /* Parse args required to build the message */
8272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8274 if (unformat (i, "sw_if_index %d", &sw_if_index))
8275 sw_if_index_is_set = 1;
8276 else if (unformat (i, "bond %u", &bond_sw_if_index))
8277 bond_sw_if_index_is_set = 1;
8278 else if (unformat (i, "passive %d", &is_passive))
8280 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8286 if (bond_sw_if_index_is_set == 0)
8288 errmsg ("Missing bond sw_if_index. ");
8291 if (sw_if_index_is_set == 0)
8293 errmsg ("Missing slave sw_if_index. ");
8297 /* Construct the API message */
8298 M (BOND_ENSLAVE, mp);
8300 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8301 mp->sw_if_index = ntohl (sw_if_index);
8302 mp->is_long_timeout = is_long_timeout;
8303 mp->is_passive = is_passive;
8308 /* Wait for a reply... */
8314 api_bond_detach_slave (vat_main_t * vam)
8316 unformat_input_t *i = vam->input;
8317 vl_api_bond_detach_slave_t *mp;
8318 u32 sw_if_index = ~0;
8319 u8 sw_if_index_set = 0;
8322 /* Parse args required to build the message */
8323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8325 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8326 sw_if_index_set = 1;
8327 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8328 sw_if_index_set = 1;
8333 if (sw_if_index_set == 0)
8335 errmsg ("missing vpp interface name. ");
8339 /* Construct the API message */
8340 M (BOND_DETACH_SLAVE, mp);
8342 mp->sw_if_index = ntohl (sw_if_index);
8347 /* Wait for a reply... */
8353 api_ip_table_add_del (vat_main_t * vam)
8355 unformat_input_t *i = vam->input;
8356 vl_api_ip_table_add_del_t *mp;
8362 /* Parse args required to build the message */
8363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8365 if (unformat (i, "ipv6"))
8367 else if (unformat (i, "del"))
8369 else if (unformat (i, "add"))
8371 else if (unformat (i, "table %d", &table_id))
8375 clib_warning ("parse error '%U'", format_unformat_error, i);
8382 errmsg ("missing table-ID");
8386 /* Construct the API message */
8387 M (IP_TABLE_ADD_DEL, mp);
8389 mp->table_id = ntohl (table_id);
8390 mp->is_ipv6 = is_ipv6;
8391 mp->is_add = is_add;
8396 /* Wait for a reply... */
8403 api_ip_add_del_route (vat_main_t * vam)
8405 unformat_input_t *i = vam->input;
8406 vl_api_ip_add_del_route_t *mp;
8407 u32 sw_if_index = ~0, vrf_id = 0;
8409 u8 is_local = 0, is_drop = 0;
8410 u8 is_unreach = 0, is_prohibit = 0;
8412 u32 next_hop_weight = 1;
8413 u8 is_multipath = 0;
8415 u8 address_length_set = 0;
8416 u32 next_hop_table_id = 0;
8417 u32 resolve_attempts = 0;
8418 u32 dst_address_length = 0;
8419 u8 next_hop_set = 0;
8420 ip4_address_t v4_dst_address, v4_next_hop_address;
8421 ip6_address_t v6_dst_address, v6_next_hop_address;
8425 u32 random_add_del = 0;
8426 u32 *random_vector = 0;
8428 u32 random_seed = 0xdeaddabe;
8429 u32 classify_table_index = ~0;
8431 u8 resolve_host = 0, resolve_attached = 0;
8432 mpls_label_t *next_hop_out_label_stack = NULL;
8433 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8434 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8436 /* Parse args required to build the message */
8437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8443 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8448 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8453 else if (unformat (i, "/%d", &dst_address_length))
8455 address_length_set = 1;
8458 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8459 &v4_next_hop_address))
8463 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8464 &v6_next_hop_address))
8468 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8470 else if (unformat (i, "weight %d", &next_hop_weight))
8472 else if (unformat (i, "drop"))
8476 else if (unformat (i, "null-send-unreach"))
8480 else if (unformat (i, "null-send-prohibit"))
8484 else if (unformat (i, "local"))
8488 else if (unformat (i, "classify %d", &classify_table_index))
8492 else if (unformat (i, "del"))
8494 else if (unformat (i, "add"))
8496 else if (unformat (i, "resolve-via-host"))
8498 else if (unformat (i, "resolve-via-attached"))
8499 resolve_attached = 1;
8500 else if (unformat (i, "multipath"))
8502 else if (unformat (i, "vrf %d", &vrf_id))
8504 else if (unformat (i, "count %d", &count))
8506 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8508 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8510 else if (unformat (i, "out-label %d", &next_hop_out_label))
8511 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8512 else if (unformat (i, "via-label %d", &next_hop_via_label))
8514 else if (unformat (i, "random"))
8516 else if (unformat (i, "seed %d", &random_seed))
8520 clib_warning ("parse error '%U'", format_unformat_error, i);
8525 if (!next_hop_set && !is_drop && !is_local &&
8526 !is_classify && !is_unreach && !is_prohibit &&
8527 MPLS_LABEL_INVALID == next_hop_via_label)
8530 ("next hop / local / drop / unreach / prohibit / classify not set");
8534 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8536 errmsg ("next hop and next-hop via label set");
8539 if (address_set == 0)
8541 errmsg ("missing addresses");
8545 if (address_length_set == 0)
8547 errmsg ("missing address length");
8551 /* Generate a pile of unique, random routes */
8554 u32 this_random_address;
8555 random_hash = hash_create (count, sizeof (uword));
8557 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8558 for (j = 0; j <= count; j++)
8562 this_random_address = random_u32 (&random_seed);
8563 this_random_address =
8564 clib_host_to_net_u32 (this_random_address);
8566 while (hash_get (random_hash, this_random_address));
8567 vec_add1 (random_vector, this_random_address);
8568 hash_set (random_hash, this_random_address, 1);
8570 hash_free (random_hash);
8571 v4_dst_address.as_u32 = random_vector[0];
8576 /* Turn on async mode */
8577 vam->async_mode = 1;
8578 vam->async_errors = 0;
8579 before = vat_time_now (vam);
8582 for (j = 0; j < count; j++)
8584 /* Construct the API message */
8585 M2 (IP_ADD_DEL_ROUTE, mp,
8586 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8588 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8589 mp->table_id = ntohl (vrf_id);
8591 mp->is_add = is_add;
8592 mp->is_drop = is_drop;
8593 mp->is_unreach = is_unreach;
8594 mp->is_prohibit = is_prohibit;
8595 mp->is_ipv6 = is_ipv6;
8596 mp->is_local = is_local;
8597 mp->is_classify = is_classify;
8598 mp->is_multipath = is_multipath;
8599 mp->is_resolve_host = resolve_host;
8600 mp->is_resolve_attached = resolve_attached;
8601 mp->next_hop_weight = next_hop_weight;
8602 mp->dst_address_length = dst_address_length;
8603 mp->next_hop_table_id = ntohl (next_hop_table_id);
8604 mp->classify_table_index = ntohl (classify_table_index);
8605 mp->next_hop_via_label = ntohl (next_hop_via_label);
8606 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8607 if (0 != mp->next_hop_n_out_labels)
8609 memcpy (mp->next_hop_out_label_stack,
8610 next_hop_out_label_stack,
8611 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8612 vec_free (next_hop_out_label_stack);
8617 clib_memcpy (mp->dst_address, &v6_dst_address,
8618 sizeof (v6_dst_address));
8620 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8621 sizeof (v6_next_hop_address));
8622 increment_v6_address (&v6_dst_address);
8626 clib_memcpy (mp->dst_address, &v4_dst_address,
8627 sizeof (v4_dst_address));
8629 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8630 sizeof (v4_next_hop_address));
8632 v4_dst_address.as_u32 = random_vector[j + 1];
8634 increment_v4_address (&v4_dst_address);
8638 /* If we receive SIGTERM, stop now... */
8643 /* When testing multiple add/del ops, use a control-ping to sync */
8646 vl_api_control_ping_t *mp_ping;
8650 /* Shut off async mode */
8651 vam->async_mode = 0;
8653 MPING (CONTROL_PING, mp_ping);
8656 timeout = vat_time_now (vam) + 1.0;
8657 while (vat_time_now (vam) < timeout)
8658 if (vam->result_ready == 1)
8663 if (vam->retval == -99)
8666 if (vam->async_errors > 0)
8668 errmsg ("%d asynchronous errors", vam->async_errors);
8671 vam->async_errors = 0;
8672 after = vat_time_now (vam);
8674 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8678 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8679 count, after - before, count / (after - before));
8685 /* Wait for a reply... */
8690 /* Return the good/bad news */
8691 return (vam->retval);
8695 api_ip_mroute_add_del (vat_main_t * vam)
8697 unformat_input_t *i = vam->input;
8698 vl_api_ip_mroute_add_del_t *mp;
8699 u32 sw_if_index = ~0, vrf_id = 0;
8704 u32 grp_address_length = 0;
8705 ip4_address_t v4_grp_address, v4_src_address;
8706 ip6_address_t v6_grp_address, v6_src_address;
8707 mfib_itf_flags_t iflags = 0;
8708 mfib_entry_flags_t eflags = 0;
8711 /* Parse args required to build the message */
8712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8714 if (unformat (i, "sw_if_index %d", &sw_if_index))
8716 else if (unformat (i, "%U %U",
8717 unformat_ip4_address, &v4_src_address,
8718 unformat_ip4_address, &v4_grp_address))
8720 grp_address_length = 64;
8724 else if (unformat (i, "%U %U",
8725 unformat_ip6_address, &v6_src_address,
8726 unformat_ip6_address, &v6_grp_address))
8728 grp_address_length = 256;
8732 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8734 memset (&v4_src_address, 0, sizeof (v4_src_address));
8735 grp_address_length = 32;
8739 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8741 memset (&v6_src_address, 0, sizeof (v6_src_address));
8742 grp_address_length = 128;
8746 else if (unformat (i, "/%d", &grp_address_length))
8748 else if (unformat (i, "local"))
8752 else if (unformat (i, "del"))
8754 else if (unformat (i, "add"))
8756 else if (unformat (i, "vrf %d", &vrf_id))
8758 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8760 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8764 clib_warning ("parse error '%U'", format_unformat_error, i);
8769 if (address_set == 0)
8771 errmsg ("missing addresses\n");
8775 /* Construct the API message */
8776 M (IP_MROUTE_ADD_DEL, mp);
8778 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8779 mp->table_id = ntohl (vrf_id);
8781 mp->is_add = is_add;
8782 mp->is_ipv6 = is_ipv6;
8783 mp->is_local = is_local;
8784 mp->itf_flags = ntohl (iflags);
8785 mp->entry_flags = ntohl (eflags);
8786 mp->grp_address_length = grp_address_length;
8787 mp->grp_address_length = ntohs (mp->grp_address_length);
8791 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8792 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8796 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8797 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8803 /* Wait for a reply... */
8809 api_mpls_table_add_del (vat_main_t * vam)
8811 unformat_input_t *i = vam->input;
8812 vl_api_mpls_table_add_del_t *mp;
8817 /* Parse args required to build the message */
8818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8820 if (unformat (i, "table %d", &table_id))
8822 else if (unformat (i, "del"))
8824 else if (unformat (i, "add"))
8828 clib_warning ("parse error '%U'", format_unformat_error, i);
8835 errmsg ("missing table-ID");
8839 /* Construct the API message */
8840 M (MPLS_TABLE_ADD_DEL, mp);
8842 mp->mt_table_id = ntohl (table_id);
8843 mp->mt_is_add = is_add;
8848 /* Wait for a reply... */
8855 api_mpls_route_add_del (vat_main_t * vam)
8857 unformat_input_t *i = vam->input;
8858 vl_api_mpls_route_add_del_t *mp;
8859 u32 sw_if_index = ~0, table_id = 0;
8861 u32 next_hop_weight = 1;
8862 u8 is_multipath = 0;
8863 u32 next_hop_table_id = 0;
8864 u8 next_hop_set = 0;
8865 ip4_address_t v4_next_hop_address = {
8868 ip6_address_t v6_next_hop_address = { {0} };
8872 u32 classify_table_index = ~0;
8874 u8 resolve_host = 0, resolve_attached = 0;
8875 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8876 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8877 mpls_label_t *next_hop_out_label_stack = NULL;
8878 mpls_label_t local_label = MPLS_LABEL_INVALID;
8880 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8882 /* Parse args required to build the message */
8883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8889 else if (unformat (i, "%d", &local_label))
8891 else if (unformat (i, "eos"))
8893 else if (unformat (i, "non-eos"))
8895 else if (unformat (i, "via %U", unformat_ip4_address,
8896 &v4_next_hop_address))
8899 next_hop_proto = DPO_PROTO_IP4;
8901 else if (unformat (i, "via %U", unformat_ip6_address,
8902 &v6_next_hop_address))
8905 next_hop_proto = DPO_PROTO_IP6;
8907 else if (unformat (i, "weight %d", &next_hop_weight))
8909 else if (unformat (i, "classify %d", &classify_table_index))
8913 else if (unformat (i, "del"))
8915 else if (unformat (i, "add"))
8917 else if (unformat (i, "resolve-via-host"))
8919 else if (unformat (i, "resolve-via-attached"))
8920 resolve_attached = 1;
8921 else if (unformat (i, "multipath"))
8923 else if (unformat (i, "count %d", &count))
8925 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8928 next_hop_proto = DPO_PROTO_IP4;
8930 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8933 next_hop_proto = DPO_PROTO_IP6;
8935 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8937 else if (unformat (i, "via-label %d", &next_hop_via_label))
8939 else if (unformat (i, "out-label %d", &next_hop_out_label))
8940 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8943 clib_warning ("parse error '%U'", format_unformat_error, i);
8948 if (!next_hop_set && !is_classify)
8950 errmsg ("next hop / classify not set");
8954 if (MPLS_LABEL_INVALID == local_label)
8956 errmsg ("missing label");
8962 /* Turn on async mode */
8963 vam->async_mode = 1;
8964 vam->async_errors = 0;
8965 before = vat_time_now (vam);
8968 for (j = 0; j < count; j++)
8970 /* Construct the API message */
8971 M2 (MPLS_ROUTE_ADD_DEL, mp,
8972 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8974 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8975 mp->mr_table_id = ntohl (table_id);
8977 mp->mr_is_add = is_add;
8978 mp->mr_next_hop_proto = next_hop_proto;
8979 mp->mr_is_classify = is_classify;
8980 mp->mr_is_multipath = is_multipath;
8981 mp->mr_is_resolve_host = resolve_host;
8982 mp->mr_is_resolve_attached = resolve_attached;
8983 mp->mr_next_hop_weight = next_hop_weight;
8984 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8985 mp->mr_classify_table_index = ntohl (classify_table_index);
8986 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8987 mp->mr_label = ntohl (local_label);
8988 mp->mr_eos = is_eos;
8990 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8991 if (0 != mp->mr_next_hop_n_out_labels)
8993 memcpy (mp->mr_next_hop_out_label_stack,
8994 next_hop_out_label_stack,
8995 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8996 vec_free (next_hop_out_label_stack);
9001 if (DPO_PROTO_IP4 == next_hop_proto)
9003 clib_memcpy (mp->mr_next_hop,
9004 &v4_next_hop_address,
9005 sizeof (v4_next_hop_address));
9007 else if (DPO_PROTO_IP6 == next_hop_proto)
9010 clib_memcpy (mp->mr_next_hop,
9011 &v6_next_hop_address,
9012 sizeof (v6_next_hop_address));
9019 /* If we receive SIGTERM, stop now... */
9024 /* When testing multiple add/del ops, use a control-ping to sync */
9027 vl_api_control_ping_t *mp_ping;
9031 /* Shut off async mode */
9032 vam->async_mode = 0;
9034 MPING (CONTROL_PING, mp_ping);
9037 timeout = vat_time_now (vam) + 1.0;
9038 while (vat_time_now (vam) < timeout)
9039 if (vam->result_ready == 1)
9044 if (vam->retval == -99)
9047 if (vam->async_errors > 0)
9049 errmsg ("%d asynchronous errors", vam->async_errors);
9052 vam->async_errors = 0;
9053 after = vat_time_now (vam);
9055 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9059 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9060 count, after - before, count / (after - before));
9066 /* Wait for a reply... */
9071 /* Return the good/bad news */
9072 return (vam->retval);
9076 api_mpls_ip_bind_unbind (vat_main_t * vam)
9078 unformat_input_t *i = vam->input;
9079 vl_api_mpls_ip_bind_unbind_t *mp;
9080 u32 ip_table_id = 0;
9083 ip4_address_t v4_address;
9084 ip6_address_t v6_address;
9087 mpls_label_t local_label = MPLS_LABEL_INVALID;
9090 /* Parse args required to build the message */
9091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9093 if (unformat (i, "%U/%d", unformat_ip4_address,
9094 &v4_address, &address_length))
9099 else if (unformat (i, "%U/%d", unformat_ip6_address,
9100 &v6_address, &address_length))
9105 else if (unformat (i, "%d", &local_label))
9107 else if (unformat (i, "table-id %d", &ip_table_id))
9109 else if (unformat (i, "unbind"))
9111 else if (unformat (i, "bind"))
9115 clib_warning ("parse error '%U'", format_unformat_error, i);
9122 errmsg ("IP addres not set");
9126 if (MPLS_LABEL_INVALID == local_label)
9128 errmsg ("missing label");
9132 /* Construct the API message */
9133 M (MPLS_IP_BIND_UNBIND, mp);
9135 mp->mb_is_bind = is_bind;
9136 mp->mb_is_ip4 = is_ip4;
9137 mp->mb_ip_table_id = ntohl (ip_table_id);
9138 mp->mb_mpls_table_id = 0;
9139 mp->mb_label = ntohl (local_label);
9140 mp->mb_address_length = address_length;
9143 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9145 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9150 /* Wait for a reply... */
9156 api_bier_table_add_del (vat_main_t * vam)
9158 unformat_input_t *i = vam->input;
9159 vl_api_bier_table_add_del_t *mp;
9161 u32 set = 0, sub_domain = 0, hdr_len = 3;
9162 mpls_label_t local_label = MPLS_LABEL_INVALID;
9165 /* Parse args required to build the message */
9166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9168 if (unformat (i, "sub-domain %d", &sub_domain))
9170 else if (unformat (i, "set %d", &set))
9172 else if (unformat (i, "label %d", &local_label))
9174 else if (unformat (i, "hdr-len %d", &hdr_len))
9176 else if (unformat (i, "add"))
9178 else if (unformat (i, "del"))
9182 clib_warning ("parse error '%U'", format_unformat_error, i);
9187 if (MPLS_LABEL_INVALID == local_label)
9189 errmsg ("missing label\n");
9193 /* Construct the API message */
9194 M (BIER_TABLE_ADD_DEL, mp);
9196 mp->bt_is_add = is_add;
9197 mp->bt_label = ntohl (local_label);
9198 mp->bt_tbl_id.bt_set = set;
9199 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9200 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9205 /* Wait for a reply... */
9212 api_bier_route_add_del (vat_main_t * vam)
9214 unformat_input_t *i = vam->input;
9215 vl_api_bier_route_add_del_t *mp;
9217 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9218 ip4_address_t v4_next_hop_address;
9219 ip6_address_t v6_next_hop_address;
9220 u8 next_hop_set = 0;
9221 u8 next_hop_proto_is_ip4 = 1;
9222 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9225 /* Parse args required to build the message */
9226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9228 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9230 next_hop_proto_is_ip4 = 1;
9233 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9235 next_hop_proto_is_ip4 = 0;
9238 if (unformat (i, "sub-domain %d", &sub_domain))
9240 else if (unformat (i, "set %d", &set))
9242 else if (unformat (i, "hdr-len %d", &hdr_len))
9244 else if (unformat (i, "bp %d", &bp))
9246 else if (unformat (i, "add"))
9248 else if (unformat (i, "del"))
9250 else if (unformat (i, "out-label %d", &next_hop_out_label))
9254 clib_warning ("parse error '%U'", format_unformat_error, i);
9259 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9261 errmsg ("next hop / label set\n");
9266 errmsg ("bit=position not set\n");
9270 /* Construct the API message */
9271 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9273 mp->br_is_add = is_add;
9274 mp->br_tbl_id.bt_set = set;
9275 mp->br_tbl_id.bt_sub_domain = sub_domain;
9276 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9277 mp->br_bp = ntohs (bp);
9279 mp->br_paths[0].n_labels = 1;
9280 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9281 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9283 if (next_hop_proto_is_ip4)
9285 clib_memcpy (mp->br_paths[0].next_hop,
9286 &v4_next_hop_address, sizeof (v4_next_hop_address));
9290 clib_memcpy (mp->br_paths[0].next_hop,
9291 &v6_next_hop_address, sizeof (v6_next_hop_address));
9297 /* Wait for a reply... */
9304 api_proxy_arp_add_del (vat_main_t * vam)
9306 unformat_input_t *i = vam->input;
9307 vl_api_proxy_arp_add_del_t *mp;
9310 ip4_address_t lo, hi;
9314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9316 if (unformat (i, "vrf %d", &vrf_id))
9318 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9319 unformat_ip4_address, &hi))
9321 else if (unformat (i, "del"))
9325 clib_warning ("parse error '%U'", format_unformat_error, i);
9332 errmsg ("address range not set");
9336 M (PROXY_ARP_ADD_DEL, mp);
9338 mp->proxy.vrf_id = ntohl (vrf_id);
9339 mp->is_add = is_add;
9340 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9341 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9349 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9351 unformat_input_t *i = vam->input;
9352 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9355 u8 sw_if_index_set = 0;
9358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9361 sw_if_index_set = 1;
9362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9363 sw_if_index_set = 1;
9364 else if (unformat (i, "enable"))
9366 else if (unformat (i, "disable"))
9370 clib_warning ("parse error '%U'", format_unformat_error, i);
9375 if (sw_if_index_set == 0)
9377 errmsg ("missing interface name or sw_if_index");
9381 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9383 mp->sw_if_index = ntohl (sw_if_index);
9384 mp->enable_disable = enable;
9392 api_mpls_tunnel_add_del (vat_main_t * vam)
9394 unformat_input_t *i = vam->input;
9395 vl_api_mpls_tunnel_add_del_t *mp;
9399 u32 sw_if_index = ~0;
9400 u32 next_hop_sw_if_index = ~0;
9401 u32 next_hop_proto_is_ip4 = 1;
9403 u32 next_hop_table_id = 0;
9404 ip4_address_t v4_next_hop_address = {
9407 ip6_address_t v6_next_hop_address = { {0} };
9408 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9413 if (unformat (i, "add"))
9415 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9417 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9419 else if (unformat (i, "via %U",
9420 unformat_ip4_address, &v4_next_hop_address))
9422 next_hop_proto_is_ip4 = 1;
9424 else if (unformat (i, "via %U",
9425 unformat_ip6_address, &v6_next_hop_address))
9427 next_hop_proto_is_ip4 = 0;
9429 else if (unformat (i, "l2-only"))
9431 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9433 else if (unformat (i, "out-label %d", &next_hop_out_label))
9434 vec_add1 (labels, ntohl (next_hop_out_label));
9437 clib_warning ("parse error '%U'", format_unformat_error, i);
9442 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9444 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9445 mp->mt_sw_if_index = ntohl (sw_if_index);
9446 mp->mt_is_add = is_add;
9447 mp->mt_l2_only = l2_only;
9448 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9449 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9451 mp->mt_next_hop_n_out_labels = vec_len (labels);
9453 if (0 != mp->mt_next_hop_n_out_labels)
9455 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9456 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9460 if (next_hop_proto_is_ip4)
9462 clib_memcpy (mp->mt_next_hop,
9463 &v4_next_hop_address, sizeof (v4_next_hop_address));
9467 clib_memcpy (mp->mt_next_hop,
9468 &v6_next_hop_address, sizeof (v6_next_hop_address));
9477 api_sw_interface_set_unnumbered (vat_main_t * vam)
9479 unformat_input_t *i = vam->input;
9480 vl_api_sw_interface_set_unnumbered_t *mp;
9482 u32 unnum_sw_index = ~0;
9484 u8 sw_if_index_set = 0;
9487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9490 sw_if_index_set = 1;
9491 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9492 sw_if_index_set = 1;
9493 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9495 else if (unformat (i, "del"))
9499 clib_warning ("parse error '%U'", format_unformat_error, i);
9504 if (sw_if_index_set == 0)
9506 errmsg ("missing interface name or sw_if_index");
9510 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9512 mp->sw_if_index = ntohl (sw_if_index);
9513 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9514 mp->is_add = is_add;
9522 api_ip_neighbor_add_del (vat_main_t * vam)
9524 unformat_input_t *i = vam->input;
9525 vl_api_ip_neighbor_add_del_t *mp;
9527 u8 sw_if_index_set = 0;
9530 u8 is_no_fib_entry = 0;
9533 u8 v4_address_set = 0;
9534 u8 v6_address_set = 0;
9535 ip4_address_t v4address;
9536 ip6_address_t v6address;
9539 memset (mac_address, 0, sizeof (mac_address));
9541 /* Parse args required to build the message */
9542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9544 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9548 else if (unformat (i, "del"))
9551 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9552 sw_if_index_set = 1;
9553 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9554 sw_if_index_set = 1;
9555 else if (unformat (i, "is_static"))
9557 else if (unformat (i, "no-fib-entry"))
9558 is_no_fib_entry = 1;
9559 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9561 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9565 clib_warning ("parse error '%U'", format_unformat_error, i);
9570 if (sw_if_index_set == 0)
9572 errmsg ("missing interface name or sw_if_index");
9575 if (v4_address_set && v6_address_set)
9577 errmsg ("both v4 and v6 addresses set");
9580 if (!v4_address_set && !v6_address_set)
9582 errmsg ("no address set");
9586 /* Construct the API message */
9587 M (IP_NEIGHBOR_ADD_DEL, mp);
9589 mp->sw_if_index = ntohl (sw_if_index);
9590 mp->is_add = is_add;
9591 mp->is_static = is_static;
9592 mp->is_no_adj_fib = is_no_fib_entry;
9594 clib_memcpy (mp->mac_address, mac_address, 6);
9598 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9602 /* mp->is_ipv6 = 0; via memset in M macro above */
9603 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9609 /* Wait for a reply, return good/bad news */
9615 api_create_vlan_subif (vat_main_t * vam)
9617 unformat_input_t *i = vam->input;
9618 vl_api_create_vlan_subif_t *mp;
9620 u8 sw_if_index_set = 0;
9625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9627 if (unformat (i, "sw_if_index %d", &sw_if_index))
9628 sw_if_index_set = 1;
9630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9631 sw_if_index_set = 1;
9632 else if (unformat (i, "vlan %d", &vlan_id))
9636 clib_warning ("parse error '%U'", format_unformat_error, i);
9641 if (sw_if_index_set == 0)
9643 errmsg ("missing interface name or sw_if_index");
9647 if (vlan_id_set == 0)
9649 errmsg ("missing vlan_id");
9652 M (CREATE_VLAN_SUBIF, mp);
9654 mp->sw_if_index = ntohl (sw_if_index);
9655 mp->vlan_id = ntohl (vlan_id);
9662 #define foreach_create_subif_bit \
9669 _(outer_vlan_id_any) \
9670 _(inner_vlan_id_any)
9673 api_create_subif (vat_main_t * vam)
9675 unformat_input_t *i = vam->input;
9676 vl_api_create_subif_t *mp;
9678 u8 sw_if_index_set = 0;
9685 u32 exact_match = 0;
9686 u32 default_sub = 0;
9687 u32 outer_vlan_id_any = 0;
9688 u32 inner_vlan_id_any = 0;
9690 u16 outer_vlan_id = 0;
9691 u16 inner_vlan_id = 0;
9694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9696 if (unformat (i, "sw_if_index %d", &sw_if_index))
9697 sw_if_index_set = 1;
9699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9700 sw_if_index_set = 1;
9701 else if (unformat (i, "sub_id %d", &sub_id))
9703 else if (unformat (i, "outer_vlan_id %d", &tmp))
9704 outer_vlan_id = tmp;
9705 else if (unformat (i, "inner_vlan_id %d", &tmp))
9706 inner_vlan_id = tmp;
9708 #define _(a) else if (unformat (i, #a)) a = 1 ;
9709 foreach_create_subif_bit
9713 clib_warning ("parse error '%U'", format_unformat_error, i);
9718 if (sw_if_index_set == 0)
9720 errmsg ("missing interface name or sw_if_index");
9724 if (sub_id_set == 0)
9726 errmsg ("missing sub_id");
9729 M (CREATE_SUBIF, mp);
9731 mp->sw_if_index = ntohl (sw_if_index);
9732 mp->sub_id = ntohl (sub_id);
9734 #define _(a) mp->a = a;
9735 foreach_create_subif_bit;
9738 mp->outer_vlan_id = ntohs (outer_vlan_id);
9739 mp->inner_vlan_id = ntohs (inner_vlan_id);
9747 api_oam_add_del (vat_main_t * vam)
9749 unformat_input_t *i = vam->input;
9750 vl_api_oam_add_del_t *mp;
9753 ip4_address_t src, dst;
9758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9760 if (unformat (i, "vrf %d", &vrf_id))
9762 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9764 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9766 else if (unformat (i, "del"))
9770 clib_warning ("parse error '%U'", format_unformat_error, i);
9777 errmsg ("missing src addr");
9783 errmsg ("missing dst addr");
9787 M (OAM_ADD_DEL, mp);
9789 mp->vrf_id = ntohl (vrf_id);
9790 mp->is_add = is_add;
9791 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9792 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9800 api_reset_fib (vat_main_t * vam)
9802 unformat_input_t *i = vam->input;
9803 vl_api_reset_fib_t *mp;
9809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9811 if (unformat (i, "vrf %d", &vrf_id))
9813 else if (unformat (i, "ipv6"))
9817 clib_warning ("parse error '%U'", format_unformat_error, i);
9822 if (vrf_id_set == 0)
9824 errmsg ("missing vrf id");
9830 mp->vrf_id = ntohl (vrf_id);
9831 mp->is_ipv6 = is_ipv6;
9839 api_dhcp_proxy_config (vat_main_t * vam)
9841 unformat_input_t *i = vam->input;
9842 vl_api_dhcp_proxy_config_t *mp;
9844 u32 server_vrf_id = 0;
9846 u8 v4_address_set = 0;
9847 u8 v6_address_set = 0;
9848 ip4_address_t v4address;
9849 ip6_address_t v6address;
9850 u8 v4_src_address_set = 0;
9851 u8 v6_src_address_set = 0;
9852 ip4_address_t v4srcaddress;
9853 ip6_address_t v6srcaddress;
9856 /* Parse args required to build the message */
9857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9859 if (unformat (i, "del"))
9861 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9863 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9865 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9867 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9869 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9870 v4_src_address_set = 1;
9871 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9872 v6_src_address_set = 1;
9877 if (v4_address_set && v6_address_set)
9879 errmsg ("both v4 and v6 server addresses set");
9882 if (!v4_address_set && !v6_address_set)
9884 errmsg ("no server addresses set");
9888 if (v4_src_address_set && v6_src_address_set)
9890 errmsg ("both v4 and v6 src addresses set");
9893 if (!v4_src_address_set && !v6_src_address_set)
9895 errmsg ("no src addresses set");
9899 if (!(v4_src_address_set && v4_address_set) &&
9900 !(v6_src_address_set && v6_address_set))
9902 errmsg ("no matching server and src addresses set");
9906 /* Construct the API message */
9907 M (DHCP_PROXY_CONFIG, mp);
9909 mp->is_add = is_add;
9910 mp->rx_vrf_id = ntohl (rx_vrf_id);
9911 mp->server_vrf_id = ntohl (server_vrf_id);
9915 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9916 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9920 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9921 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9927 /* Wait for a reply, return good/bad news */
9932 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9933 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9936 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9938 vat_main_t *vam = &vat_main;
9939 u32 i, count = mp->count;
9940 vl_api_dhcp_server_t *s;
9944 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9945 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9946 ntohl (mp->rx_vrf_id),
9947 format_ip6_address, mp->dhcp_src_address,
9948 mp->vss_type, mp->vss_vpn_ascii_id,
9949 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9952 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9953 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9954 ntohl (mp->rx_vrf_id),
9955 format_ip4_address, mp->dhcp_src_address,
9956 mp->vss_type, mp->vss_vpn_ascii_id,
9957 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9959 for (i = 0; i < count; i++)
9961 s = &mp->servers[i];
9965 " Server Table-ID %d, Server Address %U",
9966 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9969 " Server Table-ID %d, Server Address %U",
9970 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9974 static void vl_api_dhcp_proxy_details_t_handler_json
9975 (vl_api_dhcp_proxy_details_t * mp)
9977 vat_main_t *vam = &vat_main;
9978 vat_json_node_t *node = NULL;
9979 u32 i, count = mp->count;
9981 struct in6_addr ip6;
9982 vl_api_dhcp_server_t *s;
9984 if (VAT_JSON_ARRAY != vam->json_tree.type)
9986 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9987 vat_json_init_array (&vam->json_tree);
9989 node = vat_json_array_add (&vam->json_tree);
9991 vat_json_init_object (node);
9992 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9993 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9994 sizeof (mp->vss_type));
9995 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9996 mp->vss_vpn_ascii_id);
9997 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9998 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
10002 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
10003 vat_json_object_add_ip6 (node, "src_address", ip6);
10007 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
10008 vat_json_object_add_ip4 (node, "src_address", ip4);
10011 for (i = 0; i < count; i++)
10013 s = &mp->servers[i];
10015 vat_json_object_add_uint (node, "server-table-id",
10016 ntohl (s->server_vrf_id));
10020 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
10021 vat_json_object_add_ip4 (node, "src_address", ip4);
10025 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
10026 vat_json_object_add_ip6 (node, "server_address", ip6);
10032 api_dhcp_proxy_dump (vat_main_t * vam)
10034 unformat_input_t *i = vam->input;
10035 vl_api_control_ping_t *mp_ping;
10036 vl_api_dhcp_proxy_dump_t *mp;
10040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10042 if (unformat (i, "ipv6"))
10046 clib_warning ("parse error '%U'", format_unformat_error, i);
10051 M (DHCP_PROXY_DUMP, mp);
10053 mp->is_ip6 = is_ipv6;
10056 /* Use a control ping for synchronization */
10057 MPING (CONTROL_PING, mp_ping);
10065 api_dhcp_proxy_set_vss (vat_main_t * vam)
10067 unformat_input_t *i = vam->input;
10068 vl_api_dhcp_proxy_set_vss_t *mp;
10072 u8 vss_type = VSS_TYPE_DEFAULT;
10073 u8 *vpn_ascii_id = 0;
10078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10080 if (unformat (i, "tbl_id %d", &tbl_id))
10082 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10083 vss_type = VSS_TYPE_ASCII;
10084 else if (unformat (i, "fib_id %d", &fib_id))
10085 vss_type = VSS_TYPE_VPN_ID;
10086 else if (unformat (i, "oui %d", &oui))
10087 vss_type = VSS_TYPE_VPN_ID;
10088 else if (unformat (i, "ipv6"))
10090 else if (unformat (i, "del"))
10098 errmsg ("missing tbl_id ");
10099 vec_free (vpn_ascii_id);
10103 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10105 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10106 vec_free (vpn_ascii_id);
10110 M (DHCP_PROXY_SET_VSS, mp);
10111 mp->tbl_id = ntohl (tbl_id);
10112 mp->vss_type = vss_type;
10115 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10116 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10118 mp->vpn_index = ntohl (fib_id);
10119 mp->oui = ntohl (oui);
10120 mp->is_ipv6 = is_ipv6;
10121 mp->is_add = is_add;
10126 vec_free (vpn_ascii_id);
10131 api_dhcp_client_config (vat_main_t * vam)
10133 unformat_input_t *i = vam->input;
10134 vl_api_dhcp_client_config_t *mp;
10136 u8 sw_if_index_set = 0;
10139 u8 disable_event = 0;
10142 /* Parse args required to build the message */
10143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10145 if (unformat (i, "del"))
10148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10149 sw_if_index_set = 1;
10150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10151 sw_if_index_set = 1;
10152 else if (unformat (i, "hostname %s", &hostname))
10154 else if (unformat (i, "disable_event"))
10160 if (sw_if_index_set == 0)
10162 errmsg ("missing interface name or sw_if_index");
10166 if (vec_len (hostname) > 63)
10168 errmsg ("hostname too long");
10170 vec_add1 (hostname, 0);
10172 /* Construct the API message */
10173 M (DHCP_CLIENT_CONFIG, mp);
10175 mp->is_add = is_add;
10176 mp->client.sw_if_index = htonl (sw_if_index);
10177 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10178 vec_free (hostname);
10179 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10180 mp->client.pid = htonl (getpid ());
10185 /* Wait for a reply, return good/bad news */
10191 api_set_ip_flow_hash (vat_main_t * vam)
10193 unformat_input_t *i = vam->input;
10194 vl_api_set_ip_flow_hash_t *mp;
10206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10208 if (unformat (i, "vrf %d", &vrf_id))
10210 else if (unformat (i, "ipv6"))
10212 else if (unformat (i, "src"))
10214 else if (unformat (i, "dst"))
10216 else if (unformat (i, "sport"))
10218 else if (unformat (i, "dport"))
10220 else if (unformat (i, "proto"))
10222 else if (unformat (i, "reverse"))
10227 clib_warning ("parse error '%U'", format_unformat_error, i);
10232 if (vrf_id_set == 0)
10234 errmsg ("missing vrf id");
10238 M (SET_IP_FLOW_HASH, mp);
10244 mp->reverse = reverse;
10245 mp->vrf_id = ntohl (vrf_id);
10246 mp->is_ipv6 = is_ipv6;
10254 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10256 unformat_input_t *i = vam->input;
10257 vl_api_sw_interface_ip6_enable_disable_t *mp;
10259 u8 sw_if_index_set = 0;
10263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10266 sw_if_index_set = 1;
10267 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10268 sw_if_index_set = 1;
10269 else if (unformat (i, "enable"))
10271 else if (unformat (i, "disable"))
10275 clib_warning ("parse error '%U'", format_unformat_error, i);
10280 if (sw_if_index_set == 0)
10282 errmsg ("missing interface name or sw_if_index");
10286 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10288 mp->sw_if_index = ntohl (sw_if_index);
10289 mp->enable = enable;
10297 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10299 unformat_input_t *i = vam->input;
10300 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10302 u8 sw_if_index_set = 0;
10303 u8 v6_address_set = 0;
10304 ip6_address_t v6address;
10307 /* Parse args required to build the message */
10308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10310 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10311 sw_if_index_set = 1;
10312 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10313 sw_if_index_set = 1;
10314 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10315 v6_address_set = 1;
10320 if (sw_if_index_set == 0)
10322 errmsg ("missing interface name or sw_if_index");
10325 if (!v6_address_set)
10327 errmsg ("no address set");
10331 /* Construct the API message */
10332 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10334 mp->sw_if_index = ntohl (sw_if_index);
10335 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10340 /* Wait for a reply, return good/bad news */
10346 api_ip6nd_proxy_add_del (vat_main_t * vam)
10348 unformat_input_t *i = vam->input;
10349 vl_api_ip6nd_proxy_add_del_t *mp;
10350 u32 sw_if_index = ~0;
10351 u8 v6_address_set = 0;
10352 ip6_address_t v6address;
10356 /* Parse args required to build the message */
10357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10363 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10364 v6_address_set = 1;
10365 if (unformat (i, "del"))
10369 clib_warning ("parse error '%U'", format_unformat_error, i);
10374 if (sw_if_index == ~0)
10376 errmsg ("missing interface name or sw_if_index");
10379 if (!v6_address_set)
10381 errmsg ("no address set");
10385 /* Construct the API message */
10386 M (IP6ND_PROXY_ADD_DEL, mp);
10388 mp->is_del = is_del;
10389 mp->sw_if_index = ntohl (sw_if_index);
10390 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10395 /* Wait for a reply, return good/bad news */
10401 api_ip6nd_proxy_dump (vat_main_t * vam)
10403 vl_api_ip6nd_proxy_dump_t *mp;
10404 vl_api_control_ping_t *mp_ping;
10407 M (IP6ND_PROXY_DUMP, mp);
10411 /* Use a control ping for synchronization */
10412 MPING (CONTROL_PING, mp_ping);
10419 static void vl_api_ip6nd_proxy_details_t_handler
10420 (vl_api_ip6nd_proxy_details_t * mp)
10422 vat_main_t *vam = &vat_main;
10424 print (vam->ofp, "host %U sw_if_index %d",
10425 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10428 static void vl_api_ip6nd_proxy_details_t_handler_json
10429 (vl_api_ip6nd_proxy_details_t * mp)
10431 vat_main_t *vam = &vat_main;
10432 struct in6_addr ip6;
10433 vat_json_node_t *node = NULL;
10435 if (VAT_JSON_ARRAY != vam->json_tree.type)
10437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10438 vat_json_init_array (&vam->json_tree);
10440 node = vat_json_array_add (&vam->json_tree);
10442 vat_json_init_object (node);
10443 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10445 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10446 vat_json_object_add_ip6 (node, "host", ip6);
10450 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10452 unformat_input_t *i = vam->input;
10453 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10455 u8 sw_if_index_set = 0;
10456 u32 address_length = 0;
10457 u8 v6_address_set = 0;
10458 ip6_address_t v6address;
10459 u8 use_default = 0;
10460 u8 no_advertise = 0;
10462 u8 no_autoconfig = 0;
10465 u32 val_lifetime = 0;
10466 u32 pref_lifetime = 0;
10469 /* Parse args required to build the message */
10470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10472 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10473 sw_if_index_set = 1;
10474 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10475 sw_if_index_set = 1;
10476 else if (unformat (i, "%U/%d",
10477 unformat_ip6_address, &v6address, &address_length))
10478 v6_address_set = 1;
10479 else if (unformat (i, "val_life %d", &val_lifetime))
10481 else if (unformat (i, "pref_life %d", &pref_lifetime))
10483 else if (unformat (i, "def"))
10485 else if (unformat (i, "noadv"))
10487 else if (unformat (i, "offl"))
10489 else if (unformat (i, "noauto"))
10491 else if (unformat (i, "nolink"))
10493 else if (unformat (i, "isno"))
10497 clib_warning ("parse error '%U'", format_unformat_error, i);
10502 if (sw_if_index_set == 0)
10504 errmsg ("missing interface name or sw_if_index");
10507 if (!v6_address_set)
10509 errmsg ("no address set");
10513 /* Construct the API message */
10514 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10516 mp->sw_if_index = ntohl (sw_if_index);
10517 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10518 mp->address_length = address_length;
10519 mp->use_default = use_default;
10520 mp->no_advertise = no_advertise;
10521 mp->off_link = off_link;
10522 mp->no_autoconfig = no_autoconfig;
10523 mp->no_onlink = no_onlink;
10525 mp->val_lifetime = ntohl (val_lifetime);
10526 mp->pref_lifetime = ntohl (pref_lifetime);
10531 /* Wait for a reply, return good/bad news */
10537 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10539 unformat_input_t *i = vam->input;
10540 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10542 u8 sw_if_index_set = 0;
10547 u8 send_unicast = 0;
10550 u8 default_router = 0;
10551 u32 max_interval = 0;
10552 u32 min_interval = 0;
10554 u32 initial_count = 0;
10555 u32 initial_interval = 0;
10559 /* Parse args required to build the message */
10560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10563 sw_if_index_set = 1;
10564 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10565 sw_if_index_set = 1;
10566 else if (unformat (i, "maxint %d", &max_interval))
10568 else if (unformat (i, "minint %d", &min_interval))
10570 else if (unformat (i, "life %d", &lifetime))
10572 else if (unformat (i, "count %d", &initial_count))
10574 else if (unformat (i, "interval %d", &initial_interval))
10576 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10578 else if (unformat (i, "managed"))
10580 else if (unformat (i, "other"))
10582 else if (unformat (i, "ll"))
10584 else if (unformat (i, "send"))
10586 else if (unformat (i, "cease"))
10588 else if (unformat (i, "isno"))
10590 else if (unformat (i, "def"))
10591 default_router = 1;
10594 clib_warning ("parse error '%U'", format_unformat_error, i);
10599 if (sw_if_index_set == 0)
10601 errmsg ("missing interface name or sw_if_index");
10605 /* Construct the API message */
10606 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10608 mp->sw_if_index = ntohl (sw_if_index);
10609 mp->max_interval = ntohl (max_interval);
10610 mp->min_interval = ntohl (min_interval);
10611 mp->lifetime = ntohl (lifetime);
10612 mp->initial_count = ntohl (initial_count);
10613 mp->initial_interval = ntohl (initial_interval);
10614 mp->suppress = suppress;
10615 mp->managed = managed;
10617 mp->ll_option = ll_option;
10618 mp->send_unicast = send_unicast;
10621 mp->default_router = default_router;
10626 /* Wait for a reply, return good/bad news */
10632 api_set_arp_neighbor_limit (vat_main_t * vam)
10634 unformat_input_t *i = vam->input;
10635 vl_api_set_arp_neighbor_limit_t *mp;
10641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10643 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10645 else if (unformat (i, "ipv6"))
10649 clib_warning ("parse error '%U'", format_unformat_error, i);
10654 if (limit_set == 0)
10656 errmsg ("missing limit value");
10660 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10662 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10663 mp->is_ipv6 = is_ipv6;
10671 api_l2_patch_add_del (vat_main_t * vam)
10673 unformat_input_t *i = vam->input;
10674 vl_api_l2_patch_add_del_t *mp;
10675 u32 rx_sw_if_index;
10676 u8 rx_sw_if_index_set = 0;
10677 u32 tx_sw_if_index;
10678 u8 tx_sw_if_index_set = 0;
10682 /* Parse args required to build the message */
10683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10685 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10686 rx_sw_if_index_set = 1;
10687 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10688 tx_sw_if_index_set = 1;
10689 else if (unformat (i, "rx"))
10691 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10693 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10695 rx_sw_if_index_set = 1;
10700 else if (unformat (i, "tx"))
10702 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10706 tx_sw_if_index_set = 1;
10711 else if (unformat (i, "del"))
10717 if (rx_sw_if_index_set == 0)
10719 errmsg ("missing rx interface name or rx_sw_if_index");
10723 if (tx_sw_if_index_set == 0)
10725 errmsg ("missing tx interface name or tx_sw_if_index");
10729 M (L2_PATCH_ADD_DEL, mp);
10731 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10732 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10733 mp->is_add = is_add;
10741 u8 localsid_addr[16];
10750 api_sr_localsid_add_del (vat_main_t * vam)
10752 unformat_input_t *i = vam->input;
10753 vl_api_sr_localsid_add_del_t *mp;
10756 ip6_address_t localsid;
10760 u32 fib_table = ~(u32) 0;
10761 ip6_address_t next_hop;
10763 bool nexthop_set = 0;
10767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10769 if (unformat (i, "del"))
10771 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10772 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10774 else if (unformat (i, "behavior %u", &behavior));
10775 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10776 else if (unformat (i, "fib-table %u", &fib_table));
10777 else if (unformat (i, "end.psp %u", &behavior));
10782 M (SR_LOCALSID_ADD_DEL, mp);
10784 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10786 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10787 mp->behavior = behavior;
10788 mp->sw_if_index = ntohl (sw_if_index);
10789 mp->fib_table = ntohl (fib_table);
10790 mp->end_psp = end_psp;
10791 mp->is_del = is_del;
10799 api_ioam_enable (vat_main_t * vam)
10801 unformat_input_t *input = vam->input;
10802 vl_api_ioam_enable_t *mp;
10804 int has_trace_option = 0;
10805 int has_pot_option = 0;
10806 int has_seqno_option = 0;
10807 int has_analyse_option = 0;
10810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10812 if (unformat (input, "trace"))
10813 has_trace_option = 1;
10814 else if (unformat (input, "pot"))
10815 has_pot_option = 1;
10816 else if (unformat (input, "seqno"))
10817 has_seqno_option = 1;
10818 else if (unformat (input, "analyse"))
10819 has_analyse_option = 1;
10823 M (IOAM_ENABLE, mp);
10824 mp->id = htons (id);
10825 mp->seqno = has_seqno_option;
10826 mp->analyse = has_analyse_option;
10827 mp->pot_enable = has_pot_option;
10828 mp->trace_enable = has_trace_option;
10837 api_ioam_disable (vat_main_t * vam)
10839 vl_api_ioam_disable_t *mp;
10842 M (IOAM_DISABLE, mp);
10848 #define foreach_tcp_proto_field \
10852 #define foreach_udp_proto_field \
10856 #define foreach_ip4_proto_field \
10868 u16 src_port, dst_port;
10871 #if VPP_API_TEST_BUILTIN == 0
10873 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10875 u8 **maskp = va_arg (*args, u8 **);
10877 u8 found_something = 0;
10880 #define _(a) u8 a=0;
10881 foreach_tcp_proto_field;
10884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10887 #define _(a) else if (unformat (input, #a)) a=1;
10888 foreach_tcp_proto_field
10894 #define _(a) found_something += a;
10895 foreach_tcp_proto_field;
10898 if (found_something == 0)
10901 vec_validate (mask, sizeof (*tcp) - 1);
10903 tcp = (tcp_header_t *) mask;
10905 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10906 foreach_tcp_proto_field;
10914 unformat_udp_mask (unformat_input_t * input, va_list * args)
10916 u8 **maskp = va_arg (*args, u8 **);
10918 u8 found_something = 0;
10921 #define _(a) u8 a=0;
10922 foreach_udp_proto_field;
10925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10928 #define _(a) else if (unformat (input, #a)) a=1;
10929 foreach_udp_proto_field
10935 #define _(a) found_something += a;
10936 foreach_udp_proto_field;
10939 if (found_something == 0)
10942 vec_validate (mask, sizeof (*udp) - 1);
10944 udp = (udp_header_t *) mask;
10946 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10947 foreach_udp_proto_field;
10955 unformat_l4_mask (unformat_input_t * input, va_list * args)
10957 u8 **maskp = va_arg (*args, u8 **);
10958 u16 src_port = 0, dst_port = 0;
10959 tcpudp_header_t *tcpudp;
10961 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10963 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10965 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10967 else if (unformat (input, "src_port"))
10969 else if (unformat (input, "dst_port"))
10975 if (!src_port && !dst_port)
10979 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10981 tcpudp = (tcpudp_header_t *) mask;
10982 tcpudp->src_port = src_port;
10983 tcpudp->dst_port = dst_port;
10991 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10993 u8 **maskp = va_arg (*args, u8 **);
10995 u8 found_something = 0;
10998 #define _(a) u8 a=0;
10999 foreach_ip4_proto_field;
11005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11007 if (unformat (input, "version"))
11009 else if (unformat (input, "hdr_length"))
11011 else if (unformat (input, "src"))
11013 else if (unformat (input, "dst"))
11015 else if (unformat (input, "proto"))
11018 #define _(a) else if (unformat (input, #a)) a=1;
11019 foreach_ip4_proto_field
11025 #define _(a) found_something += a;
11026 foreach_ip4_proto_field;
11029 if (found_something == 0)
11032 vec_validate (mask, sizeof (*ip) - 1);
11034 ip = (ip4_header_t *) mask;
11036 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11037 foreach_ip4_proto_field;
11040 ip->ip_version_and_header_length = 0;
11043 ip->ip_version_and_header_length |= 0xF0;
11046 ip->ip_version_and_header_length |= 0x0F;
11052 #define foreach_ip6_proto_field \
11055 _(payload_length) \
11060 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11062 u8 **maskp = va_arg (*args, u8 **);
11064 u8 found_something = 0;
11066 u32 ip_version_traffic_class_and_flow_label;
11068 #define _(a) u8 a=0;
11069 foreach_ip6_proto_field;
11072 u8 traffic_class = 0;
11075 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11077 if (unformat (input, "version"))
11079 else if (unformat (input, "traffic-class"))
11081 else if (unformat (input, "flow-label"))
11083 else if (unformat (input, "src"))
11085 else if (unformat (input, "dst"))
11087 else if (unformat (input, "proto"))
11090 #define _(a) else if (unformat (input, #a)) a=1;
11091 foreach_ip6_proto_field
11097 #define _(a) found_something += a;
11098 foreach_ip6_proto_field;
11101 if (found_something == 0)
11104 vec_validate (mask, sizeof (*ip) - 1);
11106 ip = (ip6_header_t *) mask;
11108 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11109 foreach_ip6_proto_field;
11112 ip_version_traffic_class_and_flow_label = 0;
11115 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11118 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11121 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11123 ip->ip_version_traffic_class_and_flow_label =
11124 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11131 unformat_l3_mask (unformat_input_t * input, va_list * args)
11133 u8 **maskp = va_arg (*args, u8 **);
11135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11137 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11139 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11148 unformat_l2_mask (unformat_input_t * input, va_list * args)
11150 u8 **maskp = va_arg (*args, u8 **);
11157 u8 ignore_tag1 = 0;
11158 u8 ignore_tag2 = 0;
11165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11167 if (unformat (input, "src"))
11169 else if (unformat (input, "dst"))
11171 else if (unformat (input, "proto"))
11173 else if (unformat (input, "tag1"))
11175 else if (unformat (input, "tag2"))
11177 else if (unformat (input, "ignore-tag1"))
11179 else if (unformat (input, "ignore-tag2"))
11181 else if (unformat (input, "cos1"))
11183 else if (unformat (input, "cos2"))
11185 else if (unformat (input, "dot1q"))
11187 else if (unformat (input, "dot1ad"))
11192 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11193 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11196 if (tag1 || ignore_tag1 || cos1 || dot1q)
11198 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11201 vec_validate (mask, len - 1);
11204 memset (mask, 0xff, 6);
11207 memset (mask + 6, 0xff, 6);
11209 if (tag2 || dot1ad)
11211 /* inner vlan tag */
11220 mask[21] = mask[20] = 0xff;
11241 mask[16] = mask[17] = 0xff;
11251 mask[12] = mask[13] = 0xff;
11258 unformat_classify_mask (unformat_input_t * input, va_list * args)
11260 u8 **maskp = va_arg (*args, u8 **);
11261 u32 *skipp = va_arg (*args, u32 *);
11262 u32 *matchp = va_arg (*args, u32 *);
11270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11272 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11274 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11276 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11278 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11292 if (mask || l2 || l3 || l4)
11294 if (l2 || l3 || l4)
11296 /* "With a free Ethernet header in every package" */
11298 vec_validate (l2, 13);
11302 vec_append (mask, l3);
11307 vec_append (mask, l4);
11312 /* Scan forward looking for the first significant mask octet */
11313 for (i = 0; i < vec_len (mask); i++)
11317 /* compute (skip, match) params */
11318 *skipp = i / sizeof (u32x4);
11319 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11321 /* Pad mask to an even multiple of the vector size */
11322 while (vec_len (mask) % sizeof (u32x4))
11323 vec_add1 (mask, 0);
11325 match = vec_len (mask) / sizeof (u32x4);
11327 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11329 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11330 if (*tmp || *(tmp + 1))
11335 clib_warning ("BUG: match 0");
11337 _vec_len (mask) = match * sizeof (u32x4);
11347 #endif /* VPP_API_TEST_BUILTIN */
11349 #define foreach_l2_next \
11351 _(ethernet, ETHERNET_INPUT) \
11352 _(ip4, IP4_INPUT) \
11356 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11358 u32 *miss_next_indexp = va_arg (*args, u32 *);
11359 u32 next_index = 0;
11363 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11367 if (unformat (input, "%d", &tmp))
11376 *miss_next_indexp = next_index;
11380 #define foreach_ip_next \
11383 _(rewrite, REWRITE)
11386 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11388 u32 *miss_next_indexp = va_arg (*args, u32 *);
11389 u32 next_index = 0;
11393 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11397 if (unformat (input, "%d", &tmp))
11406 *miss_next_indexp = next_index;
11410 #define foreach_acl_next \
11414 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11416 u32 *miss_next_indexp = va_arg (*args, u32 *);
11417 u32 next_index = 0;
11421 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11425 if (unformat (input, "permit"))
11430 else if (unformat (input, "%d", &tmp))
11439 *miss_next_indexp = next_index;
11444 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11446 u32 *r = va_arg (*args, u32 *);
11448 if (unformat (input, "conform-color"))
11449 *r = POLICE_CONFORM;
11450 else if (unformat (input, "exceed-color"))
11451 *r = POLICE_EXCEED;
11459 api_classify_add_del_table (vat_main_t * vam)
11461 unformat_input_t *i = vam->input;
11462 vl_api_classify_add_del_table_t *mp;
11469 u32 table_index = ~0;
11470 u32 next_table_index = ~0;
11471 u32 miss_next_index = ~0;
11472 u32 memory_size = 32 << 20;
11474 u32 current_data_flag = 0;
11475 int current_data_offset = 0;
11478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11480 if (unformat (i, "del"))
11482 else if (unformat (i, "del-chain"))
11487 else if (unformat (i, "buckets %d", &nbuckets))
11489 else if (unformat (i, "memory_size %d", &memory_size))
11491 else if (unformat (i, "skip %d", &skip))
11493 else if (unformat (i, "match %d", &match))
11495 else if (unformat (i, "table %d", &table_index))
11497 else if (unformat (i, "mask %U", unformat_classify_mask,
11498 &mask, &skip, &match))
11500 else if (unformat (i, "next-table %d", &next_table_index))
11502 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11505 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11508 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11511 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11513 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11519 if (is_add && mask == 0)
11521 errmsg ("Mask required");
11525 if (is_add && skip == ~0)
11527 errmsg ("skip count required");
11531 if (is_add && match == ~0)
11533 errmsg ("match count required");
11537 if (!is_add && table_index == ~0)
11539 errmsg ("table index required for delete");
11543 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11545 mp->is_add = is_add;
11546 mp->del_chain = del_chain;
11547 mp->table_index = ntohl (table_index);
11548 mp->nbuckets = ntohl (nbuckets);
11549 mp->memory_size = ntohl (memory_size);
11550 mp->skip_n_vectors = ntohl (skip);
11551 mp->match_n_vectors = ntohl (match);
11552 mp->next_table_index = ntohl (next_table_index);
11553 mp->miss_next_index = ntohl (miss_next_index);
11554 mp->current_data_flag = ntohl (current_data_flag);
11555 mp->current_data_offset = ntohl (current_data_offset);
11556 clib_memcpy (mp->mask, mask, vec_len (mask));
11565 #if VPP_API_TEST_BUILTIN == 0
11567 unformat_l4_match (unformat_input_t * input, va_list * args)
11569 u8 **matchp = va_arg (*args, u8 **);
11571 u8 *proto_header = 0;
11577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11579 if (unformat (input, "src_port %d", &src_port))
11581 else if (unformat (input, "dst_port %d", &dst_port))
11587 h.src_port = clib_host_to_net_u16 (src_port);
11588 h.dst_port = clib_host_to_net_u16 (dst_port);
11589 vec_validate (proto_header, sizeof (h) - 1);
11590 memcpy (proto_header, &h, sizeof (h));
11592 *matchp = proto_header;
11598 unformat_ip4_match (unformat_input_t * input, va_list * args)
11600 u8 **matchp = va_arg (*args, u8 **);
11605 int hdr_length = 0;
11606 u32 hdr_length_val;
11607 int src = 0, dst = 0;
11608 ip4_address_t src_val, dst_val;
11615 int fragment_id = 0;
11616 u32 fragment_id_val;
11622 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11624 if (unformat (input, "version %d", &version_val))
11626 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11628 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11630 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11632 else if (unformat (input, "proto %d", &proto_val))
11634 else if (unformat (input, "tos %d", &tos_val))
11636 else if (unformat (input, "length %d", &length_val))
11638 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11640 else if (unformat (input, "ttl %d", &ttl_val))
11642 else if (unformat (input, "checksum %d", &checksum_val))
11648 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11649 + ttl + checksum == 0)
11653 * Aligned because we use the real comparison functions
11655 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11657 ip = (ip4_header_t *) match;
11659 /* These are realistically matched in practice */
11661 ip->src_address.as_u32 = src_val.as_u32;
11664 ip->dst_address.as_u32 = dst_val.as_u32;
11667 ip->protocol = proto_val;
11670 /* These are not, but they're included for completeness */
11672 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11675 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11681 ip->length = clib_host_to_net_u16 (length_val);
11687 ip->checksum = clib_host_to_net_u16 (checksum_val);
11694 unformat_ip6_match (unformat_input_t * input, va_list * args)
11696 u8 **matchp = va_arg (*args, u8 **);
11701 u8 traffic_class = 0;
11702 u32 traffic_class_val = 0;
11705 int src = 0, dst = 0;
11706 ip6_address_t src_val, dst_val;
11709 int payload_length = 0;
11710 u32 payload_length_val;
11713 u32 ip_version_traffic_class_and_flow_label;
11715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11717 if (unformat (input, "version %d", &version_val))
11719 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11721 else if (unformat (input, "flow_label %d", &flow_label_val))
11723 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11725 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11727 else if (unformat (input, "proto %d", &proto_val))
11729 else if (unformat (input, "payload_length %d", &payload_length_val))
11730 payload_length = 1;
11731 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11737 if (version + traffic_class + flow_label + src + dst + proto +
11738 payload_length + hop_limit == 0)
11742 * Aligned because we use the real comparison functions
11744 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11746 ip = (ip6_header_t *) match;
11749 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11752 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11755 ip->protocol = proto_val;
11757 ip_version_traffic_class_and_flow_label = 0;
11760 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11763 ip_version_traffic_class_and_flow_label |=
11764 (traffic_class_val & 0xFF) << 20;
11767 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11769 ip->ip_version_traffic_class_and_flow_label =
11770 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11772 if (payload_length)
11773 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11776 ip->hop_limit = hop_limit_val;
11783 unformat_l3_match (unformat_input_t * input, va_list * args)
11785 u8 **matchp = va_arg (*args, u8 **);
11787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11789 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11791 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11800 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11802 u8 *tagp = va_arg (*args, u8 *);
11805 if (unformat (input, "%d", &tag))
11807 tagp[0] = (tag >> 8) & 0x0F;
11808 tagp[1] = tag & 0xFF;
11816 unformat_l2_match (unformat_input_t * input, va_list * args)
11818 u8 **matchp = va_arg (*args, u8 **);
11831 u8 ignore_tag1 = 0;
11832 u8 ignore_tag2 = 0;
11838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11840 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11843 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11845 else if (unformat (input, "proto %U",
11846 unformat_ethernet_type_host_byte_order, &proto_val))
11848 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11850 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11852 else if (unformat (input, "ignore-tag1"))
11854 else if (unformat (input, "ignore-tag2"))
11856 else if (unformat (input, "cos1 %d", &cos1_val))
11858 else if (unformat (input, "cos2 %d", &cos2_val))
11863 if ((src + dst + proto + tag1 + tag2 +
11864 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11867 if (tag1 || ignore_tag1 || cos1)
11869 if (tag2 || ignore_tag2 || cos2)
11872 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11875 clib_memcpy (match, dst_val, 6);
11878 clib_memcpy (match + 6, src_val, 6);
11882 /* inner vlan tag */
11883 match[19] = tag2_val[1];
11884 match[18] = tag2_val[0];
11886 match[18] |= (cos2_val & 0x7) << 5;
11889 match[21] = proto_val & 0xff;
11890 match[20] = proto_val >> 8;
11894 match[15] = tag1_val[1];
11895 match[14] = tag1_val[0];
11898 match[14] |= (cos1_val & 0x7) << 5;
11904 match[15] = tag1_val[1];
11905 match[14] = tag1_val[0];
11908 match[17] = proto_val & 0xff;
11909 match[16] = proto_val >> 8;
11912 match[14] |= (cos1_val & 0x7) << 5;
11918 match[18] |= (cos2_val & 0x7) << 5;
11920 match[14] |= (cos1_val & 0x7) << 5;
11923 match[13] = proto_val & 0xff;
11924 match[12] = proto_val >> 8;
11932 unformat_qos_source (unformat_input_t * input, va_list * args)
11934 int *qs = va_arg (*args, int *);
11936 if (unformat (input, "ip"))
11937 *qs = QOS_SOURCE_IP;
11938 else if (unformat (input, "mpls"))
11939 *qs = QOS_SOURCE_MPLS;
11940 else if (unformat (input, "ext"))
11941 *qs = QOS_SOURCE_EXT;
11942 else if (unformat (input, "vlan"))
11943 *qs = QOS_SOURCE_VLAN;
11952 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11954 u8 **matchp = va_arg (*args, u8 **);
11955 u32 skip_n_vectors = va_arg (*args, u32);
11956 u32 match_n_vectors = va_arg (*args, u32);
11963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11965 if (unformat (input, "hex %U", unformat_hex_string, &match))
11967 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11969 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11971 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11985 if (match || l2 || l3 || l4)
11987 if (l2 || l3 || l4)
11989 /* "Win a free Ethernet header in every packet" */
11991 vec_validate_aligned (l2, 13, sizeof (u32x4));
11995 vec_append_aligned (match, l3, sizeof (u32x4));
12000 vec_append_aligned (match, l4, sizeof (u32x4));
12005 /* Make sure the vector is big enough even if key is all 0's */
12006 vec_validate_aligned
12007 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12010 /* Set size, include skipped vectors */
12011 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12022 api_classify_add_del_session (vat_main_t * vam)
12024 unformat_input_t *i = vam->input;
12025 vl_api_classify_add_del_session_t *mp;
12027 u32 table_index = ~0;
12028 u32 hit_next_index = ~0;
12029 u32 opaque_index = ~0;
12032 u32 skip_n_vectors = 0;
12033 u32 match_n_vectors = 0;
12039 * Warning: you have to supply skip_n and match_n
12040 * because the API client cant simply look at the classify
12044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12046 if (unformat (i, "del"))
12048 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12051 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12054 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12057 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12059 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12061 else if (unformat (i, "opaque-index %d", &opaque_index))
12063 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12065 else if (unformat (i, "match_n %d", &match_n_vectors))
12067 else if (unformat (i, "match %U", api_unformat_classify_match,
12068 &match, skip_n_vectors, match_n_vectors))
12070 else if (unformat (i, "advance %d", &advance))
12072 else if (unformat (i, "table-index %d", &table_index))
12074 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12076 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12078 else if (unformat (i, "action %d", &action))
12080 else if (unformat (i, "metadata %d", &metadata))
12086 if (table_index == ~0)
12088 errmsg ("Table index required");
12092 if (is_add && match == 0)
12094 errmsg ("Match value required");
12098 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12100 mp->is_add = is_add;
12101 mp->table_index = ntohl (table_index);
12102 mp->hit_next_index = ntohl (hit_next_index);
12103 mp->opaque_index = ntohl (opaque_index);
12104 mp->advance = ntohl (advance);
12105 mp->action = action;
12106 mp->metadata = ntohl (metadata);
12107 clib_memcpy (mp->match, match, vec_len (match));
12116 api_classify_set_interface_ip_table (vat_main_t * vam)
12118 unformat_input_t *i = vam->input;
12119 vl_api_classify_set_interface_ip_table_t *mp;
12121 int sw_if_index_set;
12122 u32 table_index = ~0;
12126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12128 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12129 sw_if_index_set = 1;
12130 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12131 sw_if_index_set = 1;
12132 else if (unformat (i, "table %d", &table_index))
12136 clib_warning ("parse error '%U'", format_unformat_error, i);
12141 if (sw_if_index_set == 0)
12143 errmsg ("missing interface name or sw_if_index");
12148 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12150 mp->sw_if_index = ntohl (sw_if_index);
12151 mp->table_index = ntohl (table_index);
12152 mp->is_ipv6 = is_ipv6;
12160 api_classify_set_interface_l2_tables (vat_main_t * vam)
12162 unformat_input_t *i = vam->input;
12163 vl_api_classify_set_interface_l2_tables_t *mp;
12165 int sw_if_index_set;
12166 u32 ip4_table_index = ~0;
12167 u32 ip6_table_index = ~0;
12168 u32 other_table_index = ~0;
12172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12175 sw_if_index_set = 1;
12176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12177 sw_if_index_set = 1;
12178 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12180 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12182 else if (unformat (i, "other-table %d", &other_table_index))
12184 else if (unformat (i, "is-input %d", &is_input))
12188 clib_warning ("parse error '%U'", format_unformat_error, i);
12193 if (sw_if_index_set == 0)
12195 errmsg ("missing interface name or sw_if_index");
12200 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12202 mp->sw_if_index = ntohl (sw_if_index);
12203 mp->ip4_table_index = ntohl (ip4_table_index);
12204 mp->ip6_table_index = ntohl (ip6_table_index);
12205 mp->other_table_index = ntohl (other_table_index);
12206 mp->is_input = (u8) is_input;
12214 api_set_ipfix_exporter (vat_main_t * vam)
12216 unformat_input_t *i = vam->input;
12217 vl_api_set_ipfix_exporter_t *mp;
12218 ip4_address_t collector_address;
12219 u8 collector_address_set = 0;
12220 u32 collector_port = ~0;
12221 ip4_address_t src_address;
12222 u8 src_address_set = 0;
12225 u32 template_interval = ~0;
12226 u8 udp_checksum = 0;
12229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12231 if (unformat (i, "collector_address %U", unformat_ip4_address,
12232 &collector_address))
12233 collector_address_set = 1;
12234 else if (unformat (i, "collector_port %d", &collector_port))
12236 else if (unformat (i, "src_address %U", unformat_ip4_address,
12238 src_address_set = 1;
12239 else if (unformat (i, "vrf_id %d", &vrf_id))
12241 else if (unformat (i, "path_mtu %d", &path_mtu))
12243 else if (unformat (i, "template_interval %d", &template_interval))
12245 else if (unformat (i, "udp_checksum"))
12251 if (collector_address_set == 0)
12253 errmsg ("collector_address required");
12257 if (src_address_set == 0)
12259 errmsg ("src_address required");
12263 M (SET_IPFIX_EXPORTER, mp);
12265 memcpy (mp->collector_address, collector_address.data,
12266 sizeof (collector_address.data));
12267 mp->collector_port = htons ((u16) collector_port);
12268 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12269 mp->vrf_id = htonl (vrf_id);
12270 mp->path_mtu = htonl (path_mtu);
12271 mp->template_interval = htonl (template_interval);
12272 mp->udp_checksum = udp_checksum;
12280 api_set_ipfix_classify_stream (vat_main_t * vam)
12282 unformat_input_t *i = vam->input;
12283 vl_api_set_ipfix_classify_stream_t *mp;
12285 u32 src_port = UDP_DST_PORT_ipfix;
12288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12290 if (unformat (i, "domain %d", &domain_id))
12292 else if (unformat (i, "src_port %d", &src_port))
12296 errmsg ("unknown input `%U'", format_unformat_error, i);
12301 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12303 mp->domain_id = htonl (domain_id);
12304 mp->src_port = htons ((u16) src_port);
12312 api_ipfix_classify_table_add_del (vat_main_t * vam)
12314 unformat_input_t *i = vam->input;
12315 vl_api_ipfix_classify_table_add_del_t *mp;
12317 u32 classify_table_index = ~0;
12319 u8 transport_protocol = 255;
12322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12324 if (unformat (i, "add"))
12326 else if (unformat (i, "del"))
12328 else if (unformat (i, "table %d", &classify_table_index))
12330 else if (unformat (i, "ip4"))
12332 else if (unformat (i, "ip6"))
12334 else if (unformat (i, "tcp"))
12335 transport_protocol = 6;
12336 else if (unformat (i, "udp"))
12337 transport_protocol = 17;
12340 errmsg ("unknown input `%U'", format_unformat_error, i);
12347 errmsg ("expecting: add|del");
12350 if (classify_table_index == ~0)
12352 errmsg ("classifier table not specified");
12355 if (ip_version == 0)
12357 errmsg ("IP version not specified");
12361 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12363 mp->is_add = is_add;
12364 mp->table_id = htonl (classify_table_index);
12365 mp->ip_version = ip_version;
12366 mp->transport_protocol = transport_protocol;
12374 api_get_node_index (vat_main_t * vam)
12376 unformat_input_t *i = vam->input;
12377 vl_api_get_node_index_t *mp;
12381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12383 if (unformat (i, "node %s", &name))
12390 errmsg ("node name required");
12393 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12395 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12399 M (GET_NODE_INDEX, mp);
12400 clib_memcpy (mp->node_name, name, vec_len (name));
12409 api_get_next_index (vat_main_t * vam)
12411 unformat_input_t *i = vam->input;
12412 vl_api_get_next_index_t *mp;
12413 u8 *node_name = 0, *next_node_name = 0;
12416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12418 if (unformat (i, "node-name %s", &node_name))
12420 else if (unformat (i, "next-node-name %s", &next_node_name))
12424 if (node_name == 0)
12426 errmsg ("node name required");
12429 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12431 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12435 if (next_node_name == 0)
12437 errmsg ("next node name required");
12440 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12442 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12446 M (GET_NEXT_INDEX, mp);
12447 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12448 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12449 vec_free (node_name);
12450 vec_free (next_node_name);
12458 api_add_node_next (vat_main_t * vam)
12460 unformat_input_t *i = vam->input;
12461 vl_api_add_node_next_t *mp;
12466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12468 if (unformat (i, "node %s", &name))
12470 else if (unformat (i, "next %s", &next))
12477 errmsg ("node name required");
12480 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12482 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12487 errmsg ("next node required");
12490 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12492 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12496 M (ADD_NODE_NEXT, mp);
12497 clib_memcpy (mp->node_name, name, vec_len (name));
12498 clib_memcpy (mp->next_name, next, vec_len (next));
12508 api_l2tpv3_create_tunnel (vat_main_t * vam)
12510 unformat_input_t *i = vam->input;
12511 ip6_address_t client_address, our_address;
12512 int client_address_set = 0;
12513 int our_address_set = 0;
12514 u32 local_session_id = 0;
12515 u32 remote_session_id = 0;
12516 u64 local_cookie = 0;
12517 u64 remote_cookie = 0;
12518 u8 l2_sublayer_present = 0;
12519 vl_api_l2tpv3_create_tunnel_t *mp;
12522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12524 if (unformat (i, "client_address %U", unformat_ip6_address,
12526 client_address_set = 1;
12527 else if (unformat (i, "our_address %U", unformat_ip6_address,
12529 our_address_set = 1;
12530 else if (unformat (i, "local_session_id %d", &local_session_id))
12532 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12534 else if (unformat (i, "local_cookie %lld", &local_cookie))
12536 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12538 else if (unformat (i, "l2-sublayer-present"))
12539 l2_sublayer_present = 1;
12544 if (client_address_set == 0)
12546 errmsg ("client_address required");
12550 if (our_address_set == 0)
12552 errmsg ("our_address required");
12556 M (L2TPV3_CREATE_TUNNEL, mp);
12558 clib_memcpy (mp->client_address, client_address.as_u8,
12559 sizeof (mp->client_address));
12561 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12563 mp->local_session_id = ntohl (local_session_id);
12564 mp->remote_session_id = ntohl (remote_session_id);
12565 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12566 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12567 mp->l2_sublayer_present = l2_sublayer_present;
12576 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12578 unformat_input_t *i = vam->input;
12580 u8 sw_if_index_set = 0;
12581 u64 new_local_cookie = 0;
12582 u64 new_remote_cookie = 0;
12583 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12588 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12589 sw_if_index_set = 1;
12590 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12591 sw_if_index_set = 1;
12592 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12594 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12600 if (sw_if_index_set == 0)
12602 errmsg ("missing interface name or sw_if_index");
12606 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12608 mp->sw_if_index = ntohl (sw_if_index);
12609 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12610 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12618 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12620 unformat_input_t *i = vam->input;
12621 vl_api_l2tpv3_interface_enable_disable_t *mp;
12623 u8 sw_if_index_set = 0;
12624 u8 enable_disable = 1;
12627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12629 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12630 sw_if_index_set = 1;
12631 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12632 sw_if_index_set = 1;
12633 else if (unformat (i, "enable"))
12634 enable_disable = 1;
12635 else if (unformat (i, "disable"))
12636 enable_disable = 0;
12641 if (sw_if_index_set == 0)
12643 errmsg ("missing interface name or sw_if_index");
12647 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12649 mp->sw_if_index = ntohl (sw_if_index);
12650 mp->enable_disable = enable_disable;
12658 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12660 unformat_input_t *i = vam->input;
12661 vl_api_l2tpv3_set_lookup_key_t *mp;
12665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12667 if (unformat (i, "lookup_v6_src"))
12668 key = L2T_LOOKUP_SRC_ADDRESS;
12669 else if (unformat (i, "lookup_v6_dst"))
12670 key = L2T_LOOKUP_DST_ADDRESS;
12671 else if (unformat (i, "lookup_session_id"))
12672 key = L2T_LOOKUP_SESSION_ID;
12677 if (key == (u8) ~ 0)
12679 errmsg ("l2tp session lookup key unset");
12683 M (L2TPV3_SET_LOOKUP_KEY, mp);
12692 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12693 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12695 vat_main_t *vam = &vat_main;
12697 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12698 format_ip6_address, mp->our_address,
12699 format_ip6_address, mp->client_address,
12700 clib_net_to_host_u32 (mp->sw_if_index));
12703 " local cookies %016llx %016llx remote cookie %016llx",
12704 clib_net_to_host_u64 (mp->local_cookie[0]),
12705 clib_net_to_host_u64 (mp->local_cookie[1]),
12706 clib_net_to_host_u64 (mp->remote_cookie));
12708 print (vam->ofp, " local session-id %d remote session-id %d",
12709 clib_net_to_host_u32 (mp->local_session_id),
12710 clib_net_to_host_u32 (mp->remote_session_id));
12712 print (vam->ofp, " l2 specific sublayer %s\n",
12713 mp->l2_sublayer_present ? "preset" : "absent");
12717 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12718 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12720 vat_main_t *vam = &vat_main;
12721 vat_json_node_t *node = NULL;
12722 struct in6_addr addr;
12724 if (VAT_JSON_ARRAY != vam->json_tree.type)
12726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12727 vat_json_init_array (&vam->json_tree);
12729 node = vat_json_array_add (&vam->json_tree);
12731 vat_json_init_object (node);
12733 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12734 vat_json_object_add_ip6 (node, "our_address", addr);
12735 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12736 vat_json_object_add_ip6 (node, "client_address", addr);
12738 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12739 vat_json_init_array (lc);
12740 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12741 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12742 vat_json_object_add_uint (node, "remote_cookie",
12743 clib_net_to_host_u64 (mp->remote_cookie));
12745 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12746 vat_json_object_add_uint (node, "local_session_id",
12747 clib_net_to_host_u32 (mp->local_session_id));
12748 vat_json_object_add_uint (node, "remote_session_id",
12749 clib_net_to_host_u32 (mp->remote_session_id));
12750 vat_json_object_add_string_copy (node, "l2_sublayer",
12751 mp->l2_sublayer_present ? (u8 *) "present"
12752 : (u8 *) "absent");
12756 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12758 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12759 vl_api_control_ping_t *mp_ping;
12762 /* Get list of l2tpv3-tunnel interfaces */
12763 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12766 /* Use a control ping for synchronization */
12767 MPING (CONTROL_PING, mp_ping);
12775 static void vl_api_sw_interface_tap_details_t_handler
12776 (vl_api_sw_interface_tap_details_t * mp)
12778 vat_main_t *vam = &vat_main;
12780 print (vam->ofp, "%-16s %d",
12781 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12784 static void vl_api_sw_interface_tap_details_t_handler_json
12785 (vl_api_sw_interface_tap_details_t * mp)
12787 vat_main_t *vam = &vat_main;
12788 vat_json_node_t *node = NULL;
12790 if (VAT_JSON_ARRAY != vam->json_tree.type)
12792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12793 vat_json_init_array (&vam->json_tree);
12795 node = vat_json_array_add (&vam->json_tree);
12797 vat_json_init_object (node);
12798 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12799 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12803 api_sw_interface_tap_dump (vat_main_t * vam)
12805 vl_api_sw_interface_tap_dump_t *mp;
12806 vl_api_control_ping_t *mp_ping;
12809 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12810 /* Get list of tap interfaces */
12811 M (SW_INTERFACE_TAP_DUMP, mp);
12814 /* Use a control ping for synchronization */
12815 MPING (CONTROL_PING, mp_ping);
12822 static void vl_api_sw_interface_tap_v2_details_t_handler
12823 (vl_api_sw_interface_tap_v2_details_t * mp)
12825 vat_main_t *vam = &vat_main;
12827 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12828 mp->host_ip4_prefix_len);
12829 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12830 mp->host_ip6_prefix_len);
12833 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12834 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12835 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12836 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12837 mp->host_bridge, ip4, ip6);
12843 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12844 (vl_api_sw_interface_tap_v2_details_t * mp)
12846 vat_main_t *vam = &vat_main;
12847 vat_json_node_t *node = NULL;
12849 if (VAT_JSON_ARRAY != vam->json_tree.type)
12851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12852 vat_json_init_array (&vam->json_tree);
12854 node = vat_json_array_add (&vam->json_tree);
12856 vat_json_init_object (node);
12857 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12858 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12859 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12860 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12861 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12862 vat_json_object_add_string_copy (node, "host_mac_addr",
12863 format (0, "%U", format_ethernet_address,
12864 &mp->host_mac_addr));
12865 vat_json_object_add_string_copy (node, "host_namespace",
12866 mp->host_namespace);
12867 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12868 vat_json_object_add_string_copy (node, "host_ip4_addr",
12869 format (0, "%U/%d", format_ip4_address,
12871 mp->host_ip4_prefix_len));
12872 vat_json_object_add_string_copy (node, "host_ip6_addr",
12873 format (0, "%U/%d", format_ip6_address,
12875 mp->host_ip6_prefix_len));
12880 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12882 vl_api_sw_interface_tap_v2_dump_t *mp;
12883 vl_api_control_ping_t *mp_ping;
12887 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12888 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12889 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12892 /* Get list of tap interfaces */
12893 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12896 /* Use a control ping for synchronization */
12897 MPING (CONTROL_PING, mp_ping);
12905 api_vxlan_offload_rx (vat_main_t * vam)
12907 unformat_input_t *line_input = vam->input;
12908 vl_api_vxlan_offload_rx_t *mp;
12909 u32 hw_if_index = ~0, rx_if_index = ~0;
12913 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12915 if (unformat (line_input, "del"))
12917 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12920 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12922 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12925 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12929 errmsg ("parse error '%U'", format_unformat_error, line_input);
12934 if (hw_if_index == ~0)
12936 errmsg ("no hw interface");
12940 if (rx_if_index == ~0)
12942 errmsg ("no rx tunnel");
12946 M (VXLAN_OFFLOAD_RX, mp);
12948 mp->hw_if_index = ntohl (hw_if_index);
12949 mp->sw_if_index = ntohl (rx_if_index);
12950 mp->enable = is_add;
12957 static uword unformat_vxlan_decap_next
12958 (unformat_input_t * input, va_list * args)
12960 u32 *result = va_arg (*args, u32 *);
12963 if (unformat (input, "l2"))
12964 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12965 else if (unformat (input, "%d", &tmp))
12973 api_vxlan_add_del_tunnel (vat_main_t * vam)
12975 unformat_input_t *line_input = vam->input;
12976 vl_api_vxlan_add_del_tunnel_t *mp;
12977 ip46_address_t src, dst;
12979 u8 ipv4_set = 0, ipv6_set = 0;
12984 u32 mcast_sw_if_index = ~0;
12985 u32 encap_vrf_id = 0;
12986 u32 decap_next_index = ~0;
12990 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12991 memset (&src, 0, sizeof src);
12992 memset (&dst, 0, sizeof dst);
12994 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12996 if (unformat (line_input, "del"))
12998 else if (unformat (line_input, "instance %d", &instance))
13001 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13007 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13013 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13019 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13024 else if (unformat (line_input, "group %U %U",
13025 unformat_ip4_address, &dst.ip4,
13026 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13028 grp_set = dst_set = 1;
13031 else if (unformat (line_input, "group %U",
13032 unformat_ip4_address, &dst.ip4))
13034 grp_set = dst_set = 1;
13037 else if (unformat (line_input, "group %U %U",
13038 unformat_ip6_address, &dst.ip6,
13039 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13041 grp_set = dst_set = 1;
13044 else if (unformat (line_input, "group %U",
13045 unformat_ip6_address, &dst.ip6))
13047 grp_set = dst_set = 1;
13051 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13053 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13055 else if (unformat (line_input, "decap-next %U",
13056 unformat_vxlan_decap_next, &decap_next_index))
13058 else if (unformat (line_input, "vni %d", &vni))
13062 errmsg ("parse error '%U'", format_unformat_error, line_input);
13069 errmsg ("tunnel src address not specified");
13074 errmsg ("tunnel dst address not specified");
13078 if (grp_set && !ip46_address_is_multicast (&dst))
13080 errmsg ("tunnel group address not multicast");
13083 if (grp_set && mcast_sw_if_index == ~0)
13085 errmsg ("tunnel nonexistent multicast device");
13088 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13090 errmsg ("tunnel dst address must be unicast");
13095 if (ipv4_set && ipv6_set)
13097 errmsg ("both IPv4 and IPv6 addresses specified");
13101 if ((vni == 0) || (vni >> 24))
13103 errmsg ("vni not specified or out of range");
13107 M (VXLAN_ADD_DEL_TUNNEL, mp);
13111 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13112 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13116 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13117 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13120 mp->instance = htonl (instance);
13121 mp->encap_vrf_id = ntohl (encap_vrf_id);
13122 mp->decap_next_index = ntohl (decap_next_index);
13123 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13124 mp->vni = ntohl (vni);
13125 mp->is_add = is_add;
13126 mp->is_ipv6 = ipv6_set;
13133 static void vl_api_vxlan_tunnel_details_t_handler
13134 (vl_api_vxlan_tunnel_details_t * mp)
13136 vat_main_t *vam = &vat_main;
13137 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13138 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13140 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13141 ntohl (mp->sw_if_index),
13142 ntohl (mp->instance),
13143 format_ip46_address, &src, IP46_TYPE_ANY,
13144 format_ip46_address, &dst, IP46_TYPE_ANY,
13145 ntohl (mp->encap_vrf_id),
13146 ntohl (mp->decap_next_index), ntohl (mp->vni),
13147 ntohl (mp->mcast_sw_if_index));
13150 static void vl_api_vxlan_tunnel_details_t_handler_json
13151 (vl_api_vxlan_tunnel_details_t * mp)
13153 vat_main_t *vam = &vat_main;
13154 vat_json_node_t *node = NULL;
13156 if (VAT_JSON_ARRAY != vam->json_tree.type)
13158 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13159 vat_json_init_array (&vam->json_tree);
13161 node = vat_json_array_add (&vam->json_tree);
13163 vat_json_init_object (node);
13164 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13166 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13170 struct in6_addr ip6;
13172 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13173 vat_json_object_add_ip6 (node, "src_address", ip6);
13174 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13175 vat_json_object_add_ip6 (node, "dst_address", ip6);
13179 struct in_addr ip4;
13181 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13182 vat_json_object_add_ip4 (node, "src_address", ip4);
13183 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13184 vat_json_object_add_ip4 (node, "dst_address", ip4);
13186 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13187 vat_json_object_add_uint (node, "decap_next_index",
13188 ntohl (mp->decap_next_index));
13189 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13190 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13191 vat_json_object_add_uint (node, "mcast_sw_if_index",
13192 ntohl (mp->mcast_sw_if_index));
13196 api_vxlan_tunnel_dump (vat_main_t * vam)
13198 unformat_input_t *i = vam->input;
13199 vl_api_vxlan_tunnel_dump_t *mp;
13200 vl_api_control_ping_t *mp_ping;
13202 u8 sw_if_index_set = 0;
13205 /* Parse args required to build the message */
13206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13208 if (unformat (i, "sw_if_index %d", &sw_if_index))
13209 sw_if_index_set = 1;
13214 if (sw_if_index_set == 0)
13219 if (!vam->json_output)
13221 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13222 "sw_if_index", "instance", "src_address", "dst_address",
13223 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13226 /* Get list of vxlan-tunnel interfaces */
13227 M (VXLAN_TUNNEL_DUMP, mp);
13229 mp->sw_if_index = htonl (sw_if_index);
13233 /* Use a control ping for synchronization */
13234 MPING (CONTROL_PING, mp_ping);
13241 static uword unformat_geneve_decap_next
13242 (unformat_input_t * input, va_list * args)
13244 u32 *result = va_arg (*args, u32 *);
13247 if (unformat (input, "l2"))
13248 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13249 else if (unformat (input, "%d", &tmp))
13257 api_geneve_add_del_tunnel (vat_main_t * vam)
13259 unformat_input_t *line_input = vam->input;
13260 vl_api_geneve_add_del_tunnel_t *mp;
13261 ip46_address_t src, dst;
13263 u8 ipv4_set = 0, ipv6_set = 0;
13267 u32 mcast_sw_if_index = ~0;
13268 u32 encap_vrf_id = 0;
13269 u32 decap_next_index = ~0;
13273 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13274 memset (&src, 0, sizeof src);
13275 memset (&dst, 0, sizeof dst);
13277 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13279 if (unformat (line_input, "del"))
13282 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13288 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13294 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13300 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13305 else if (unformat (line_input, "group %U %U",
13306 unformat_ip4_address, &dst.ip4,
13307 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13309 grp_set = dst_set = 1;
13312 else if (unformat (line_input, "group %U",
13313 unformat_ip4_address, &dst.ip4))
13315 grp_set = dst_set = 1;
13318 else if (unformat (line_input, "group %U %U",
13319 unformat_ip6_address, &dst.ip6,
13320 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13322 grp_set = dst_set = 1;
13325 else if (unformat (line_input, "group %U",
13326 unformat_ip6_address, &dst.ip6))
13328 grp_set = dst_set = 1;
13332 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13334 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13336 else if (unformat (line_input, "decap-next %U",
13337 unformat_geneve_decap_next, &decap_next_index))
13339 else if (unformat (line_input, "vni %d", &vni))
13343 errmsg ("parse error '%U'", format_unformat_error, line_input);
13350 errmsg ("tunnel src address not specified");
13355 errmsg ("tunnel dst address not specified");
13359 if (grp_set && !ip46_address_is_multicast (&dst))
13361 errmsg ("tunnel group address not multicast");
13364 if (grp_set && mcast_sw_if_index == ~0)
13366 errmsg ("tunnel nonexistent multicast device");
13369 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13371 errmsg ("tunnel dst address must be unicast");
13376 if (ipv4_set && ipv6_set)
13378 errmsg ("both IPv4 and IPv6 addresses specified");
13382 if ((vni == 0) || (vni >> 24))
13384 errmsg ("vni not specified or out of range");
13388 M (GENEVE_ADD_DEL_TUNNEL, mp);
13392 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13393 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13397 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13398 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13400 mp->encap_vrf_id = ntohl (encap_vrf_id);
13401 mp->decap_next_index = ntohl (decap_next_index);
13402 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13403 mp->vni = ntohl (vni);
13404 mp->is_add = is_add;
13405 mp->is_ipv6 = ipv6_set;
13412 static void vl_api_geneve_tunnel_details_t_handler
13413 (vl_api_geneve_tunnel_details_t * mp)
13415 vat_main_t *vam = &vat_main;
13416 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13417 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13419 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13420 ntohl (mp->sw_if_index),
13421 format_ip46_address, &src, IP46_TYPE_ANY,
13422 format_ip46_address, &dst, IP46_TYPE_ANY,
13423 ntohl (mp->encap_vrf_id),
13424 ntohl (mp->decap_next_index), ntohl (mp->vni),
13425 ntohl (mp->mcast_sw_if_index));
13428 static void vl_api_geneve_tunnel_details_t_handler_json
13429 (vl_api_geneve_tunnel_details_t * mp)
13431 vat_main_t *vam = &vat_main;
13432 vat_json_node_t *node = NULL;
13434 if (VAT_JSON_ARRAY != vam->json_tree.type)
13436 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13437 vat_json_init_array (&vam->json_tree);
13439 node = vat_json_array_add (&vam->json_tree);
13441 vat_json_init_object (node);
13442 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13445 struct in6_addr ip6;
13447 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13448 vat_json_object_add_ip6 (node, "src_address", ip6);
13449 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13450 vat_json_object_add_ip6 (node, "dst_address", ip6);
13454 struct in_addr ip4;
13456 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13457 vat_json_object_add_ip4 (node, "src_address", ip4);
13458 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13459 vat_json_object_add_ip4 (node, "dst_address", ip4);
13461 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13462 vat_json_object_add_uint (node, "decap_next_index",
13463 ntohl (mp->decap_next_index));
13464 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13465 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13466 vat_json_object_add_uint (node, "mcast_sw_if_index",
13467 ntohl (mp->mcast_sw_if_index));
13471 api_geneve_tunnel_dump (vat_main_t * vam)
13473 unformat_input_t *i = vam->input;
13474 vl_api_geneve_tunnel_dump_t *mp;
13475 vl_api_control_ping_t *mp_ping;
13477 u8 sw_if_index_set = 0;
13480 /* Parse args required to build the message */
13481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13483 if (unformat (i, "sw_if_index %d", &sw_if_index))
13484 sw_if_index_set = 1;
13489 if (sw_if_index_set == 0)
13494 if (!vam->json_output)
13496 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13497 "sw_if_index", "local_address", "remote_address",
13498 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13501 /* Get list of geneve-tunnel interfaces */
13502 M (GENEVE_TUNNEL_DUMP, mp);
13504 mp->sw_if_index = htonl (sw_if_index);
13508 /* Use a control ping for synchronization */
13509 M (CONTROL_PING, mp_ping);
13517 api_gre_add_del_tunnel (vat_main_t * vam)
13519 unformat_input_t *line_input = vam->input;
13520 vl_api_gre_add_del_tunnel_t *mp;
13521 ip4_address_t src4, dst4;
13522 ip6_address_t src6, dst6;
13526 u8 t_type = GRE_TUNNEL_TYPE_L3;
13529 u32 outer_fib_id = 0;
13530 u32 session_id = 0;
13534 memset (&src4, 0, sizeof src4);
13535 memset (&dst4, 0, sizeof dst4);
13536 memset (&src6, 0, sizeof src6);
13537 memset (&dst6, 0, sizeof dst6);
13539 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13541 if (unformat (line_input, "del"))
13543 else if (unformat (line_input, "instance %d", &instance))
13545 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13550 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13555 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13560 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13565 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13567 else if (unformat (line_input, "teb"))
13568 t_type = GRE_TUNNEL_TYPE_TEB;
13569 else if (unformat (line_input, "erspan %d", &session_id))
13570 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13573 errmsg ("parse error '%U'", format_unformat_error, line_input);
13580 errmsg ("tunnel src address not specified");
13585 errmsg ("tunnel dst address not specified");
13588 if (ipv4_set && ipv6_set)
13590 errmsg ("both IPv4 and IPv6 addresses specified");
13595 M (GRE_ADD_DEL_TUNNEL, mp);
13599 clib_memcpy (&mp->src_address, &src4, 4);
13600 clib_memcpy (&mp->dst_address, &dst4, 4);
13604 clib_memcpy (&mp->src_address, &src6, 16);
13605 clib_memcpy (&mp->dst_address, &dst6, 16);
13607 mp->instance = htonl (instance);
13608 mp->outer_fib_id = htonl (outer_fib_id);
13609 mp->is_add = is_add;
13610 mp->session_id = htons ((u16) session_id);
13611 mp->tunnel_type = t_type;
13612 mp->is_ipv6 = ipv6_set;
13619 static void vl_api_gre_tunnel_details_t_handler
13620 (vl_api_gre_tunnel_details_t * mp)
13622 vat_main_t *vam = &vat_main;
13623 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13624 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13626 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13627 ntohl (mp->sw_if_index),
13628 ntohl (mp->instance),
13629 format_ip46_address, &src, IP46_TYPE_ANY,
13630 format_ip46_address, &dst, IP46_TYPE_ANY,
13631 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13634 static void vl_api_gre_tunnel_details_t_handler_json
13635 (vl_api_gre_tunnel_details_t * mp)
13637 vat_main_t *vam = &vat_main;
13638 vat_json_node_t *node = NULL;
13639 struct in_addr ip4;
13640 struct in6_addr ip6;
13642 if (VAT_JSON_ARRAY != vam->json_tree.type)
13644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13645 vat_json_init_array (&vam->json_tree);
13647 node = vat_json_array_add (&vam->json_tree);
13649 vat_json_init_object (node);
13650 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13651 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13654 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13655 vat_json_object_add_ip4 (node, "src_address", ip4);
13656 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13657 vat_json_object_add_ip4 (node, "dst_address", ip4);
13661 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13662 vat_json_object_add_ip6 (node, "src_address", ip6);
13663 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13664 vat_json_object_add_ip6 (node, "dst_address", ip6);
13666 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13667 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13668 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13669 vat_json_object_add_uint (node, "session_id", mp->session_id);
13673 api_gre_tunnel_dump (vat_main_t * vam)
13675 unformat_input_t *i = vam->input;
13676 vl_api_gre_tunnel_dump_t *mp;
13677 vl_api_control_ping_t *mp_ping;
13679 u8 sw_if_index_set = 0;
13682 /* Parse args required to build the message */
13683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13685 if (unformat (i, "sw_if_index %d", &sw_if_index))
13686 sw_if_index_set = 1;
13691 if (sw_if_index_set == 0)
13696 if (!vam->json_output)
13698 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13699 "sw_if_index", "instance", "src_address", "dst_address",
13700 "tunnel_type", "outer_fib_id", "session_id");
13703 /* Get list of gre-tunnel interfaces */
13704 M (GRE_TUNNEL_DUMP, mp);
13706 mp->sw_if_index = htonl (sw_if_index);
13710 /* Use a control ping for synchronization */
13711 MPING (CONTROL_PING, mp_ping);
13719 api_l2_fib_clear_table (vat_main_t * vam)
13721 // unformat_input_t * i = vam->input;
13722 vl_api_l2_fib_clear_table_t *mp;
13725 M (L2_FIB_CLEAR_TABLE, mp);
13733 api_l2_interface_efp_filter (vat_main_t * vam)
13735 unformat_input_t *i = vam->input;
13736 vl_api_l2_interface_efp_filter_t *mp;
13739 u8 sw_if_index_set = 0;
13742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13745 sw_if_index_set = 1;
13746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13747 sw_if_index_set = 1;
13748 else if (unformat (i, "enable"))
13750 else if (unformat (i, "disable"))
13754 clib_warning ("parse error '%U'", format_unformat_error, i);
13759 if (sw_if_index_set == 0)
13761 errmsg ("missing sw_if_index");
13765 M (L2_INTERFACE_EFP_FILTER, mp);
13767 mp->sw_if_index = ntohl (sw_if_index);
13768 mp->enable_disable = enable;
13775 #define foreach_vtr_op \
13776 _("disable", L2_VTR_DISABLED) \
13777 _("push-1", L2_VTR_PUSH_1) \
13778 _("push-2", L2_VTR_PUSH_2) \
13779 _("pop-1", L2_VTR_POP_1) \
13780 _("pop-2", L2_VTR_POP_2) \
13781 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13782 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13783 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13784 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13787 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13789 unformat_input_t *i = vam->input;
13790 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13792 u8 sw_if_index_set = 0;
13795 u32 push_dot1q = 1;
13800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13802 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13803 sw_if_index_set = 1;
13804 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13805 sw_if_index_set = 1;
13806 else if (unformat (i, "vtr_op %d", &vtr_op))
13808 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13811 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13813 else if (unformat (i, "tag1 %d", &tag1))
13815 else if (unformat (i, "tag2 %d", &tag2))
13819 clib_warning ("parse error '%U'", format_unformat_error, i);
13824 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13826 errmsg ("missing vtr operation or sw_if_index");
13830 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13831 mp->sw_if_index = ntohl (sw_if_index);
13832 mp->vtr_op = ntohl (vtr_op);
13833 mp->push_dot1q = ntohl (push_dot1q);
13834 mp->tag1 = ntohl (tag1);
13835 mp->tag2 = ntohl (tag2);
13843 api_create_vhost_user_if (vat_main_t * vam)
13845 unformat_input_t *i = vam->input;
13846 vl_api_create_vhost_user_if_t *mp;
13849 u8 file_name_set = 0;
13850 u32 custom_dev_instance = ~0;
13852 u8 use_custom_mac = 0;
13856 /* Shut up coverity */
13857 memset (hwaddr, 0, sizeof (hwaddr));
13859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13861 if (unformat (i, "socket %s", &file_name))
13865 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13867 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13868 use_custom_mac = 1;
13869 else if (unformat (i, "server"))
13871 else if (unformat (i, "tag %s", &tag))
13877 if (file_name_set == 0)
13879 errmsg ("missing socket file name");
13883 if (vec_len (file_name) > 255)
13885 errmsg ("socket file name too long");
13888 vec_add1 (file_name, 0);
13890 M (CREATE_VHOST_USER_IF, mp);
13892 mp->is_server = is_server;
13893 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13894 vec_free (file_name);
13895 if (custom_dev_instance != ~0)
13898 mp->custom_dev_instance = ntohl (custom_dev_instance);
13900 mp->use_custom_mac = use_custom_mac;
13901 clib_memcpy (mp->mac_address, hwaddr, 6);
13903 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13912 api_modify_vhost_user_if (vat_main_t * vam)
13914 unformat_input_t *i = vam->input;
13915 vl_api_modify_vhost_user_if_t *mp;
13918 u8 file_name_set = 0;
13919 u32 custom_dev_instance = ~0;
13920 u8 sw_if_index_set = 0;
13921 u32 sw_if_index = (u32) ~ 0;
13924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13927 sw_if_index_set = 1;
13928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13929 sw_if_index_set = 1;
13930 else if (unformat (i, "socket %s", &file_name))
13934 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13936 else if (unformat (i, "server"))
13942 if (sw_if_index_set == 0)
13944 errmsg ("missing sw_if_index or interface name");
13948 if (file_name_set == 0)
13950 errmsg ("missing socket file name");
13954 if (vec_len (file_name) > 255)
13956 errmsg ("socket file name too long");
13959 vec_add1 (file_name, 0);
13961 M (MODIFY_VHOST_USER_IF, mp);
13963 mp->sw_if_index = ntohl (sw_if_index);
13964 mp->is_server = is_server;
13965 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13966 vec_free (file_name);
13967 if (custom_dev_instance != ~0)
13970 mp->custom_dev_instance = ntohl (custom_dev_instance);
13979 api_delete_vhost_user_if (vat_main_t * vam)
13981 unformat_input_t *i = vam->input;
13982 vl_api_delete_vhost_user_if_t *mp;
13983 u32 sw_if_index = ~0;
13984 u8 sw_if_index_set = 0;
13987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13989 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13990 sw_if_index_set = 1;
13991 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13992 sw_if_index_set = 1;
13997 if (sw_if_index_set == 0)
13999 errmsg ("missing sw_if_index or interface name");
14004 M (DELETE_VHOST_USER_IF, mp);
14006 mp->sw_if_index = ntohl (sw_if_index);
14013 static void vl_api_sw_interface_vhost_user_details_t_handler
14014 (vl_api_sw_interface_vhost_user_details_t * mp)
14016 vat_main_t *vam = &vat_main;
14018 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14019 (char *) mp->interface_name,
14020 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14021 clib_net_to_host_u64 (mp->features), mp->is_server,
14022 ntohl (mp->num_regions), (char *) mp->sock_filename);
14023 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14026 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14027 (vl_api_sw_interface_vhost_user_details_t * mp)
14029 vat_main_t *vam = &vat_main;
14030 vat_json_node_t *node = NULL;
14032 if (VAT_JSON_ARRAY != vam->json_tree.type)
14034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14035 vat_json_init_array (&vam->json_tree);
14037 node = vat_json_array_add (&vam->json_tree);
14039 vat_json_init_object (node);
14040 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14041 vat_json_object_add_string_copy (node, "interface_name",
14042 mp->interface_name);
14043 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14044 ntohl (mp->virtio_net_hdr_sz));
14045 vat_json_object_add_uint (node, "features",
14046 clib_net_to_host_u64 (mp->features));
14047 vat_json_object_add_uint (node, "is_server", mp->is_server);
14048 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14049 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14050 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14054 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14056 vl_api_sw_interface_vhost_user_dump_t *mp;
14057 vl_api_control_ping_t *mp_ping;
14060 "Interface name idx hdr_sz features server regions filename");
14062 /* Get list of vhost-user interfaces */
14063 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14066 /* Use a control ping for synchronization */
14067 MPING (CONTROL_PING, mp_ping);
14075 api_show_version (vat_main_t * vam)
14077 vl_api_show_version_t *mp;
14080 M (SHOW_VERSION, mp);
14089 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14091 unformat_input_t *line_input = vam->input;
14092 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14093 ip4_address_t local4, remote4;
14094 ip6_address_t local6, remote6;
14096 u8 ipv4_set = 0, ipv6_set = 0;
14100 u32 mcast_sw_if_index = ~0;
14101 u32 encap_vrf_id = 0;
14102 u32 decap_vrf_id = 0;
14108 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14109 memset (&local4, 0, sizeof local4);
14110 memset (&remote4, 0, sizeof remote4);
14111 memset (&local6, 0, sizeof local6);
14112 memset (&remote6, 0, sizeof remote6);
14114 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14116 if (unformat (line_input, "del"))
14118 else if (unformat (line_input, "local %U",
14119 unformat_ip4_address, &local4))
14124 else if (unformat (line_input, "remote %U",
14125 unformat_ip4_address, &remote4))
14130 else if (unformat (line_input, "local %U",
14131 unformat_ip6_address, &local6))
14136 else if (unformat (line_input, "remote %U",
14137 unformat_ip6_address, &remote6))
14142 else if (unformat (line_input, "group %U %U",
14143 unformat_ip4_address, &remote4,
14144 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14146 grp_set = remote_set = 1;
14149 else if (unformat (line_input, "group %U",
14150 unformat_ip4_address, &remote4))
14152 grp_set = remote_set = 1;
14155 else if (unformat (line_input, "group %U %U",
14156 unformat_ip6_address, &remote6,
14157 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14159 grp_set = remote_set = 1;
14162 else if (unformat (line_input, "group %U",
14163 unformat_ip6_address, &remote6))
14165 grp_set = remote_set = 1;
14169 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14171 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14173 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14175 else if (unformat (line_input, "vni %d", &vni))
14177 else if (unformat (line_input, "next-ip4"))
14179 else if (unformat (line_input, "next-ip6"))
14181 else if (unformat (line_input, "next-ethernet"))
14183 else if (unformat (line_input, "next-nsh"))
14187 errmsg ("parse error '%U'", format_unformat_error, line_input);
14192 if (local_set == 0)
14194 errmsg ("tunnel local address not specified");
14197 if (remote_set == 0)
14199 errmsg ("tunnel remote address not specified");
14202 if (grp_set && mcast_sw_if_index == ~0)
14204 errmsg ("tunnel nonexistent multicast device");
14207 if (ipv4_set && ipv6_set)
14209 errmsg ("both IPv4 and IPv6 addresses specified");
14215 errmsg ("vni not specified");
14219 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14224 clib_memcpy (&mp->local, &local6, sizeof (local6));
14225 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14229 clib_memcpy (&mp->local, &local4, sizeof (local4));
14230 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14233 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14234 mp->encap_vrf_id = ntohl (encap_vrf_id);
14235 mp->decap_vrf_id = ntohl (decap_vrf_id);
14236 mp->protocol = protocol;
14237 mp->vni = ntohl (vni);
14238 mp->is_add = is_add;
14239 mp->is_ipv6 = ipv6_set;
14246 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14247 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14249 vat_main_t *vam = &vat_main;
14250 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14251 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14253 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14254 ntohl (mp->sw_if_index),
14255 format_ip46_address, &local, IP46_TYPE_ANY,
14256 format_ip46_address, &remote, IP46_TYPE_ANY,
14257 ntohl (mp->vni), mp->protocol,
14258 ntohl (mp->mcast_sw_if_index),
14259 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14263 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14264 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14266 vat_main_t *vam = &vat_main;
14267 vat_json_node_t *node = NULL;
14268 struct in_addr ip4;
14269 struct in6_addr ip6;
14271 if (VAT_JSON_ARRAY != vam->json_tree.type)
14273 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14274 vat_json_init_array (&vam->json_tree);
14276 node = vat_json_array_add (&vam->json_tree);
14278 vat_json_init_object (node);
14279 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14282 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14283 vat_json_object_add_ip6 (node, "local", ip6);
14284 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14285 vat_json_object_add_ip6 (node, "remote", ip6);
14289 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14290 vat_json_object_add_ip4 (node, "local", ip4);
14291 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14292 vat_json_object_add_ip4 (node, "remote", ip4);
14294 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14295 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14296 vat_json_object_add_uint (node, "mcast_sw_if_index",
14297 ntohl (mp->mcast_sw_if_index));
14298 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14299 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14300 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14304 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14306 unformat_input_t *i = vam->input;
14307 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14308 vl_api_control_ping_t *mp_ping;
14310 u8 sw_if_index_set = 0;
14313 /* Parse args required to build the message */
14314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14316 if (unformat (i, "sw_if_index %d", &sw_if_index))
14317 sw_if_index_set = 1;
14322 if (sw_if_index_set == 0)
14327 if (!vam->json_output)
14329 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14330 "sw_if_index", "local", "remote", "vni",
14331 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14334 /* Get list of vxlan-tunnel interfaces */
14335 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14337 mp->sw_if_index = htonl (sw_if_index);
14341 /* Use a control ping for synchronization */
14342 MPING (CONTROL_PING, mp_ping);
14349 static void vl_api_l2_fib_table_details_t_handler
14350 (vl_api_l2_fib_table_details_t * mp)
14352 vat_main_t *vam = &vat_main;
14354 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14356 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14357 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14361 static void vl_api_l2_fib_table_details_t_handler_json
14362 (vl_api_l2_fib_table_details_t * mp)
14364 vat_main_t *vam = &vat_main;
14365 vat_json_node_t *node = NULL;
14367 if (VAT_JSON_ARRAY != vam->json_tree.type)
14369 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14370 vat_json_init_array (&vam->json_tree);
14372 node = vat_json_array_add (&vam->json_tree);
14374 vat_json_init_object (node);
14375 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14376 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14378 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14379 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14380 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14384 api_l2_fib_table_dump (vat_main_t * vam)
14386 unformat_input_t *i = vam->input;
14387 vl_api_l2_fib_table_dump_t *mp;
14388 vl_api_control_ping_t *mp_ping;
14393 /* Parse args required to build the message */
14394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14396 if (unformat (i, "bd_id %d", &bd_id))
14402 if (bd_id_set == 0)
14404 errmsg ("missing bridge domain");
14408 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14410 /* Get list of l2 fib entries */
14411 M (L2_FIB_TABLE_DUMP, mp);
14413 mp->bd_id = ntohl (bd_id);
14416 /* Use a control ping for synchronization */
14417 MPING (CONTROL_PING, mp_ping);
14426 api_interface_name_renumber (vat_main_t * vam)
14428 unformat_input_t *line_input = vam->input;
14429 vl_api_interface_name_renumber_t *mp;
14430 u32 sw_if_index = ~0;
14431 u32 new_show_dev_instance = ~0;
14434 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14436 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14439 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14441 else if (unformat (line_input, "new_show_dev_instance %d",
14442 &new_show_dev_instance))
14448 if (sw_if_index == ~0)
14450 errmsg ("missing interface name or sw_if_index");
14454 if (new_show_dev_instance == ~0)
14456 errmsg ("missing new_show_dev_instance");
14460 M (INTERFACE_NAME_RENUMBER, mp);
14462 mp->sw_if_index = ntohl (sw_if_index);
14463 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14471 api_ip_probe_neighbor (vat_main_t * vam)
14473 unformat_input_t *i = vam->input;
14474 vl_api_ip_probe_neighbor_t *mp;
14482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14488 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14490 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14501 errmsg ("missing interface");
14507 errmsg ("missing addresses");
14511 M (IP_PROBE_NEIGHBOR, mp);
14513 mp->sw_if_index = ntohl (sw_if_index);
14514 mp->is_ipv6 = is_ipv6;
14515 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14523 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14525 unformat_input_t *i = vam->input;
14526 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14527 u8 mode = IP_SCAN_V46_NEIGHBORS;
14528 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14533 if (unformat (i, "ip4"))
14534 mode = IP_SCAN_V4_NEIGHBORS;
14535 else if (unformat (i, "ip6"))
14536 mode = IP_SCAN_V6_NEIGHBORS;
14537 if (unformat (i, "both"))
14538 mode = IP_SCAN_V46_NEIGHBORS;
14539 else if (unformat (i, "disable"))
14540 mode = IP_SCAN_DISABLED;
14541 else if (unformat (i, "interval %d", &interval))
14543 else if (unformat (i, "max-time %d", &time))
14545 else if (unformat (i, "max-update %d", &update))
14547 else if (unformat (i, "delay %d", &delay))
14549 else if (unformat (i, "stale %d", &stale))
14555 if (interval > 255)
14557 errmsg ("interval cannot exceed 255 minutes.");
14562 errmsg ("max-time cannot exceed 255 usec.");
14567 errmsg ("max-update cannot exceed 255.");
14572 errmsg ("delay cannot exceed 255 msec.");
14577 errmsg ("stale cannot exceed 255 minutes.");
14581 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14583 mp->scan_interval = interval;
14584 mp->max_proc_time = time;
14585 mp->max_update = update;
14586 mp->scan_int_delay = delay;
14587 mp->stale_threshold = stale;
14595 api_want_ip4_arp_events (vat_main_t * vam)
14597 unformat_input_t *line_input = vam->input;
14598 vl_api_want_ip4_arp_events_t *mp;
14599 ip4_address_t address;
14600 int address_set = 0;
14601 u32 enable_disable = 1;
14604 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14606 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14608 else if (unformat (line_input, "del"))
14609 enable_disable = 0;
14614 if (address_set == 0)
14616 errmsg ("missing addresses");
14620 M (WANT_IP4_ARP_EVENTS, mp);
14621 mp->enable_disable = enable_disable;
14622 mp->pid = htonl (getpid ());
14623 mp->address = address.as_u32;
14631 api_want_ip6_nd_events (vat_main_t * vam)
14633 unformat_input_t *line_input = vam->input;
14634 vl_api_want_ip6_nd_events_t *mp;
14635 ip6_address_t address;
14636 int address_set = 0;
14637 u32 enable_disable = 1;
14640 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14642 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14644 else if (unformat (line_input, "del"))
14645 enable_disable = 0;
14650 if (address_set == 0)
14652 errmsg ("missing addresses");
14656 M (WANT_IP6_ND_EVENTS, mp);
14657 mp->enable_disable = enable_disable;
14658 mp->pid = htonl (getpid ());
14659 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14667 api_want_l2_macs_events (vat_main_t * vam)
14669 unformat_input_t *line_input = vam->input;
14670 vl_api_want_l2_macs_events_t *mp;
14671 u8 enable_disable = 1;
14672 u32 scan_delay = 0;
14673 u32 max_macs_in_event = 0;
14674 u32 learn_limit = 0;
14677 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (line_input, "learn-limit %d", &learn_limit))
14681 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14683 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14685 else if (unformat (line_input, "disable"))
14686 enable_disable = 0;
14691 M (WANT_L2_MACS_EVENTS, mp);
14692 mp->enable_disable = enable_disable;
14693 mp->pid = htonl (getpid ());
14694 mp->learn_limit = htonl (learn_limit);
14695 mp->scan_delay = (u8) scan_delay;
14696 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14703 api_input_acl_set_interface (vat_main_t * vam)
14705 unformat_input_t *i = vam->input;
14706 vl_api_input_acl_set_interface_t *mp;
14708 int sw_if_index_set;
14709 u32 ip4_table_index = ~0;
14710 u32 ip6_table_index = ~0;
14711 u32 l2_table_index = ~0;
14715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14718 sw_if_index_set = 1;
14719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14720 sw_if_index_set = 1;
14721 else if (unformat (i, "del"))
14723 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14725 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14727 else if (unformat (i, "l2-table %d", &l2_table_index))
14731 clib_warning ("parse error '%U'", format_unformat_error, i);
14736 if (sw_if_index_set == 0)
14738 errmsg ("missing interface name or sw_if_index");
14742 M (INPUT_ACL_SET_INTERFACE, mp);
14744 mp->sw_if_index = ntohl (sw_if_index);
14745 mp->ip4_table_index = ntohl (ip4_table_index);
14746 mp->ip6_table_index = ntohl (ip6_table_index);
14747 mp->l2_table_index = ntohl (l2_table_index);
14748 mp->is_add = is_add;
14756 api_output_acl_set_interface (vat_main_t * vam)
14758 unformat_input_t *i = vam->input;
14759 vl_api_output_acl_set_interface_t *mp;
14761 int sw_if_index_set;
14762 u32 ip4_table_index = ~0;
14763 u32 ip6_table_index = ~0;
14764 u32 l2_table_index = ~0;
14768 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14770 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14771 sw_if_index_set = 1;
14772 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14773 sw_if_index_set = 1;
14774 else if (unformat (i, "del"))
14776 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14778 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14780 else if (unformat (i, "l2-table %d", &l2_table_index))
14784 clib_warning ("parse error '%U'", format_unformat_error, i);
14789 if (sw_if_index_set == 0)
14791 errmsg ("missing interface name or sw_if_index");
14795 M (OUTPUT_ACL_SET_INTERFACE, mp);
14797 mp->sw_if_index = ntohl (sw_if_index);
14798 mp->ip4_table_index = ntohl (ip4_table_index);
14799 mp->ip6_table_index = ntohl (ip6_table_index);
14800 mp->l2_table_index = ntohl (l2_table_index);
14801 mp->is_add = is_add;
14809 api_ip_address_dump (vat_main_t * vam)
14811 unformat_input_t *i = vam->input;
14812 vl_api_ip_address_dump_t *mp;
14813 vl_api_control_ping_t *mp_ping;
14814 u32 sw_if_index = ~0;
14815 u8 sw_if_index_set = 0;
14820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14822 if (unformat (i, "sw_if_index %d", &sw_if_index))
14823 sw_if_index_set = 1;
14825 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14826 sw_if_index_set = 1;
14827 else if (unformat (i, "ipv4"))
14829 else if (unformat (i, "ipv6"))
14835 if (ipv4_set && ipv6_set)
14837 errmsg ("ipv4 and ipv6 flags cannot be both set");
14841 if ((!ipv4_set) && (!ipv6_set))
14843 errmsg ("no ipv4 nor ipv6 flag set");
14847 if (sw_if_index_set == 0)
14849 errmsg ("missing interface name or sw_if_index");
14853 vam->current_sw_if_index = sw_if_index;
14854 vam->is_ipv6 = ipv6_set;
14856 M (IP_ADDRESS_DUMP, mp);
14857 mp->sw_if_index = ntohl (sw_if_index);
14858 mp->is_ipv6 = ipv6_set;
14861 /* Use a control ping for synchronization */
14862 MPING (CONTROL_PING, mp_ping);
14870 api_ip_dump (vat_main_t * vam)
14872 vl_api_ip_dump_t *mp;
14873 vl_api_control_ping_t *mp_ping;
14874 unformat_input_t *in = vam->input;
14881 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14883 if (unformat (in, "ipv4"))
14885 else if (unformat (in, "ipv6"))
14891 if (ipv4_set && ipv6_set)
14893 errmsg ("ipv4 and ipv6 flags cannot be both set");
14897 if ((!ipv4_set) && (!ipv6_set))
14899 errmsg ("no ipv4 nor ipv6 flag set");
14903 is_ipv6 = ipv6_set;
14904 vam->is_ipv6 = is_ipv6;
14906 /* free old data */
14907 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14909 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14911 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14914 mp->is_ipv6 = ipv6_set;
14917 /* Use a control ping for synchronization */
14918 MPING (CONTROL_PING, mp_ping);
14926 api_ipsec_spd_add_del (vat_main_t * vam)
14928 unformat_input_t *i = vam->input;
14929 vl_api_ipsec_spd_add_del_t *mp;
14934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14936 if (unformat (i, "spd_id %d", &spd_id))
14938 else if (unformat (i, "del"))
14942 clib_warning ("parse error '%U'", format_unformat_error, i);
14948 errmsg ("spd_id must be set");
14952 M (IPSEC_SPD_ADD_DEL, mp);
14954 mp->spd_id = ntohl (spd_id);
14955 mp->is_add = is_add;
14963 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14965 unformat_input_t *i = vam->input;
14966 vl_api_ipsec_interface_add_del_spd_t *mp;
14968 u8 sw_if_index_set = 0;
14969 u32 spd_id = (u32) ~ 0;
14973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14975 if (unformat (i, "del"))
14977 else if (unformat (i, "spd_id %d", &spd_id))
14980 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14981 sw_if_index_set = 1;
14982 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14983 sw_if_index_set = 1;
14986 clib_warning ("parse error '%U'", format_unformat_error, i);
14992 if (spd_id == (u32) ~ 0)
14994 errmsg ("spd_id must be set");
14998 if (sw_if_index_set == 0)
15000 errmsg ("missing interface name or sw_if_index");
15004 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15006 mp->spd_id = ntohl (spd_id);
15007 mp->sw_if_index = ntohl (sw_if_index);
15008 mp->is_add = is_add;
15016 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15018 unformat_input_t *i = vam->input;
15019 vl_api_ipsec_spd_add_del_entry_t *mp;
15020 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15021 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15023 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15024 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15025 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15026 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15029 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15030 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15031 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15032 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15033 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15034 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15036 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15038 if (unformat (i, "del"))
15040 if (unformat (i, "outbound"))
15042 if (unformat (i, "inbound"))
15044 else if (unformat (i, "spd_id %d", &spd_id))
15046 else if (unformat (i, "sa_id %d", &sa_id))
15048 else if (unformat (i, "priority %d", &priority))
15050 else if (unformat (i, "protocol %d", &protocol))
15052 else if (unformat (i, "lport_start %d", &lport_start))
15054 else if (unformat (i, "lport_stop %d", &lport_stop))
15056 else if (unformat (i, "rport_start %d", &rport_start))
15058 else if (unformat (i, "rport_stop %d", &rport_stop))
15062 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15068 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15075 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15081 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15088 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15094 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15101 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15107 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15113 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15115 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15117 clib_warning ("unsupported action: 'resolve'");
15123 clib_warning ("parse error '%U'", format_unformat_error, i);
15129 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15131 mp->spd_id = ntohl (spd_id);
15132 mp->priority = ntohl (priority);
15133 mp->is_outbound = is_outbound;
15135 mp->is_ipv6 = is_ipv6;
15136 if (is_ipv6 || is_ip_any)
15138 clib_memcpy (mp->remote_address_start, &raddr6_start,
15139 sizeof (ip6_address_t));
15140 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15141 sizeof (ip6_address_t));
15142 clib_memcpy (mp->local_address_start, &laddr6_start,
15143 sizeof (ip6_address_t));
15144 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15145 sizeof (ip6_address_t));
15149 clib_memcpy (mp->remote_address_start, &raddr4_start,
15150 sizeof (ip4_address_t));
15151 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15152 sizeof (ip4_address_t));
15153 clib_memcpy (mp->local_address_start, &laddr4_start,
15154 sizeof (ip4_address_t));
15155 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15156 sizeof (ip4_address_t));
15158 mp->protocol = (u8) protocol;
15159 mp->local_port_start = ntohs ((u16) lport_start);
15160 mp->local_port_stop = ntohs ((u16) lport_stop);
15161 mp->remote_port_start = ntohs ((u16) rport_start);
15162 mp->remote_port_stop = ntohs ((u16) rport_stop);
15163 mp->policy = (u8) policy;
15164 mp->sa_id = ntohl (sa_id);
15165 mp->is_add = is_add;
15166 mp->is_ip_any = is_ip_any;
15173 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15175 unformat_input_t *i = vam->input;
15176 vl_api_ipsec_sad_add_del_entry_t *mp;
15177 u32 sad_id = 0, spi = 0;
15178 u8 *ck = 0, *ik = 0;
15181 u8 protocol = IPSEC_PROTOCOL_AH;
15182 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15183 u32 crypto_alg = 0, integ_alg = 0;
15184 ip4_address_t tun_src4;
15185 ip4_address_t tun_dst4;
15186 ip6_address_t tun_src6;
15187 ip6_address_t tun_dst6;
15190 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15192 if (unformat (i, "del"))
15194 else if (unformat (i, "sad_id %d", &sad_id))
15196 else if (unformat (i, "spi %d", &spi))
15198 else if (unformat (i, "esp"))
15199 protocol = IPSEC_PROTOCOL_ESP;
15200 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15203 is_tunnel_ipv6 = 0;
15205 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15208 is_tunnel_ipv6 = 0;
15210 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15213 is_tunnel_ipv6 = 1;
15215 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15218 is_tunnel_ipv6 = 1;
15222 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15224 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15225 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15227 clib_warning ("unsupported crypto-alg: '%U'",
15228 format_ipsec_crypto_alg, crypto_alg);
15232 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15236 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15238 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15239 integ_alg >= IPSEC_INTEG_N_ALG)
15241 clib_warning ("unsupported integ-alg: '%U'",
15242 format_ipsec_integ_alg, integ_alg);
15246 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15250 clib_warning ("parse error '%U'", format_unformat_error, i);
15256 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15258 mp->sad_id = ntohl (sad_id);
15259 mp->is_add = is_add;
15260 mp->protocol = protocol;
15261 mp->spi = ntohl (spi);
15262 mp->is_tunnel = is_tunnel;
15263 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15264 mp->crypto_algorithm = crypto_alg;
15265 mp->integrity_algorithm = integ_alg;
15266 mp->crypto_key_length = vec_len (ck);
15267 mp->integrity_key_length = vec_len (ik);
15269 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15270 mp->crypto_key_length = sizeof (mp->crypto_key);
15272 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15273 mp->integrity_key_length = sizeof (mp->integrity_key);
15276 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15278 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15282 if (is_tunnel_ipv6)
15284 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15285 sizeof (ip6_address_t));
15286 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15287 sizeof (ip6_address_t));
15291 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15292 sizeof (ip4_address_t));
15293 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15294 sizeof (ip4_address_t));
15304 api_ipsec_sa_set_key (vat_main_t * vam)
15306 unformat_input_t *i = vam->input;
15307 vl_api_ipsec_sa_set_key_t *mp;
15309 u8 *ck = 0, *ik = 0;
15312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15314 if (unformat (i, "sa_id %d", &sa_id))
15316 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15318 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15322 clib_warning ("parse error '%U'", format_unformat_error, i);
15327 M (IPSEC_SA_SET_KEY, mp);
15329 mp->sa_id = ntohl (sa_id);
15330 mp->crypto_key_length = vec_len (ck);
15331 mp->integrity_key_length = vec_len (ik);
15333 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15334 mp->crypto_key_length = sizeof (mp->crypto_key);
15336 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15337 mp->integrity_key_length = sizeof (mp->integrity_key);
15340 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15342 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15350 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15352 unformat_input_t *i = vam->input;
15353 vl_api_ipsec_tunnel_if_add_del_t *mp;
15354 u32 local_spi = 0, remote_spi = 0;
15355 u32 crypto_alg = 0, integ_alg = 0;
15356 u8 *lck = NULL, *rck = NULL;
15357 u8 *lik = NULL, *rik = NULL;
15358 ip4_address_t local_ip = { {0} };
15359 ip4_address_t remote_ip = { {0} };
15362 u8 anti_replay = 0;
15367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15369 if (unformat (i, "del"))
15371 else if (unformat (i, "esn"))
15373 else if (unformat (i, "anti_replay"))
15375 else if (unformat (i, "local_spi %d", &local_spi))
15377 else if (unformat (i, "remote_spi %d", &remote_spi))
15379 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15381 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15383 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15386 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15388 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15390 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15394 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15396 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15397 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15399 errmsg ("unsupported crypto-alg: '%U'\n",
15400 format_ipsec_crypto_alg, crypto_alg);
15406 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15408 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15409 integ_alg >= IPSEC_INTEG_N_ALG)
15411 errmsg ("unsupported integ-alg: '%U'\n",
15412 format_ipsec_integ_alg, integ_alg);
15416 else if (unformat (i, "instance %u", &instance))
15420 errmsg ("parse error '%U'\n", format_unformat_error, i);
15425 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15427 mp->is_add = is_add;
15429 mp->anti_replay = anti_replay;
15431 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15432 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15434 mp->local_spi = htonl (local_spi);
15435 mp->remote_spi = htonl (remote_spi);
15436 mp->crypto_alg = (u8) crypto_alg;
15438 mp->local_crypto_key_len = 0;
15441 mp->local_crypto_key_len = vec_len (lck);
15442 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15443 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15444 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15447 mp->remote_crypto_key_len = 0;
15450 mp->remote_crypto_key_len = vec_len (rck);
15451 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15452 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15453 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15456 mp->integ_alg = (u8) integ_alg;
15458 mp->local_integ_key_len = 0;
15461 mp->local_integ_key_len = vec_len (lik);
15462 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15463 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15464 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15467 mp->remote_integ_key_len = 0;
15470 mp->remote_integ_key_len = vec_len (rik);
15471 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15472 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15473 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15478 mp->renumber = renumber;
15479 mp->show_instance = ntohl (instance);
15488 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15490 vat_main_t *vam = &vat_main;
15492 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15493 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15494 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15495 "tunnel_src_addr %U tunnel_dst_addr %U "
15496 "salt %u seq_outbound %lu last_seq_inbound %lu "
15497 "replay_window %lu total_data_size %lu\n",
15498 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15500 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15501 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15502 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15503 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15504 mp->tunnel_src_addr,
15505 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15506 mp->tunnel_dst_addr,
15508 clib_net_to_host_u64 (mp->seq_outbound),
15509 clib_net_to_host_u64 (mp->last_seq_inbound),
15510 clib_net_to_host_u64 (mp->replay_window),
15511 clib_net_to_host_u64 (mp->total_data_size));
15514 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15515 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15517 static void vl_api_ipsec_sa_details_t_handler_json
15518 (vl_api_ipsec_sa_details_t * mp)
15520 vat_main_t *vam = &vat_main;
15521 vat_json_node_t *node = NULL;
15522 struct in_addr src_ip4, dst_ip4;
15523 struct in6_addr src_ip6, dst_ip6;
15525 if (VAT_JSON_ARRAY != vam->json_tree.type)
15527 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15528 vat_json_init_array (&vam->json_tree);
15530 node = vat_json_array_add (&vam->json_tree);
15532 vat_json_init_object (node);
15533 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15534 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15535 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15536 vat_json_object_add_uint (node, "proto", mp->protocol);
15537 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15538 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15539 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15540 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15541 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15542 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15543 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15544 mp->crypto_key_len);
15545 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15546 mp->integ_key_len);
15547 if (mp->is_tunnel_ip6)
15549 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15550 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15551 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15552 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15556 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15557 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15558 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15559 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15561 vat_json_object_add_uint (node, "replay_window",
15562 clib_net_to_host_u64 (mp->replay_window));
15563 vat_json_object_add_uint (node, "total_data_size",
15564 clib_net_to_host_u64 (mp->total_data_size));
15569 api_ipsec_sa_dump (vat_main_t * vam)
15571 unformat_input_t *i = vam->input;
15572 vl_api_ipsec_sa_dump_t *mp;
15573 vl_api_control_ping_t *mp_ping;
15577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15579 if (unformat (i, "sa_id %d", &sa_id))
15583 clib_warning ("parse error '%U'", format_unformat_error, i);
15588 M (IPSEC_SA_DUMP, mp);
15590 mp->sa_id = ntohl (sa_id);
15594 /* Use a control ping for synchronization */
15595 M (CONTROL_PING, mp_ping);
15603 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15605 unformat_input_t *i = vam->input;
15606 vl_api_ipsec_tunnel_if_set_key_t *mp;
15607 u32 sw_if_index = ~0;
15608 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15618 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15619 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15621 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15622 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15623 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15624 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15626 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15627 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15628 else if (unformat (i, "%U", unformat_hex_string, &key))
15632 clib_warning ("parse error '%U'", format_unformat_error, i);
15637 if (sw_if_index == ~0)
15639 errmsg ("interface must be specified");
15643 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15645 errmsg ("key type must be specified");
15651 errmsg ("algorithm must be specified");
15655 if (vec_len (key) == 0)
15657 errmsg ("key must be specified");
15661 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15663 mp->sw_if_index = htonl (sw_if_index);
15665 mp->key_type = key_type;
15666 mp->key_len = vec_len (key);
15667 clib_memcpy (mp->key, key, vec_len (key));
15676 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15678 unformat_input_t *i = vam->input;
15679 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15680 u32 sw_if_index = ~0;
15682 u8 is_outbound = (u8) ~ 0;
15685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15689 else if (unformat (i, "sa_id %d", &sa_id))
15691 else if (unformat (i, "outbound"))
15693 else if (unformat (i, "inbound"))
15697 clib_warning ("parse error '%U'", format_unformat_error, i);
15702 if (sw_if_index == ~0)
15704 errmsg ("interface must be specified");
15710 errmsg ("SA ID must be specified");
15714 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15716 mp->sw_if_index = htonl (sw_if_index);
15717 mp->sa_id = htonl (sa_id);
15718 mp->is_outbound = is_outbound;
15727 api_ikev2_profile_add_del (vat_main_t * vam)
15729 unformat_input_t *i = vam->input;
15730 vl_api_ikev2_profile_add_del_t *mp;
15735 const char *valid_chars = "a-zA-Z0-9_";
15737 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (i, "del"))
15741 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15742 vec_add1 (name, 0);
15745 errmsg ("parse error '%U'", format_unformat_error, i);
15750 if (!vec_len (name))
15752 errmsg ("profile name must be specified");
15756 if (vec_len (name) > 64)
15758 errmsg ("profile name too long");
15762 M (IKEV2_PROFILE_ADD_DEL, mp);
15764 clib_memcpy (mp->name, name, vec_len (name));
15765 mp->is_add = is_add;
15774 api_ikev2_profile_set_auth (vat_main_t * vam)
15776 unformat_input_t *i = vam->input;
15777 vl_api_ikev2_profile_set_auth_t *mp;
15780 u32 auth_method = 0;
15784 const char *valid_chars = "a-zA-Z0-9_";
15786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15788 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15789 vec_add1 (name, 0);
15790 else if (unformat (i, "auth_method %U",
15791 unformat_ikev2_auth_method, &auth_method))
15793 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15795 else if (unformat (i, "auth_data %v", &data))
15799 errmsg ("parse error '%U'", format_unformat_error, i);
15804 if (!vec_len (name))
15806 errmsg ("profile name must be specified");
15810 if (vec_len (name) > 64)
15812 errmsg ("profile name too long");
15816 if (!vec_len (data))
15818 errmsg ("auth_data must be specified");
15824 errmsg ("auth_method must be specified");
15828 M (IKEV2_PROFILE_SET_AUTH, mp);
15830 mp->is_hex = is_hex;
15831 mp->auth_method = (u8) auth_method;
15832 mp->data_len = vec_len (data);
15833 clib_memcpy (mp->name, name, vec_len (name));
15834 clib_memcpy (mp->data, data, vec_len (data));
15844 api_ikev2_profile_set_id (vat_main_t * vam)
15846 unformat_input_t *i = vam->input;
15847 vl_api_ikev2_profile_set_id_t *mp;
15855 const char *valid_chars = "a-zA-Z0-9_";
15857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15859 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15860 vec_add1 (name, 0);
15861 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15863 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15865 data = vec_new (u8, 4);
15866 clib_memcpy (data, ip4.as_u8, 4);
15868 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15870 else if (unformat (i, "id_data %v", &data))
15872 else if (unformat (i, "local"))
15874 else if (unformat (i, "remote"))
15878 errmsg ("parse error '%U'", format_unformat_error, i);
15883 if (!vec_len (name))
15885 errmsg ("profile name must be specified");
15889 if (vec_len (name) > 64)
15891 errmsg ("profile name too long");
15895 if (!vec_len (data))
15897 errmsg ("id_data must be specified");
15903 errmsg ("id_type must be specified");
15907 M (IKEV2_PROFILE_SET_ID, mp);
15909 mp->is_local = is_local;
15910 mp->id_type = (u8) id_type;
15911 mp->data_len = vec_len (data);
15912 clib_memcpy (mp->name, name, vec_len (name));
15913 clib_memcpy (mp->data, data, vec_len (data));
15923 api_ikev2_profile_set_ts (vat_main_t * vam)
15925 unformat_input_t *i = vam->input;
15926 vl_api_ikev2_profile_set_ts_t *mp;
15929 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15930 ip4_address_t start_addr, end_addr;
15932 const char *valid_chars = "a-zA-Z0-9_";
15935 start_addr.as_u32 = 0;
15936 end_addr.as_u32 = (u32) ~ 0;
15938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15940 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15941 vec_add1 (name, 0);
15942 else if (unformat (i, "protocol %d", &proto))
15944 else if (unformat (i, "start_port %d", &start_port))
15946 else if (unformat (i, "end_port %d", &end_port))
15949 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15951 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15953 else if (unformat (i, "local"))
15955 else if (unformat (i, "remote"))
15959 errmsg ("parse error '%U'", format_unformat_error, i);
15964 if (!vec_len (name))
15966 errmsg ("profile name must be specified");
15970 if (vec_len (name) > 64)
15972 errmsg ("profile name too long");
15976 M (IKEV2_PROFILE_SET_TS, mp);
15978 mp->is_local = is_local;
15979 mp->proto = (u8) proto;
15980 mp->start_port = (u16) start_port;
15981 mp->end_port = (u16) end_port;
15982 mp->start_addr = start_addr.as_u32;
15983 mp->end_addr = end_addr.as_u32;
15984 clib_memcpy (mp->name, name, vec_len (name));
15993 api_ikev2_set_local_key (vat_main_t * vam)
15995 unformat_input_t *i = vam->input;
15996 vl_api_ikev2_set_local_key_t *mp;
16000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16002 if (unformat (i, "file %v", &file))
16003 vec_add1 (file, 0);
16006 errmsg ("parse error '%U'", format_unformat_error, i);
16011 if (!vec_len (file))
16013 errmsg ("RSA key file must be specified");
16017 if (vec_len (file) > 256)
16019 errmsg ("file name too long");
16023 M (IKEV2_SET_LOCAL_KEY, mp);
16025 clib_memcpy (mp->key_file, file, vec_len (file));
16034 api_ikev2_set_responder (vat_main_t * vam)
16036 unformat_input_t *i = vam->input;
16037 vl_api_ikev2_set_responder_t *mp;
16040 u32 sw_if_index = ~0;
16041 ip4_address_t address;
16043 const char *valid_chars = "a-zA-Z0-9_";
16045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16048 (i, "%U interface %d address %U", unformat_token, valid_chars,
16049 &name, &sw_if_index, unformat_ip4_address, &address))
16050 vec_add1 (name, 0);
16053 errmsg ("parse error '%U'", format_unformat_error, i);
16058 if (!vec_len (name))
16060 errmsg ("profile name must be specified");
16064 if (vec_len (name) > 64)
16066 errmsg ("profile name too long");
16070 M (IKEV2_SET_RESPONDER, mp);
16072 clib_memcpy (mp->name, name, vec_len (name));
16075 mp->sw_if_index = sw_if_index;
16076 clib_memcpy (mp->address, &address, sizeof (address));
16084 api_ikev2_set_ike_transforms (vat_main_t * vam)
16086 unformat_input_t *i = vam->input;
16087 vl_api_ikev2_set_ike_transforms_t *mp;
16090 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16092 const char *valid_chars = "a-zA-Z0-9_";
16094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16096 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16097 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16098 vec_add1 (name, 0);
16101 errmsg ("parse error '%U'", format_unformat_error, i);
16106 if (!vec_len (name))
16108 errmsg ("profile name must be specified");
16112 if (vec_len (name) > 64)
16114 errmsg ("profile name too long");
16118 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16120 clib_memcpy (mp->name, name, vec_len (name));
16122 mp->crypto_alg = crypto_alg;
16123 mp->crypto_key_size = crypto_key_size;
16124 mp->integ_alg = integ_alg;
16125 mp->dh_group = dh_group;
16134 api_ikev2_set_esp_transforms (vat_main_t * vam)
16136 unformat_input_t *i = vam->input;
16137 vl_api_ikev2_set_esp_transforms_t *mp;
16140 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16142 const char *valid_chars = "a-zA-Z0-9_";
16144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16147 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16148 vec_add1 (name, 0);
16151 errmsg ("parse error '%U'", format_unformat_error, i);
16156 if (!vec_len (name))
16158 errmsg ("profile name must be specified");
16162 if (vec_len (name) > 64)
16164 errmsg ("profile name too long");
16168 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16170 clib_memcpy (mp->name, name, vec_len (name));
16172 mp->crypto_alg = crypto_alg;
16173 mp->crypto_key_size = crypto_key_size;
16174 mp->integ_alg = integ_alg;
16175 mp->dh_group = dh_group;
16183 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16185 unformat_input_t *i = vam->input;
16186 vl_api_ikev2_set_sa_lifetime_t *mp;
16189 u64 lifetime, lifetime_maxdata;
16190 u32 lifetime_jitter, handover;
16192 const char *valid_chars = "a-zA-Z0-9_";
16194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16196 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16197 &lifetime, &lifetime_jitter, &handover,
16198 &lifetime_maxdata))
16199 vec_add1 (name, 0);
16202 errmsg ("parse error '%U'", format_unformat_error, i);
16207 if (!vec_len (name))
16209 errmsg ("profile name must be specified");
16213 if (vec_len (name) > 64)
16215 errmsg ("profile name too long");
16219 M (IKEV2_SET_SA_LIFETIME, mp);
16221 clib_memcpy (mp->name, name, vec_len (name));
16223 mp->lifetime = lifetime;
16224 mp->lifetime_jitter = lifetime_jitter;
16225 mp->handover = handover;
16226 mp->lifetime_maxdata = lifetime_maxdata;
16234 api_ikev2_initiate_sa_init (vat_main_t * vam)
16236 unformat_input_t *i = vam->input;
16237 vl_api_ikev2_initiate_sa_init_t *mp;
16241 const char *valid_chars = "a-zA-Z0-9_";
16243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16245 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16246 vec_add1 (name, 0);
16249 errmsg ("parse error '%U'", format_unformat_error, i);
16254 if (!vec_len (name))
16256 errmsg ("profile name must be specified");
16260 if (vec_len (name) > 64)
16262 errmsg ("profile name too long");
16266 M (IKEV2_INITIATE_SA_INIT, mp);
16268 clib_memcpy (mp->name, name, vec_len (name));
16277 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16279 unformat_input_t *i = vam->input;
16280 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16287 if (unformat (i, "%lx", &ispi))
16291 errmsg ("parse error '%U'", format_unformat_error, i);
16296 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16306 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16308 unformat_input_t *i = vam->input;
16309 vl_api_ikev2_initiate_del_child_sa_t *mp;
16314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16316 if (unformat (i, "%x", &ispi))
16320 errmsg ("parse error '%U'", format_unformat_error, i);
16325 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16335 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16337 unformat_input_t *i = vam->input;
16338 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16345 if (unformat (i, "%x", &ispi))
16349 errmsg ("parse error '%U'", format_unformat_error, i);
16354 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16367 api_map_add_domain (vat_main_t * vam)
16369 unformat_input_t *i = vam->input;
16370 vl_api_map_add_domain_t *mp;
16372 ip4_address_t ip4_prefix;
16373 ip6_address_t ip6_prefix;
16374 ip6_address_t ip6_src;
16375 u32 num_m_args = 0;
16376 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16377 0, psid_length = 0;
16378 u8 is_translation = 0;
16380 u32 ip6_src_len = 128;
16383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16385 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16386 &ip4_prefix, &ip4_prefix_len))
16388 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16389 &ip6_prefix, &ip6_prefix_len))
16393 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16396 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16398 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16400 else if (unformat (i, "psid-offset %d", &psid_offset))
16402 else if (unformat (i, "psid-len %d", &psid_length))
16404 else if (unformat (i, "mtu %d", &mtu))
16406 else if (unformat (i, "map-t"))
16407 is_translation = 1;
16410 clib_warning ("parse error '%U'", format_unformat_error, i);
16415 if (num_m_args < 3)
16417 errmsg ("mandatory argument(s) missing");
16421 /* Construct the API message */
16422 M (MAP_ADD_DOMAIN, mp);
16424 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16425 mp->ip4_prefix_len = ip4_prefix_len;
16427 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16428 mp->ip6_prefix_len = ip6_prefix_len;
16430 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16431 mp->ip6_src_prefix_len = ip6_src_len;
16433 mp->ea_bits_len = ea_bits_len;
16434 mp->psid_offset = psid_offset;
16435 mp->psid_length = psid_length;
16436 mp->is_translation = is_translation;
16437 mp->mtu = htons (mtu);
16442 /* Wait for a reply, return good/bad news */
16448 api_map_del_domain (vat_main_t * vam)
16450 unformat_input_t *i = vam->input;
16451 vl_api_map_del_domain_t *mp;
16453 u32 num_m_args = 0;
16457 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16459 if (unformat (i, "index %d", &index))
16463 clib_warning ("parse error '%U'", format_unformat_error, i);
16468 if (num_m_args != 1)
16470 errmsg ("mandatory argument(s) missing");
16474 /* Construct the API message */
16475 M (MAP_DEL_DOMAIN, mp);
16477 mp->index = ntohl (index);
16482 /* Wait for a reply, return good/bad news */
16488 api_map_add_del_rule (vat_main_t * vam)
16490 unformat_input_t *i = vam->input;
16491 vl_api_map_add_del_rule_t *mp;
16493 ip6_address_t ip6_dst;
16494 u32 num_m_args = 0, index, psid = 0;
16497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16499 if (unformat (i, "index %d", &index))
16501 else if (unformat (i, "psid %d", &psid))
16503 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16505 else if (unformat (i, "del"))
16511 clib_warning ("parse error '%U'", format_unformat_error, i);
16516 /* Construct the API message */
16517 M (MAP_ADD_DEL_RULE, mp);
16519 mp->index = ntohl (index);
16520 mp->is_add = is_add;
16521 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16522 mp->psid = ntohs (psid);
16527 /* Wait for a reply, return good/bad news */
16533 api_map_domain_dump (vat_main_t * vam)
16535 vl_api_map_domain_dump_t *mp;
16536 vl_api_control_ping_t *mp_ping;
16539 /* Construct the API message */
16540 M (MAP_DOMAIN_DUMP, mp);
16545 /* Use a control ping for synchronization */
16546 MPING (CONTROL_PING, mp_ping);
16554 api_map_rule_dump (vat_main_t * vam)
16556 unformat_input_t *i = vam->input;
16557 vl_api_map_rule_dump_t *mp;
16558 vl_api_control_ping_t *mp_ping;
16559 u32 domain_index = ~0;
16562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16564 if (unformat (i, "index %u", &domain_index))
16570 if (domain_index == ~0)
16572 clib_warning ("parse error: domain index expected");
16576 /* Construct the API message */
16577 M (MAP_RULE_DUMP, mp);
16579 mp->domain_index = htonl (domain_index);
16584 /* Use a control ping for synchronization */
16585 MPING (CONTROL_PING, mp_ping);
16592 static void vl_api_map_add_domain_reply_t_handler
16593 (vl_api_map_add_domain_reply_t * mp)
16595 vat_main_t *vam = &vat_main;
16596 i32 retval = ntohl (mp->retval);
16598 if (vam->async_mode)
16600 vam->async_errors += (retval < 0);
16604 vam->retval = retval;
16605 vam->result_ready = 1;
16609 static void vl_api_map_add_domain_reply_t_handler_json
16610 (vl_api_map_add_domain_reply_t * mp)
16612 vat_main_t *vam = &vat_main;
16613 vat_json_node_t node;
16615 vat_json_init_object (&node);
16616 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16617 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16619 vat_json_print (vam->ofp, &node);
16620 vat_json_free (&node);
16622 vam->retval = ntohl (mp->retval);
16623 vam->result_ready = 1;
16627 api_get_first_msg_id (vat_main_t * vam)
16629 vl_api_get_first_msg_id_t *mp;
16630 unformat_input_t *i = vam->input;
16635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16637 if (unformat (i, "client %s", &name))
16645 errmsg ("missing client name");
16648 vec_add1 (name, 0);
16650 if (vec_len (name) > 63)
16652 errmsg ("client name too long");
16656 M (GET_FIRST_MSG_ID, mp);
16657 clib_memcpy (mp->name, name, vec_len (name));
16664 api_cop_interface_enable_disable (vat_main_t * vam)
16666 unformat_input_t *line_input = vam->input;
16667 vl_api_cop_interface_enable_disable_t *mp;
16668 u32 sw_if_index = ~0;
16669 u8 enable_disable = 1;
16672 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16674 if (unformat (line_input, "disable"))
16675 enable_disable = 0;
16676 if (unformat (line_input, "enable"))
16677 enable_disable = 1;
16678 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16679 vam, &sw_if_index))
16681 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16687 if (sw_if_index == ~0)
16689 errmsg ("missing interface name or sw_if_index");
16693 /* Construct the API message */
16694 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16695 mp->sw_if_index = ntohl (sw_if_index);
16696 mp->enable_disable = enable_disable;
16700 /* Wait for the reply */
16706 api_cop_whitelist_enable_disable (vat_main_t * vam)
16708 unformat_input_t *line_input = vam->input;
16709 vl_api_cop_whitelist_enable_disable_t *mp;
16710 u32 sw_if_index = ~0;
16711 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16715 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16717 if (unformat (line_input, "ip4"))
16719 else if (unformat (line_input, "ip6"))
16721 else if (unformat (line_input, "default"))
16723 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16724 vam, &sw_if_index))
16726 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16728 else if (unformat (line_input, "fib-id %d", &fib_id))
16734 if (sw_if_index == ~0)
16736 errmsg ("missing interface name or sw_if_index");
16740 /* Construct the API message */
16741 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16742 mp->sw_if_index = ntohl (sw_if_index);
16743 mp->fib_id = ntohl (fib_id);
16746 mp->default_cop = default_cop;
16750 /* Wait for the reply */
16756 api_get_node_graph (vat_main_t * vam)
16758 vl_api_get_node_graph_t *mp;
16761 M (GET_NODE_GRAPH, mp);
16765 /* Wait for the reply */
16771 /** Used for parsing LISP eids */
16772 typedef CLIB_PACKED(struct{
16773 u8 addr[16]; /**< eid address */
16774 u32 len; /**< prefix length if IP */
16775 u8 type; /**< type of eid */
16780 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16782 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16784 memset (a, 0, sizeof (a[0]));
16786 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16788 a->type = 0; /* ipv4 type */
16790 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16792 a->type = 1; /* ipv6 type */
16794 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16796 a->type = 2; /* mac type */
16798 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16800 a->type = 3; /* NSH type */
16801 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16802 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16809 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16818 lisp_eid_size_vat (u8 type)
16835 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16837 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16841 api_one_add_del_locator_set (vat_main_t * vam)
16843 unformat_input_t *input = vam->input;
16844 vl_api_one_add_del_locator_set_t *mp;
16846 u8 *locator_set_name = NULL;
16847 u8 locator_set_name_set = 0;
16848 vl_api_local_locator_t locator, *locators = 0;
16849 u32 sw_if_index, priority, weight;
16853 /* Parse args required to build the message */
16854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16856 if (unformat (input, "del"))
16860 else if (unformat (input, "locator-set %s", &locator_set_name))
16862 locator_set_name_set = 1;
16864 else if (unformat (input, "sw_if_index %u p %u w %u",
16865 &sw_if_index, &priority, &weight))
16867 locator.sw_if_index = htonl (sw_if_index);
16868 locator.priority = priority;
16869 locator.weight = weight;
16870 vec_add1 (locators, locator);
16874 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16875 &sw_if_index, &priority, &weight))
16877 locator.sw_if_index = htonl (sw_if_index);
16878 locator.priority = priority;
16879 locator.weight = weight;
16880 vec_add1 (locators, locator);
16886 if (locator_set_name_set == 0)
16888 errmsg ("missing locator-set name");
16889 vec_free (locators);
16893 if (vec_len (locator_set_name) > 64)
16895 errmsg ("locator-set name too long");
16896 vec_free (locator_set_name);
16897 vec_free (locators);
16900 vec_add1 (locator_set_name, 0);
16902 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16904 /* Construct the API message */
16905 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16907 mp->is_add = is_add;
16908 clib_memcpy (mp->locator_set_name, locator_set_name,
16909 vec_len (locator_set_name));
16910 vec_free (locator_set_name);
16912 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16914 clib_memcpy (mp->locators, locators, data_len);
16915 vec_free (locators);
16920 /* Wait for a reply... */
16925 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16928 api_one_add_del_locator (vat_main_t * vam)
16930 unformat_input_t *input = vam->input;
16931 vl_api_one_add_del_locator_t *mp;
16932 u32 tmp_if_index = ~0;
16933 u32 sw_if_index = ~0;
16934 u8 sw_if_index_set = 0;
16935 u8 sw_if_index_if_name_set = 0;
16937 u8 priority_set = 0;
16941 u8 *locator_set_name = NULL;
16942 u8 locator_set_name_set = 0;
16945 /* Parse args required to build the message */
16946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16948 if (unformat (input, "del"))
16952 else if (unformat (input, "locator-set %s", &locator_set_name))
16954 locator_set_name_set = 1;
16956 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16959 sw_if_index_if_name_set = 1;
16960 sw_if_index = tmp_if_index;
16962 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16964 sw_if_index_set = 1;
16965 sw_if_index = tmp_if_index;
16967 else if (unformat (input, "p %d", &priority))
16971 else if (unformat (input, "w %d", &weight))
16979 if (locator_set_name_set == 0)
16981 errmsg ("missing locator-set name");
16985 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16987 errmsg ("missing sw_if_index");
16988 vec_free (locator_set_name);
16992 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16994 errmsg ("cannot use both params interface name and sw_if_index");
16995 vec_free (locator_set_name);
16999 if (priority_set == 0)
17001 errmsg ("missing locator-set priority");
17002 vec_free (locator_set_name);
17006 if (weight_set == 0)
17008 errmsg ("missing locator-set weight");
17009 vec_free (locator_set_name);
17013 if (vec_len (locator_set_name) > 64)
17015 errmsg ("locator-set name too long");
17016 vec_free (locator_set_name);
17019 vec_add1 (locator_set_name, 0);
17021 /* Construct the API message */
17022 M (ONE_ADD_DEL_LOCATOR, mp);
17024 mp->is_add = is_add;
17025 mp->sw_if_index = ntohl (sw_if_index);
17026 mp->priority = priority;
17027 mp->weight = weight;
17028 clib_memcpy (mp->locator_set_name, locator_set_name,
17029 vec_len (locator_set_name));
17030 vec_free (locator_set_name);
17035 /* Wait for a reply... */
17040 #define api_lisp_add_del_locator api_one_add_del_locator
17043 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17045 u32 *key_id = va_arg (*args, u32 *);
17048 if (unformat (input, "%s", &s))
17050 if (!strcmp ((char *) s, "sha1"))
17051 key_id[0] = HMAC_SHA_1_96;
17052 else if (!strcmp ((char *) s, "sha256"))
17053 key_id[0] = HMAC_SHA_256_128;
17056 clib_warning ("invalid key_id: '%s'", s);
17057 key_id[0] = HMAC_NO_KEY;
17068 api_one_add_del_local_eid (vat_main_t * vam)
17070 unformat_input_t *input = vam->input;
17071 vl_api_one_add_del_local_eid_t *mp;
17074 lisp_eid_vat_t _eid, *eid = &_eid;
17075 u8 *locator_set_name = 0;
17076 u8 locator_set_name_set = 0;
17082 /* Parse args required to build the message */
17083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17085 if (unformat (input, "del"))
17089 else if (unformat (input, "vni %d", &vni))
17093 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17097 else if (unformat (input, "locator-set %s", &locator_set_name))
17099 locator_set_name_set = 1;
17101 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17103 else if (unformat (input, "secret-key %_%v%_", &key))
17109 if (locator_set_name_set == 0)
17111 errmsg ("missing locator-set name");
17117 errmsg ("EID address not set!");
17118 vec_free (locator_set_name);
17122 if (key && (0 == key_id))
17124 errmsg ("invalid key_id!");
17128 if (vec_len (key) > 64)
17130 errmsg ("key too long");
17135 if (vec_len (locator_set_name) > 64)
17137 errmsg ("locator-set name too long");
17138 vec_free (locator_set_name);
17141 vec_add1 (locator_set_name, 0);
17143 /* Construct the API message */
17144 M (ONE_ADD_DEL_LOCAL_EID, mp);
17146 mp->is_add = is_add;
17147 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17148 mp->eid_type = eid->type;
17149 mp->prefix_len = eid->len;
17150 mp->vni = clib_host_to_net_u32 (vni);
17151 mp->key_id = clib_host_to_net_u16 (key_id);
17152 clib_memcpy (mp->locator_set_name, locator_set_name,
17153 vec_len (locator_set_name));
17154 clib_memcpy (mp->key, key, vec_len (key));
17156 vec_free (locator_set_name);
17162 /* Wait for a reply... */
17167 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17170 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17172 u32 dp_table = 0, vni = 0;;
17173 unformat_input_t *input = vam->input;
17174 vl_api_gpe_add_del_fwd_entry_t *mp;
17176 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17177 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17178 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17179 u32 action = ~0, w;
17180 ip4_address_t rmt_rloc4, lcl_rloc4;
17181 ip6_address_t rmt_rloc6, lcl_rloc6;
17182 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17185 memset (&rloc, 0, sizeof (rloc));
17187 /* Parse args required to build the message */
17188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17190 if (unformat (input, "del"))
17192 else if (unformat (input, "add"))
17194 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17198 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17202 else if (unformat (input, "vrf %d", &dp_table))
17204 else if (unformat (input, "bd %d", &dp_table))
17206 else if (unformat (input, "vni %d", &vni))
17208 else if (unformat (input, "w %d", &w))
17212 errmsg ("No RLOC configured for setting priority/weight!");
17215 curr_rloc->weight = w;
17217 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17218 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17222 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17224 vec_add1 (lcl_locs, rloc);
17226 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17227 vec_add1 (rmt_locs, rloc);
17228 /* weight saved in rmt loc */
17229 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17231 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17232 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17235 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17237 vec_add1 (lcl_locs, rloc);
17239 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17240 vec_add1 (rmt_locs, rloc);
17241 /* weight saved in rmt loc */
17242 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17244 else if (unformat (input, "action %d", &action))
17250 clib_warning ("parse error '%U'", format_unformat_error, input);
17257 errmsg ("remote eid addresses not set");
17261 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17263 errmsg ("eid types don't match");
17267 if (0 == rmt_locs && (u32) ~ 0 == action)
17269 errmsg ("action not set for negative mapping");
17273 /* Construct the API message */
17274 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17275 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17277 mp->is_add = is_add;
17278 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17279 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17280 mp->eid_type = rmt_eid->type;
17281 mp->dp_table = clib_host_to_net_u32 (dp_table);
17282 mp->vni = clib_host_to_net_u32 (vni);
17283 mp->rmt_len = rmt_eid->len;
17284 mp->lcl_len = lcl_eid->len;
17285 mp->action = action;
17287 if (0 != rmt_locs && 0 != lcl_locs)
17289 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17290 clib_memcpy (mp->locs, lcl_locs,
17291 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17293 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17294 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17295 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17297 vec_free (lcl_locs);
17298 vec_free (rmt_locs);
17303 /* Wait for a reply... */
17309 api_one_add_del_map_server (vat_main_t * vam)
17311 unformat_input_t *input = vam->input;
17312 vl_api_one_add_del_map_server_t *mp;
17316 ip4_address_t ipv4;
17317 ip6_address_t ipv6;
17320 /* Parse args required to build the message */
17321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17323 if (unformat (input, "del"))
17327 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17331 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17339 if (ipv4_set && ipv6_set)
17341 errmsg ("both eid v4 and v6 addresses set");
17345 if (!ipv4_set && !ipv6_set)
17347 errmsg ("eid addresses not set");
17351 /* Construct the API message */
17352 M (ONE_ADD_DEL_MAP_SERVER, mp);
17354 mp->is_add = is_add;
17358 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17363 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17369 /* Wait for a reply... */
17374 #define api_lisp_add_del_map_server api_one_add_del_map_server
17377 api_one_add_del_map_resolver (vat_main_t * vam)
17379 unformat_input_t *input = vam->input;
17380 vl_api_one_add_del_map_resolver_t *mp;
17384 ip4_address_t ipv4;
17385 ip6_address_t ipv6;
17388 /* Parse args required to build the message */
17389 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17391 if (unformat (input, "del"))
17395 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17399 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17407 if (ipv4_set && ipv6_set)
17409 errmsg ("both eid v4 and v6 addresses set");
17413 if (!ipv4_set && !ipv6_set)
17415 errmsg ("eid addresses not set");
17419 /* Construct the API message */
17420 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17422 mp->is_add = is_add;
17426 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17431 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17437 /* Wait for a reply... */
17442 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17445 api_lisp_gpe_enable_disable (vat_main_t * vam)
17447 unformat_input_t *input = vam->input;
17448 vl_api_gpe_enable_disable_t *mp;
17453 /* Parse args required to build the message */
17454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17456 if (unformat (input, "enable"))
17461 else if (unformat (input, "disable"))
17472 errmsg ("Value not set");
17476 /* Construct the API message */
17477 M (GPE_ENABLE_DISABLE, mp);
17484 /* Wait for a reply... */
17490 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17492 unformat_input_t *input = vam->input;
17493 vl_api_one_rloc_probe_enable_disable_t *mp;
17498 /* Parse args required to build the message */
17499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17501 if (unformat (input, "enable"))
17506 else if (unformat (input, "disable"))
17514 errmsg ("Value not set");
17518 /* Construct the API message */
17519 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17521 mp->is_enabled = is_en;
17526 /* Wait for a reply... */
17531 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17534 api_one_map_register_enable_disable (vat_main_t * vam)
17536 unformat_input_t *input = vam->input;
17537 vl_api_one_map_register_enable_disable_t *mp;
17542 /* Parse args required to build the message */
17543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17545 if (unformat (input, "enable"))
17550 else if (unformat (input, "disable"))
17558 errmsg ("Value not set");
17562 /* Construct the API message */
17563 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17565 mp->is_enabled = is_en;
17570 /* Wait for a reply... */
17575 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17578 api_one_enable_disable (vat_main_t * vam)
17580 unformat_input_t *input = vam->input;
17581 vl_api_one_enable_disable_t *mp;
17586 /* Parse args required to build the message */
17587 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17589 if (unformat (input, "enable"))
17594 else if (unformat (input, "disable"))
17604 errmsg ("Value not set");
17608 /* Construct the API message */
17609 M (ONE_ENABLE_DISABLE, mp);
17616 /* Wait for a reply... */
17621 #define api_lisp_enable_disable api_one_enable_disable
17624 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17626 unformat_input_t *input = vam->input;
17627 vl_api_one_enable_disable_xtr_mode_t *mp;
17632 /* Parse args required to build the message */
17633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17635 if (unformat (input, "enable"))
17640 else if (unformat (input, "disable"))
17650 errmsg ("Value not set");
17654 /* Construct the API message */
17655 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17662 /* Wait for a reply... */
17668 api_one_show_xtr_mode (vat_main_t * vam)
17670 vl_api_one_show_xtr_mode_t *mp;
17673 /* Construct the API message */
17674 M (ONE_SHOW_XTR_MODE, mp);
17679 /* Wait for a reply... */
17685 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17687 unformat_input_t *input = vam->input;
17688 vl_api_one_enable_disable_pitr_mode_t *mp;
17693 /* Parse args required to build the message */
17694 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17696 if (unformat (input, "enable"))
17701 else if (unformat (input, "disable"))
17711 errmsg ("Value not set");
17715 /* Construct the API message */
17716 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17723 /* Wait for a reply... */
17729 api_one_show_pitr_mode (vat_main_t * vam)
17731 vl_api_one_show_pitr_mode_t *mp;
17734 /* Construct the API message */
17735 M (ONE_SHOW_PITR_MODE, mp);
17740 /* Wait for a reply... */
17746 api_one_enable_disable_petr_mode (vat_main_t * vam)
17748 unformat_input_t *input = vam->input;
17749 vl_api_one_enable_disable_petr_mode_t *mp;
17754 /* Parse args required to build the message */
17755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17757 if (unformat (input, "enable"))
17762 else if (unformat (input, "disable"))
17772 errmsg ("Value not set");
17776 /* Construct the API message */
17777 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17784 /* Wait for a reply... */
17790 api_one_show_petr_mode (vat_main_t * vam)
17792 vl_api_one_show_petr_mode_t *mp;
17795 /* Construct the API message */
17796 M (ONE_SHOW_PETR_MODE, mp);
17801 /* Wait for a reply... */
17807 api_show_one_map_register_state (vat_main_t * vam)
17809 vl_api_show_one_map_register_state_t *mp;
17812 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17817 /* wait for reply */
17822 #define api_show_lisp_map_register_state api_show_one_map_register_state
17825 api_show_one_rloc_probe_state (vat_main_t * vam)
17827 vl_api_show_one_rloc_probe_state_t *mp;
17830 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17835 /* wait for reply */
17840 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17843 api_one_add_del_ndp_entry (vat_main_t * vam)
17845 vl_api_one_add_del_ndp_entry_t *mp;
17846 unformat_input_t *input = vam->input;
17851 u8 mac[6] = { 0, };
17852 u8 ip6[16] = { 0, };
17856 /* Parse args required to build the message */
17857 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17859 if (unformat (input, "del"))
17861 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17863 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17865 else if (unformat (input, "bd %d", &bd))
17869 errmsg ("parse error '%U'", format_unformat_error, input);
17874 if (!bd_set || !ip_set || (!mac_set && is_add))
17876 errmsg ("Missing BD, IP or MAC!");
17880 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17881 mp->is_add = is_add;
17882 clib_memcpy (mp->mac, mac, 6);
17883 mp->bd = clib_host_to_net_u32 (bd);
17884 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17889 /* wait for reply */
17895 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17897 vl_api_one_add_del_l2_arp_entry_t *mp;
17898 unformat_input_t *input = vam->input;
17903 u8 mac[6] = { 0, };
17904 u32 ip4 = 0, bd = ~0;
17907 /* Parse args required to build the message */
17908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17910 if (unformat (input, "del"))
17912 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17914 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17916 else if (unformat (input, "bd %d", &bd))
17920 errmsg ("parse error '%U'", format_unformat_error, input);
17925 if (!bd_set || !ip_set || (!mac_set && is_add))
17927 errmsg ("Missing BD, IP or MAC!");
17931 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17932 mp->is_add = is_add;
17933 clib_memcpy (mp->mac, mac, 6);
17934 mp->bd = clib_host_to_net_u32 (bd);
17940 /* wait for reply */
17946 api_one_ndp_bd_get (vat_main_t * vam)
17948 vl_api_one_ndp_bd_get_t *mp;
17951 M (ONE_NDP_BD_GET, mp);
17956 /* wait for reply */
17962 api_one_ndp_entries_get (vat_main_t * vam)
17964 vl_api_one_ndp_entries_get_t *mp;
17965 unformat_input_t *input = vam->input;
17970 /* Parse args required to build the message */
17971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17973 if (unformat (input, "bd %d", &bd))
17977 errmsg ("parse error '%U'", format_unformat_error, input);
17984 errmsg ("Expected bridge domain!");
17988 M (ONE_NDP_ENTRIES_GET, mp);
17989 mp->bd = clib_host_to_net_u32 (bd);
17994 /* wait for reply */
18000 api_one_l2_arp_bd_get (vat_main_t * vam)
18002 vl_api_one_l2_arp_bd_get_t *mp;
18005 M (ONE_L2_ARP_BD_GET, mp);
18010 /* wait for reply */
18016 api_one_l2_arp_entries_get (vat_main_t * vam)
18018 vl_api_one_l2_arp_entries_get_t *mp;
18019 unformat_input_t *input = vam->input;
18024 /* Parse args required to build the message */
18025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18027 if (unformat (input, "bd %d", &bd))
18031 errmsg ("parse error '%U'", format_unformat_error, input);
18038 errmsg ("Expected bridge domain!");
18042 M (ONE_L2_ARP_ENTRIES_GET, mp);
18043 mp->bd = clib_host_to_net_u32 (bd);
18048 /* wait for reply */
18054 api_one_stats_enable_disable (vat_main_t * vam)
18056 vl_api_one_stats_enable_disable_t *mp;
18057 unformat_input_t *input = vam->input;
18062 /* Parse args required to build the message */
18063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18065 if (unformat (input, "enable"))
18070 else if (unformat (input, "disable"))
18080 errmsg ("Value not set");
18084 M (ONE_STATS_ENABLE_DISABLE, mp);
18090 /* wait for reply */
18096 api_show_one_stats_enable_disable (vat_main_t * vam)
18098 vl_api_show_one_stats_enable_disable_t *mp;
18101 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18106 /* wait for reply */
18112 api_show_one_map_request_mode (vat_main_t * vam)
18114 vl_api_show_one_map_request_mode_t *mp;
18117 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18122 /* wait for reply */
18127 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18130 api_one_map_request_mode (vat_main_t * vam)
18132 unformat_input_t *input = vam->input;
18133 vl_api_one_map_request_mode_t *mp;
18137 /* Parse args required to build the message */
18138 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18140 if (unformat (input, "dst-only"))
18142 else if (unformat (input, "src-dst"))
18146 errmsg ("parse error '%U'", format_unformat_error, input);
18151 M (ONE_MAP_REQUEST_MODE, mp);
18158 /* wait for reply */
18163 #define api_lisp_map_request_mode api_one_map_request_mode
18166 * Enable/disable ONE proxy ITR.
18168 * @param vam vpp API test context
18169 * @return return code
18172 api_one_pitr_set_locator_set (vat_main_t * vam)
18174 u8 ls_name_set = 0;
18175 unformat_input_t *input = vam->input;
18176 vl_api_one_pitr_set_locator_set_t *mp;
18181 /* Parse args required to build the message */
18182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18184 if (unformat (input, "del"))
18186 else if (unformat (input, "locator-set %s", &ls_name))
18190 errmsg ("parse error '%U'", format_unformat_error, input);
18197 errmsg ("locator-set name not set!");
18201 M (ONE_PITR_SET_LOCATOR_SET, mp);
18203 mp->is_add = is_add;
18204 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18205 vec_free (ls_name);
18210 /* wait for reply */
18215 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18218 api_one_nsh_set_locator_set (vat_main_t * vam)
18220 u8 ls_name_set = 0;
18221 unformat_input_t *input = vam->input;
18222 vl_api_one_nsh_set_locator_set_t *mp;
18227 /* Parse args required to build the message */
18228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18230 if (unformat (input, "del"))
18232 else if (unformat (input, "ls %s", &ls_name))
18236 errmsg ("parse error '%U'", format_unformat_error, input);
18241 if (!ls_name_set && is_add)
18243 errmsg ("locator-set name not set!");
18247 M (ONE_NSH_SET_LOCATOR_SET, mp);
18249 mp->is_add = is_add;
18250 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18251 vec_free (ls_name);
18256 /* wait for reply */
18262 api_show_one_pitr (vat_main_t * vam)
18264 vl_api_show_one_pitr_t *mp;
18267 if (!vam->json_output)
18269 print (vam->ofp, "%=20s", "lisp status:");
18272 M (SHOW_ONE_PITR, mp);
18276 /* Wait for a reply... */
18281 #define api_show_lisp_pitr api_show_one_pitr
18284 api_one_use_petr (vat_main_t * vam)
18286 unformat_input_t *input = vam->input;
18287 vl_api_one_use_petr_t *mp;
18292 memset (&ip, 0, sizeof (ip));
18294 /* Parse args required to build the message */
18295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18297 if (unformat (input, "disable"))
18300 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18303 ip_addr_version (&ip) = IP4;
18306 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18309 ip_addr_version (&ip) = IP6;
18313 errmsg ("parse error '%U'", format_unformat_error, input);
18318 M (ONE_USE_PETR, mp);
18320 mp->is_add = is_add;
18323 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18325 clib_memcpy (mp->address, &ip, 4);
18327 clib_memcpy (mp->address, &ip, 16);
18333 /* wait for reply */
18338 #define api_lisp_use_petr api_one_use_petr
18341 api_show_one_nsh_mapping (vat_main_t * vam)
18343 vl_api_show_one_use_petr_t *mp;
18346 if (!vam->json_output)
18348 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18351 M (SHOW_ONE_NSH_MAPPING, mp);
18355 /* Wait for a reply... */
18361 api_show_one_use_petr (vat_main_t * vam)
18363 vl_api_show_one_use_petr_t *mp;
18366 if (!vam->json_output)
18368 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18371 M (SHOW_ONE_USE_PETR, mp);
18375 /* Wait for a reply... */
18380 #define api_show_lisp_use_petr api_show_one_use_petr
18383 * Add/delete mapping between vni and vrf
18386 api_one_eid_table_add_del_map (vat_main_t * vam)
18388 unformat_input_t *input = vam->input;
18389 vl_api_one_eid_table_add_del_map_t *mp;
18390 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18391 u32 vni, vrf, bd_index;
18394 /* Parse args required to build the message */
18395 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18397 if (unformat (input, "del"))
18399 else if (unformat (input, "vrf %d", &vrf))
18401 else if (unformat (input, "bd_index %d", &bd_index))
18403 else if (unformat (input, "vni %d", &vni))
18409 if (!vni_set || (!vrf_set && !bd_index_set))
18411 errmsg ("missing arguments!");
18415 if (vrf_set && bd_index_set)
18417 errmsg ("error: both vrf and bd entered!");
18421 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18423 mp->is_add = is_add;
18424 mp->vni = htonl (vni);
18425 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18426 mp->is_l2 = bd_index_set;
18431 /* wait for reply */
18436 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18439 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18441 u32 *action = va_arg (*args, u32 *);
18444 if (unformat (input, "%s", &s))
18446 if (!strcmp ((char *) s, "no-action"))
18448 else if (!strcmp ((char *) s, "natively-forward"))
18450 else if (!strcmp ((char *) s, "send-map-request"))
18452 else if (!strcmp ((char *) s, "drop"))
18456 clib_warning ("invalid action: '%s'", s);
18468 * Add/del remote mapping to/from ONE control plane
18470 * @param vam vpp API test context
18471 * @return return code
18474 api_one_add_del_remote_mapping (vat_main_t * vam)
18476 unformat_input_t *input = vam->input;
18477 vl_api_one_add_del_remote_mapping_t *mp;
18479 lisp_eid_vat_t _eid, *eid = &_eid;
18480 lisp_eid_vat_t _seid, *seid = &_seid;
18481 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18482 u32 action = ~0, p, w, data_len;
18483 ip4_address_t rloc4;
18484 ip6_address_t rloc6;
18485 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18488 memset (&rloc, 0, sizeof (rloc));
18490 /* Parse args required to build the message */
18491 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18493 if (unformat (input, "del-all"))
18497 else if (unformat (input, "del"))
18501 else if (unformat (input, "add"))
18505 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18509 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18513 else if (unformat (input, "vni %d", &vni))
18517 else if (unformat (input, "p %d w %d", &p, &w))
18521 errmsg ("No RLOC configured for setting priority/weight!");
18524 curr_rloc->priority = p;
18525 curr_rloc->weight = w;
18527 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18530 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18531 vec_add1 (rlocs, rloc);
18532 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18534 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18537 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18538 vec_add1 (rlocs, rloc);
18539 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18541 else if (unformat (input, "action %U",
18542 unformat_negative_mapping_action, &action))
18548 clib_warning ("parse error '%U'", format_unformat_error, input);
18555 errmsg ("missing params!");
18559 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18561 errmsg ("no action set for negative map-reply!");
18565 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18567 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18568 mp->is_add = is_add;
18569 mp->vni = htonl (vni);
18570 mp->action = (u8) action;
18571 mp->is_src_dst = seid_set;
18572 mp->eid_len = eid->len;
18573 mp->seid_len = seid->len;
18574 mp->del_all = del_all;
18575 mp->eid_type = eid->type;
18576 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18577 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18579 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18580 clib_memcpy (mp->rlocs, rlocs, data_len);
18586 /* Wait for a reply... */
18591 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18594 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18595 * forwarding entries in data-plane accordingly.
18597 * @param vam vpp API test context
18598 * @return return code
18601 api_one_add_del_adjacency (vat_main_t * vam)
18603 unformat_input_t *input = vam->input;
18604 vl_api_one_add_del_adjacency_t *mp;
18606 ip4_address_t leid4, reid4;
18607 ip6_address_t leid6, reid6;
18608 u8 reid_mac[6] = { 0 };
18609 u8 leid_mac[6] = { 0 };
18610 u8 reid_type, leid_type;
18611 u32 leid_len = 0, reid_len = 0, len;
18615 leid_type = reid_type = (u8) ~ 0;
18617 /* Parse args required to build the message */
18618 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18620 if (unformat (input, "del"))
18624 else if (unformat (input, "add"))
18628 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18631 reid_type = 0; /* ipv4 */
18634 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18637 reid_type = 1; /* ipv6 */
18640 else if (unformat (input, "reid %U", unformat_ethernet_address,
18643 reid_type = 2; /* mac */
18645 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18648 leid_type = 0; /* ipv4 */
18651 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18654 leid_type = 1; /* ipv6 */
18657 else if (unformat (input, "leid %U", unformat_ethernet_address,
18660 leid_type = 2; /* mac */
18662 else if (unformat (input, "vni %d", &vni))
18668 errmsg ("parse error '%U'", format_unformat_error, input);
18673 if ((u8) ~ 0 == reid_type)
18675 errmsg ("missing params!");
18679 if (leid_type != reid_type)
18681 errmsg ("remote and local EIDs are of different types!");
18685 M (ONE_ADD_DEL_ADJACENCY, mp);
18686 mp->is_add = is_add;
18687 mp->vni = htonl (vni);
18688 mp->leid_len = leid_len;
18689 mp->reid_len = reid_len;
18690 mp->eid_type = reid_type;
18692 switch (mp->eid_type)
18695 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18696 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18699 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18700 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18703 clib_memcpy (mp->leid, leid_mac, 6);
18704 clib_memcpy (mp->reid, reid_mac, 6);
18707 errmsg ("unknown EID type %d!", mp->eid_type);
18714 /* Wait for a reply... */
18719 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18722 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18724 u32 *mode = va_arg (*args, u32 *);
18726 if (unformat (input, "lisp"))
18728 else if (unformat (input, "vxlan"))
18737 api_gpe_get_encap_mode (vat_main_t * vam)
18739 vl_api_gpe_get_encap_mode_t *mp;
18742 /* Construct the API message */
18743 M (GPE_GET_ENCAP_MODE, mp);
18748 /* Wait for a reply... */
18754 api_gpe_set_encap_mode (vat_main_t * vam)
18756 unformat_input_t *input = vam->input;
18757 vl_api_gpe_set_encap_mode_t *mp;
18761 /* Parse args required to build the message */
18762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18764 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18770 /* Construct the API message */
18771 M (GPE_SET_ENCAP_MODE, mp);
18778 /* Wait for a reply... */
18784 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18786 unformat_input_t *input = vam->input;
18787 vl_api_gpe_add_del_iface_t *mp;
18788 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18789 u32 dp_table = 0, vni = 0;
18792 /* Parse args required to build the message */
18793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18795 if (unformat (input, "up"))
18800 else if (unformat (input, "down"))
18805 else if (unformat (input, "table_id %d", &dp_table))
18809 else if (unformat (input, "bd_id %d", &dp_table))
18814 else if (unformat (input, "vni %d", &vni))
18822 if (action_set == 0)
18824 errmsg ("Action not set");
18827 if (dp_table_set == 0 || vni_set == 0)
18829 errmsg ("vni and dp_table must be set");
18833 /* Construct the API message */
18834 M (GPE_ADD_DEL_IFACE, mp);
18836 mp->is_add = is_add;
18837 mp->dp_table = clib_host_to_net_u32 (dp_table);
18839 mp->vni = clib_host_to_net_u32 (vni);
18844 /* Wait for a reply... */
18850 api_one_map_register_fallback_threshold (vat_main_t * vam)
18852 unformat_input_t *input = vam->input;
18853 vl_api_one_map_register_fallback_threshold_t *mp;
18858 /* Parse args required to build the message */
18859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18861 if (unformat (input, "%u", &value))
18865 clib_warning ("parse error '%U'", format_unformat_error, input);
18872 errmsg ("fallback threshold value is missing!");
18876 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18877 mp->value = clib_host_to_net_u32 (value);
18882 /* Wait for a reply... */
18888 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18890 vl_api_show_one_map_register_fallback_threshold_t *mp;
18893 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18898 /* Wait for a reply... */
18904 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18906 u32 *proto = va_arg (*args, u32 *);
18908 if (unformat (input, "udp"))
18910 else if (unformat (input, "api"))
18919 api_one_set_transport_protocol (vat_main_t * vam)
18921 unformat_input_t *input = vam->input;
18922 vl_api_one_set_transport_protocol_t *mp;
18927 /* Parse args required to build the message */
18928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18930 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18934 clib_warning ("parse error '%U'", format_unformat_error, input);
18941 errmsg ("Transport protocol missing!");
18945 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18946 mp->protocol = (u8) protocol;
18951 /* Wait for a reply... */
18957 api_one_get_transport_protocol (vat_main_t * vam)
18959 vl_api_one_get_transport_protocol_t *mp;
18962 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18967 /* Wait for a reply... */
18973 api_one_map_register_set_ttl (vat_main_t * vam)
18975 unformat_input_t *input = vam->input;
18976 vl_api_one_map_register_set_ttl_t *mp;
18981 /* Parse args required to build the message */
18982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18984 if (unformat (input, "%u", &ttl))
18988 clib_warning ("parse error '%U'", format_unformat_error, input);
18995 errmsg ("TTL value missing!");
18999 M (ONE_MAP_REGISTER_SET_TTL, mp);
19000 mp->ttl = clib_host_to_net_u32 (ttl);
19005 /* Wait for a reply... */
19011 api_show_one_map_register_ttl (vat_main_t * vam)
19013 vl_api_show_one_map_register_ttl_t *mp;
19016 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19021 /* Wait for a reply... */
19027 * Add/del map request itr rlocs from ONE control plane and updates
19029 * @param vam vpp API test context
19030 * @return return code
19033 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19035 unformat_input_t *input = vam->input;
19036 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19037 u8 *locator_set_name = 0;
19038 u8 locator_set_name_set = 0;
19042 /* Parse args required to build the message */
19043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19045 if (unformat (input, "del"))
19049 else if (unformat (input, "%_%v%_", &locator_set_name))
19051 locator_set_name_set = 1;
19055 clib_warning ("parse error '%U'", format_unformat_error, input);
19060 if (is_add && !locator_set_name_set)
19062 errmsg ("itr-rloc is not set!");
19066 if (is_add && vec_len (locator_set_name) > 64)
19068 errmsg ("itr-rloc locator-set name too long");
19069 vec_free (locator_set_name);
19073 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19074 mp->is_add = is_add;
19077 clib_memcpy (mp->locator_set_name, locator_set_name,
19078 vec_len (locator_set_name));
19082 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19084 vec_free (locator_set_name);
19089 /* Wait for a reply... */
19094 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19097 api_one_locator_dump (vat_main_t * vam)
19099 unformat_input_t *input = vam->input;
19100 vl_api_one_locator_dump_t *mp;
19101 vl_api_control_ping_t *mp_ping;
19102 u8 is_index_set = 0, is_name_set = 0;
19107 /* Parse args required to build the message */
19108 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19110 if (unformat (input, "ls_name %_%v%_", &ls_name))
19114 else if (unformat (input, "ls_index %d", &ls_index))
19120 errmsg ("parse error '%U'", format_unformat_error, input);
19125 if (!is_index_set && !is_name_set)
19127 errmsg ("error: expected one of index or name!");
19131 if (is_index_set && is_name_set)
19133 errmsg ("error: only one param expected!");
19137 if (vec_len (ls_name) > 62)
19139 errmsg ("error: locator set name too long!");
19143 if (!vam->json_output)
19145 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19148 M (ONE_LOCATOR_DUMP, mp);
19149 mp->is_index_set = is_index_set;
19152 mp->ls_index = clib_host_to_net_u32 (ls_index);
19155 vec_add1 (ls_name, 0);
19156 strncpy ((char *) mp->ls_name, (char *) ls_name,
19157 sizeof (mp->ls_name) - 1);
19163 /* Use a control ping for synchronization */
19164 MPING (CONTROL_PING, mp_ping);
19167 /* Wait for a reply... */
19172 #define api_lisp_locator_dump api_one_locator_dump
19175 api_one_locator_set_dump (vat_main_t * vam)
19177 vl_api_one_locator_set_dump_t *mp;
19178 vl_api_control_ping_t *mp_ping;
19179 unformat_input_t *input = vam->input;
19183 /* Parse args required to build the message */
19184 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19186 if (unformat (input, "local"))
19190 else if (unformat (input, "remote"))
19196 errmsg ("parse error '%U'", format_unformat_error, input);
19201 if (!vam->json_output)
19203 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19206 M (ONE_LOCATOR_SET_DUMP, mp);
19208 mp->filter = filter;
19213 /* Use a control ping for synchronization */
19214 MPING (CONTROL_PING, mp_ping);
19217 /* Wait for a reply... */
19222 #define api_lisp_locator_set_dump api_one_locator_set_dump
19225 api_one_eid_table_map_dump (vat_main_t * vam)
19229 unformat_input_t *input = vam->input;
19230 vl_api_one_eid_table_map_dump_t *mp;
19231 vl_api_control_ping_t *mp_ping;
19234 /* Parse args required to build the message */
19235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19237 if (unformat (input, "l2"))
19242 else if (unformat (input, "l3"))
19249 errmsg ("parse error '%U'", format_unformat_error, input);
19256 errmsg ("expected one of 'l2' or 'l3' parameter!");
19260 if (!vam->json_output)
19262 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19265 M (ONE_EID_TABLE_MAP_DUMP, mp);
19271 /* Use a control ping for synchronization */
19272 MPING (CONTROL_PING, mp_ping);
19275 /* Wait for a reply... */
19280 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19283 api_one_eid_table_vni_dump (vat_main_t * vam)
19285 vl_api_one_eid_table_vni_dump_t *mp;
19286 vl_api_control_ping_t *mp_ping;
19289 if (!vam->json_output)
19291 print (vam->ofp, "VNI");
19294 M (ONE_EID_TABLE_VNI_DUMP, mp);
19299 /* Use a control ping for synchronization */
19300 MPING (CONTROL_PING, mp_ping);
19303 /* Wait for a reply... */
19308 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19311 api_one_eid_table_dump (vat_main_t * vam)
19313 unformat_input_t *i = vam->input;
19314 vl_api_one_eid_table_dump_t *mp;
19315 vl_api_control_ping_t *mp_ping;
19316 struct in_addr ip4;
19317 struct in6_addr ip6;
19319 u8 eid_type = ~0, eid_set = 0;
19320 u32 prefix_length = ~0, t, vni = 0;
19323 lisp_nsh_api_t nsh;
19325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19327 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19333 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19339 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19344 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19349 else if (unformat (i, "vni %d", &t))
19353 else if (unformat (i, "local"))
19357 else if (unformat (i, "remote"))
19363 errmsg ("parse error '%U'", format_unformat_error, i);
19368 if (!vam->json_output)
19370 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19371 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19374 M (ONE_EID_TABLE_DUMP, mp);
19376 mp->filter = filter;
19380 mp->vni = htonl (vni);
19381 mp->eid_type = eid_type;
19385 mp->prefix_length = prefix_length;
19386 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19389 mp->prefix_length = prefix_length;
19390 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19393 clib_memcpy (mp->eid, mac, sizeof (mac));
19396 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19399 errmsg ("unknown EID type %d!", eid_type);
19407 /* Use a control ping for synchronization */
19408 MPING (CONTROL_PING, mp_ping);
19411 /* Wait for a reply... */
19416 #define api_lisp_eid_table_dump api_one_eid_table_dump
19419 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19421 unformat_input_t *i = vam->input;
19422 vl_api_gpe_fwd_entries_get_t *mp;
19427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19429 if (unformat (i, "vni %d", &vni))
19435 errmsg ("parse error '%U'", format_unformat_error, i);
19442 errmsg ("vni not set!");
19446 if (!vam->json_output)
19448 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19452 M (GPE_FWD_ENTRIES_GET, mp);
19453 mp->vni = clib_host_to_net_u32 (vni);
19458 /* Wait for a reply... */
19463 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19464 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19465 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19466 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19467 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19468 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19469 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19470 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19473 api_one_adjacencies_get (vat_main_t * vam)
19475 unformat_input_t *i = vam->input;
19476 vl_api_one_adjacencies_get_t *mp;
19481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19483 if (unformat (i, "vni %d", &vni))
19489 errmsg ("parse error '%U'", format_unformat_error, i);
19496 errmsg ("vni not set!");
19500 if (!vam->json_output)
19502 print (vam->ofp, "%s %40s", "leid", "reid");
19505 M (ONE_ADJACENCIES_GET, mp);
19506 mp->vni = clib_host_to_net_u32 (vni);
19511 /* Wait for a reply... */
19516 #define api_lisp_adjacencies_get api_one_adjacencies_get
19519 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19521 unformat_input_t *i = vam->input;
19522 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19524 u8 ip_family_set = 0, is_ip4 = 1;
19526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19528 if (unformat (i, "ip4"))
19533 else if (unformat (i, "ip6"))
19540 errmsg ("parse error '%U'", format_unformat_error, i);
19545 if (!ip_family_set)
19547 errmsg ("ip family not set!");
19551 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19552 mp->is_ip4 = is_ip4;
19557 /* Wait for a reply... */
19563 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19565 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19568 if (!vam->json_output)
19570 print (vam->ofp, "VNIs");
19573 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19578 /* Wait for a reply... */
19584 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19586 unformat_input_t *i = vam->input;
19587 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19589 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19590 struct in_addr ip4;
19591 struct in6_addr ip6;
19592 u32 table_id = 0, nh_sw_if_index = ~0;
19594 memset (&ip4, 0, sizeof (ip4));
19595 memset (&ip6, 0, sizeof (ip6));
19597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19599 if (unformat (i, "del"))
19601 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19602 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19607 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19608 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19613 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19617 nh_sw_if_index = ~0;
19619 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19623 nh_sw_if_index = ~0;
19625 else if (unformat (i, "table %d", &table_id))
19629 errmsg ("parse error '%U'", format_unformat_error, i);
19636 errmsg ("nh addr not set!");
19640 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19641 mp->is_add = is_add;
19642 mp->table_id = clib_host_to_net_u32 (table_id);
19643 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19644 mp->is_ip4 = is_ip4;
19646 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19648 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19653 /* Wait for a reply... */
19659 api_one_map_server_dump (vat_main_t * vam)
19661 vl_api_one_map_server_dump_t *mp;
19662 vl_api_control_ping_t *mp_ping;
19665 if (!vam->json_output)
19667 print (vam->ofp, "%=20s", "Map server");
19670 M (ONE_MAP_SERVER_DUMP, mp);
19674 /* Use a control ping for synchronization */
19675 MPING (CONTROL_PING, mp_ping);
19678 /* Wait for a reply... */
19683 #define api_lisp_map_server_dump api_one_map_server_dump
19686 api_one_map_resolver_dump (vat_main_t * vam)
19688 vl_api_one_map_resolver_dump_t *mp;
19689 vl_api_control_ping_t *mp_ping;
19692 if (!vam->json_output)
19694 print (vam->ofp, "%=20s", "Map resolver");
19697 M (ONE_MAP_RESOLVER_DUMP, mp);
19701 /* Use a control ping for synchronization */
19702 MPING (CONTROL_PING, mp_ping);
19705 /* Wait for a reply... */
19710 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19713 api_one_stats_flush (vat_main_t * vam)
19715 vl_api_one_stats_flush_t *mp;
19718 M (ONE_STATS_FLUSH, mp);
19725 api_one_stats_dump (vat_main_t * vam)
19727 vl_api_one_stats_dump_t *mp;
19728 vl_api_control_ping_t *mp_ping;
19731 M (ONE_STATS_DUMP, mp);
19735 /* Use a control ping for synchronization */
19736 MPING (CONTROL_PING, mp_ping);
19739 /* Wait for a reply... */
19745 api_show_one_status (vat_main_t * vam)
19747 vl_api_show_one_status_t *mp;
19750 if (!vam->json_output)
19752 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19755 M (SHOW_ONE_STATUS, mp);
19758 /* Wait for a reply... */
19763 #define api_show_lisp_status api_show_one_status
19766 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19768 vl_api_gpe_fwd_entry_path_dump_t *mp;
19769 vl_api_control_ping_t *mp_ping;
19770 unformat_input_t *i = vam->input;
19771 u32 fwd_entry_index = ~0;
19774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19776 if (unformat (i, "index %d", &fwd_entry_index))
19782 if (~0 == fwd_entry_index)
19784 errmsg ("no index specified!");
19788 if (!vam->json_output)
19790 print (vam->ofp, "first line");
19793 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19797 /* Use a control ping for synchronization */
19798 MPING (CONTROL_PING, mp_ping);
19801 /* Wait for a reply... */
19807 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19809 vl_api_one_get_map_request_itr_rlocs_t *mp;
19812 if (!vam->json_output)
19814 print (vam->ofp, "%=20s", "itr-rlocs:");
19817 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19820 /* Wait for a reply... */
19825 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19828 api_af_packet_create (vat_main_t * vam)
19830 unformat_input_t *i = vam->input;
19831 vl_api_af_packet_create_t *mp;
19832 u8 *host_if_name = 0;
19834 u8 random_hw_addr = 1;
19837 memset (hw_addr, 0, sizeof (hw_addr));
19839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19841 if (unformat (i, "name %s", &host_if_name))
19842 vec_add1 (host_if_name, 0);
19843 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19844 random_hw_addr = 0;
19849 if (!vec_len (host_if_name))
19851 errmsg ("host-interface name must be specified");
19855 if (vec_len (host_if_name) > 64)
19857 errmsg ("host-interface name too long");
19861 M (AF_PACKET_CREATE, mp);
19863 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19864 clib_memcpy (mp->hw_addr, hw_addr, 6);
19865 mp->use_random_hw_addr = random_hw_addr;
19866 vec_free (host_if_name);
19874 fprintf (vam->ofp ? vam->ofp : stderr,
19875 " new sw_if_index = %d\n", vam->sw_if_index);
19882 api_af_packet_delete (vat_main_t * vam)
19884 unformat_input_t *i = vam->input;
19885 vl_api_af_packet_delete_t *mp;
19886 u8 *host_if_name = 0;
19889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19891 if (unformat (i, "name %s", &host_if_name))
19892 vec_add1 (host_if_name, 0);
19897 if (!vec_len (host_if_name))
19899 errmsg ("host-interface name must be specified");
19903 if (vec_len (host_if_name) > 64)
19905 errmsg ("host-interface name too long");
19909 M (AF_PACKET_DELETE, mp);
19911 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19912 vec_free (host_if_name);
19919 static void vl_api_af_packet_details_t_handler
19920 (vl_api_af_packet_details_t * mp)
19922 vat_main_t *vam = &vat_main;
19924 print (vam->ofp, "%-16s %d",
19925 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19928 static void vl_api_af_packet_details_t_handler_json
19929 (vl_api_af_packet_details_t * mp)
19931 vat_main_t *vam = &vat_main;
19932 vat_json_node_t *node = NULL;
19934 if (VAT_JSON_ARRAY != vam->json_tree.type)
19936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19937 vat_json_init_array (&vam->json_tree);
19939 node = vat_json_array_add (&vam->json_tree);
19941 vat_json_init_object (node);
19942 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19943 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19947 api_af_packet_dump (vat_main_t * vam)
19949 vl_api_af_packet_dump_t *mp;
19950 vl_api_control_ping_t *mp_ping;
19953 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19954 /* Get list of tap interfaces */
19955 M (AF_PACKET_DUMP, mp);
19958 /* Use a control ping for synchronization */
19959 MPING (CONTROL_PING, mp_ping);
19967 api_policer_add_del (vat_main_t * vam)
19969 unformat_input_t *i = vam->input;
19970 vl_api_policer_add_del_t *mp;
19980 u8 color_aware = 0;
19981 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19984 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19985 conform_action.dscp = 0;
19986 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19987 exceed_action.dscp = 0;
19988 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19989 violate_action.dscp = 0;
19991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19993 if (unformat (i, "del"))
19995 else if (unformat (i, "name %s", &name))
19996 vec_add1 (name, 0);
19997 else if (unformat (i, "cir %u", &cir))
19999 else if (unformat (i, "eir %u", &eir))
20001 else if (unformat (i, "cb %u", &cb))
20003 else if (unformat (i, "eb %u", &eb))
20005 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20008 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20011 else if (unformat (i, "type %U", unformat_policer_type, &type))
20013 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20016 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20019 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20022 else if (unformat (i, "color-aware"))
20028 if (!vec_len (name))
20030 errmsg ("policer name must be specified");
20034 if (vec_len (name) > 64)
20036 errmsg ("policer name too long");
20040 M (POLICER_ADD_DEL, mp);
20042 clib_memcpy (mp->name, name, vec_len (name));
20044 mp->is_add = is_add;
20045 mp->cir = ntohl (cir);
20046 mp->eir = ntohl (eir);
20047 mp->cb = clib_net_to_host_u64 (cb);
20048 mp->eb = clib_net_to_host_u64 (eb);
20049 mp->rate_type = rate_type;
20050 mp->round_type = round_type;
20052 mp->conform_action_type = conform_action.action_type;
20053 mp->conform_dscp = conform_action.dscp;
20054 mp->exceed_action_type = exceed_action.action_type;
20055 mp->exceed_dscp = exceed_action.dscp;
20056 mp->violate_action_type = violate_action.action_type;
20057 mp->violate_dscp = violate_action.dscp;
20058 mp->color_aware = color_aware;
20066 api_policer_dump (vat_main_t * vam)
20068 unformat_input_t *i = vam->input;
20069 vl_api_policer_dump_t *mp;
20070 vl_api_control_ping_t *mp_ping;
20071 u8 *match_name = 0;
20072 u8 match_name_valid = 0;
20075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20077 if (unformat (i, "name %s", &match_name))
20079 vec_add1 (match_name, 0);
20080 match_name_valid = 1;
20086 M (POLICER_DUMP, mp);
20087 mp->match_name_valid = match_name_valid;
20088 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20089 vec_free (match_name);
20093 /* Use a control ping for synchronization */
20094 MPING (CONTROL_PING, mp_ping);
20097 /* Wait for a reply... */
20103 api_policer_classify_set_interface (vat_main_t * vam)
20105 unformat_input_t *i = vam->input;
20106 vl_api_policer_classify_set_interface_t *mp;
20108 int sw_if_index_set;
20109 u32 ip4_table_index = ~0;
20110 u32 ip6_table_index = ~0;
20111 u32 l2_table_index = ~0;
20115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20117 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20118 sw_if_index_set = 1;
20119 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20120 sw_if_index_set = 1;
20121 else if (unformat (i, "del"))
20123 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20125 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20127 else if (unformat (i, "l2-table %d", &l2_table_index))
20131 clib_warning ("parse error '%U'", format_unformat_error, i);
20136 if (sw_if_index_set == 0)
20138 errmsg ("missing interface name or sw_if_index");
20142 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20144 mp->sw_if_index = ntohl (sw_if_index);
20145 mp->ip4_table_index = ntohl (ip4_table_index);
20146 mp->ip6_table_index = ntohl (ip6_table_index);
20147 mp->l2_table_index = ntohl (l2_table_index);
20148 mp->is_add = is_add;
20156 api_policer_classify_dump (vat_main_t * vam)
20158 unformat_input_t *i = vam->input;
20159 vl_api_policer_classify_dump_t *mp;
20160 vl_api_control_ping_t *mp_ping;
20161 u8 type = POLICER_CLASSIFY_N_TABLES;
20164 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20168 errmsg ("classify table type must be specified");
20172 if (!vam->json_output)
20174 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20177 M (POLICER_CLASSIFY_DUMP, mp);
20182 /* Use a control ping for synchronization */
20183 MPING (CONTROL_PING, mp_ping);
20186 /* Wait for a reply... */
20192 api_netmap_create (vat_main_t * vam)
20194 unformat_input_t *i = vam->input;
20195 vl_api_netmap_create_t *mp;
20198 u8 random_hw_addr = 1;
20203 memset (hw_addr, 0, sizeof (hw_addr));
20205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20207 if (unformat (i, "name %s", &if_name))
20208 vec_add1 (if_name, 0);
20209 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20210 random_hw_addr = 0;
20211 else if (unformat (i, "pipe"))
20213 else if (unformat (i, "master"))
20215 else if (unformat (i, "slave"))
20221 if (!vec_len (if_name))
20223 errmsg ("interface name must be specified");
20227 if (vec_len (if_name) > 64)
20229 errmsg ("interface name too long");
20233 M (NETMAP_CREATE, mp);
20235 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20236 clib_memcpy (mp->hw_addr, hw_addr, 6);
20237 mp->use_random_hw_addr = random_hw_addr;
20238 mp->is_pipe = is_pipe;
20239 mp->is_master = is_master;
20240 vec_free (if_name);
20248 api_netmap_delete (vat_main_t * vam)
20250 unformat_input_t *i = vam->input;
20251 vl_api_netmap_delete_t *mp;
20255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20257 if (unformat (i, "name %s", &if_name))
20258 vec_add1 (if_name, 0);
20263 if (!vec_len (if_name))
20265 errmsg ("interface name must be specified");
20269 if (vec_len (if_name) > 64)
20271 errmsg ("interface name too long");
20275 M (NETMAP_DELETE, mp);
20277 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20278 vec_free (if_name);
20286 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20288 if (fp->afi == IP46_TYPE_IP6)
20290 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20291 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20292 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20293 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20294 format_ip6_address, fp->next_hop);
20295 else if (fp->afi == IP46_TYPE_IP4)
20297 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20298 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20299 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20300 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20301 format_ip4_address, fp->next_hop);
20305 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20306 vl_api_fib_path_t * fp)
20308 struct in_addr ip4;
20309 struct in6_addr ip6;
20311 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20312 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20313 vat_json_object_add_uint (node, "is_local", fp->is_local);
20314 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20315 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20316 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20317 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20318 if (fp->afi == IP46_TYPE_IP4)
20320 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20321 vat_json_object_add_ip4 (node, "next_hop", ip4);
20323 else if (fp->afi == IP46_TYPE_IP6)
20325 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20326 vat_json_object_add_ip6 (node, "next_hop", ip6);
20331 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20333 vat_main_t *vam = &vat_main;
20334 int count = ntohl (mp->mt_count);
20335 vl_api_fib_path_t *fp;
20338 print (vam->ofp, "[%d]: sw_if_index %d via:",
20339 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20341 for (i = 0; i < count; i++)
20343 vl_api_mpls_fib_path_print (vam, fp);
20347 print (vam->ofp, "");
20350 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20351 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20354 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20356 vat_main_t *vam = &vat_main;
20357 vat_json_node_t *node = NULL;
20358 int count = ntohl (mp->mt_count);
20359 vl_api_fib_path_t *fp;
20362 if (VAT_JSON_ARRAY != vam->json_tree.type)
20364 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20365 vat_json_init_array (&vam->json_tree);
20367 node = vat_json_array_add (&vam->json_tree);
20369 vat_json_init_object (node);
20370 vat_json_object_add_uint (node, "tunnel_index",
20371 ntohl (mp->mt_tunnel_index));
20372 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20374 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20377 for (i = 0; i < count; i++)
20379 vl_api_mpls_fib_path_json_print (node, fp);
20385 api_mpls_tunnel_dump (vat_main_t * vam)
20387 vl_api_mpls_tunnel_dump_t *mp;
20388 vl_api_control_ping_t *mp_ping;
20392 /* Parse args required to build the message */
20393 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20395 if (!unformat (vam->input, "tunnel_index %d", &index))
20402 print (vam->ofp, " tunnel_index %d", index);
20404 M (MPLS_TUNNEL_DUMP, mp);
20405 mp->tunnel_index = htonl (index);
20408 /* Use a control ping for synchronization */
20409 MPING (CONTROL_PING, mp_ping);
20416 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20417 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20421 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20423 vat_main_t *vam = &vat_main;
20424 int count = ntohl (mp->count);
20425 vl_api_fib_path_t *fp;
20429 "table-id %d, label %u, ess_bit %u",
20430 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20432 for (i = 0; i < count; i++)
20434 vl_api_mpls_fib_path_print (vam, fp);
20439 static void vl_api_mpls_fib_details_t_handler_json
20440 (vl_api_mpls_fib_details_t * mp)
20442 vat_main_t *vam = &vat_main;
20443 int count = ntohl (mp->count);
20444 vat_json_node_t *node = NULL;
20445 vl_api_fib_path_t *fp;
20448 if (VAT_JSON_ARRAY != vam->json_tree.type)
20450 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20451 vat_json_init_array (&vam->json_tree);
20453 node = vat_json_array_add (&vam->json_tree);
20455 vat_json_init_object (node);
20456 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20457 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20458 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20459 vat_json_object_add_uint (node, "path_count", count);
20461 for (i = 0; i < count; i++)
20463 vl_api_mpls_fib_path_json_print (node, fp);
20469 api_mpls_fib_dump (vat_main_t * vam)
20471 vl_api_mpls_fib_dump_t *mp;
20472 vl_api_control_ping_t *mp_ping;
20475 M (MPLS_FIB_DUMP, mp);
20478 /* Use a control ping for synchronization */
20479 MPING (CONTROL_PING, mp_ping);
20486 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20487 #define vl_api_ip_fib_details_t_print vl_noop_handler
20490 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20492 vat_main_t *vam = &vat_main;
20493 int count = ntohl (mp->count);
20494 vl_api_fib_path_t *fp;
20498 "table-id %d, prefix %U/%d",
20499 ntohl (mp->table_id), format_ip4_address, mp->address,
20500 mp->address_length);
20502 for (i = 0; i < count; i++)
20504 if (fp->afi == IP46_TYPE_IP6)
20506 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20507 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20508 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20509 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20510 format_ip6_address, fp->next_hop);
20511 else if (fp->afi == IP46_TYPE_IP4)
20513 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20514 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20515 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20516 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20517 format_ip4_address, fp->next_hop);
20522 static void vl_api_ip_fib_details_t_handler_json
20523 (vl_api_ip_fib_details_t * mp)
20525 vat_main_t *vam = &vat_main;
20526 int count = ntohl (mp->count);
20527 vat_json_node_t *node = NULL;
20528 struct in_addr ip4;
20529 struct in6_addr ip6;
20530 vl_api_fib_path_t *fp;
20533 if (VAT_JSON_ARRAY != vam->json_tree.type)
20535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20536 vat_json_init_array (&vam->json_tree);
20538 node = vat_json_array_add (&vam->json_tree);
20540 vat_json_init_object (node);
20541 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20542 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20543 vat_json_object_add_ip4 (node, "prefix", ip4);
20544 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20545 vat_json_object_add_uint (node, "path_count", count);
20547 for (i = 0; i < count; i++)
20549 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20550 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20551 vat_json_object_add_uint (node, "is_local", fp->is_local);
20552 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20553 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20554 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20555 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20556 if (fp->afi == IP46_TYPE_IP4)
20558 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20559 vat_json_object_add_ip4 (node, "next_hop", ip4);
20561 else if (fp->afi == IP46_TYPE_IP6)
20563 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20564 vat_json_object_add_ip6 (node, "next_hop", ip6);
20570 api_ip_fib_dump (vat_main_t * vam)
20572 vl_api_ip_fib_dump_t *mp;
20573 vl_api_control_ping_t *mp_ping;
20576 M (IP_FIB_DUMP, mp);
20579 /* Use a control ping for synchronization */
20580 MPING (CONTROL_PING, mp_ping);
20588 api_ip_mfib_dump (vat_main_t * vam)
20590 vl_api_ip_mfib_dump_t *mp;
20591 vl_api_control_ping_t *mp_ping;
20594 M (IP_MFIB_DUMP, mp);
20597 /* Use a control ping for synchronization */
20598 MPING (CONTROL_PING, mp_ping);
20605 static void vl_api_ip_neighbor_details_t_handler
20606 (vl_api_ip_neighbor_details_t * mp)
20608 vat_main_t *vam = &vat_main;
20610 print (vam->ofp, "%c %U %U",
20611 (mp->is_static) ? 'S' : 'D',
20612 format_ethernet_address, &mp->mac_address,
20613 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20617 static void vl_api_ip_neighbor_details_t_handler_json
20618 (vl_api_ip_neighbor_details_t * mp)
20621 vat_main_t *vam = &vat_main;
20622 vat_json_node_t *node;
20623 struct in_addr ip4;
20624 struct in6_addr ip6;
20626 if (VAT_JSON_ARRAY != vam->json_tree.type)
20628 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20629 vat_json_init_array (&vam->json_tree);
20631 node = vat_json_array_add (&vam->json_tree);
20633 vat_json_init_object (node);
20634 vat_json_object_add_string_copy (node, "flag",
20635 (mp->is_static) ? (u8 *) "static" : (u8 *)
20638 vat_json_object_add_string_copy (node, "link_layer",
20639 format (0, "%U", format_ethernet_address,
20640 &mp->mac_address));
20644 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20645 vat_json_object_add_ip6 (node, "ip_address", ip6);
20649 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20650 vat_json_object_add_ip4 (node, "ip_address", ip4);
20655 api_ip_neighbor_dump (vat_main_t * vam)
20657 unformat_input_t *i = vam->input;
20658 vl_api_ip_neighbor_dump_t *mp;
20659 vl_api_control_ping_t *mp_ping;
20661 u32 sw_if_index = ~0;
20664 /* Parse args required to build the message */
20665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20667 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20669 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20671 else if (unformat (i, "ip6"))
20677 if (sw_if_index == ~0)
20679 errmsg ("missing interface name or sw_if_index");
20683 M (IP_NEIGHBOR_DUMP, mp);
20684 mp->is_ipv6 = (u8) is_ipv6;
20685 mp->sw_if_index = ntohl (sw_if_index);
20688 /* Use a control ping for synchronization */
20689 MPING (CONTROL_PING, mp_ping);
20696 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20697 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20700 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20702 vat_main_t *vam = &vat_main;
20703 int count = ntohl (mp->count);
20704 vl_api_fib_path_t *fp;
20708 "table-id %d, prefix %U/%d",
20709 ntohl (mp->table_id), format_ip6_address, mp->address,
20710 mp->address_length);
20712 for (i = 0; i < count; i++)
20714 if (fp->afi == IP46_TYPE_IP6)
20716 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20717 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20718 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20719 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20720 format_ip6_address, fp->next_hop);
20721 else if (fp->afi == IP46_TYPE_IP4)
20723 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20724 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20725 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20726 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20727 format_ip4_address, fp->next_hop);
20732 static void vl_api_ip6_fib_details_t_handler_json
20733 (vl_api_ip6_fib_details_t * mp)
20735 vat_main_t *vam = &vat_main;
20736 int count = ntohl (mp->count);
20737 vat_json_node_t *node = NULL;
20738 struct in_addr ip4;
20739 struct in6_addr ip6;
20740 vl_api_fib_path_t *fp;
20743 if (VAT_JSON_ARRAY != vam->json_tree.type)
20745 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20746 vat_json_init_array (&vam->json_tree);
20748 node = vat_json_array_add (&vam->json_tree);
20750 vat_json_init_object (node);
20751 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20752 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20753 vat_json_object_add_ip6 (node, "prefix", ip6);
20754 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20755 vat_json_object_add_uint (node, "path_count", count);
20757 for (i = 0; i < count; i++)
20759 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20760 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20761 vat_json_object_add_uint (node, "is_local", fp->is_local);
20762 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20763 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20764 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20765 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20766 if (fp->afi == IP46_TYPE_IP4)
20768 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20769 vat_json_object_add_ip4 (node, "next_hop", ip4);
20771 else if (fp->afi == IP46_TYPE_IP6)
20773 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20774 vat_json_object_add_ip6 (node, "next_hop", ip6);
20780 api_ip6_fib_dump (vat_main_t * vam)
20782 vl_api_ip6_fib_dump_t *mp;
20783 vl_api_control_ping_t *mp_ping;
20786 M (IP6_FIB_DUMP, mp);
20789 /* Use a control ping for synchronization */
20790 MPING (CONTROL_PING, mp_ping);
20798 api_ip6_mfib_dump (vat_main_t * vam)
20800 vl_api_ip6_mfib_dump_t *mp;
20801 vl_api_control_ping_t *mp_ping;
20804 M (IP6_MFIB_DUMP, mp);
20807 /* Use a control ping for synchronization */
20808 MPING (CONTROL_PING, mp_ping);
20816 api_classify_table_ids (vat_main_t * vam)
20818 vl_api_classify_table_ids_t *mp;
20821 /* Construct the API message */
20822 M (CLASSIFY_TABLE_IDS, mp);
20831 api_classify_table_by_interface (vat_main_t * vam)
20833 unformat_input_t *input = vam->input;
20834 vl_api_classify_table_by_interface_t *mp;
20836 u32 sw_if_index = ~0;
20838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20840 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20842 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20847 if (sw_if_index == ~0)
20849 errmsg ("missing interface name or sw_if_index");
20853 /* Construct the API message */
20854 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20856 mp->sw_if_index = ntohl (sw_if_index);
20864 api_classify_table_info (vat_main_t * vam)
20866 unformat_input_t *input = vam->input;
20867 vl_api_classify_table_info_t *mp;
20871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20873 if (unformat (input, "table_id %d", &table_id))
20878 if (table_id == ~0)
20880 errmsg ("missing table id");
20884 /* Construct the API message */
20885 M (CLASSIFY_TABLE_INFO, mp);
20887 mp->table_id = ntohl (table_id);
20895 api_classify_session_dump (vat_main_t * vam)
20897 unformat_input_t *input = vam->input;
20898 vl_api_classify_session_dump_t *mp;
20899 vl_api_control_ping_t *mp_ping;
20903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20905 if (unformat (input, "table_id %d", &table_id))
20910 if (table_id == ~0)
20912 errmsg ("missing table id");
20916 /* Construct the API message */
20917 M (CLASSIFY_SESSION_DUMP, mp);
20919 mp->table_id = ntohl (table_id);
20922 /* Use a control ping for synchronization */
20923 MPING (CONTROL_PING, mp_ping);
20931 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20933 vat_main_t *vam = &vat_main;
20935 print (vam->ofp, "collector_address %U, collector_port %d, "
20936 "src_address %U, vrf_id %d, path_mtu %u, "
20937 "template_interval %u, udp_checksum %d",
20938 format_ip4_address, mp->collector_address,
20939 ntohs (mp->collector_port),
20940 format_ip4_address, mp->src_address,
20941 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20942 ntohl (mp->template_interval), mp->udp_checksum);
20945 vam->result_ready = 1;
20949 vl_api_ipfix_exporter_details_t_handler_json
20950 (vl_api_ipfix_exporter_details_t * mp)
20952 vat_main_t *vam = &vat_main;
20953 vat_json_node_t node;
20954 struct in_addr collector_address;
20955 struct in_addr src_address;
20957 vat_json_init_object (&node);
20958 clib_memcpy (&collector_address, &mp->collector_address,
20959 sizeof (collector_address));
20960 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20961 vat_json_object_add_uint (&node, "collector_port",
20962 ntohs (mp->collector_port));
20963 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20964 vat_json_object_add_ip4 (&node, "src_address", src_address);
20965 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20966 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20967 vat_json_object_add_uint (&node, "template_interval",
20968 ntohl (mp->template_interval));
20969 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20971 vat_json_print (vam->ofp, &node);
20972 vat_json_free (&node);
20974 vam->result_ready = 1;
20978 api_ipfix_exporter_dump (vat_main_t * vam)
20980 vl_api_ipfix_exporter_dump_t *mp;
20983 /* Construct the API message */
20984 M (IPFIX_EXPORTER_DUMP, mp);
20993 api_ipfix_classify_stream_dump (vat_main_t * vam)
20995 vl_api_ipfix_classify_stream_dump_t *mp;
20998 /* Construct the API message */
20999 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21010 vl_api_ipfix_classify_stream_details_t_handler
21011 (vl_api_ipfix_classify_stream_details_t * mp)
21013 vat_main_t *vam = &vat_main;
21014 print (vam->ofp, "domain_id %d, src_port %d",
21015 ntohl (mp->domain_id), ntohs (mp->src_port));
21017 vam->result_ready = 1;
21021 vl_api_ipfix_classify_stream_details_t_handler_json
21022 (vl_api_ipfix_classify_stream_details_t * mp)
21024 vat_main_t *vam = &vat_main;
21025 vat_json_node_t node;
21027 vat_json_init_object (&node);
21028 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21029 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21031 vat_json_print (vam->ofp, &node);
21032 vat_json_free (&node);
21034 vam->result_ready = 1;
21038 api_ipfix_classify_table_dump (vat_main_t * vam)
21040 vl_api_ipfix_classify_table_dump_t *mp;
21041 vl_api_control_ping_t *mp_ping;
21044 if (!vam->json_output)
21046 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21047 "transport_protocol");
21050 /* Construct the API message */
21051 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21056 /* Use a control ping for synchronization */
21057 MPING (CONTROL_PING, mp_ping);
21065 vl_api_ipfix_classify_table_details_t_handler
21066 (vl_api_ipfix_classify_table_details_t * mp)
21068 vat_main_t *vam = &vat_main;
21069 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21070 mp->transport_protocol);
21074 vl_api_ipfix_classify_table_details_t_handler_json
21075 (vl_api_ipfix_classify_table_details_t * mp)
21077 vat_json_node_t *node = NULL;
21078 vat_main_t *vam = &vat_main;
21080 if (VAT_JSON_ARRAY != vam->json_tree.type)
21082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21083 vat_json_init_array (&vam->json_tree);
21086 node = vat_json_array_add (&vam->json_tree);
21087 vat_json_init_object (node);
21089 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21090 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21091 vat_json_object_add_uint (node, "transport_protocol",
21092 mp->transport_protocol);
21096 api_sw_interface_span_enable_disable (vat_main_t * vam)
21098 unformat_input_t *i = vam->input;
21099 vl_api_sw_interface_span_enable_disable_t *mp;
21100 u32 src_sw_if_index = ~0;
21101 u32 dst_sw_if_index = ~0;
21106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21109 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21111 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21115 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21117 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21119 else if (unformat (i, "disable"))
21121 else if (unformat (i, "rx"))
21123 else if (unformat (i, "tx"))
21125 else if (unformat (i, "both"))
21127 else if (unformat (i, "l2"))
21133 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21135 mp->sw_if_index_from = htonl (src_sw_if_index);
21136 mp->sw_if_index_to = htonl (dst_sw_if_index);
21146 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21149 vat_main_t *vam = &vat_main;
21150 u8 *sw_if_from_name = 0;
21151 u8 *sw_if_to_name = 0;
21152 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21153 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21154 char *states[] = { "none", "rx", "tx", "both" };
21158 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21160 if ((u32) p->value[0] == sw_if_index_from)
21162 sw_if_from_name = (u8 *)(p->key);
21166 if ((u32) p->value[0] == sw_if_index_to)
21168 sw_if_to_name = (u8 *)(p->key);
21169 if (sw_if_from_name)
21174 print (vam->ofp, "%20s => %20s (%s) %s",
21175 sw_if_from_name, sw_if_to_name, states[mp->state],
21176 mp->is_l2 ? "l2" : "device");
21180 vl_api_sw_interface_span_details_t_handler_json
21181 (vl_api_sw_interface_span_details_t * mp)
21183 vat_main_t *vam = &vat_main;
21184 vat_json_node_t *node = NULL;
21185 u8 *sw_if_from_name = 0;
21186 u8 *sw_if_to_name = 0;
21187 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21188 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21192 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21194 if ((u32) p->value[0] == sw_if_index_from)
21196 sw_if_from_name = (u8 *)(p->key);
21200 if ((u32) p->value[0] == sw_if_index_to)
21202 sw_if_to_name = (u8 *)(p->key);
21203 if (sw_if_from_name)
21209 if (VAT_JSON_ARRAY != vam->json_tree.type)
21211 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21212 vat_json_init_array (&vam->json_tree);
21214 node = vat_json_array_add (&vam->json_tree);
21216 vat_json_init_object (node);
21217 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21218 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21219 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21220 if (0 != sw_if_to_name)
21222 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21224 vat_json_object_add_uint (node, "state", mp->state);
21225 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21229 api_sw_interface_span_dump (vat_main_t * vam)
21231 unformat_input_t *input = vam->input;
21232 vl_api_sw_interface_span_dump_t *mp;
21233 vl_api_control_ping_t *mp_ping;
21237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21239 if (unformat (input, "l2"))
21245 M (SW_INTERFACE_SPAN_DUMP, mp);
21249 /* Use a control ping for synchronization */
21250 MPING (CONTROL_PING, mp_ping);
21258 api_pg_create_interface (vat_main_t * vam)
21260 unformat_input_t *input = vam->input;
21261 vl_api_pg_create_interface_t *mp;
21265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21267 if (unformat (input, "if_id %d", &if_id))
21274 errmsg ("missing pg interface index");
21278 /* Construct the API message */
21279 M (PG_CREATE_INTERFACE, mp);
21281 mp->interface_id = ntohl (if_id);
21289 api_pg_capture (vat_main_t * vam)
21291 unformat_input_t *input = vam->input;
21292 vl_api_pg_capture_t *mp;
21297 u8 pcap_file_set = 0;
21300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21302 if (unformat (input, "if_id %d", &if_id))
21304 else if (unformat (input, "pcap %s", &pcap_file))
21306 else if (unformat (input, "count %d", &count))
21308 else if (unformat (input, "disable"))
21315 errmsg ("missing pg interface index");
21318 if (pcap_file_set > 0)
21320 if (vec_len (pcap_file) > 255)
21322 errmsg ("pcap file name is too long");
21327 u32 name_len = vec_len (pcap_file);
21328 /* Construct the API message */
21329 M (PG_CAPTURE, mp);
21331 mp->interface_id = ntohl (if_id);
21332 mp->is_enabled = enable;
21333 mp->count = ntohl (count);
21334 mp->pcap_name_length = ntohl (name_len);
21335 if (pcap_file_set != 0)
21337 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21339 vec_free (pcap_file);
21347 api_pg_enable_disable (vat_main_t * vam)
21349 unformat_input_t *input = vam->input;
21350 vl_api_pg_enable_disable_t *mp;
21353 u8 stream_name_set = 0;
21354 u8 *stream_name = 0;
21356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21358 if (unformat (input, "stream %s", &stream_name))
21359 stream_name_set = 1;
21360 else if (unformat (input, "disable"))
21366 if (stream_name_set > 0)
21368 if (vec_len (stream_name) > 255)
21370 errmsg ("stream name too long");
21375 u32 name_len = vec_len (stream_name);
21376 /* Construct the API message */
21377 M (PG_ENABLE_DISABLE, mp);
21379 mp->is_enabled = enable;
21380 if (stream_name_set != 0)
21382 mp->stream_name_length = ntohl (name_len);
21383 clib_memcpy (mp->stream_name, stream_name, name_len);
21385 vec_free (stream_name);
21393 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21395 unformat_input_t *input = vam->input;
21396 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21398 u16 *low_ports = 0;
21399 u16 *high_ports = 0;
21402 ip4_address_t ip4_addr;
21403 ip6_address_t ip6_addr;
21412 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21414 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21420 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21425 else if (unformat (input, "vrf %d", &vrf_id))
21427 else if (unformat (input, "del"))
21429 else if (unformat (input, "port %d", &tmp))
21431 if (tmp == 0 || tmp > 65535)
21433 errmsg ("port %d out of range", tmp);
21437 this_hi = this_low + 1;
21438 vec_add1 (low_ports, this_low);
21439 vec_add1 (high_ports, this_hi);
21441 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21443 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21445 errmsg ("incorrect range parameters");
21449 /* Note: in debug CLI +1 is added to high before
21450 passing to real fn that does "the work"
21451 (ip_source_and_port_range_check_add_del).
21452 This fn is a wrapper around the binary API fn a
21453 control plane will call, which expects this increment
21454 to have occurred. Hence letting the binary API control
21455 plane fn do the increment for consistency between VAT
21456 and other control planes.
21459 vec_add1 (low_ports, this_low);
21460 vec_add1 (high_ports, this_hi);
21466 if (prefix_set == 0)
21468 errmsg ("<address>/<mask> not specified");
21474 errmsg ("VRF ID required, not specified");
21481 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21485 if (vec_len (low_ports) == 0)
21487 errmsg ("At least one port or port range required");
21491 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21493 mp->is_add = is_add;
21498 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21503 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21506 mp->mask_length = length;
21507 mp->number_of_ranges = vec_len (low_ports);
21509 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21510 vec_free (low_ports);
21512 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21513 vec_free (high_ports);
21515 mp->vrf_id = ntohl (vrf_id);
21523 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21525 unformat_input_t *input = vam->input;
21526 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21527 u32 sw_if_index = ~0;
21529 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21530 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21536 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21538 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21540 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21542 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21544 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21546 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21548 else if (unformat (input, "del"))
21554 if (sw_if_index == ~0)
21556 errmsg ("Interface required but not specified");
21562 errmsg ("VRF ID required but not specified");
21566 if (tcp_out_vrf_id == 0
21567 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21570 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21574 /* Construct the API message */
21575 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21577 mp->sw_if_index = ntohl (sw_if_index);
21578 mp->is_add = is_add;
21579 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21580 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21581 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21582 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21587 /* Wait for a reply... */
21593 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21595 unformat_input_t *i = vam->input;
21596 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21597 u32 local_sa_id = 0;
21598 u32 remote_sa_id = 0;
21599 ip4_address_t src_address;
21600 ip4_address_t dst_address;
21604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21606 if (unformat (i, "local_sa %d", &local_sa_id))
21608 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21610 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21612 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21614 else if (unformat (i, "del"))
21618 clib_warning ("parse error '%U'", format_unformat_error, i);
21623 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21625 mp->local_sa_id = ntohl (local_sa_id);
21626 mp->remote_sa_id = ntohl (remote_sa_id);
21627 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21628 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21629 mp->is_add = is_add;
21637 api_punt (vat_main_t * vam)
21639 unformat_input_t *i = vam->input;
21647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21649 if (unformat (i, "ip %d", &ipv))
21651 else if (unformat (i, "protocol %d", &protocol))
21653 else if (unformat (i, "port %d", &port))
21655 else if (unformat (i, "del"))
21659 clib_warning ("parse error '%U'", format_unformat_error, i);
21666 mp->is_add = (u8) is_add;
21667 mp->ipv = (u8) ipv;
21668 mp->l4_protocol = (u8) protocol;
21669 mp->l4_port = htons ((u16) port);
21676 static void vl_api_ipsec_gre_tunnel_details_t_handler
21677 (vl_api_ipsec_gre_tunnel_details_t * mp)
21679 vat_main_t *vam = &vat_main;
21681 print (vam->ofp, "%11d%15U%15U%14d%14d",
21682 ntohl (mp->sw_if_index),
21683 format_ip4_address, &mp->src_address,
21684 format_ip4_address, &mp->dst_address,
21685 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21688 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21689 (vl_api_ipsec_gre_tunnel_details_t * mp)
21691 vat_main_t *vam = &vat_main;
21692 vat_json_node_t *node = NULL;
21693 struct in_addr ip4;
21695 if (VAT_JSON_ARRAY != vam->json_tree.type)
21697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21698 vat_json_init_array (&vam->json_tree);
21700 node = vat_json_array_add (&vam->json_tree);
21702 vat_json_init_object (node);
21703 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21704 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21705 vat_json_object_add_ip4 (node, "src_address", ip4);
21706 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21707 vat_json_object_add_ip4 (node, "dst_address", ip4);
21708 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21709 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21713 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21715 unformat_input_t *i = vam->input;
21716 vl_api_ipsec_gre_tunnel_dump_t *mp;
21717 vl_api_control_ping_t *mp_ping;
21719 u8 sw_if_index_set = 0;
21722 /* Parse args required to build the message */
21723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21725 if (unformat (i, "sw_if_index %d", &sw_if_index))
21726 sw_if_index_set = 1;
21731 if (sw_if_index_set == 0)
21736 if (!vam->json_output)
21738 print (vam->ofp, "%11s%15s%15s%14s%14s",
21739 "sw_if_index", "src_address", "dst_address",
21740 "local_sa_id", "remote_sa_id");
21743 /* Get list of gre-tunnel interfaces */
21744 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21746 mp->sw_if_index = htonl (sw_if_index);
21750 /* Use a control ping for synchronization */
21751 MPING (CONTROL_PING, mp_ping);
21759 api_delete_subif (vat_main_t * vam)
21761 unformat_input_t *i = vam->input;
21762 vl_api_delete_subif_t *mp;
21763 u32 sw_if_index = ~0;
21766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21770 if (unformat (i, "sw_if_index %d", &sw_if_index))
21776 if (sw_if_index == ~0)
21778 errmsg ("missing sw_if_index");
21782 /* Construct the API message */
21783 M (DELETE_SUBIF, mp);
21784 mp->sw_if_index = ntohl (sw_if_index);
21791 #define foreach_pbb_vtr_op \
21792 _("disable", L2_VTR_DISABLED) \
21793 _("pop", L2_VTR_POP_2) \
21794 _("push", L2_VTR_PUSH_2)
21797 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21799 unformat_input_t *i = vam->input;
21800 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21801 u32 sw_if_index = ~0, vtr_op = ~0;
21802 u16 outer_tag = ~0;
21803 u8 dmac[6], smac[6];
21804 u8 dmac_set = 0, smac_set = 0;
21810 /* Shut up coverity */
21811 memset (dmac, 0, sizeof (dmac));
21812 memset (smac, 0, sizeof (smac));
21814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21820 else if (unformat (i, "vtr_op %d", &vtr_op))
21822 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21825 else if (unformat (i, "translate_pbb_stag"))
21827 if (unformat (i, "%d", &tmp))
21829 vtr_op = L2_VTR_TRANSLATE_2_1;
21835 ("translate_pbb_stag operation requires outer tag definition");
21839 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21841 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21843 else if (unformat (i, "sid %d", &sid))
21845 else if (unformat (i, "vlanid %d", &tmp))
21849 clib_warning ("parse error '%U'", format_unformat_error, i);
21854 if ((sw_if_index == ~0) || (vtr_op == ~0))
21856 errmsg ("missing sw_if_index or vtr operation");
21859 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21860 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21863 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21867 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21868 mp->sw_if_index = ntohl (sw_if_index);
21869 mp->vtr_op = ntohl (vtr_op);
21870 mp->outer_tag = ntohs (outer_tag);
21871 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21872 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21873 mp->b_vlanid = ntohs (vlanid);
21874 mp->i_sid = ntohl (sid);
21882 api_flow_classify_set_interface (vat_main_t * vam)
21884 unformat_input_t *i = vam->input;
21885 vl_api_flow_classify_set_interface_t *mp;
21887 int sw_if_index_set;
21888 u32 ip4_table_index = ~0;
21889 u32 ip6_table_index = ~0;
21893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21896 sw_if_index_set = 1;
21897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21898 sw_if_index_set = 1;
21899 else if (unformat (i, "del"))
21901 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21903 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21907 clib_warning ("parse error '%U'", format_unformat_error, i);
21912 if (sw_if_index_set == 0)
21914 errmsg ("missing interface name or sw_if_index");
21918 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21920 mp->sw_if_index = ntohl (sw_if_index);
21921 mp->ip4_table_index = ntohl (ip4_table_index);
21922 mp->ip6_table_index = ntohl (ip6_table_index);
21923 mp->is_add = is_add;
21931 api_flow_classify_dump (vat_main_t * vam)
21933 unformat_input_t *i = vam->input;
21934 vl_api_flow_classify_dump_t *mp;
21935 vl_api_control_ping_t *mp_ping;
21936 u8 type = FLOW_CLASSIFY_N_TABLES;
21939 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21943 errmsg ("classify table type must be specified");
21947 if (!vam->json_output)
21949 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21952 M (FLOW_CLASSIFY_DUMP, mp);
21957 /* Use a control ping for synchronization */
21958 MPING (CONTROL_PING, mp_ping);
21961 /* Wait for a reply... */
21967 api_feature_enable_disable (vat_main_t * vam)
21969 unformat_input_t *i = vam->input;
21970 vl_api_feature_enable_disable_t *mp;
21972 u8 *feature_name = 0;
21973 u32 sw_if_index = ~0;
21977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21979 if (unformat (i, "arc_name %s", &arc_name))
21981 else if (unformat (i, "feature_name %s", &feature_name))
21984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21988 else if (unformat (i, "disable"))
21996 errmsg ("missing arc name");
21999 if (vec_len (arc_name) > 63)
22001 errmsg ("arc name too long");
22004 if (feature_name == 0)
22006 errmsg ("missing feature name");
22009 if (vec_len (feature_name) > 63)
22011 errmsg ("feature name too long");
22014 if (sw_if_index == ~0)
22016 errmsg ("missing interface name or sw_if_index");
22020 /* Construct the API message */
22021 M (FEATURE_ENABLE_DISABLE, mp);
22022 mp->sw_if_index = ntohl (sw_if_index);
22023 mp->enable = enable;
22024 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22025 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22026 vec_free (arc_name);
22027 vec_free (feature_name);
22035 api_sw_interface_tag_add_del (vat_main_t * vam)
22037 unformat_input_t *i = vam->input;
22038 vl_api_sw_interface_tag_add_del_t *mp;
22039 u32 sw_if_index = ~0;
22044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22046 if (unformat (i, "tag %s", &tag))
22048 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22050 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22052 else if (unformat (i, "del"))
22058 if (sw_if_index == ~0)
22060 errmsg ("missing interface name or sw_if_index");
22064 if (enable && (tag == 0))
22066 errmsg ("no tag specified");
22070 /* Construct the API message */
22071 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22072 mp->sw_if_index = ntohl (sw_if_index);
22073 mp->is_add = enable;
22075 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22083 static void vl_api_l2_xconnect_details_t_handler
22084 (vl_api_l2_xconnect_details_t * mp)
22086 vat_main_t *vam = &vat_main;
22088 print (vam->ofp, "%15d%15d",
22089 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22092 static void vl_api_l2_xconnect_details_t_handler_json
22093 (vl_api_l2_xconnect_details_t * mp)
22095 vat_main_t *vam = &vat_main;
22096 vat_json_node_t *node = NULL;
22098 if (VAT_JSON_ARRAY != vam->json_tree.type)
22100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22101 vat_json_init_array (&vam->json_tree);
22103 node = vat_json_array_add (&vam->json_tree);
22105 vat_json_init_object (node);
22106 vat_json_object_add_uint (node, "rx_sw_if_index",
22107 ntohl (mp->rx_sw_if_index));
22108 vat_json_object_add_uint (node, "tx_sw_if_index",
22109 ntohl (mp->tx_sw_if_index));
22113 api_l2_xconnect_dump (vat_main_t * vam)
22115 vl_api_l2_xconnect_dump_t *mp;
22116 vl_api_control_ping_t *mp_ping;
22119 if (!vam->json_output)
22121 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22124 M (L2_XCONNECT_DUMP, mp);
22128 /* Use a control ping for synchronization */
22129 MPING (CONTROL_PING, mp_ping);
22137 api_hw_interface_set_mtu (vat_main_t * vam)
22139 unformat_input_t *i = vam->input;
22140 vl_api_hw_interface_set_mtu_t *mp;
22141 u32 sw_if_index = ~0;
22145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22147 if (unformat (i, "mtu %d", &mtu))
22149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22157 if (sw_if_index == ~0)
22159 errmsg ("missing interface name or sw_if_index");
22165 errmsg ("no mtu specified");
22169 /* Construct the API message */
22170 M (HW_INTERFACE_SET_MTU, mp);
22171 mp->sw_if_index = ntohl (sw_if_index);
22172 mp->mtu = ntohs ((u16) mtu);
22180 api_p2p_ethernet_add (vat_main_t * vam)
22182 unformat_input_t *i = vam->input;
22183 vl_api_p2p_ethernet_add_t *mp;
22184 u32 parent_if_index = ~0;
22190 memset (remote_mac, 0, sizeof (remote_mac));
22191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22193 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22195 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22199 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22201 else if (unformat (i, "sub_id %d", &sub_id))
22205 clib_warning ("parse error '%U'", format_unformat_error, i);
22210 if (parent_if_index == ~0)
22212 errmsg ("missing interface name or sw_if_index");
22217 errmsg ("missing remote mac address");
22222 errmsg ("missing sub-interface id");
22226 M (P2P_ETHERNET_ADD, mp);
22227 mp->parent_if_index = ntohl (parent_if_index);
22228 mp->subif_id = ntohl (sub_id);
22229 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22237 api_p2p_ethernet_del (vat_main_t * vam)
22239 unformat_input_t *i = vam->input;
22240 vl_api_p2p_ethernet_del_t *mp;
22241 u32 parent_if_index = ~0;
22246 memset (remote_mac, 0, sizeof (remote_mac));
22247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22251 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22255 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22259 clib_warning ("parse error '%U'", format_unformat_error, i);
22264 if (parent_if_index == ~0)
22266 errmsg ("missing interface name or sw_if_index");
22271 errmsg ("missing remote mac address");
22275 M (P2P_ETHERNET_DEL, mp);
22276 mp->parent_if_index = ntohl (parent_if_index);
22277 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22285 api_lldp_config (vat_main_t * vam)
22287 unformat_input_t *i = vam->input;
22288 vl_api_lldp_config_t *mp;
22290 int tx_interval = 0;
22291 u8 *sys_name = NULL;
22294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (i, "system-name %s", &sys_name))
22298 else if (unformat (i, "tx-hold %d", &tx_hold))
22300 else if (unformat (i, "tx-interval %d", &tx_interval))
22304 clib_warning ("parse error '%U'", format_unformat_error, i);
22309 vec_add1 (sys_name, 0);
22311 M (LLDP_CONFIG, mp);
22312 mp->tx_hold = htonl (tx_hold);
22313 mp->tx_interval = htonl (tx_interval);
22314 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22315 vec_free (sys_name);
22323 api_sw_interface_set_lldp (vat_main_t * vam)
22325 unformat_input_t *i = vam->input;
22326 vl_api_sw_interface_set_lldp_t *mp;
22327 u32 sw_if_index = ~0;
22329 u8 *port_desc = NULL, *mgmt_oid = NULL;
22330 ip4_address_t ip4_addr;
22331 ip6_address_t ip6_addr;
22334 memset (&ip4_addr, 0, sizeof (ip4_addr));
22335 memset (&ip6_addr, 0, sizeof (ip6_addr));
22337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22339 if (unformat (i, "disable"))
22342 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22344 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22346 else if (unformat (i, "port-desc %s", &port_desc))
22348 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22350 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22352 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22358 if (sw_if_index == ~0)
22360 errmsg ("missing interface name or sw_if_index");
22364 /* Construct the API message */
22365 vec_add1 (port_desc, 0);
22366 vec_add1 (mgmt_oid, 0);
22367 M (SW_INTERFACE_SET_LLDP, mp);
22368 mp->sw_if_index = ntohl (sw_if_index);
22369 mp->enable = enable;
22370 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22371 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22372 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22373 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22374 vec_free (port_desc);
22375 vec_free (mgmt_oid);
22383 api_tcp_configure_src_addresses (vat_main_t * vam)
22385 vl_api_tcp_configure_src_addresses_t *mp;
22386 unformat_input_t *i = vam->input;
22387 ip4_address_t v4first, v4last;
22388 ip6_address_t v6first, v6last;
22393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22395 if (unformat (i, "%U - %U",
22396 unformat_ip4_address, &v4first,
22397 unformat_ip4_address, &v4last))
22401 errmsg ("one range per message (range already set)");
22406 else if (unformat (i, "%U - %U",
22407 unformat_ip6_address, &v6first,
22408 unformat_ip6_address, &v6last))
22412 errmsg ("one range per message (range already set)");
22417 else if (unformat (i, "vrf %d", &vrf_id))
22423 if (range_set == 0)
22425 errmsg ("address range not set");
22429 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22430 mp->vrf_id = ntohl (vrf_id);
22432 if (range_set == 2)
22435 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22436 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22441 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22442 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22449 static void vl_api_app_namespace_add_del_reply_t_handler
22450 (vl_api_app_namespace_add_del_reply_t * mp)
22452 vat_main_t *vam = &vat_main;
22453 i32 retval = ntohl (mp->retval);
22454 if (vam->async_mode)
22456 vam->async_errors += (retval < 0);
22460 vam->retval = retval;
22462 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22463 vam->result_ready = 1;
22467 static void vl_api_app_namespace_add_del_reply_t_handler_json
22468 (vl_api_app_namespace_add_del_reply_t * mp)
22470 vat_main_t *vam = &vat_main;
22471 vat_json_node_t node;
22473 vat_json_init_object (&node);
22474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22475 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22477 vat_json_print (vam->ofp, &node);
22478 vat_json_free (&node);
22480 vam->retval = ntohl (mp->retval);
22481 vam->result_ready = 1;
22485 api_app_namespace_add_del (vat_main_t * vam)
22487 vl_api_app_namespace_add_del_t *mp;
22488 unformat_input_t *i = vam->input;
22489 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22490 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22496 if (unformat (i, "id %_%v%_", &ns_id))
22498 else if (unformat (i, "secret %lu", &secret))
22500 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22501 sw_if_index_set = 1;
22502 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22504 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22509 if (!ns_id || !secret_set || !sw_if_index_set)
22511 errmsg ("namespace id, secret and sw_if_index must be set");
22514 if (vec_len (ns_id) > 64)
22516 errmsg ("namespace id too long");
22519 M (APP_NAMESPACE_ADD_DEL, mp);
22521 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22522 mp->namespace_id_len = vec_len (ns_id);
22523 mp->secret = clib_host_to_net_u64 (secret);
22524 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22525 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22526 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22533 static void vl_api_map_stats_segment_reply_t_handler
22534 (vl_api_map_stats_segment_reply_t * mp)
22536 #if VPP_API_TEST_BUILTIN == 0
22537 vat_main_t *vam = &vat_main;
22538 ssvm_private_t *ssvmp = &vam->stat_segment;
22539 ssvm_shared_header_t *shared_header;
22540 socket_client_main_t *scm = vam->socket_client_main;
22541 int rv = ntohl (mp->retval);
22543 clib_error_t *error;
22549 vam->result_ready = 1;
22554 * Check the socket for the magic fd
22556 error = vl_sock_api_recv_fd_msg (scm->socket_fd, &my_fd, 5);
22559 clib_error_report (error);
22561 vam->result_ready = 1;
22565 memset (ssvmp, 0, sizeof (*ssvmp));
22568 /* Note: this closes memfd.fd */
22569 retval = ssvm_slave_init_memfd (ssvmp);
22572 clib_warning ("WARNING: segment map returned %d", retval);
22574 vam->result_ready = 1;
22578 errmsg ("stat segment mapped OK...");
22580 ASSERT (ssvmp && ssvmp->sh);
22582 /* Pick up the segment lock from the shared memory header */
22583 shared_header = ssvmp->sh;
22584 vam->stat_segment_lockp = (clib_spinlock_t *) (shared_header->opaque[0]);
22586 vam->result_ready = 1;
22590 static void vl_api_map_stats_segment_reply_t_handler_json
22591 (vl_api_map_stats_segment_reply_t * mp)
22593 #if VPP_API_TEST_BUILTIN == 0
22594 vat_main_t *vam = &vat_main;
22595 clib_warning ("not implemented");
22597 vam->result_ready = 1;
22602 api_map_stats_segment (vat_main_t * vam)
22604 #if VPP_API_TEST_BUILTIN == 0
22605 vl_api_map_stats_segment_t *mp;
22608 M (MAP_STATS_SEGMENT, mp);
22614 errmsg ("api unavailable");
22620 api_sock_init_shm (vat_main_t * vam)
22622 #if VPP_API_TEST_BUILTIN == 0
22623 unformat_input_t *i = vam->input;
22624 vl_api_shm_elem_config_t *config = 0;
22625 u64 size = 64 << 20;
22628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22630 if (unformat (i, "size %U", unformat_memory_size, &size))
22637 * Canned custom ring allocator config.
22638 * Should probably parse all of this
22640 vec_validate (config, 6);
22641 config[0].type = VL_API_VLIB_RING;
22642 config[0].size = 256;
22643 config[0].count = 32;
22645 config[1].type = VL_API_VLIB_RING;
22646 config[1].size = 1024;
22647 config[1].count = 16;
22649 config[2].type = VL_API_VLIB_RING;
22650 config[2].size = 4096;
22651 config[2].count = 2;
22653 config[3].type = VL_API_CLIENT_RING;
22654 config[3].size = 256;
22655 config[3].count = 32;
22657 config[4].type = VL_API_CLIENT_RING;
22658 config[4].size = 1024;
22659 config[4].count = 16;
22661 config[5].type = VL_API_CLIENT_RING;
22662 config[5].size = 4096;
22663 config[5].count = 2;
22665 config[6].type = VL_API_QUEUE;
22666 config[6].count = 128;
22667 config[6].size = sizeof (uword);
22669 rv = vl_socket_client_init_shm (config);
22671 vam->client_index_invalid = 1;
22679 api_dns_enable_disable (vat_main_t * vam)
22681 unformat_input_t *line_input = vam->input;
22682 vl_api_dns_enable_disable_t *mp;
22683 u8 enable_disable = 1;
22686 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22688 if (unformat (line_input, "disable"))
22689 enable_disable = 0;
22690 if (unformat (line_input, "enable"))
22691 enable_disable = 1;
22696 /* Construct the API message */
22697 M (DNS_ENABLE_DISABLE, mp);
22698 mp->enable = enable_disable;
22702 /* Wait for the reply */
22708 api_dns_resolve_name (vat_main_t * vam)
22710 unformat_input_t *line_input = vam->input;
22711 vl_api_dns_resolve_name_t *mp;
22715 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22717 if (unformat (line_input, "%s", &name))
22723 if (vec_len (name) > 127)
22725 errmsg ("name too long");
22729 /* Construct the API message */
22730 M (DNS_RESOLVE_NAME, mp);
22731 memcpy (mp->name, name, vec_len (name));
22736 /* Wait for the reply */
22742 api_dns_resolve_ip (vat_main_t * vam)
22744 unformat_input_t *line_input = vam->input;
22745 vl_api_dns_resolve_ip_t *mp;
22747 ip4_address_t addr4;
22748 ip6_address_t addr6;
22751 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22753 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22755 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22763 errmsg ("missing address");
22767 /* Construct the API message */
22768 M (DNS_RESOLVE_IP, mp);
22769 mp->is_ip6 = is_ip6;
22771 memcpy (mp->address, &addr6, sizeof (addr6));
22773 memcpy (mp->address, &addr4, sizeof (addr4));
22777 /* Wait for the reply */
22783 api_dns_name_server_add_del (vat_main_t * vam)
22785 unformat_input_t *i = vam->input;
22786 vl_api_dns_name_server_add_del_t *mp;
22788 ip6_address_t ip6_server;
22789 ip4_address_t ip4_server;
22794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22796 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22798 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22800 else if (unformat (i, "del"))
22804 clib_warning ("parse error '%U'", format_unformat_error, i);
22809 if (ip4_set && ip6_set)
22811 errmsg ("Only one server address allowed per message");
22814 if ((ip4_set + ip6_set) == 0)
22816 errmsg ("Server address required");
22820 /* Construct the API message */
22821 M (DNS_NAME_SERVER_ADD_DEL, mp);
22825 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22830 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22834 mp->is_add = is_add;
22839 /* Wait for a reply, return good/bad news */
22845 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22847 vat_main_t *vam = &vat_main;
22852 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22853 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22854 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22855 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22856 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22857 clib_net_to_host_u32 (mp->action_index), mp->tag);
22862 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22863 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22864 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22865 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22866 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22867 clib_net_to_host_u32 (mp->action_index), mp->tag);
22872 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22875 vat_main_t *vam = &vat_main;
22876 vat_json_node_t *node = NULL;
22877 struct in6_addr ip6;
22878 struct in_addr ip4;
22880 if (VAT_JSON_ARRAY != vam->json_tree.type)
22882 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22883 vat_json_init_array (&vam->json_tree);
22885 node = vat_json_array_add (&vam->json_tree);
22886 vat_json_init_object (node);
22888 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22889 vat_json_object_add_uint (node, "appns_index",
22890 clib_net_to_host_u32 (mp->appns_index));
22891 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22892 vat_json_object_add_uint (node, "scope", mp->scope);
22893 vat_json_object_add_uint (node, "action_index",
22894 clib_net_to_host_u32 (mp->action_index));
22895 vat_json_object_add_uint (node, "lcl_port",
22896 clib_net_to_host_u16 (mp->lcl_port));
22897 vat_json_object_add_uint (node, "rmt_port",
22898 clib_net_to_host_u16 (mp->rmt_port));
22899 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22900 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22901 vat_json_object_add_string_copy (node, "tag", mp->tag);
22904 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22905 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22906 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22907 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22911 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22912 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22913 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22914 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22919 api_session_rule_add_del (vat_main_t * vam)
22921 vl_api_session_rule_add_del_t *mp;
22922 unformat_input_t *i = vam->input;
22923 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22924 u32 appns_index = 0, scope = 0;
22925 ip4_address_t lcl_ip4, rmt_ip4;
22926 ip6_address_t lcl_ip6, rmt_ip6;
22927 u8 is_ip4 = 1, conn_set = 0;
22928 u8 is_add = 1, *tag = 0;
22931 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22933 if (unformat (i, "del"))
22935 else if (unformat (i, "add"))
22937 else if (unformat (i, "proto tcp"))
22939 else if (unformat (i, "proto udp"))
22941 else if (unformat (i, "appns %d", &appns_index))
22943 else if (unformat (i, "scope %d", &scope))
22945 else if (unformat (i, "tag %_%v%_", &tag))
22949 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22950 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22958 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22959 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22965 else if (unformat (i, "action %d", &action))
22970 if (proto == ~0 || !conn_set || action == ~0)
22972 errmsg ("transport proto, connection and action must be set");
22978 errmsg ("scope should be 0-3");
22982 M (SESSION_RULE_ADD_DEL, mp);
22984 mp->is_ip4 = is_ip4;
22985 mp->transport_proto = proto;
22986 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22987 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22988 mp->lcl_plen = lcl_plen;
22989 mp->rmt_plen = rmt_plen;
22990 mp->action_index = clib_host_to_net_u32 (action);
22991 mp->appns_index = clib_host_to_net_u32 (appns_index);
22993 mp->is_add = is_add;
22996 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22997 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
23001 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
23002 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
23006 clib_memcpy (mp->tag, tag, vec_len (tag));
23016 api_session_rules_dump (vat_main_t * vam)
23018 vl_api_session_rules_dump_t *mp;
23019 vl_api_control_ping_t *mp_ping;
23022 if (!vam->json_output)
23024 print (vam->ofp, "%=20s", "Session Rules");
23027 M (SESSION_RULES_DUMP, mp);
23031 /* Use a control ping for synchronization */
23032 MPING (CONTROL_PING, mp_ping);
23035 /* Wait for a reply... */
23041 api_ip_container_proxy_add_del (vat_main_t * vam)
23043 vl_api_ip_container_proxy_add_del_t *mp;
23044 unformat_input_t *i = vam->input;
23045 u32 plen = ~0, sw_if_index = ~0;
23052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23054 if (unformat (i, "del"))
23056 else if (unformat (i, "add"))
23058 if (unformat (i, "%U", unformat_ip4_address, &ip4))
23063 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
23068 else if (unformat (i, "sw_if_index %u", &sw_if_index))
23073 if (sw_if_index == ~0 || plen == ~0)
23075 errmsg ("address and sw_if_index must be set");
23079 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23081 mp->is_ip4 = is_ip4;
23082 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23084 mp->is_add = is_add;
23086 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23088 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23096 api_qos_record_enable_disable (vat_main_t * vam)
23098 unformat_input_t *i = vam->input;
23099 vl_api_qos_record_enable_disable_t *mp;
23100 u32 sw_if_index, qs = 0xff;
23101 u8 sw_if_index_set = 0;
23105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23108 sw_if_index_set = 1;
23109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23110 sw_if_index_set = 1;
23111 else if (unformat (i, "%U", unformat_qos_source, &qs))
23113 else if (unformat (i, "disable"))
23117 clib_warning ("parse error '%U'", format_unformat_error, i);
23122 if (sw_if_index_set == 0)
23124 errmsg ("missing interface name or sw_if_index");
23129 errmsg ("input location must be specified");
23133 M (QOS_RECORD_ENABLE_DISABLE, mp);
23135 mp->sw_if_index = ntohl (sw_if_index);
23136 mp->input_source = qs;
23137 mp->enable = enable;
23146 q_or_quit (vat_main_t * vam)
23148 #if VPP_API_TEST_BUILTIN == 0
23149 longjmp (vam->jump_buf, 1);
23151 return 0; /* not so much */
23155 q (vat_main_t * vam)
23157 return q_or_quit (vam);
23161 quit (vat_main_t * vam)
23163 return q_or_quit (vam);
23167 comment (vat_main_t * vam)
23173 statseg (vat_main_t * vam)
23175 ssvm_private_t *ssvmp = &vam->stat_segment;
23176 ssvm_shared_header_t *shared_header = ssvmp->sh;
23177 vlib_counter_t **counters;
23178 u64 thread0_index1_packets;
23179 u64 thread0_index1_bytes;
23180 f64 vector_rate, input_rate;
23183 uword *counter_vector_by_name;
23184 if (vam->stat_segment_lockp == 0)
23186 errmsg ("Stat segment not mapped...");
23190 /* look up "/if/rx for sw_if_index 1 as a test */
23192 clib_spinlock_lock (vam->stat_segment_lockp);
23194 counter_vector_by_name = (uword *) shared_header->opaque[1];
23196 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23199 clib_spinlock_unlock (vam->stat_segment_lockp);
23200 errmsg ("/if/tx not found?");
23204 /* Fish per-thread vector of combined counters from shared memory */
23205 counters = (vlib_counter_t **) p[0];
23207 if (vec_len (counters[0]) < 2)
23209 clib_spinlock_unlock (vam->stat_segment_lockp);
23210 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23214 /* Read thread 0 sw_if_index 1 counter */
23215 thread0_index1_packets = counters[0][1].packets;
23216 thread0_index1_bytes = counters[0][1].bytes;
23218 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23221 clib_spinlock_unlock (vam->stat_segment_lockp);
23222 errmsg ("vector_rate not found?");
23226 vector_rate = *(f64 *) (p[0]);
23227 p = hash_get_mem (counter_vector_by_name, "input_rate");
23230 clib_spinlock_unlock (vam->stat_segment_lockp);
23231 errmsg ("input_rate not found?");
23234 input_rate = *(f64 *) (p[0]);
23236 clib_spinlock_unlock (vam->stat_segment_lockp);
23238 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23239 vector_rate, input_rate);
23240 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23241 thread0_index1_packets, thread0_index1_bytes);
23247 cmd_cmp (void *a1, void *a2)
23252 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23256 help (vat_main_t * vam)
23261 unformat_input_t *i = vam->input;
23264 if (unformat (i, "%s", &name))
23268 vec_add1 (name, 0);
23270 hs = hash_get_mem (vam->help_by_name, name);
23272 print (vam->ofp, "usage: %s %s", name, hs[0]);
23274 print (vam->ofp, "No such msg / command '%s'", name);
23279 print (vam->ofp, "Help is available for the following:");
23282 hash_foreach_pair (p, vam->function_by_name,
23284 vec_add1 (cmds, (u8 *)(p->key));
23288 vec_sort_with_function (cmds, cmd_cmp);
23290 for (j = 0; j < vec_len (cmds); j++)
23291 print (vam->ofp, "%s", cmds[j]);
23298 set (vat_main_t * vam)
23300 u8 *name = 0, *value = 0;
23301 unformat_input_t *i = vam->input;
23303 if (unformat (i, "%s", &name))
23305 /* The input buffer is a vector, not a string. */
23306 value = vec_dup (i->buffer);
23307 vec_delete (value, i->index, 0);
23308 /* Almost certainly has a trailing newline */
23309 if (value[vec_len (value) - 1] == '\n')
23310 value[vec_len (value) - 1] = 0;
23311 /* Make sure it's a proper string, one way or the other */
23312 vec_add1 (value, 0);
23313 (void) clib_macro_set_value (&vam->macro_main,
23314 (char *) name, (char *) value);
23317 errmsg ("usage: set <name> <value>");
23325 unset (vat_main_t * vam)
23329 if (unformat (vam->input, "%s", &name))
23330 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23331 errmsg ("unset: %s wasn't set", name);
23344 macro_sort_cmp (void *a1, void *a2)
23346 macro_sort_t *s1 = a1;
23347 macro_sort_t *s2 = a2;
23349 return strcmp ((char *) (s1->name), (char *) (s2->name));
23353 dump_macro_table (vat_main_t * vam)
23355 macro_sort_t *sort_me = 0, *sm;
23360 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23362 vec_add2 (sort_me, sm, 1);
23363 sm->name = (u8 *)(p->key);
23364 sm->value = (u8 *) (p->value[0]);
23368 vec_sort_with_function (sort_me, macro_sort_cmp);
23370 if (vec_len (sort_me))
23371 print (vam->ofp, "%-15s%s", "Name", "Value");
23373 print (vam->ofp, "The macro table is empty...");
23375 for (i = 0; i < vec_len (sort_me); i++)
23376 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23381 dump_node_table (vat_main_t * vam)
23384 vlib_node_t *node, *next_node;
23386 if (vec_len (vam->graph_nodes) == 0)
23388 print (vam->ofp, "Node table empty, issue get_node_graph...");
23392 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23394 node = vam->graph_nodes[i];
23395 print (vam->ofp, "[%d] %s", i, node->name);
23396 for (j = 0; j < vec_len (node->next_nodes); j++)
23398 if (node->next_nodes[j] != ~0)
23400 next_node = vam->graph_nodes[node->next_nodes[j]];
23401 print (vam->ofp, " [%d] %s", j, next_node->name);
23409 value_sort_cmp (void *a1, void *a2)
23411 name_sort_t *n1 = a1;
23412 name_sort_t *n2 = a2;
23414 if (n1->value < n2->value)
23416 if (n1->value > n2->value)
23423 dump_msg_api_table (vat_main_t * vam)
23425 api_main_t *am = &api_main;
23426 name_sort_t *nses = 0, *ns;
23431 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23433 vec_add2 (nses, ns, 1);
23434 ns->name = (u8 *)(hp->key);
23435 ns->value = (u32) hp->value[0];
23439 vec_sort_with_function (nses, value_sort_cmp);
23441 for (i = 0; i < vec_len (nses); i++)
23442 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23448 get_msg_id (vat_main_t * vam)
23453 if (unformat (vam->input, "%s", &name_and_crc))
23455 message_index = vl_msg_api_get_msg_index (name_and_crc);
23456 if (message_index == ~0)
23458 print (vam->ofp, " '%s' not found", name_and_crc);
23461 print (vam->ofp, " '%s' has message index %d",
23462 name_and_crc, message_index);
23465 errmsg ("name_and_crc required...");
23470 search_node_table (vat_main_t * vam)
23472 unformat_input_t *line_input = vam->input;
23475 vlib_node_t *node, *next_node;
23478 if (vam->graph_node_index_by_name == 0)
23480 print (vam->ofp, "Node table empty, issue get_node_graph...");
23484 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23486 if (unformat (line_input, "%s", &node_to_find))
23488 vec_add1 (node_to_find, 0);
23489 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23492 print (vam->ofp, "%s not found...", node_to_find);
23495 node = vam->graph_nodes[p[0]];
23496 print (vam->ofp, "[%d] %s", p[0], node->name);
23497 for (j = 0; j < vec_len (node->next_nodes); j++)
23499 if (node->next_nodes[j] != ~0)
23501 next_node = vam->graph_nodes[node->next_nodes[j]];
23502 print (vam->ofp, " [%d] %s", j, next_node->name);
23509 clib_warning ("parse error '%U'", format_unformat_error,
23515 vec_free (node_to_find);
23524 script (vat_main_t * vam)
23526 #if (VPP_API_TEST_BUILTIN==0)
23528 char *save_current_file;
23529 unformat_input_t save_input;
23530 jmp_buf save_jump_buf;
23531 u32 save_line_number;
23533 FILE *new_fp, *save_ifp;
23535 if (unformat (vam->input, "%s", &s))
23537 new_fp = fopen ((char *) s, "r");
23540 errmsg ("Couldn't open script file %s", s);
23547 errmsg ("Missing script name");
23551 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23552 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23553 save_ifp = vam->ifp;
23554 save_line_number = vam->input_line_number;
23555 save_current_file = (char *) vam->current_file;
23557 vam->input_line_number = 0;
23559 vam->current_file = s;
23562 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23563 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23564 vam->ifp = save_ifp;
23565 vam->input_line_number = save_line_number;
23566 vam->current_file = (u8 *) save_current_file;
23571 clib_warning ("use the exec command...");
23577 echo (vat_main_t * vam)
23579 print (vam->ofp, "%v", vam->input->buffer);
23583 /* List of API message constructors, CLI names map to api_xxx */
23584 #define foreach_vpe_api_msg \
23585 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23586 _(sw_interface_dump,"") \
23587 _(sw_interface_set_flags, \
23588 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23589 _(sw_interface_add_del_address, \
23590 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23591 _(sw_interface_set_rx_mode, \
23592 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23593 _(sw_interface_set_table, \
23594 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23595 _(sw_interface_set_mpls_enable, \
23596 "<intfc> | sw_if_index [disable | dis]") \
23597 _(sw_interface_set_vpath, \
23598 "<intfc> | sw_if_index <id> enable | disable") \
23599 _(sw_interface_set_vxlan_bypass, \
23600 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23601 _(sw_interface_set_geneve_bypass, \
23602 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23603 _(sw_interface_set_l2_xconnect, \
23604 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23605 "enable | disable") \
23606 _(sw_interface_set_l2_bridge, \
23607 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23608 "[shg <split-horizon-group>] [bvi]\n" \
23609 "enable | disable") \
23610 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23611 _(bridge_domain_add_del, \
23612 "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") \
23613 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23615 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23616 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23617 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23619 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23621 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23623 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23625 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23627 "<vpp-if-name> | sw_if_index <id>") \
23628 _(sw_interface_tap_dump, "") \
23630 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23632 "<vpp-if-name> | sw_if_index <id>") \
23633 _(sw_interface_tap_v2_dump, "") \
23635 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23636 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23638 "<vpp-if-name> | sw_if_index <id>") \
23640 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23641 _(bond_detach_slave, \
23642 "sw_if_index <n>") \
23643 _(sw_interface_bond_dump, "") \
23644 _(sw_interface_slave_dump, \
23645 "<vpp-if-name> | sw_if_index <id>") \
23646 _(ip_table_add_del, \
23647 "table-id <n> [ipv6]\n") \
23648 _(ip_add_del_route, \
23649 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23650 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23651 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23652 "[multipath] [count <n>]") \
23653 _(ip_mroute_add_del, \
23654 "<src> <grp>/<mask> [table-id <n>]\n" \
23655 "[<intfc> | sw_if_index <id>] [local] [del]") \
23656 _(mpls_table_add_del, \
23657 "table-id <n>\n") \
23658 _(mpls_route_add_del, \
23659 "<label> <eos> via <addr> [table-id <n>]\n" \
23660 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23661 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23662 "[multipath] [count <n>]") \
23663 _(mpls_ip_bind_unbind, \
23664 "<label> <addr/len>") \
23665 _(mpls_tunnel_add_del, \
23666 " via <addr> [table-id <n>]\n" \
23667 "sw_if_index <id>] [l2] [del]") \
23668 _(bier_table_add_del, \
23669 "<label> <sub-domain> <set> <bsl> [del]") \
23670 _(bier_route_add_del, \
23671 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23672 "[<intfc> | sw_if_index <id>]" \
23673 "[weight <n>] [del] [multipath]") \
23674 _(proxy_arp_add_del, \
23675 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23676 _(proxy_arp_intfc_enable_disable, \
23677 "<intfc> | sw_if_index <id> enable | disable") \
23678 _(sw_interface_set_unnumbered, \
23679 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23680 _(ip_neighbor_add_del, \
23681 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23682 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23683 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23684 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23685 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23686 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23687 "[outer_vlan_id_any][inner_vlan_id_any]") \
23688 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23689 _(reset_fib, "vrf <n> [ipv6]") \
23690 _(dhcp_proxy_config, \
23691 "svr <v46-address> src <v46-address>\n" \
23692 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23693 _(dhcp_proxy_set_vss, \
23694 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23695 _(dhcp_proxy_dump, "ip6") \
23696 _(dhcp_client_config, \
23697 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23698 _(set_ip_flow_hash, \
23699 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23700 _(sw_interface_ip6_enable_disable, \
23701 "<intfc> | sw_if_index <id> enable | disable") \
23702 _(sw_interface_ip6_set_link_local_address, \
23703 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23704 _(ip6nd_proxy_add_del, \
23705 "<intfc> | sw_if_index <id> <ip6-address>") \
23706 _(ip6nd_proxy_dump, "") \
23707 _(sw_interface_ip6nd_ra_prefix, \
23708 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23709 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23710 "[nolink] [isno]") \
23711 _(sw_interface_ip6nd_ra_config, \
23712 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23713 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23714 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23715 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23716 _(l2_patch_add_del, \
23717 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23718 "enable | disable") \
23719 _(sr_localsid_add_del, \
23720 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23721 "fib-table <num> (end.psp) sw_if_index <num>") \
23722 _(classify_add_del_table, \
23723 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23724 " [del] [del-chain] mask <mask-value>\n" \
23725 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23726 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23727 _(classify_add_del_session, \
23728 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23729 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23730 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23731 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23732 _(classify_set_interface_ip_table, \
23733 "<intfc> | sw_if_index <nn> table <nn>") \
23734 _(classify_set_interface_l2_tables, \
23735 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23736 " [other-table <nn>]") \
23737 _(get_node_index, "node <node-name") \
23738 _(add_node_next, "node <node-name> next <next-node-name>") \
23739 _(l2tpv3_create_tunnel, \
23740 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23741 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23742 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23743 _(l2tpv3_set_tunnel_cookies, \
23744 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23745 "[new_remote_cookie <nn>]\n") \
23746 _(l2tpv3_interface_enable_disable, \
23747 "<intfc> | sw_if_index <nn> enable | disable") \
23748 _(l2tpv3_set_lookup_key, \
23749 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23750 _(sw_if_l2tpv3_tunnel_dump, "") \
23751 _(vxlan_offload_rx, \
23752 "hw { <interface name> | hw_if_index <nn>} " \
23753 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23754 _(vxlan_add_del_tunnel, \
23755 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23756 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23757 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23758 _(geneve_add_del_tunnel, \
23759 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23760 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23761 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23762 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23763 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23764 _(gre_add_del_tunnel, \
23765 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23766 "[teb | erspan <session-id>] [del]") \
23767 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23768 _(l2_fib_clear_table, "") \
23769 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23770 _(l2_interface_vlan_tag_rewrite, \
23771 "<intfc> | sw_if_index <nn> \n" \
23772 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23773 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23774 _(create_vhost_user_if, \
23775 "socket <filename> [server] [renumber <dev_instance>] " \
23776 "[mac <mac_address>]") \
23777 _(modify_vhost_user_if, \
23778 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23779 "[server] [renumber <dev_instance>]") \
23780 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23781 _(sw_interface_vhost_user_dump, "") \
23782 _(show_version, "") \
23783 _(vxlan_gpe_add_del_tunnel, \
23784 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23785 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23786 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23787 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23788 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23789 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23790 _(interface_name_renumber, \
23791 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23792 _(input_acl_set_interface, \
23793 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23794 " [l2-table <nn>] [del]") \
23795 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23796 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23797 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23798 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23799 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23800 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23801 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23802 _(ip_dump, "ipv4 | ipv6") \
23803 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23804 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23806 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23807 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23808 " integ_alg <alg> integ_key <hex>") \
23809 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23810 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23811 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23812 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23813 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23814 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23815 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23816 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23817 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23818 " [instance <n>]") \
23819 _(ipsec_sa_dump, "[sa_id <n>]") \
23820 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23821 " <alg> <hex>\n") \
23822 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23823 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23824 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23825 "(auth_data 0x<data> | auth_data <data>)") \
23826 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23827 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23828 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23829 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23830 "(local|remote)") \
23831 _(ikev2_set_local_key, "file <absolute_file_path>") \
23832 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23833 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23834 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23835 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23836 _(ikev2_initiate_sa_init, "<profile_name>") \
23837 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23838 _(ikev2_initiate_del_child_sa, "<ispi>") \
23839 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23840 _(delete_loopback,"sw_if_index <nn>") \
23841 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23842 _(map_add_domain, \
23843 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23844 "ip6-src <ip6addr> " \
23845 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23846 _(map_del_domain, "index <n>") \
23847 _(map_add_del_rule, \
23848 "index <n> psid <n> dst <ip6addr> [del]") \
23849 _(map_domain_dump, "") \
23850 _(map_rule_dump, "index <map-domain>") \
23851 _(want_interface_events, "enable|disable") \
23852 _(want_stats,"enable|disable") \
23853 _(get_first_msg_id, "client <name>") \
23854 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23855 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23856 "fib-id <nn> [ip4][ip6][default]") \
23857 _(get_node_graph, " ") \
23858 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23859 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23860 _(ioam_disable, "") \
23861 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23862 " sw_if_index <sw_if_index> p <priority> " \
23863 "w <weight>] [del]") \
23864 _(one_add_del_locator, "locator-set <locator_name> " \
23865 "iface <intf> | sw_if_index <sw_if_index> " \
23866 "p <priority> w <weight> [del]") \
23867 _(one_add_del_local_eid,"vni <vni> eid " \
23868 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23869 "locator-set <locator_name> [del]" \
23870 "[key-id sha1|sha256 secret-key <secret-key>]")\
23871 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23872 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23873 _(one_enable_disable, "enable|disable") \
23874 _(one_map_register_enable_disable, "enable|disable") \
23875 _(one_map_register_fallback_threshold, "<value>") \
23876 _(one_rloc_probe_enable_disable, "enable|disable") \
23877 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23879 "rloc <locator> p <prio> " \
23880 "w <weight> [rloc <loc> ... ] " \
23881 "action <action> [del-all]") \
23882 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23884 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23885 _(one_use_petr, "ip-address> | disable") \
23886 _(one_map_request_mode, "src-dst|dst-only") \
23887 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23888 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23889 _(one_locator_set_dump, "[local | remote]") \
23890 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23891 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23892 "[local] | [remote]") \
23893 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23894 _(one_ndp_bd_get, "") \
23895 _(one_ndp_entries_get, "bd <bridge-domain>") \
23896 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23897 _(one_l2_arp_bd_get, "") \
23898 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23899 _(one_stats_enable_disable, "enable|disalbe") \
23900 _(show_one_stats_enable_disable, "") \
23901 _(one_eid_table_vni_dump, "") \
23902 _(one_eid_table_map_dump, "l2|l3") \
23903 _(one_map_resolver_dump, "") \
23904 _(one_map_server_dump, "") \
23905 _(one_adjacencies_get, "vni <vni>") \
23906 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23907 _(show_one_rloc_probe_state, "") \
23908 _(show_one_map_register_state, "") \
23909 _(show_one_status, "") \
23910 _(one_stats_dump, "") \
23911 _(one_stats_flush, "") \
23912 _(one_get_map_request_itr_rlocs, "") \
23913 _(one_map_register_set_ttl, "<ttl>") \
23914 _(one_set_transport_protocol, "udp|api") \
23915 _(one_get_transport_protocol, "") \
23916 _(one_enable_disable_xtr_mode, "enable|disable") \
23917 _(one_show_xtr_mode, "") \
23918 _(one_enable_disable_pitr_mode, "enable|disable") \
23919 _(one_show_pitr_mode, "") \
23920 _(one_enable_disable_petr_mode, "enable|disable") \
23921 _(one_show_petr_mode, "") \
23922 _(show_one_nsh_mapping, "") \
23923 _(show_one_pitr, "") \
23924 _(show_one_use_petr, "") \
23925 _(show_one_map_request_mode, "") \
23926 _(show_one_map_register_ttl, "") \
23927 _(show_one_map_register_fallback_threshold, "") \
23928 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23929 " sw_if_index <sw_if_index> p <priority> " \
23930 "w <weight>] [del]") \
23931 _(lisp_add_del_locator, "locator-set <locator_name> " \
23932 "iface <intf> | sw_if_index <sw_if_index> " \
23933 "p <priority> w <weight> [del]") \
23934 _(lisp_add_del_local_eid,"vni <vni> eid " \
23935 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23936 "locator-set <locator_name> [del]" \
23937 "[key-id sha1|sha256 secret-key <secret-key>]") \
23938 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23939 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23940 _(lisp_enable_disable, "enable|disable") \
23941 _(lisp_map_register_enable_disable, "enable|disable") \
23942 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23943 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23945 "rloc <locator> p <prio> " \
23946 "w <weight> [rloc <loc> ... ] " \
23947 "action <action> [del-all]") \
23948 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23950 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23951 _(lisp_use_petr, "<ip-address> | disable") \
23952 _(lisp_map_request_mode, "src-dst|dst-only") \
23953 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23954 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23955 _(lisp_locator_set_dump, "[local | remote]") \
23956 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23957 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23958 "[local] | [remote]") \
23959 _(lisp_eid_table_vni_dump, "") \
23960 _(lisp_eid_table_map_dump, "l2|l3") \
23961 _(lisp_map_resolver_dump, "") \
23962 _(lisp_map_server_dump, "") \
23963 _(lisp_adjacencies_get, "vni <vni>") \
23964 _(gpe_fwd_entry_vnis_get, "") \
23965 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23966 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23967 "[table <table-id>]") \
23968 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23969 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23970 _(gpe_set_encap_mode, "lisp|vxlan") \
23971 _(gpe_get_encap_mode, "") \
23972 _(lisp_gpe_add_del_iface, "up|down") \
23973 _(lisp_gpe_enable_disable, "enable|disable") \
23974 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23975 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23976 _(show_lisp_rloc_probe_state, "") \
23977 _(show_lisp_map_register_state, "") \
23978 _(show_lisp_status, "") \
23979 _(lisp_get_map_request_itr_rlocs, "") \
23980 _(show_lisp_pitr, "") \
23981 _(show_lisp_use_petr, "") \
23982 _(show_lisp_map_request_mode, "") \
23983 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23984 _(af_packet_delete, "name <host interface name>") \
23985 _(af_packet_dump, "") \
23986 _(policer_add_del, "name <policer name> <params> [del]") \
23987 _(policer_dump, "[name <policer name>]") \
23988 _(policer_classify_set_interface, \
23989 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23990 " [l2-table <nn>] [del]") \
23991 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23992 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23993 "[master|slave]") \
23994 _(netmap_delete, "name <interface name>") \
23995 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23996 _(mpls_fib_dump, "") \
23997 _(classify_table_ids, "") \
23998 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23999 _(classify_table_info, "table_id <nn>") \
24000 _(classify_session_dump, "table_id <nn>") \
24001 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
24002 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
24003 "[template_interval <nn>] [udp_checksum]") \
24004 _(ipfix_exporter_dump, "") \
24005 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
24006 _(ipfix_classify_stream_dump, "") \
24007 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
24008 _(ipfix_classify_table_dump, "") \
24009 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
24010 _(sw_interface_span_dump, "[l2]") \
24011 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
24012 _(pg_create_interface, "if_id <nn>") \
24013 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
24014 _(pg_enable_disable, "[stream <id>] disable") \
24015 _(ip_source_and_port_range_check_add_del, \
24016 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
24017 _(ip_source_and_port_range_check_interface_add_del, \
24018 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
24019 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
24020 _(ipsec_gre_add_del_tunnel, \
24021 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
24022 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
24023 _(delete_subif,"<intfc> | sw_if_index <nn>") \
24024 _(l2_interface_pbb_tag_rewrite, \
24025 "<intfc> | sw_if_index <nn> \n" \
24026 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
24027 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
24028 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
24029 _(flow_classify_set_interface, \
24030 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
24031 _(flow_classify_dump, "type [ip4|ip6]") \
24032 _(ip_fib_dump, "") \
24033 _(ip_mfib_dump, "") \
24034 _(ip6_fib_dump, "") \
24035 _(ip6_mfib_dump, "") \
24036 _(feature_enable_disable, "arc_name <arc_name> " \
24037 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
24038 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
24040 _(l2_xconnect_dump, "") \
24041 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
24042 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
24043 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
24044 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
24045 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
24046 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
24047 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
24048 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
24049 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
24050 _(sock_init_shm, "size <nnn>") \
24051 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
24052 _(dns_enable_disable, "[enable][disable]") \
24053 _(dns_name_server_add_del, "<ip-address> [del]") \
24054 _(dns_resolve_name, "<hostname>") \
24055 _(dns_resolve_ip, "<ip4|ip6>") \
24056 _(dns_name_server_add_del, "<ip-address> [del]") \
24057 _(dns_resolve_name, "<hostname>") \
24058 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
24059 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
24060 _(session_rules_dump, "") \
24061 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
24062 _(output_acl_set_interface, \
24063 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
24064 " [l2-table <nn>] [del]") \
24065 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]") \
24066 _(map_stats_segment, "<no-args>")
24068 /* List of command functions, CLI names map directly to functions */
24069 #define foreach_cli_function \
24070 _(comment, "usage: comment <ignore-rest-of-line>") \
24071 _(dump_interface_table, "usage: dump_interface_table") \
24072 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
24073 _(dump_ipv4_table, "usage: dump_ipv4_table") \
24074 _(dump_ipv6_table, "usage: dump_ipv6_table") \
24075 _(dump_stats_table, "usage: dump_stats_table") \
24076 _(dump_macro_table, "usage: dump_macro_table ") \
24077 _(dump_node_table, "usage: dump_node_table") \
24078 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24079 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24080 _(echo, "usage: echo <message>") \
24081 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24082 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24083 _(help, "usage: help") \
24084 _(q, "usage: quit") \
24085 _(quit, "usage: quit") \
24086 _(search_node_table, "usage: search_node_table <name>...") \
24087 _(set, "usage: set <variable-name> <value>") \
24088 _(script, "usage: script <file-name>") \
24089 _(statseg, "usage: statseg"); \
24090 _(unset, "usage: unset <variable-name>")
24093 static void vl_api_##n##_t_handler_uni \
24094 (vl_api_##n##_t * mp) \
24096 vat_main_t * vam = &vat_main; \
24097 if (vam->json_output) { \
24098 vl_api_##n##_t_handler_json(mp); \
24100 vl_api_##n##_t_handler(mp); \
24103 foreach_vpe_api_reply_msg;
24104 #if VPP_API_TEST_BUILTIN == 0
24105 foreach_standalone_reply_msg;
24110 vat_api_hookup (vat_main_t * vam)
24113 vl_msg_api_set_handlers(VL_API_##N, #n, \
24114 vl_api_##n##_t_handler_uni, \
24116 vl_api_##n##_t_endian, \
24117 vl_api_##n##_t_print, \
24118 sizeof(vl_api_##n##_t), 1);
24119 foreach_vpe_api_reply_msg;
24120 #if VPP_API_TEST_BUILTIN == 0
24121 foreach_standalone_reply_msg;
24125 #if (VPP_API_TEST_BUILTIN==0)
24126 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24128 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24130 vam->function_by_name = hash_create_string (0, sizeof (uword));
24132 vam->help_by_name = hash_create_string (0, sizeof (uword));
24135 /* API messages we can send */
24136 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24137 foreach_vpe_api_msg;
24141 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24142 foreach_vpe_api_msg;
24145 /* CLI functions */
24146 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24147 foreach_cli_function;
24151 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24152 foreach_cli_function;
24156 #if VPP_API_TEST_BUILTIN
24157 static clib_error_t *
24158 vat_api_hookup_shim (vlib_main_t * vm)
24160 vat_api_hookup (&vat_main);
24164 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24168 * fd.io coding-style-patch-verification: ON
24171 * eval: (c-set-style "gnu")