2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vppinfra/socket.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/ip/ip_neighbor.h>
26 #include <vnet/l2/l2_input.h>
27 #include <vnet/l2tp/l2tp.h>
28 #include <vnet/vxlan/vxlan.h>
29 #include <vnet/geneve/geneve.h>
30 #include <vnet/gre/gre.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/lisp-gpe/lisp_gpe.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
42 #include <vnet/ipsec/ikev2.h>
44 #include <vnet/map/map.h>
45 #include <vnet/cop/cop.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/dhcp/dhcp_proxy.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include "vat/json_format.h"
61 #define vl_typedefs /* define message structures */
62 #include <vpp/api/vpe_all_api_h.h>
65 /* declare message handlers for each api */
67 #define vl_endianfun /* define message structures */
68 #include <vpp/api/vpe_all_api_h.h>
71 /* instantiate all the print functions we know about */
72 #define vl_print(handle, ...)
74 #include <vpp/api/vpe_all_api_h.h>
77 #define __plugin_msg_base 0
78 #include <vlibapi/vat_helper_macros.h>
80 #if VPP_API_TEST_BUILTIN == 0
90 vat_socket_connect (vat_main_t * vam)
92 vam->socket_client_main = &socket_client_main;
93 return vl_socket_client_connect ((char *) vam->socket_name, "vpp_api_test",
94 0 /* default socket rx, tx buffer */ );
96 #else /* vpp built-in case, we don't do sockets... */
98 vat_socket_connect (vat_main_t * vam)
104 vl_socket_client_read (int wait)
110 vl_socket_client_write ()
116 vl_socket_client_msg_alloc (int nbytes)
124 vat_time_now (vat_main_t * vam)
126 #if VPP_API_TEST_BUILTIN
127 return vlib_time_now (vam->vlib_main);
129 return clib_time_now (&vam->clib_time);
134 errmsg (char *fmt, ...)
136 vat_main_t *vam = &vat_main;
141 s = va_format (0, fmt, &va);
146 #if VPP_API_TEST_BUILTIN
147 vlib_cli_output (vam->vlib_main, (char *) s);
150 if (vam->ifp != stdin)
151 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
152 vam->input_line_number);
153 fformat (vam->ofp, (char *) s);
161 #if VPP_API_TEST_BUILTIN == 0
163 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
165 vat_main_t *vam = va_arg (*args, vat_main_t *);
166 u32 *result = va_arg (*args, u32 *);
170 if (!unformat (input, "%s", &if_name))
173 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
181 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
186 /* Parse an IP4 address %d.%d.%d.%d. */
188 unformat_ip4_address (unformat_input_t * input, va_list * args)
190 u8 *result = va_arg (*args, u8 *);
193 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
196 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
208 unformat_ethernet_address (unformat_input_t * input, va_list * args)
210 u8 *result = va_arg (*args, u8 *);
213 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
214 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
218 for (i = 0; i < 6; i++)
219 if (a[i] >= (1 << 8))
222 for (i = 0; i < 6; i++)
228 /* Returns ethernet type as an int in host byte order. */
230 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
233 u16 *result = va_arg (*args, u16 *);
237 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
239 if (type >= (1 << 16))
247 /* Parse an IP6 address. */
249 unformat_ip6_address (unformat_input_t * input, va_list * args)
251 ip6_address_t *result = va_arg (*args, ip6_address_t *);
253 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
254 uword c, n_colon, double_colon_index;
256 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
257 double_colon_index = ARRAY_LEN (hex_quads);
258 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
261 if (c >= '0' && c <= '9')
263 else if (c >= 'a' && c <= 'f')
264 hex_digit = c + 10 - 'a';
265 else if (c >= 'A' && c <= 'F')
266 hex_digit = c + 10 - 'A';
267 else if (c == ':' && n_colon < 2)
271 unformat_put_input (input);
275 /* Too many hex quads. */
276 if (n_hex_quads >= ARRAY_LEN (hex_quads))
281 hex_quad = (hex_quad << 4) | hex_digit;
283 /* Hex quad must fit in 16 bits. */
284 if (n_hex_digits >= 4)
291 /* Save position of :: */
294 /* More than one :: ? */
295 if (double_colon_index < ARRAY_LEN (hex_quads))
297 double_colon_index = n_hex_quads;
300 if (n_colon > 0 && n_hex_digits > 0)
302 hex_quads[n_hex_quads++] = hex_quad;
308 if (n_hex_digits > 0)
309 hex_quads[n_hex_quads++] = hex_quad;
314 /* Expand :: to appropriate number of zero hex quads. */
315 if (double_colon_index < ARRAY_LEN (hex_quads))
317 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
319 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
320 hex_quads[n_zero + i] = hex_quads[i];
322 for (i = 0; i < n_zero; i++)
323 hex_quads[double_colon_index + i] = 0;
325 n_hex_quads = ARRAY_LEN (hex_quads);
328 /* Too few hex quads given. */
329 if (n_hex_quads < ARRAY_LEN (hex_quads))
332 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
333 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
340 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
342 u32 *r = va_arg (*args, u32 *);
345 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
346 foreach_ipsec_policy_action
354 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
356 u32 *r = va_arg (*args, u32 *);
359 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
360 foreach_ipsec_crypto_alg
368 format_ipsec_crypto_alg (u8 * s, va_list * args)
370 u32 i = va_arg (*args, u32);
375 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
376 foreach_ipsec_crypto_alg
379 return format (s, "unknown");
381 return format (s, "%s", t);
385 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
387 u32 *r = va_arg (*args, u32 *);
390 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
391 foreach_ipsec_integ_alg
399 format_ipsec_integ_alg (u8 * s, va_list * args)
401 u32 i = va_arg (*args, u32);
406 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
407 foreach_ipsec_integ_alg
410 return format (s, "unknown");
412 return format (s, "%s", t);
416 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
418 u32 *r = va_arg (*args, u32 *);
421 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
422 foreach_ikev2_auth_method
430 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
432 u32 *r = va_arg (*args, u32 *);
435 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
436 foreach_ikev2_id_type
442 #else /* VPP_API_TEST_BUILTIN == 1 */
444 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
446 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
447 vnet_main_t *vnm = vnet_get_main ();
448 u32 *result = va_arg (*args, u32 *);
450 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
454 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
456 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
457 vnet_main_t *vnm = vnet_get_main ();
458 u32 *result = va_arg (*args, u32 *);
460 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
463 #endif /* VPP_API_TEST_BUILTIN */
466 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
468 u8 *r = va_arg (*args, u8 *);
470 if (unformat (input, "kbps"))
471 *r = SSE2_QOS_RATE_KBPS;
472 else if (unformat (input, "pps"))
473 *r = SSE2_QOS_RATE_PPS;
480 unformat_policer_round_type (unformat_input_t * input, va_list * args)
482 u8 *r = va_arg (*args, u8 *);
484 if (unformat (input, "closest"))
485 *r = SSE2_QOS_ROUND_TO_CLOSEST;
486 else if (unformat (input, "up"))
487 *r = SSE2_QOS_ROUND_TO_UP;
488 else if (unformat (input, "down"))
489 *r = SSE2_QOS_ROUND_TO_DOWN;
496 unformat_policer_type (unformat_input_t * input, va_list * args)
498 u8 *r = va_arg (*args, u8 *);
500 if (unformat (input, "1r2c"))
501 *r = SSE2_QOS_POLICER_TYPE_1R2C;
502 else if (unformat (input, "1r3c"))
503 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
504 else if (unformat (input, "2r3c-2698"))
505 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
506 else if (unformat (input, "2r3c-4115"))
507 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
508 else if (unformat (input, "2r3c-mef5cf1"))
509 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
516 unformat_dscp (unformat_input_t * input, va_list * va)
518 u8 *r = va_arg (*va, u8 *);
521 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
530 unformat_policer_action_type (unformat_input_t * input, va_list * va)
532 sse2_qos_pol_action_params_st *a
533 = va_arg (*va, sse2_qos_pol_action_params_st *);
535 if (unformat (input, "drop"))
536 a->action_type = SSE2_QOS_ACTION_DROP;
537 else if (unformat (input, "transmit"))
538 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
539 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
540 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
547 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
549 u32 *r = va_arg (*va, u32 *);
552 if (unformat (input, "ip4"))
553 tid = POLICER_CLASSIFY_TABLE_IP4;
554 else if (unformat (input, "ip6"))
555 tid = POLICER_CLASSIFY_TABLE_IP6;
556 else if (unformat (input, "l2"))
557 tid = POLICER_CLASSIFY_TABLE_L2;
566 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
568 u32 *r = va_arg (*va, u32 *);
571 if (unformat (input, "ip4"))
572 tid = FLOW_CLASSIFY_TABLE_IP4;
573 else if (unformat (input, "ip6"))
574 tid = FLOW_CLASSIFY_TABLE_IP6;
582 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
583 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
584 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
585 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
587 #if (VPP_API_TEST_BUILTIN==0)
589 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
591 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
592 mfib_itf_attribute_t attr;
595 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
597 if (unformat (input, mfib_itf_flag_long_names[attr]))
598 *iflags |= (1 << attr);
600 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
602 if (unformat (input, mfib_itf_flag_names[attr]))
603 *iflags |= (1 << attr);
606 return (old == *iflags ? 0 : 1);
610 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
612 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
613 mfib_entry_attribute_t attr;
616 FOR_EACH_MFIB_ATTRIBUTE (attr)
618 if (unformat (input, mfib_flag_long_names[attr]))
619 *eflags |= (1 << attr);
621 FOR_EACH_MFIB_ATTRIBUTE (attr)
623 if (unformat (input, mfib_flag_names[attr]))
624 *eflags |= (1 << attr);
627 return (old == *eflags ? 0 : 1);
631 format_ip4_address (u8 * s, va_list * args)
633 u8 *a = va_arg (*args, u8 *);
634 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
638 format_ip6_address (u8 * s, va_list * args)
640 ip6_address_t *a = va_arg (*args, ip6_address_t *);
641 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
643 i_max_n_zero = ARRAY_LEN (a->as_u16);
645 i_first_zero = i_max_n_zero;
647 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
649 u32 is_zero = a->as_u16[i] == 0;
650 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
656 if ((!is_zero && n_zeros > max_n_zeros)
657 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
659 i_max_n_zero = i_first_zero;
660 max_n_zeros = n_zeros;
661 i_first_zero = ARRAY_LEN (a->as_u16);
666 last_double_colon = 0;
667 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
669 if (i == i_max_n_zero && max_n_zeros > 1)
671 s = format (s, "::");
672 i += max_n_zeros - 1;
673 last_double_colon = 1;
677 s = format (s, "%s%x",
678 (last_double_colon || i == 0) ? "" : ":",
679 clib_net_to_host_u16 (a->as_u16[i]));
680 last_double_colon = 0;
687 /* Format an IP46 address. */
689 format_ip46_address (u8 * s, va_list * args)
691 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
692 ip46_type_t type = va_arg (*args, ip46_type_t);
698 is_ip4 = ip46_address_is_ip4 (ip46);
709 format (s, "%U", format_ip4_address, &ip46->ip4) :
710 format (s, "%U", format_ip6_address, &ip46->ip6);
714 format_ethernet_address (u8 * s, va_list * args)
716 u8 *a = va_arg (*args, u8 *);
718 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
719 a[0], a[1], a[2], a[3], a[4], a[5]);
724 increment_v4_address (ip4_address_t * a)
728 v = ntohl (a->as_u32) + 1;
729 a->as_u32 = ntohl (v);
733 increment_v6_address (ip6_address_t * a)
737 v0 = clib_net_to_host_u64 (a->as_u64[0]);
738 v1 = clib_net_to_host_u64 (a->as_u64[1]);
743 a->as_u64[0] = clib_net_to_host_u64 (v0);
744 a->as_u64[1] = clib_net_to_host_u64 (v1);
748 increment_mac_address (u8 * mac)
750 u64 tmp = *((u64 *) mac);
751 tmp = clib_net_to_host_u64 (tmp);
752 tmp += 1 << 16; /* skip unused (least significant) octets */
753 tmp = clib_host_to_net_u64 (tmp);
755 clib_memcpy (mac, &tmp, 6);
758 static void vl_api_create_loopback_reply_t_handler
759 (vl_api_create_loopback_reply_t * mp)
761 vat_main_t *vam = &vat_main;
762 i32 retval = ntohl (mp->retval);
764 vam->retval = retval;
765 vam->regenerate_interface_table = 1;
766 vam->sw_if_index = ntohl (mp->sw_if_index);
767 vam->result_ready = 1;
770 static void vl_api_create_loopback_reply_t_handler_json
771 (vl_api_create_loopback_reply_t * mp)
773 vat_main_t *vam = &vat_main;
774 vat_json_node_t node;
776 vat_json_init_object (&node);
777 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
778 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
780 vat_json_print (vam->ofp, &node);
781 vat_json_free (&node);
782 vam->retval = ntohl (mp->retval);
783 vam->result_ready = 1;
786 static void vl_api_create_loopback_instance_reply_t_handler
787 (vl_api_create_loopback_instance_reply_t * mp)
789 vat_main_t *vam = &vat_main;
790 i32 retval = ntohl (mp->retval);
792 vam->retval = retval;
793 vam->regenerate_interface_table = 1;
794 vam->sw_if_index = ntohl (mp->sw_if_index);
795 vam->result_ready = 1;
798 static void vl_api_create_loopback_instance_reply_t_handler_json
799 (vl_api_create_loopback_instance_reply_t * mp)
801 vat_main_t *vam = &vat_main;
802 vat_json_node_t node;
804 vat_json_init_object (&node);
805 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
806 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
808 vat_json_print (vam->ofp, &node);
809 vat_json_free (&node);
810 vam->retval = ntohl (mp->retval);
811 vam->result_ready = 1;
814 static void vl_api_af_packet_create_reply_t_handler
815 (vl_api_af_packet_create_reply_t * mp)
817 vat_main_t *vam = &vat_main;
818 i32 retval = ntohl (mp->retval);
820 vam->retval = retval;
821 vam->regenerate_interface_table = 1;
822 vam->sw_if_index = ntohl (mp->sw_if_index);
823 vam->result_ready = 1;
826 static void vl_api_af_packet_create_reply_t_handler_json
827 (vl_api_af_packet_create_reply_t * mp)
829 vat_main_t *vam = &vat_main;
830 vat_json_node_t node;
832 vat_json_init_object (&node);
833 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
834 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
836 vat_json_print (vam->ofp, &node);
837 vat_json_free (&node);
839 vam->retval = ntohl (mp->retval);
840 vam->result_ready = 1;
843 static void vl_api_create_vlan_subif_reply_t_handler
844 (vl_api_create_vlan_subif_reply_t * mp)
846 vat_main_t *vam = &vat_main;
847 i32 retval = ntohl (mp->retval);
849 vam->retval = retval;
850 vam->regenerate_interface_table = 1;
851 vam->sw_if_index = ntohl (mp->sw_if_index);
852 vam->result_ready = 1;
855 static void vl_api_create_vlan_subif_reply_t_handler_json
856 (vl_api_create_vlan_subif_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 vat_json_node_t node;
861 vat_json_init_object (&node);
862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
863 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
865 vat_json_print (vam->ofp, &node);
866 vat_json_free (&node);
868 vam->retval = ntohl (mp->retval);
869 vam->result_ready = 1;
872 static void vl_api_create_subif_reply_t_handler
873 (vl_api_create_subif_reply_t * mp)
875 vat_main_t *vam = &vat_main;
876 i32 retval = ntohl (mp->retval);
878 vam->retval = retval;
879 vam->regenerate_interface_table = 1;
880 vam->sw_if_index = ntohl (mp->sw_if_index);
881 vam->result_ready = 1;
884 static void vl_api_create_subif_reply_t_handler_json
885 (vl_api_create_subif_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 vat_json_node_t node;
890 vat_json_init_object (&node);
891 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
892 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
901 static void vl_api_interface_name_renumber_reply_t_handler
902 (vl_api_interface_name_renumber_reply_t * mp)
904 vat_main_t *vam = &vat_main;
905 i32 retval = ntohl (mp->retval);
907 vam->retval = retval;
908 vam->regenerate_interface_table = 1;
909 vam->result_ready = 1;
912 static void vl_api_interface_name_renumber_reply_t_handler_json
913 (vl_api_interface_name_renumber_reply_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t node;
918 vat_json_init_object (&node);
919 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
921 vat_json_print (vam->ofp, &node);
922 vat_json_free (&node);
924 vam->retval = ntohl (mp->retval);
925 vam->result_ready = 1;
929 * Special-case: build the interface table, maintain
930 * the next loopback sw_if_index vbl.
932 static void vl_api_sw_interface_details_t_handler
933 (vl_api_sw_interface_details_t * mp)
935 vat_main_t *vam = &vat_main;
936 u8 *s = format (0, "%s%c", mp->interface_name, 0);
938 hash_set_mem (vam->sw_if_index_by_interface_name, s,
939 ntohl (mp->sw_if_index));
941 /* In sub interface case, fill the sub interface table entry */
942 if (mp->sw_if_index != mp->sup_sw_if_index)
944 sw_interface_subif_t *sub = NULL;
946 vec_add2 (vam->sw_if_subif_table, sub, 1);
948 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
949 strncpy ((char *) sub->interface_name, (char *) s,
950 vec_len (sub->interface_name));
951 sub->sw_if_index = ntohl (mp->sw_if_index);
952 sub->sub_id = ntohl (mp->sub_id);
954 sub->sub_dot1ad = mp->sub_dot1ad;
955 sub->sub_number_of_tags = mp->sub_number_of_tags;
956 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
957 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
958 sub->sub_exact_match = mp->sub_exact_match;
959 sub->sub_default = mp->sub_default;
960 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
961 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
963 /* vlan tag rewrite */
964 sub->vtr_op = ntohl (mp->vtr_op);
965 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
966 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
967 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
971 static void vl_api_sw_interface_details_t_handler_json
972 (vl_api_sw_interface_details_t * mp)
974 vat_main_t *vam = &vat_main;
975 vat_json_node_t *node = NULL;
977 if (VAT_JSON_ARRAY != vam->json_tree.type)
979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
980 vat_json_init_array (&vam->json_tree);
982 node = vat_json_array_add (&vam->json_tree);
984 vat_json_init_object (node);
985 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
986 vat_json_object_add_uint (node, "sup_sw_if_index",
987 ntohl (mp->sup_sw_if_index));
988 vat_json_object_add_uint (node, "l2_address_length",
989 ntohl (mp->l2_address_length));
990 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
991 sizeof (mp->l2_address));
992 vat_json_object_add_string_copy (node, "interface_name",
994 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
995 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
996 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
997 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
998 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
999 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1000 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1001 vat_json_object_add_uint (node, "sub_number_of_tags",
1002 mp->sub_number_of_tags);
1003 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1004 ntohs (mp->sub_outer_vlan_id));
1005 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1006 ntohs (mp->sub_inner_vlan_id));
1007 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1008 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1009 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1010 mp->sub_outer_vlan_id_any);
1011 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1012 mp->sub_inner_vlan_id_any);
1013 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1014 vat_json_object_add_uint (node, "vtr_push_dot1q",
1015 ntohl (mp->vtr_push_dot1q));
1016 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1017 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1020 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1022 format_ethernet_address,
1024 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1026 format_ethernet_address,
1028 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1029 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1033 #if VPP_API_TEST_BUILTIN == 0
1034 static void vl_api_sw_interface_event_t_handler
1035 (vl_api_sw_interface_event_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 if (vam->interface_event_display)
1039 errmsg ("interface flags: sw_if_index %d %s %s",
1040 ntohl (mp->sw_if_index),
1041 mp->admin_up_down ? "admin-up" : "admin-down",
1042 mp->link_up_down ? "link-up" : "link-down");
1046 static void vl_api_sw_interface_event_t_handler_json
1047 (vl_api_sw_interface_event_t * mp)
1049 /* JSON output not supported */
1053 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1055 vat_main_t *vam = &vat_main;
1056 i32 retval = ntohl (mp->retval);
1058 vam->retval = retval;
1059 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1060 vam->result_ready = 1;
1064 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1066 vat_main_t *vam = &vat_main;
1067 vat_json_node_t node;
1068 api_main_t *am = &api_main;
1072 vat_json_init_object (&node);
1073 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1074 vat_json_object_add_uint (&node, "reply_in_shmem",
1075 ntohl (mp->reply_in_shmem));
1076 /* Toss the shared-memory original... */
1077 pthread_mutex_lock (&am->vlib_rp->mutex);
1078 oldheap = svm_push_data_heap (am->vlib_rp);
1080 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1083 svm_pop_heap (oldheap);
1084 pthread_mutex_unlock (&am->vlib_rp->mutex);
1086 vat_json_print (vam->ofp, &node);
1087 vat_json_free (&node);
1089 vam->retval = ntohl (mp->retval);
1090 vam->result_ready = 1;
1094 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1096 vat_main_t *vam = &vat_main;
1097 i32 retval = ntohl (mp->retval);
1098 u32 length = ntohl (mp->length);
1100 vec_reset_length (vam->cmd_reply);
1102 vam->retval = retval;
1105 vec_validate (vam->cmd_reply, length);
1106 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1107 vam->cmd_reply[length] = 0;
1109 vam->result_ready = 1;
1113 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1115 vat_main_t *vam = &vat_main;
1116 vat_json_node_t node;
1118 vec_reset_length (vam->cmd_reply);
1120 vat_json_init_object (&node);
1121 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1122 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1124 vat_json_print (vam->ofp, &node);
1125 vat_json_free (&node);
1127 vam->retval = ntohl (mp->retval);
1128 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 i32 retval = ntohl (mp->retval);
1136 if (vam->async_mode)
1138 vam->async_errors += (retval < 0);
1142 vam->retval = retval;
1144 ((mp->new_table_index != 0xFFFFFFFF) ||
1145 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1146 (mp->match_n_vectors != 0xFFFFFFFF)))
1148 * Note: this is just barely thread-safe, depends on
1149 * the main thread spinning waiting for an answer...
1151 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1152 ntohl (mp->new_table_index),
1153 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1154 vam->result_ready = 1;
1158 static void vl_api_classify_add_del_table_reply_t_handler_json
1159 (vl_api_classify_add_del_table_reply_t * mp)
1161 vat_main_t *vam = &vat_main;
1162 vat_json_node_t node;
1164 vat_json_init_object (&node);
1165 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1166 vat_json_object_add_uint (&node, "new_table_index",
1167 ntohl (mp->new_table_index));
1168 vat_json_object_add_uint (&node, "skip_n_vectors",
1169 ntohl (mp->skip_n_vectors));
1170 vat_json_object_add_uint (&node, "match_n_vectors",
1171 ntohl (mp->match_n_vectors));
1173 vat_json_print (vam->ofp, &node);
1174 vat_json_free (&node);
1176 vam->retval = ntohl (mp->retval);
1177 vam->result_ready = 1;
1180 static void vl_api_get_node_index_reply_t_handler
1181 (vl_api_get_node_index_reply_t * mp)
1183 vat_main_t *vam = &vat_main;
1184 i32 retval = ntohl (mp->retval);
1185 if (vam->async_mode)
1187 vam->async_errors += (retval < 0);
1191 vam->retval = retval;
1193 errmsg ("node index %d", ntohl (mp->node_index));
1194 vam->result_ready = 1;
1198 static void vl_api_get_node_index_reply_t_handler_json
1199 (vl_api_get_node_index_reply_t * mp)
1201 vat_main_t *vam = &vat_main;
1202 vat_json_node_t node;
1204 vat_json_init_object (&node);
1205 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1206 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1208 vat_json_print (vam->ofp, &node);
1209 vat_json_free (&node);
1211 vam->retval = ntohl (mp->retval);
1212 vam->result_ready = 1;
1215 static void vl_api_get_next_index_reply_t_handler
1216 (vl_api_get_next_index_reply_t * mp)
1218 vat_main_t *vam = &vat_main;
1219 i32 retval = ntohl (mp->retval);
1220 if (vam->async_mode)
1222 vam->async_errors += (retval < 0);
1226 vam->retval = retval;
1228 errmsg ("next node index %d", ntohl (mp->next_index));
1229 vam->result_ready = 1;
1233 static void vl_api_get_next_index_reply_t_handler_json
1234 (vl_api_get_next_index_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1243 vat_json_print (vam->ofp, &node);
1244 vat_json_free (&node);
1246 vam->retval = ntohl (mp->retval);
1247 vam->result_ready = 1;
1250 static void vl_api_add_node_next_reply_t_handler
1251 (vl_api_add_node_next_reply_t * mp)
1253 vat_main_t *vam = &vat_main;
1254 i32 retval = ntohl (mp->retval);
1255 if (vam->async_mode)
1257 vam->async_errors += (retval < 0);
1261 vam->retval = retval;
1263 errmsg ("next index %d", ntohl (mp->next_index));
1264 vam->result_ready = 1;
1268 static void vl_api_add_node_next_reply_t_handler_json
1269 (vl_api_add_node_next_reply_t * mp)
1271 vat_main_t *vam = &vat_main;
1272 vat_json_node_t node;
1274 vat_json_init_object (&node);
1275 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1276 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1278 vat_json_print (vam->ofp, &node);
1279 vat_json_free (&node);
1281 vam->retval = ntohl (mp->retval);
1282 vam->result_ready = 1;
1285 static void vl_api_show_version_reply_t_handler
1286 (vl_api_show_version_reply_t * mp)
1288 vat_main_t *vam = &vat_main;
1289 i32 retval = ntohl (mp->retval);
1293 errmsg (" program: %s", mp->program);
1294 errmsg (" version: %s", mp->version);
1295 errmsg (" build date: %s", mp->build_date);
1296 errmsg ("build directory: %s", mp->build_directory);
1298 vam->retval = retval;
1299 vam->result_ready = 1;
1302 static void vl_api_show_version_reply_t_handler_json
1303 (vl_api_show_version_reply_t * mp)
1305 vat_main_t *vam = &vat_main;
1306 vat_json_node_t node;
1308 vat_json_init_object (&node);
1309 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1310 vat_json_object_add_string_copy (&node, "program", mp->program);
1311 vat_json_object_add_string_copy (&node, "version", mp->version);
1312 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1313 vat_json_object_add_string_copy (&node, "build_directory",
1314 mp->build_directory);
1316 vat_json_print (vam->ofp, &node);
1317 vat_json_free (&node);
1319 vam->retval = ntohl (mp->retval);
1320 vam->result_ready = 1;
1324 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1326 u32 sw_if_index = ntohl (mp->sw_if_index);
1327 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1328 mp->mac_ip ? "mac/ip binding" : "address resolution",
1329 ntohl (mp->pid), format_ip4_address, &mp->address,
1330 format_ethernet_address, mp->new_mac, sw_if_index);
1334 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1336 /* JSON output not supported */
1340 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1342 u32 sw_if_index = ntohl (mp->sw_if_index);
1343 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1344 mp->mac_ip ? "mac/ip binding" : "address resolution",
1345 ntohl (mp->pid), format_ip6_address, mp->address,
1346 format_ethernet_address, mp->new_mac, sw_if_index);
1350 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1352 /* JSON output not supported */
1356 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1358 u32 n_macs = ntohl (mp->n_macs);
1359 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1360 ntohl (mp->pid), mp->client_index, n_macs);
1362 for (i = 0; i < n_macs; i++)
1364 vl_api_mac_entry_t *mac = &mp->mac[i];
1365 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1366 i + 1, ntohl (mac->sw_if_index),
1367 format_ethernet_address, mac->mac_addr, mac->action);
1374 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1376 /* JSON output not supported */
1379 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1380 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1383 * Special-case: build the bridge domain table, maintain
1384 * the next bd id vbl.
1386 static void vl_api_bridge_domain_details_t_handler
1387 (vl_api_bridge_domain_details_t * mp)
1389 vat_main_t *vam = &vat_main;
1390 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1393 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1394 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1396 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1397 ntohl (mp->bd_id), mp->learn, mp->forward,
1398 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1402 vl_api_bridge_domain_sw_if_t *sw_ifs;
1403 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1406 sw_ifs = mp->sw_if_details;
1407 for (i = 0; i < n_sw_ifs; i++)
1413 sw_if_index = ntohl (sw_ifs->sw_if_index);
1416 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1418 if ((u32) p->value[0] == sw_if_index)
1420 sw_if_name = (u8 *)(p->key);
1425 print (vam->ofp, "%7d %3d %s", sw_if_index,
1426 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1427 "sw_if_index not found!");
1434 static void vl_api_bridge_domain_details_t_handler_json
1435 (vl_api_bridge_domain_details_t * mp)
1437 vat_main_t *vam = &vat_main;
1438 vat_json_node_t *node, *array = NULL;
1439 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1441 if (VAT_JSON_ARRAY != vam->json_tree.type)
1443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1444 vat_json_init_array (&vam->json_tree);
1446 node = vat_json_array_add (&vam->json_tree);
1448 vat_json_init_object (node);
1449 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1450 vat_json_object_add_uint (node, "flood", mp->flood);
1451 vat_json_object_add_uint (node, "forward", mp->forward);
1452 vat_json_object_add_uint (node, "learn", mp->learn);
1453 vat_json_object_add_uint (node, "bvi_sw_if_index",
1454 ntohl (mp->bvi_sw_if_index));
1455 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1456 array = vat_json_object_add (node, "sw_if");
1457 vat_json_init_array (array);
1463 vl_api_bridge_domain_sw_if_t *sw_ifs;
1466 sw_ifs = mp->sw_if_details;
1467 for (i = 0; i < n_sw_ifs; i++)
1469 node = vat_json_array_add (array);
1470 vat_json_init_object (node);
1471 vat_json_object_add_uint (node, "sw_if_index",
1472 ntohl (sw_ifs->sw_if_index));
1473 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1479 static void vl_api_control_ping_reply_t_handler
1480 (vl_api_control_ping_reply_t * mp)
1482 vat_main_t *vam = &vat_main;
1483 i32 retval = ntohl (mp->retval);
1484 if (vam->async_mode)
1486 vam->async_errors += (retval < 0);
1490 vam->retval = retval;
1491 vam->result_ready = 1;
1493 if (vam->socket_client_main)
1494 vam->socket_client_main->control_pings_outstanding--;
1497 static void vl_api_control_ping_reply_t_handler_json
1498 (vl_api_control_ping_reply_t * mp)
1500 vat_main_t *vam = &vat_main;
1501 i32 retval = ntohl (mp->retval);
1503 if (VAT_JSON_NONE != vam->json_tree.type)
1505 vat_json_print (vam->ofp, &vam->json_tree);
1506 vat_json_free (&vam->json_tree);
1507 vam->json_tree.type = VAT_JSON_NONE;
1512 vat_json_init_array (&vam->json_tree);
1513 vat_json_print (vam->ofp, &vam->json_tree);
1514 vam->json_tree.type = VAT_JSON_NONE;
1517 vam->retval = retval;
1518 vam->result_ready = 1;
1522 vl_api_bridge_domain_set_mac_age_reply_t_handler
1523 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1525 vat_main_t *vam = &vat_main;
1526 i32 retval = ntohl (mp->retval);
1527 if (vam->async_mode)
1529 vam->async_errors += (retval < 0);
1533 vam->retval = retval;
1534 vam->result_ready = 1;
1538 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1539 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1541 vat_main_t *vam = &vat_main;
1542 vat_json_node_t node;
1544 vat_json_init_object (&node);
1545 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1547 vat_json_print (vam->ofp, &node);
1548 vat_json_free (&node);
1550 vam->retval = ntohl (mp->retval);
1551 vam->result_ready = 1;
1555 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1557 vat_main_t *vam = &vat_main;
1558 i32 retval = ntohl (mp->retval);
1559 if (vam->async_mode)
1561 vam->async_errors += (retval < 0);
1565 vam->retval = retval;
1566 vam->result_ready = 1;
1570 static void vl_api_l2_flags_reply_t_handler_json
1571 (vl_api_l2_flags_reply_t * mp)
1573 vat_main_t *vam = &vat_main;
1574 vat_json_node_t node;
1576 vat_json_init_object (&node);
1577 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1578 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1579 ntohl (mp->resulting_feature_bitmap));
1581 vat_json_print (vam->ofp, &node);
1582 vat_json_free (&node);
1584 vam->retval = ntohl (mp->retval);
1585 vam->result_ready = 1;
1588 static void vl_api_bridge_flags_reply_t_handler
1589 (vl_api_bridge_flags_reply_t * mp)
1591 vat_main_t *vam = &vat_main;
1592 i32 retval = ntohl (mp->retval);
1593 if (vam->async_mode)
1595 vam->async_errors += (retval < 0);
1599 vam->retval = retval;
1600 vam->result_ready = 1;
1604 static void vl_api_bridge_flags_reply_t_handler_json
1605 (vl_api_bridge_flags_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1613 ntohl (mp->resulting_feature_bitmap));
1615 vat_json_print (vam->ofp, &node);
1616 vat_json_free (&node);
1618 vam->retval = ntohl (mp->retval);
1619 vam->result_ready = 1;
1622 static void vl_api_tap_connect_reply_t_handler
1623 (vl_api_tap_connect_reply_t * mp)
1625 vat_main_t *vam = &vat_main;
1626 i32 retval = ntohl (mp->retval);
1627 if (vam->async_mode)
1629 vam->async_errors += (retval < 0);
1633 vam->retval = retval;
1634 vam->sw_if_index = ntohl (mp->sw_if_index);
1635 vam->result_ready = 1;
1640 static void vl_api_tap_connect_reply_t_handler_json
1641 (vl_api_tap_connect_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1648 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1650 vat_json_print (vam->ofp, &node);
1651 vat_json_free (&node);
1653 vam->retval = ntohl (mp->retval);
1654 vam->result_ready = 1;
1659 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->sw_if_index = ntohl (mp->sw_if_index);
1671 vam->result_ready = 1;
1675 static void vl_api_tap_modify_reply_t_handler_json
1676 (vl_api_tap_modify_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1685 vat_json_print (vam->ofp, &node);
1686 vat_json_free (&node);
1688 vam->retval = ntohl (mp->retval);
1689 vam->result_ready = 1;
1693 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1695 vat_main_t *vam = &vat_main;
1696 i32 retval = ntohl (mp->retval);
1697 if (vam->async_mode)
1699 vam->async_errors += (retval < 0);
1703 vam->retval = retval;
1704 vam->result_ready = 1;
1708 static void vl_api_tap_delete_reply_t_handler_json
1709 (vl_api_tap_delete_reply_t * mp)
1711 vat_main_t *vam = &vat_main;
1712 vat_json_node_t node;
1714 vat_json_init_object (&node);
1715 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1717 vat_json_print (vam->ofp, &node);
1718 vat_json_free (&node);
1720 vam->retval = ntohl (mp->retval);
1721 vam->result_ready = 1;
1725 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1727 vat_main_t *vam = &vat_main;
1728 i32 retval = ntohl (mp->retval);
1729 if (vam->async_mode)
1731 vam->async_errors += (retval < 0);
1735 vam->retval = retval;
1736 vam->sw_if_index = ntohl (mp->sw_if_index);
1737 vam->result_ready = 1;
1742 static void vl_api_tap_create_v2_reply_t_handler_json
1743 (vl_api_tap_create_v2_reply_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t node;
1748 vat_json_init_object (&node);
1749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1752 vat_json_print (vam->ofp, &node);
1753 vat_json_free (&node);
1755 vam->retval = ntohl (mp->retval);
1756 vam->result_ready = 1;
1761 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1763 vat_main_t *vam = &vat_main;
1764 i32 retval = ntohl (mp->retval);
1765 if (vam->async_mode)
1767 vam->async_errors += (retval < 0);
1771 vam->retval = retval;
1772 vam->result_ready = 1;
1776 static void vl_api_tap_delete_v2_reply_t_handler_json
1777 (vl_api_tap_delete_v2_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 vat_json_node_t node;
1782 vat_json_init_object (&node);
1783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1785 vat_json_print (vam->ofp, &node);
1786 vat_json_free (&node);
1788 vam->retval = ntohl (mp->retval);
1789 vam->result_ready = 1;
1793 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1795 vat_main_t *vam = &vat_main;
1796 i32 retval = ntohl (mp->retval);
1798 if (vam->async_mode)
1800 vam->async_errors += (retval < 0);
1804 vam->retval = retval;
1805 vam->sw_if_index = ntohl (mp->sw_if_index);
1806 vam->result_ready = 1;
1810 static void vl_api_bond_create_reply_t_handler_json
1811 (vl_api_bond_create_reply_t * mp)
1813 vat_main_t *vam = &vat_main;
1814 vat_json_node_t node;
1816 vat_json_init_object (&node);
1817 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1818 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1820 vat_json_print (vam->ofp, &node);
1821 vat_json_free (&node);
1823 vam->retval = ntohl (mp->retval);
1824 vam->result_ready = 1;
1828 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1830 vat_main_t *vam = &vat_main;
1831 i32 retval = ntohl (mp->retval);
1833 if (vam->async_mode)
1835 vam->async_errors += (retval < 0);
1839 vam->retval = retval;
1840 vam->result_ready = 1;
1844 static void vl_api_bond_delete_reply_t_handler_json
1845 (vl_api_bond_delete_reply_t * mp)
1847 vat_main_t *vam = &vat_main;
1848 vat_json_node_t node;
1850 vat_json_init_object (&node);
1851 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1853 vat_json_print (vam->ofp, &node);
1854 vat_json_free (&node);
1856 vam->retval = ntohl (mp->retval);
1857 vam->result_ready = 1;
1861 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1863 vat_main_t *vam = &vat_main;
1864 i32 retval = ntohl (mp->retval);
1866 if (vam->async_mode)
1868 vam->async_errors += (retval < 0);
1872 vam->retval = retval;
1873 vam->result_ready = 1;
1877 static void vl_api_bond_enslave_reply_t_handler_json
1878 (vl_api_bond_enslave_reply_t * mp)
1880 vat_main_t *vam = &vat_main;
1881 vat_json_node_t node;
1883 vat_json_init_object (&node);
1884 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1886 vat_json_print (vam->ofp, &node);
1887 vat_json_free (&node);
1889 vam->retval = ntohl (mp->retval);
1890 vam->result_ready = 1;
1894 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1897 vat_main_t *vam = &vat_main;
1898 i32 retval = ntohl (mp->retval);
1900 if (vam->async_mode)
1902 vam->async_errors += (retval < 0);
1906 vam->retval = retval;
1907 vam->result_ready = 1;
1911 static void vl_api_bond_detach_slave_reply_t_handler_json
1912 (vl_api_bond_detach_slave_reply_t * mp)
1914 vat_main_t *vam = &vat_main;
1915 vat_json_node_t node;
1917 vat_json_init_object (&node);
1918 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1920 vat_json_print (vam->ofp, &node);
1921 vat_json_free (&node);
1923 vam->retval = ntohl (mp->retval);
1924 vam->result_ready = 1;
1927 static void vl_api_sw_interface_bond_details_t_handler
1928 (vl_api_sw_interface_bond_details_t * mp)
1930 vat_main_t *vam = &vat_main;
1933 "%-16s %-12d %-12U %-13U %-14u %-14u",
1934 mp->interface_name, ntohl (mp->sw_if_index),
1935 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1936 ntohl (mp->active_slaves), ntohl (mp->slaves));
1939 static void vl_api_sw_interface_bond_details_t_handler_json
1940 (vl_api_sw_interface_bond_details_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 vat_json_node_t *node = NULL;
1945 if (VAT_JSON_ARRAY != vam->json_tree.type)
1947 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1948 vat_json_init_array (&vam->json_tree);
1950 node = vat_json_array_add (&vam->json_tree);
1952 vat_json_init_object (node);
1953 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1954 vat_json_object_add_string_copy (node, "interface_name",
1955 mp->interface_name);
1956 vat_json_object_add_uint (node, "mode", mp->mode);
1957 vat_json_object_add_uint (node, "load_balance", mp->lb);
1958 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1959 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1963 api_sw_interface_bond_dump (vat_main_t * vam)
1965 vl_api_sw_interface_bond_dump_t *mp;
1966 vl_api_control_ping_t *mp_ping;
1970 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1971 "interface name", "sw_if_index", "mode", "load balance",
1972 "active slaves", "slaves");
1974 /* Get list of bond interfaces */
1975 M (SW_INTERFACE_BOND_DUMP, mp);
1978 /* Use a control ping for synchronization */
1979 MPING (CONTROL_PING, mp_ping);
1986 static void vl_api_sw_interface_slave_details_t_handler
1987 (vl_api_sw_interface_slave_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1992 "%-25s %-12d %-12d %d", mp->interface_name,
1993 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1996 static void vl_api_sw_interface_slave_details_t_handler_json
1997 (vl_api_sw_interface_slave_details_t * mp)
1999 vat_main_t *vam = &vat_main;
2000 vat_json_node_t *node = NULL;
2002 if (VAT_JSON_ARRAY != vam->json_tree.type)
2004 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2005 vat_json_init_array (&vam->json_tree);
2007 node = vat_json_array_add (&vam->json_tree);
2009 vat_json_init_object (node);
2010 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2011 vat_json_object_add_string_copy (node, "interface_name",
2012 mp->interface_name);
2013 vat_json_object_add_uint (node, "passive", mp->is_passive);
2014 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2018 api_sw_interface_slave_dump (vat_main_t * vam)
2020 unformat_input_t *i = vam->input;
2021 vl_api_sw_interface_slave_dump_t *mp;
2022 vl_api_control_ping_t *mp_ping;
2023 u32 sw_if_index = ~0;
2024 u8 sw_if_index_set = 0;
2027 /* Parse args required to build the message */
2028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2031 sw_if_index_set = 1;
2032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2033 sw_if_index_set = 1;
2038 if (sw_if_index_set == 0)
2040 errmsg ("missing vpp interface name. ");
2045 "\n%-25s %-12s %-12s %s",
2046 "slave interface name", "sw_if_index", "passive", "long_timeout");
2048 /* Get list of bond interfaces */
2049 M (SW_INTERFACE_SLAVE_DUMP, mp);
2050 mp->sw_if_index = ntohl (sw_if_index);
2053 /* Use a control ping for synchronization */
2054 MPING (CONTROL_PING, mp_ping);
2061 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2062 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2064 vat_main_t *vam = &vat_main;
2065 i32 retval = ntohl (mp->retval);
2066 if (vam->async_mode)
2068 vam->async_errors += (retval < 0);
2072 vam->retval = retval;
2073 vam->result_ready = 1;
2077 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2078 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2080 vat_main_t *vam = &vat_main;
2081 vat_json_node_t node;
2083 vat_json_init_object (&node);
2084 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2085 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2086 ntohl (mp->sw_if_index));
2088 vat_json_print (vam->ofp, &node);
2089 vat_json_free (&node);
2091 vam->retval = ntohl (mp->retval);
2092 vam->result_ready = 1;
2095 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2096 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2098 vat_main_t *vam = &vat_main;
2099 i32 retval = ntohl (mp->retval);
2100 if (vam->async_mode)
2102 vam->async_errors += (retval < 0);
2106 vam->retval = retval;
2107 vam->sw_if_index = ntohl (mp->sw_if_index);
2108 vam->result_ready = 1;
2112 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2113 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t node;
2118 vat_json_init_object (&node);
2119 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2120 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2122 vat_json_print (vam->ofp, &node);
2123 vat_json_free (&node);
2125 vam->retval = ntohl (mp->retval);
2126 vam->result_ready = 1;
2129 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2130 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2132 vat_main_t *vam = &vat_main;
2133 i32 retval = ntohl (mp->retval);
2134 if (vam->async_mode)
2136 vam->async_errors += (retval < 0);
2140 vam->retval = retval;
2141 vam->result_ready = 1;
2145 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2146 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2148 vat_main_t *vam = &vat_main;
2149 vat_json_node_t node;
2151 vat_json_init_object (&node);
2152 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2153 vat_json_object_add_uint (&node, "fwd_entry_index",
2154 clib_net_to_host_u32 (mp->fwd_entry_index));
2156 vat_json_print (vam->ofp, &node);
2157 vat_json_free (&node);
2159 vam->retval = ntohl (mp->retval);
2160 vam->result_ready = 1;
2164 format_lisp_transport_protocol (u8 * s, va_list * args)
2166 u32 proto = va_arg (*args, u32);
2171 return format (s, "udp");
2173 return format (s, "api");
2180 static void vl_api_one_get_transport_protocol_reply_t_handler
2181 (vl_api_one_get_transport_protocol_reply_t * mp)
2183 vat_main_t *vam = &vat_main;
2184 i32 retval = ntohl (mp->retval);
2185 if (vam->async_mode)
2187 vam->async_errors += (retval < 0);
2191 u32 proto = mp->protocol;
2192 print (vam->ofp, "Transport protocol: %U",
2193 format_lisp_transport_protocol, proto);
2194 vam->retval = retval;
2195 vam->result_ready = 1;
2199 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2200 (vl_api_one_get_transport_protocol_reply_t * mp)
2202 vat_main_t *vam = &vat_main;
2203 vat_json_node_t node;
2206 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2209 vat_json_init_object (&node);
2210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2211 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2214 vat_json_print (vam->ofp, &node);
2215 vat_json_free (&node);
2217 vam->retval = ntohl (mp->retval);
2218 vam->result_ready = 1;
2221 static void vl_api_one_add_del_locator_set_reply_t_handler
2222 (vl_api_one_add_del_locator_set_reply_t * mp)
2224 vat_main_t *vam = &vat_main;
2225 i32 retval = ntohl (mp->retval);
2226 if (vam->async_mode)
2228 vam->async_errors += (retval < 0);
2232 vam->retval = retval;
2233 vam->result_ready = 1;
2237 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2238 (vl_api_one_add_del_locator_set_reply_t * mp)
2240 vat_main_t *vam = &vat_main;
2241 vat_json_node_t node;
2243 vat_json_init_object (&node);
2244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2245 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2247 vat_json_print (vam->ofp, &node);
2248 vat_json_free (&node);
2250 vam->retval = ntohl (mp->retval);
2251 vam->result_ready = 1;
2254 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2255 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 i32 retval = ntohl (mp->retval);
2259 if (vam->async_mode)
2261 vam->async_errors += (retval < 0);
2265 vam->retval = retval;
2266 vam->sw_if_index = ntohl (mp->sw_if_index);
2267 vam->result_ready = 1;
2269 vam->regenerate_interface_table = 1;
2272 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2273 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2275 vat_main_t *vam = &vat_main;
2276 vat_json_node_t node;
2278 vat_json_init_object (&node);
2279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2280 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2282 vat_json_print (vam->ofp, &node);
2283 vat_json_free (&node);
2285 vam->retval = ntohl (mp->retval);
2286 vam->result_ready = 1;
2289 static void vl_api_vxlan_offload_rx_reply_t_handler
2290 (vl_api_vxlan_offload_rx_reply_t * mp)
2292 vat_main_t *vam = &vat_main;
2293 i32 retval = ntohl (mp->retval);
2294 if (vam->async_mode)
2296 vam->async_errors += (retval < 0);
2300 vam->retval = retval;
2301 vam->result_ready = 1;
2305 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2306 (vl_api_vxlan_offload_rx_reply_t * mp)
2308 vat_main_t *vam = &vat_main;
2309 vat_json_node_t node;
2311 vat_json_init_object (&node);
2312 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2314 vat_json_print (vam->ofp, &node);
2315 vat_json_free (&node);
2317 vam->retval = ntohl (mp->retval);
2318 vam->result_ready = 1;
2321 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2322 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2324 vat_main_t *vam = &vat_main;
2325 i32 retval = ntohl (mp->retval);
2326 if (vam->async_mode)
2328 vam->async_errors += (retval < 0);
2332 vam->retval = retval;
2333 vam->sw_if_index = ntohl (mp->sw_if_index);
2334 vam->result_ready = 1;
2338 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2339 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2341 vat_main_t *vam = &vat_main;
2342 vat_json_node_t node;
2344 vat_json_init_object (&node);
2345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2346 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2348 vat_json_print (vam->ofp, &node);
2349 vat_json_free (&node);
2351 vam->retval = ntohl (mp->retval);
2352 vam->result_ready = 1;
2355 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2356 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 i32 retval = ntohl (mp->retval);
2360 if (vam->async_mode)
2362 vam->async_errors += (retval < 0);
2366 vam->retval = retval;
2367 vam->sw_if_index = ntohl (mp->sw_if_index);
2368 vam->result_ready = 1;
2370 vam->regenerate_interface_table = 1;
2373 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2374 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2376 vat_main_t *vam = &vat_main;
2377 vat_json_node_t node;
2379 vat_json_init_object (&node);
2380 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2381 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2383 vat_json_print (vam->ofp, &node);
2384 vat_json_free (&node);
2386 vam->retval = ntohl (mp->retval);
2387 vam->result_ready = 1;
2390 static void vl_api_gre_add_del_tunnel_reply_t_handler
2391 (vl_api_gre_add_del_tunnel_reply_t * mp)
2393 vat_main_t *vam = &vat_main;
2394 i32 retval = ntohl (mp->retval);
2395 if (vam->async_mode)
2397 vam->async_errors += (retval < 0);
2401 vam->retval = retval;
2402 vam->sw_if_index = ntohl (mp->sw_if_index);
2403 vam->result_ready = 1;
2407 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2408 (vl_api_gre_add_del_tunnel_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 vat_json_node_t node;
2413 vat_json_init_object (&node);
2414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2415 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2417 vat_json_print (vam->ofp, &node);
2418 vat_json_free (&node);
2420 vam->retval = ntohl (mp->retval);
2421 vam->result_ready = 1;
2424 static void vl_api_create_vhost_user_if_reply_t_handler
2425 (vl_api_create_vhost_user_if_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 i32 retval = ntohl (mp->retval);
2429 if (vam->async_mode)
2431 vam->async_errors += (retval < 0);
2435 vam->retval = retval;
2436 vam->sw_if_index = ntohl (mp->sw_if_index);
2437 vam->result_ready = 1;
2439 vam->regenerate_interface_table = 1;
2442 static void vl_api_create_vhost_user_if_reply_t_handler_json
2443 (vl_api_create_vhost_user_if_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 vat_json_node_t node;
2448 vat_json_init_object (&node);
2449 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2450 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2452 vat_json_print (vam->ofp, &node);
2453 vat_json_free (&node);
2455 vam->retval = ntohl (mp->retval);
2456 vam->result_ready = 1;
2459 static void vl_api_dns_resolve_name_reply_t_handler
2460 (vl_api_dns_resolve_name_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 i32 retval = ntohl (mp->retval);
2464 if (vam->async_mode)
2466 vam->async_errors += (retval < 0);
2470 vam->retval = retval;
2471 vam->result_ready = 1;
2476 clib_warning ("ip4 address %U", format_ip4_address,
2477 (ip4_address_t *) mp->ip4_address);
2479 clib_warning ("ip6 address %U", format_ip6_address,
2480 (ip6_address_t *) mp->ip6_address);
2483 clib_warning ("retval %d", retval);
2487 static void vl_api_dns_resolve_name_reply_t_handler_json
2488 (vl_api_dns_resolve_name_reply_t * mp)
2490 clib_warning ("not implemented");
2493 static void vl_api_dns_resolve_ip_reply_t_handler
2494 (vl_api_dns_resolve_ip_reply_t * mp)
2496 vat_main_t *vam = &vat_main;
2497 i32 retval = ntohl (mp->retval);
2498 if (vam->async_mode)
2500 vam->async_errors += (retval < 0);
2504 vam->retval = retval;
2505 vam->result_ready = 1;
2509 clib_warning ("canonical name %s", mp->name);
2512 clib_warning ("retval %d", retval);
2516 static void vl_api_dns_resolve_ip_reply_t_handler_json
2517 (vl_api_dns_resolve_ip_reply_t * mp)
2519 clib_warning ("not implemented");
2523 static void vl_api_ip_address_details_t_handler
2524 (vl_api_ip_address_details_t * mp)
2526 vat_main_t *vam = &vat_main;
2527 static ip_address_details_t empty_ip_address_details = { {0} };
2528 ip_address_details_t *address = NULL;
2529 ip_details_t *current_ip_details = NULL;
2530 ip_details_t *details = NULL;
2532 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2534 if (!details || vam->current_sw_if_index >= vec_len (details)
2535 || !details[vam->current_sw_if_index].present)
2537 errmsg ("ip address details arrived but not stored");
2538 errmsg ("ip_dump should be called first");
2542 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2544 #define addresses (current_ip_details->addr)
2546 vec_validate_init_empty (addresses, vec_len (addresses),
2547 empty_ip_address_details);
2549 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2551 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2552 address->prefix_length = mp->prefix_length;
2556 static void vl_api_ip_address_details_t_handler_json
2557 (vl_api_ip_address_details_t * mp)
2559 vat_main_t *vam = &vat_main;
2560 vat_json_node_t *node = NULL;
2561 struct in6_addr ip6;
2564 if (VAT_JSON_ARRAY != vam->json_tree.type)
2566 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2567 vat_json_init_array (&vam->json_tree);
2569 node = vat_json_array_add (&vam->json_tree);
2571 vat_json_init_object (node);
2574 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2575 vat_json_object_add_ip6 (node, "ip", ip6);
2579 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2580 vat_json_object_add_ip4 (node, "ip", ip4);
2582 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2586 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 static ip_details_t empty_ip_details = { 0 };
2590 ip_details_t *ip = NULL;
2591 u32 sw_if_index = ~0;
2593 sw_if_index = ntohl (mp->sw_if_index);
2595 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2596 sw_if_index, empty_ip_details);
2598 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2605 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2607 vat_main_t *vam = &vat_main;
2609 if (VAT_JSON_ARRAY != vam->json_tree.type)
2611 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2612 vat_json_init_array (&vam->json_tree);
2614 vat_json_array_add_uint (&vam->json_tree,
2615 clib_net_to_host_u32 (mp->sw_if_index));
2618 static void vl_api_map_domain_details_t_handler_json
2619 (vl_api_map_domain_details_t * mp)
2621 vat_json_node_t *node = NULL;
2622 vat_main_t *vam = &vat_main;
2623 struct in6_addr ip6;
2626 if (VAT_JSON_ARRAY != vam->json_tree.type)
2628 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2629 vat_json_init_array (&vam->json_tree);
2632 node = vat_json_array_add (&vam->json_tree);
2633 vat_json_init_object (node);
2635 vat_json_object_add_uint (node, "domain_index",
2636 clib_net_to_host_u32 (mp->domain_index));
2637 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2638 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2639 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2640 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2641 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2642 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2643 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2644 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2645 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2646 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2647 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2648 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2649 vat_json_object_add_uint (node, "flags", mp->flags);
2650 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2651 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2654 static void vl_api_map_domain_details_t_handler
2655 (vl_api_map_domain_details_t * mp)
2657 vat_main_t *vam = &vat_main;
2659 if (mp->is_translation)
2662 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2663 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2664 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2665 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2666 clib_net_to_host_u32 (mp->domain_index));
2671 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2672 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2673 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2674 format_ip6_address, mp->ip6_src,
2675 clib_net_to_host_u32 (mp->domain_index));
2677 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2678 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2679 mp->is_translation ? "map-t" : "");
2682 static void vl_api_map_rule_details_t_handler_json
2683 (vl_api_map_rule_details_t * mp)
2685 struct in6_addr ip6;
2686 vat_json_node_t *node = NULL;
2687 vat_main_t *vam = &vat_main;
2689 if (VAT_JSON_ARRAY != vam->json_tree.type)
2691 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2692 vat_json_init_array (&vam->json_tree);
2695 node = vat_json_array_add (&vam->json_tree);
2696 vat_json_init_object (node);
2698 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2699 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2700 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2704 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2708 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2712 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2714 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2715 "router_addr %U host_mac %U",
2716 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2718 format_ip4_address, &mp->lease.host_address,
2719 format_ip4_address, &mp->lease.router_address,
2720 format_ethernet_address, mp->lease.host_mac);
2723 static void vl_api_dhcp_compl_event_t_handler_json
2724 (vl_api_dhcp_compl_event_t * mp)
2726 /* JSON output not supported */
2730 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2733 vat_main_t *vam = &vat_main;
2734 static u64 default_counter = 0;
2736 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2738 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2739 sw_if_index, default_counter);
2740 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2744 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2745 interface_counter_t counter)
2747 vat_main_t *vam = &vat_main;
2748 static interface_counter_t default_counter = { 0, };
2750 vec_validate_init_empty (vam->combined_interface_counters,
2751 vnet_counter_type, NULL);
2752 vec_validate_init_empty (vam->combined_interface_counters
2753 [vnet_counter_type], sw_if_index, default_counter);
2754 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2757 static void vl_api_vnet_interface_simple_counters_t_handler
2758 (vl_api_vnet_interface_simple_counters_t * mp)
2763 static void vl_api_vnet_interface_combined_counters_t_handler
2764 (vl_api_vnet_interface_combined_counters_t * mp)
2769 static void vl_api_vnet_interface_simple_counters_t_handler_json
2770 (vl_api_vnet_interface_simple_counters_t * mp)
2775 u32 first_sw_if_index;
2778 count = ntohl (mp->count);
2779 first_sw_if_index = ntohl (mp->first_sw_if_index);
2781 v_packets = (u64 *) & mp->data;
2782 for (i = 0; i < count; i++)
2784 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2785 set_simple_interface_counter (mp->vnet_counter_type,
2786 first_sw_if_index + i, packets);
2791 static void vl_api_vnet_interface_combined_counters_t_handler_json
2792 (vl_api_vnet_interface_combined_counters_t * mp)
2794 interface_counter_t counter;
2796 u32 first_sw_if_index;
2800 count = ntohl (mp->count);
2801 first_sw_if_index = ntohl (mp->first_sw_if_index);
2803 v = (vlib_counter_t *) & mp->data;
2804 for (i = 0; i < count; i++)
2807 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2809 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2810 set_combined_interface_counter (mp->vnet_counter_type,
2811 first_sw_if_index + i, counter);
2817 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2819 vat_main_t *vam = &vat_main;
2822 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2824 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2833 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2835 vat_main_t *vam = &vat_main;
2838 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2840 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2848 static void vl_api_vnet_ip4_fib_counters_t_handler
2849 (vl_api_vnet_ip4_fib_counters_t * mp)
2854 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2855 (vl_api_vnet_ip4_fib_counters_t * mp)
2857 vat_main_t *vam = &vat_main;
2858 vl_api_ip4_fib_counter_t *v;
2859 ip4_fib_counter_t *counter;
2866 vrf_id = ntohl (mp->vrf_id);
2867 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2868 if (~0 == vrf_index)
2870 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2871 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2872 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2873 vec_validate (vam->ip4_fib_counters, vrf_index);
2874 vam->ip4_fib_counters[vrf_index] = NULL;
2877 vec_free (vam->ip4_fib_counters[vrf_index]);
2878 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2879 count = ntohl (mp->count);
2880 for (i = 0; i < count; i++)
2882 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2883 counter = &vam->ip4_fib_counters[vrf_index][i];
2884 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2885 counter->address = ip4;
2886 counter->address_length = v->address_length;
2887 counter->packets = clib_net_to_host_u64 (v->packets);
2888 counter->bytes = clib_net_to_host_u64 (v->bytes);
2893 static void vl_api_vnet_ip4_nbr_counters_t_handler
2894 (vl_api_vnet_ip4_nbr_counters_t * mp)
2899 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2900 (vl_api_vnet_ip4_nbr_counters_t * mp)
2902 vat_main_t *vam = &vat_main;
2903 vl_api_ip4_nbr_counter_t *v;
2904 ip4_nbr_counter_t *counter;
2909 sw_if_index = ntohl (mp->sw_if_index);
2910 count = ntohl (mp->count);
2911 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2914 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2916 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2917 for (i = 0; i < count; i++)
2919 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2920 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2921 counter->address.s_addr = v->address;
2922 counter->packets = clib_net_to_host_u64 (v->packets);
2923 counter->bytes = clib_net_to_host_u64 (v->bytes);
2924 counter->linkt = v->link_type;
2929 static void vl_api_vnet_ip6_fib_counters_t_handler
2930 (vl_api_vnet_ip6_fib_counters_t * mp)
2935 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2936 (vl_api_vnet_ip6_fib_counters_t * mp)
2938 vat_main_t *vam = &vat_main;
2939 vl_api_ip6_fib_counter_t *v;
2940 ip6_fib_counter_t *counter;
2941 struct in6_addr ip6;
2947 vrf_id = ntohl (mp->vrf_id);
2948 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2949 if (~0 == vrf_index)
2951 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2952 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2953 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2954 vec_validate (vam->ip6_fib_counters, vrf_index);
2955 vam->ip6_fib_counters[vrf_index] = NULL;
2958 vec_free (vam->ip6_fib_counters[vrf_index]);
2959 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2960 count = ntohl (mp->count);
2961 for (i = 0; i < count; i++)
2963 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2964 counter = &vam->ip6_fib_counters[vrf_index][i];
2965 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2966 counter->address = ip6;
2967 counter->address_length = v->address_length;
2968 counter->packets = clib_net_to_host_u64 (v->packets);
2969 counter->bytes = clib_net_to_host_u64 (v->bytes);
2974 static void vl_api_vnet_ip6_nbr_counters_t_handler
2975 (vl_api_vnet_ip6_nbr_counters_t * mp)
2980 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2981 (vl_api_vnet_ip6_nbr_counters_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 vl_api_ip6_nbr_counter_t *v;
2985 ip6_nbr_counter_t *counter;
2986 struct in6_addr ip6;
2991 sw_if_index = ntohl (mp->sw_if_index);
2992 count = ntohl (mp->count);
2993 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2996 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2998 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2999 for (i = 0; i < count; i++)
3001 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
3002 counter = &vam->ip6_nbr_counters[sw_if_index][i];
3003 clib_memcpy (&ip6, &v->address, sizeof (ip6));
3004 counter->address = ip6;
3005 counter->packets = clib_net_to_host_u64 (v->packets);
3006 counter->bytes = clib_net_to_host_u64 (v->bytes);
3011 static void vl_api_get_first_msg_id_reply_t_handler
3012 (vl_api_get_first_msg_id_reply_t * mp)
3014 vat_main_t *vam = &vat_main;
3015 i32 retval = ntohl (mp->retval);
3017 if (vam->async_mode)
3019 vam->async_errors += (retval < 0);
3023 vam->retval = retval;
3024 vam->result_ready = 1;
3028 errmsg ("first message id %d", ntohs (mp->first_msg_id));
3032 static void vl_api_get_first_msg_id_reply_t_handler_json
3033 (vl_api_get_first_msg_id_reply_t * mp)
3035 vat_main_t *vam = &vat_main;
3036 vat_json_node_t node;
3038 vat_json_init_object (&node);
3039 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3040 vat_json_object_add_uint (&node, "first_msg_id",
3041 (uint) ntohs (mp->first_msg_id));
3043 vat_json_print (vam->ofp, &node);
3044 vat_json_free (&node);
3046 vam->retval = ntohl (mp->retval);
3047 vam->result_ready = 1;
3050 static void vl_api_get_node_graph_reply_t_handler
3051 (vl_api_get_node_graph_reply_t * mp)
3053 vat_main_t *vam = &vat_main;
3054 api_main_t *am = &api_main;
3055 i32 retval = ntohl (mp->retval);
3056 u8 *pvt_copy, *reply;
3061 if (vam->async_mode)
3063 vam->async_errors += (retval < 0);
3067 vam->retval = retval;
3068 vam->result_ready = 1;
3071 /* "Should never happen..." */
3075 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3076 pvt_copy = vec_dup (reply);
3078 /* Toss the shared-memory original... */
3079 pthread_mutex_lock (&am->vlib_rp->mutex);
3080 oldheap = svm_push_data_heap (am->vlib_rp);
3084 svm_pop_heap (oldheap);
3085 pthread_mutex_unlock (&am->vlib_rp->mutex);
3087 if (vam->graph_nodes)
3089 hash_free (vam->graph_node_index_by_name);
3091 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3093 node = vam->graph_nodes[0][i];
3094 vec_free (node->name);
3095 vec_free (node->next_nodes);
3098 vec_free (vam->graph_nodes[0]);
3099 vec_free (vam->graph_nodes);
3102 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3103 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3104 vec_free (pvt_copy);
3106 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
3108 node = vam->graph_nodes[0][i];
3109 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3113 static void vl_api_get_node_graph_reply_t_handler_json
3114 (vl_api_get_node_graph_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 api_main_t *am = &api_main;
3119 vat_json_node_t node;
3122 /* $$$$ make this real? */
3123 vat_json_init_object (&node);
3124 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3125 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3127 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3129 /* Toss the shared-memory original... */
3130 pthread_mutex_lock (&am->vlib_rp->mutex);
3131 oldheap = svm_push_data_heap (am->vlib_rp);
3135 svm_pop_heap (oldheap);
3136 pthread_mutex_unlock (&am->vlib_rp->mutex);
3138 vat_json_print (vam->ofp, &node);
3139 vat_json_free (&node);
3141 vam->retval = ntohl (mp->retval);
3142 vam->result_ready = 1;
3146 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3148 vat_main_t *vam = &vat_main;
3153 s = format (s, "%=16d%=16d%=16d",
3154 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3158 s = format (s, "%=16U%=16d%=16d",
3159 mp->is_ipv6 ? format_ip6_address :
3161 mp->ip_address, mp->priority, mp->weight);
3164 print (vam->ofp, "%v", s);
3169 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3171 vat_main_t *vam = &vat_main;
3172 vat_json_node_t *node = NULL;
3173 struct in6_addr ip6;
3176 if (VAT_JSON_ARRAY != vam->json_tree.type)
3178 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3179 vat_json_init_array (&vam->json_tree);
3181 node = vat_json_array_add (&vam->json_tree);
3182 vat_json_init_object (node);
3184 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3185 vat_json_object_add_uint (node, "priority", mp->priority);
3186 vat_json_object_add_uint (node, "weight", mp->weight);
3189 vat_json_object_add_uint (node, "sw_if_index",
3190 clib_net_to_host_u32 (mp->sw_if_index));
3195 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3196 vat_json_object_add_ip6 (node, "address", ip6);
3200 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3201 vat_json_object_add_ip4 (node, "address", ip4);
3207 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3210 vat_main_t *vam = &vat_main;
3213 ls_name = format (0, "%s", mp->ls_name);
3215 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3221 vl_api_one_locator_set_details_t_handler_json
3222 (vl_api_one_locator_set_details_t * mp)
3224 vat_main_t *vam = &vat_main;
3225 vat_json_node_t *node = 0;
3228 ls_name = format (0, "%s", mp->ls_name);
3229 vec_add1 (ls_name, 0);
3231 if (VAT_JSON_ARRAY != vam->json_tree.type)
3233 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3234 vat_json_init_array (&vam->json_tree);
3236 node = vat_json_array_add (&vam->json_tree);
3238 vat_json_init_object (node);
3239 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3240 vat_json_object_add_uint (node, "ls_index",
3241 clib_net_to_host_u32 (mp->ls_index));
3249 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3252 unformat_nsh_address (unformat_input_t * input, va_list * args)
3254 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3255 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3259 format_nsh_address_vat (u8 * s, va_list * args)
3261 nsh_t *a = va_arg (*args, nsh_t *);
3262 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3266 format_lisp_flat_eid (u8 * s, va_list * args)
3268 u32 type = va_arg (*args, u32);
3269 u8 *eid = va_arg (*args, u8 *);
3270 u32 eid_len = va_arg (*args, u32);
3275 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3277 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3279 return format (s, "%U", format_ethernet_address, eid);
3281 return format (s, "%U", format_nsh_address_vat, eid);
3287 format_lisp_eid_vat (u8 * s, va_list * args)
3289 u32 type = va_arg (*args, u32);
3290 u8 *eid = va_arg (*args, u8 *);
3291 u32 eid_len = va_arg (*args, u32);
3292 u8 *seid = va_arg (*args, u8 *);
3293 u32 seid_len = va_arg (*args, u32);
3294 u32 is_src_dst = va_arg (*args, u32);
3297 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3299 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3305 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3307 vat_main_t *vam = &vat_main;
3308 u8 *s = 0, *eid = 0;
3310 if (~0 == mp->locator_set_index)
3311 s = format (0, "action: %d", mp->action);
3313 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3315 eid = format (0, "%U", format_lisp_eid_vat,
3319 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3322 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3323 clib_net_to_host_u32 (mp->vni),
3325 mp->is_local ? "local" : "remote",
3326 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3327 clib_net_to_host_u16 (mp->key_id), mp->key);
3334 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3337 vat_main_t *vam = &vat_main;
3338 vat_json_node_t *node = 0;
3341 if (VAT_JSON_ARRAY != vam->json_tree.type)
3343 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3344 vat_json_init_array (&vam->json_tree);
3346 node = vat_json_array_add (&vam->json_tree);
3348 vat_json_init_object (node);
3349 if (~0 == mp->locator_set_index)
3350 vat_json_object_add_uint (node, "action", mp->action);
3352 vat_json_object_add_uint (node, "locator_set_index",
3353 clib_net_to_host_u32 (mp->locator_set_index));
3355 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3356 if (mp->eid_type == 3)
3358 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3359 vat_json_init_object (nsh_json);
3360 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3361 vat_json_object_add_uint (nsh_json, "spi",
3362 clib_net_to_host_u32 (nsh->spi));
3363 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3367 eid = format (0, "%U", format_lisp_eid_vat,
3371 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3373 vat_json_object_add_string_copy (node, "eid", eid);
3376 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3377 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3378 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3382 vat_json_object_add_uint (node, "key_id",
3383 clib_net_to_host_u16 (mp->key_id));
3384 vat_json_object_add_string_copy (node, "key", mp->key);
3389 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3391 vat_main_t *vam = &vat_main;
3392 u8 *seid = 0, *deid = 0;
3393 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3395 deid = format (0, "%U", format_lisp_eid_vat,
3396 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3398 seid = format (0, "%U", format_lisp_eid_vat,
3399 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3405 format_ip_address_fcn = format_ip4_address;
3407 format_ip_address_fcn = format_ip6_address;
3410 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3411 clib_net_to_host_u32 (mp->vni),
3413 format_ip_address_fcn, mp->lloc,
3414 format_ip_address_fcn, mp->rloc,
3415 clib_net_to_host_u32 (mp->pkt_count),
3416 clib_net_to_host_u32 (mp->bytes));
3423 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3425 struct in6_addr ip6;
3427 vat_main_t *vam = &vat_main;
3428 vat_json_node_t *node = 0;
3429 u8 *deid = 0, *seid = 0;
3431 if (VAT_JSON_ARRAY != vam->json_tree.type)
3433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3434 vat_json_init_array (&vam->json_tree);
3436 node = vat_json_array_add (&vam->json_tree);
3438 vat_json_init_object (node);
3439 deid = format (0, "%U", format_lisp_eid_vat,
3440 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3442 seid = format (0, "%U", format_lisp_eid_vat,
3443 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3448 vat_json_object_add_string_copy (node, "seid", seid);
3449 vat_json_object_add_string_copy (node, "deid", deid);
3450 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3454 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3455 vat_json_object_add_ip4 (node, "lloc", ip4);
3456 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3457 vat_json_object_add_ip4 (node, "rloc", ip4);
3461 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3462 vat_json_object_add_ip6 (node, "lloc", ip6);
3463 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3464 vat_json_object_add_ip6 (node, "rloc", ip6);
3466 vat_json_object_add_uint (node, "pkt_count",
3467 clib_net_to_host_u32 (mp->pkt_count));
3468 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3475 vl_api_one_eid_table_map_details_t_handler
3476 (vl_api_one_eid_table_map_details_t * mp)
3478 vat_main_t *vam = &vat_main;
3480 u8 *line = format (0, "%=10d%=10d",
3481 clib_net_to_host_u32 (mp->vni),
3482 clib_net_to_host_u32 (mp->dp_table));
3483 print (vam->ofp, "%v", line);
3488 vl_api_one_eid_table_map_details_t_handler_json
3489 (vl_api_one_eid_table_map_details_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 vat_json_node_t *node = NULL;
3494 if (VAT_JSON_ARRAY != vam->json_tree.type)
3496 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3497 vat_json_init_array (&vam->json_tree);
3499 node = vat_json_array_add (&vam->json_tree);
3500 vat_json_init_object (node);
3501 vat_json_object_add_uint (node, "dp_table",
3502 clib_net_to_host_u32 (mp->dp_table));
3503 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3507 vl_api_one_eid_table_vni_details_t_handler
3508 (vl_api_one_eid_table_vni_details_t * mp)
3510 vat_main_t *vam = &vat_main;
3512 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3513 print (vam->ofp, "%v", line);
3518 vl_api_one_eid_table_vni_details_t_handler_json
3519 (vl_api_one_eid_table_vni_details_t * mp)
3521 vat_main_t *vam = &vat_main;
3522 vat_json_node_t *node = NULL;
3524 if (VAT_JSON_ARRAY != vam->json_tree.type)
3526 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3527 vat_json_init_array (&vam->json_tree);
3529 node = vat_json_array_add (&vam->json_tree);
3530 vat_json_init_object (node);
3531 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3535 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3536 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 int retval = clib_net_to_host_u32 (mp->retval);
3541 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3542 print (vam->ofp, "fallback threshold value: %d", mp->value);
3544 vam->retval = retval;
3545 vam->result_ready = 1;
3549 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3550 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3552 vat_main_t *vam = &vat_main;
3553 vat_json_node_t _node, *node = &_node;
3554 int retval = clib_net_to_host_u32 (mp->retval);
3556 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3557 vat_json_init_object (node);
3558 vat_json_object_add_uint (node, "value", mp->value);
3560 vat_json_print (vam->ofp, node);
3561 vat_json_free (node);
3563 vam->retval = retval;
3564 vam->result_ready = 1;
3568 vl_api_show_one_map_register_state_reply_t_handler
3569 (vl_api_show_one_map_register_state_reply_t * mp)
3571 vat_main_t *vam = &vat_main;
3572 int retval = clib_net_to_host_u32 (mp->retval);
3574 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3576 vam->retval = retval;
3577 vam->result_ready = 1;
3581 vl_api_show_one_map_register_state_reply_t_handler_json
3582 (vl_api_show_one_map_register_state_reply_t * mp)
3584 vat_main_t *vam = &vat_main;
3585 vat_json_node_t _node, *node = &_node;
3586 int retval = clib_net_to_host_u32 (mp->retval);
3588 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3590 vat_json_init_object (node);
3591 vat_json_object_add_string_copy (node, "state", s);
3593 vat_json_print (vam->ofp, node);
3594 vat_json_free (node);
3596 vam->retval = retval;
3597 vam->result_ready = 1;
3602 vl_api_show_one_rloc_probe_state_reply_t_handler
3603 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3605 vat_main_t *vam = &vat_main;
3606 int retval = clib_net_to_host_u32 (mp->retval);
3611 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3613 vam->retval = retval;
3614 vam->result_ready = 1;
3618 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3619 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3621 vat_main_t *vam = &vat_main;
3622 vat_json_node_t _node, *node = &_node;
3623 int retval = clib_net_to_host_u32 (mp->retval);
3625 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3626 vat_json_init_object (node);
3627 vat_json_object_add_string_copy (node, "state", s);
3629 vat_json_print (vam->ofp, node);
3630 vat_json_free (node);
3632 vam->retval = retval;
3633 vam->result_ready = 1;
3638 vl_api_show_one_stats_enable_disable_reply_t_handler
3639 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3641 vat_main_t *vam = &vat_main;
3642 int retval = clib_net_to_host_u32 (mp->retval);
3647 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3654 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3655 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3657 vat_main_t *vam = &vat_main;
3658 vat_json_node_t _node, *node = &_node;
3659 int retval = clib_net_to_host_u32 (mp->retval);
3661 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3662 vat_json_init_object (node);
3663 vat_json_object_add_string_copy (node, "state", s);
3665 vat_json_print (vam->ofp, node);
3666 vat_json_free (node);
3668 vam->retval = retval;
3669 vam->result_ready = 1;
3674 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3676 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3677 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3678 e->vni = clib_net_to_host_u32 (e->vni);
3682 gpe_fwd_entries_get_reply_t_net_to_host
3683 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3687 mp->count = clib_net_to_host_u32 (mp->count);
3688 for (i = 0; i < mp->count; i++)
3690 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3695 format_gpe_encap_mode (u8 * s, va_list * args)
3697 u32 mode = va_arg (*args, u32);
3702 return format (s, "lisp");
3704 return format (s, "vxlan");
3710 vl_api_gpe_get_encap_mode_reply_t_handler
3711 (vl_api_gpe_get_encap_mode_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3715 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3716 vam->retval = ntohl (mp->retval);
3717 vam->result_ready = 1;
3721 vl_api_gpe_get_encap_mode_reply_t_handler_json
3722 (vl_api_gpe_get_encap_mode_reply_t * mp)
3724 vat_main_t *vam = &vat_main;
3725 vat_json_node_t node;
3727 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3728 vec_add1 (encap_mode, 0);
3730 vat_json_init_object (&node);
3731 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3733 vec_free (encap_mode);
3734 vat_json_print (vam->ofp, &node);
3735 vat_json_free (&node);
3737 vam->retval = ntohl (mp->retval);
3738 vam->result_ready = 1;
3742 vl_api_gpe_fwd_entry_path_details_t_handler
3743 (vl_api_gpe_fwd_entry_path_details_t * mp)
3745 vat_main_t *vam = &vat_main;
3746 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3748 if (mp->lcl_loc.is_ip4)
3749 format_ip_address_fcn = format_ip4_address;
3751 format_ip_address_fcn = format_ip6_address;
3753 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3754 format_ip_address_fcn, &mp->lcl_loc,
3755 format_ip_address_fcn, &mp->rmt_loc);
3759 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3761 struct in6_addr ip6;
3766 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3767 vat_json_object_add_ip4 (n, "address", ip4);
3771 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3772 vat_json_object_add_ip6 (n, "address", ip6);
3774 vat_json_object_add_uint (n, "weight", loc->weight);
3778 vl_api_gpe_fwd_entry_path_details_t_handler_json
3779 (vl_api_gpe_fwd_entry_path_details_t * mp)
3781 vat_main_t *vam = &vat_main;
3782 vat_json_node_t *node = NULL;
3783 vat_json_node_t *loc_node;
3785 if (VAT_JSON_ARRAY != vam->json_tree.type)
3787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3788 vat_json_init_array (&vam->json_tree);
3790 node = vat_json_array_add (&vam->json_tree);
3791 vat_json_init_object (node);
3793 loc_node = vat_json_object_add (node, "local_locator");
3794 vat_json_init_object (loc_node);
3795 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3797 loc_node = vat_json_object_add (node, "remote_locator");
3798 vat_json_init_object (loc_node);
3799 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3803 vl_api_gpe_fwd_entries_get_reply_t_handler
3804 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3808 int retval = clib_net_to_host_u32 (mp->retval);
3809 vl_api_gpe_fwd_entry_t *e;
3814 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3816 for (i = 0; i < mp->count; i++)
3818 e = &mp->entries[i];
3819 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3820 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3821 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3825 vam->retval = retval;
3826 vam->result_ready = 1;
3830 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3831 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3834 vat_main_t *vam = &vat_main;
3835 vat_json_node_t *e = 0, root;
3837 int retval = clib_net_to_host_u32 (mp->retval);
3838 vl_api_gpe_fwd_entry_t *fwd;
3843 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3844 vat_json_init_array (&root);
3846 for (i = 0; i < mp->count; i++)
3848 e = vat_json_array_add (&root);
3849 fwd = &mp->entries[i];
3851 vat_json_init_object (e);
3852 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3853 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3854 vat_json_object_add_int (e, "vni", fwd->vni);
3855 vat_json_object_add_int (e, "action", fwd->action);
3857 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3858 fwd->leid_prefix_len);
3860 vat_json_object_add_string_copy (e, "leid", s);
3863 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3864 fwd->reid_prefix_len);
3866 vat_json_object_add_string_copy (e, "reid", s);
3870 vat_json_print (vam->ofp, &root);
3871 vat_json_free (&root);
3874 vam->retval = retval;
3875 vam->result_ready = 1;
3879 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3880 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3882 vat_main_t *vam = &vat_main;
3884 int retval = clib_net_to_host_u32 (mp->retval);
3885 vl_api_gpe_native_fwd_rpath_t *r;
3890 n = clib_net_to_host_u32 (mp->count);
3892 for (i = 0; i < n; i++)
3894 r = &mp->entries[i];
3895 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3896 clib_net_to_host_u32 (r->fib_index),
3897 clib_net_to_host_u32 (r->nh_sw_if_index),
3898 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3902 vam->retval = retval;
3903 vam->result_ready = 1;
3907 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3908 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3910 vat_main_t *vam = &vat_main;
3911 vat_json_node_t root, *e;
3913 int retval = clib_net_to_host_u32 (mp->retval);
3914 vl_api_gpe_native_fwd_rpath_t *r;
3920 n = clib_net_to_host_u32 (mp->count);
3921 vat_json_init_array (&root);
3923 for (i = 0; i < n; i++)
3925 e = vat_json_array_add (&root);
3926 vat_json_init_object (e);
3927 r = &mp->entries[i];
3929 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3932 vat_json_object_add_string_copy (e, "ip4", s);
3935 vat_json_object_add_uint (e, "fib_index",
3936 clib_net_to_host_u32 (r->fib_index));
3937 vat_json_object_add_uint (e, "nh_sw_if_index",
3938 clib_net_to_host_u32 (r->nh_sw_if_index));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3951 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3960 n = clib_net_to_host_u32 (mp->count);
3962 for (i = 0; i < n; i++)
3963 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3966 vam->retval = retval;
3967 vam->result_ready = 1;
3971 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3972 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3975 vat_json_node_t root;
3977 int retval = clib_net_to_host_u32 (mp->retval);
3982 n = clib_net_to_host_u32 (mp->count);
3983 vat_json_init_array (&root);
3985 for (i = 0; i < n; i++)
3986 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3988 vat_json_print (vam->ofp, &root);
3989 vat_json_free (&root);
3992 vam->retval = retval;
3993 vam->result_ready = 1;
3997 vl_api_one_ndp_entries_get_reply_t_handler
3998 (vl_api_one_ndp_entries_get_reply_t * mp)
4000 vat_main_t *vam = &vat_main;
4002 int retval = clib_net_to_host_u32 (mp->retval);
4007 n = clib_net_to_host_u32 (mp->count);
4009 for (i = 0; i < n; i++)
4010 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
4011 format_ethernet_address, mp->entries[i].mac);
4014 vam->retval = retval;
4015 vam->result_ready = 1;
4019 vl_api_one_ndp_entries_get_reply_t_handler_json
4020 (vl_api_one_ndp_entries_get_reply_t * mp)
4023 vat_main_t *vam = &vat_main;
4024 vat_json_node_t *e = 0, root;
4026 int retval = clib_net_to_host_u32 (mp->retval);
4027 vl_api_one_ndp_entry_t *arp_entry;
4032 n = clib_net_to_host_u32 (mp->count);
4033 vat_json_init_array (&root);
4035 for (i = 0; i < n; i++)
4037 e = vat_json_array_add (&root);
4038 arp_entry = &mp->entries[i];
4040 vat_json_init_object (e);
4041 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4044 vat_json_object_add_string_copy (e, "mac", s);
4047 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4049 vat_json_object_add_string_copy (e, "ip6", s);
4053 vat_json_print (vam->ofp, &root);
4054 vat_json_free (&root);
4057 vam->retval = retval;
4058 vam->result_ready = 1;
4062 vl_api_one_l2_arp_entries_get_reply_t_handler
4063 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4065 vat_main_t *vam = &vat_main;
4067 int retval = clib_net_to_host_u32 (mp->retval);
4072 n = clib_net_to_host_u32 (mp->count);
4074 for (i = 0; i < n; i++)
4075 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4076 format_ethernet_address, mp->entries[i].mac);
4079 vam->retval = retval;
4080 vam->result_ready = 1;
4084 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4085 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4088 vat_main_t *vam = &vat_main;
4089 vat_json_node_t *e = 0, root;
4091 int retval = clib_net_to_host_u32 (mp->retval);
4092 vl_api_one_l2_arp_entry_t *arp_entry;
4097 n = clib_net_to_host_u32 (mp->count);
4098 vat_json_init_array (&root);
4100 for (i = 0; i < n; i++)
4102 e = vat_json_array_add (&root);
4103 arp_entry = &mp->entries[i];
4105 vat_json_init_object (e);
4106 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4109 vat_json_object_add_string_copy (e, "mac", s);
4112 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4114 vat_json_object_add_string_copy (e, "ip4", s);
4118 vat_json_print (vam->ofp, &root);
4119 vat_json_free (&root);
4122 vam->retval = retval;
4123 vam->result_ready = 1;
4127 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4129 vat_main_t *vam = &vat_main;
4131 int retval = clib_net_to_host_u32 (mp->retval);
4136 n = clib_net_to_host_u32 (mp->count);
4138 for (i = 0; i < n; i++)
4140 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4144 vam->retval = retval;
4145 vam->result_ready = 1;
4149 vl_api_one_ndp_bd_get_reply_t_handler_json
4150 (vl_api_one_ndp_bd_get_reply_t * mp)
4152 vat_main_t *vam = &vat_main;
4153 vat_json_node_t root;
4155 int retval = clib_net_to_host_u32 (mp->retval);
4160 n = clib_net_to_host_u32 (mp->count);
4161 vat_json_init_array (&root);
4163 for (i = 0; i < n; i++)
4165 vat_json_array_add_uint (&root,
4166 clib_net_to_host_u32 (mp->bridge_domains[i]));
4169 vat_json_print (vam->ofp, &root);
4170 vat_json_free (&root);
4173 vam->retval = retval;
4174 vam->result_ready = 1;
4178 vl_api_one_l2_arp_bd_get_reply_t_handler
4179 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4181 vat_main_t *vam = &vat_main;
4183 int retval = clib_net_to_host_u32 (mp->retval);
4188 n = clib_net_to_host_u32 (mp->count);
4190 for (i = 0; i < n; i++)
4192 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4196 vam->retval = retval;
4197 vam->result_ready = 1;
4201 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4202 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 vat_json_node_t root;
4207 int retval = clib_net_to_host_u32 (mp->retval);
4212 n = clib_net_to_host_u32 (mp->count);
4213 vat_json_init_array (&root);
4215 for (i = 0; i < n; i++)
4217 vat_json_array_add_uint (&root,
4218 clib_net_to_host_u32 (mp->bridge_domains[i]));
4221 vat_json_print (vam->ofp, &root);
4222 vat_json_free (&root);
4225 vam->retval = retval;
4226 vam->result_ready = 1;
4230 vl_api_one_adjacencies_get_reply_t_handler
4231 (vl_api_one_adjacencies_get_reply_t * mp)
4233 vat_main_t *vam = &vat_main;
4235 int retval = clib_net_to_host_u32 (mp->retval);
4236 vl_api_one_adjacency_t *a;
4241 n = clib_net_to_host_u32 (mp->count);
4243 for (i = 0; i < n; i++)
4245 a = &mp->adjacencies[i];
4246 print (vam->ofp, "%U %40U",
4247 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4248 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4252 vam->retval = retval;
4253 vam->result_ready = 1;
4257 vl_api_one_adjacencies_get_reply_t_handler_json
4258 (vl_api_one_adjacencies_get_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t *e = 0, root;
4264 int retval = clib_net_to_host_u32 (mp->retval);
4265 vl_api_one_adjacency_t *a;
4270 n = clib_net_to_host_u32 (mp->count);
4271 vat_json_init_array (&root);
4273 for (i = 0; i < n; i++)
4275 e = vat_json_array_add (&root);
4276 a = &mp->adjacencies[i];
4278 vat_json_init_object (e);
4279 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4280 a->leid_prefix_len);
4282 vat_json_object_add_string_copy (e, "leid", s);
4285 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4286 a->reid_prefix_len);
4288 vat_json_object_add_string_copy (e, "reid", s);
4292 vat_json_print (vam->ofp, &root);
4293 vat_json_free (&root);
4296 vam->retval = retval;
4297 vam->result_ready = 1;
4301 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4303 vat_main_t *vam = &vat_main;
4305 print (vam->ofp, "%=20U",
4306 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4311 vl_api_one_map_server_details_t_handler_json
4312 (vl_api_one_map_server_details_t * mp)
4314 vat_main_t *vam = &vat_main;
4315 vat_json_node_t *node = NULL;
4316 struct in6_addr ip6;
4319 if (VAT_JSON_ARRAY != vam->json_tree.type)
4321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4322 vat_json_init_array (&vam->json_tree);
4324 node = vat_json_array_add (&vam->json_tree);
4326 vat_json_init_object (node);
4329 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4330 vat_json_object_add_ip6 (node, "map-server", ip6);
4334 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4335 vat_json_object_add_ip4 (node, "map-server", ip4);
4340 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4343 vat_main_t *vam = &vat_main;
4345 print (vam->ofp, "%=20U",
4346 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4351 vl_api_one_map_resolver_details_t_handler_json
4352 (vl_api_one_map_resolver_details_t * mp)
4354 vat_main_t *vam = &vat_main;
4355 vat_json_node_t *node = NULL;
4356 struct in6_addr ip6;
4359 if (VAT_JSON_ARRAY != vam->json_tree.type)
4361 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4362 vat_json_init_array (&vam->json_tree);
4364 node = vat_json_array_add (&vam->json_tree);
4366 vat_json_init_object (node);
4369 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4370 vat_json_object_add_ip6 (node, "map resolver", ip6);
4374 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4375 vat_json_object_add_ip4 (node, "map resolver", ip4);
4380 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4382 vat_main_t *vam = &vat_main;
4383 i32 retval = ntohl (mp->retval);
4387 print (vam->ofp, "feature: %s\ngpe: %s",
4388 mp->feature_status ? "enabled" : "disabled",
4389 mp->gpe_status ? "enabled" : "disabled");
4392 vam->retval = retval;
4393 vam->result_ready = 1;
4397 vl_api_show_one_status_reply_t_handler_json
4398 (vl_api_show_one_status_reply_t * mp)
4400 vat_main_t *vam = &vat_main;
4401 vat_json_node_t node;
4402 u8 *gpe_status = NULL;
4403 u8 *feature_status = NULL;
4405 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4406 feature_status = format (0, "%s",
4407 mp->feature_status ? "enabled" : "disabled");
4408 vec_add1 (gpe_status, 0);
4409 vec_add1 (feature_status, 0);
4411 vat_json_init_object (&node);
4412 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4413 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4415 vec_free (gpe_status);
4416 vec_free (feature_status);
4418 vat_json_print (vam->ofp, &node);
4419 vat_json_free (&node);
4421 vam->retval = ntohl (mp->retval);
4422 vam->result_ready = 1;
4426 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4427 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4429 vat_main_t *vam = &vat_main;
4430 i32 retval = ntohl (mp->retval);
4434 print (vam->ofp, "%=20s", mp->locator_set_name);
4437 vam->retval = retval;
4438 vam->result_ready = 1;
4442 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4443 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4445 vat_main_t *vam = &vat_main;
4446 vat_json_node_t *node = NULL;
4448 if (VAT_JSON_ARRAY != vam->json_tree.type)
4450 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4451 vat_json_init_array (&vam->json_tree);
4453 node = vat_json_array_add (&vam->json_tree);
4455 vat_json_init_object (node);
4456 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4458 vat_json_print (vam->ofp, node);
4459 vat_json_free (node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 format_lisp_map_request_mode (u8 * s, va_list * args)
4468 u32 mode = va_arg (*args, u32);
4473 return format (0, "dst-only");
4475 return format (0, "src-dst");
4481 vl_api_show_one_map_request_mode_reply_t_handler
4482 (vl_api_show_one_map_request_mode_reply_t * mp)
4484 vat_main_t *vam = &vat_main;
4485 i32 retval = ntohl (mp->retval);
4489 u32 mode = mp->mode;
4490 print (vam->ofp, "map_request_mode: %U",
4491 format_lisp_map_request_mode, mode);
4494 vam->retval = retval;
4495 vam->result_ready = 1;
4499 vl_api_show_one_map_request_mode_reply_t_handler_json
4500 (vl_api_show_one_map_request_mode_reply_t * mp)
4502 vat_main_t *vam = &vat_main;
4503 vat_json_node_t node;
4508 s = format (0, "%U", format_lisp_map_request_mode, mode);
4511 vat_json_init_object (&node);
4512 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4513 vat_json_print (vam->ofp, &node);
4514 vat_json_free (&node);
4517 vam->retval = ntohl (mp->retval);
4518 vam->result_ready = 1;
4522 vl_api_one_show_xtr_mode_reply_t_handler
4523 (vl_api_one_show_xtr_mode_reply_t * mp)
4525 vat_main_t *vam = &vat_main;
4526 i32 retval = ntohl (mp->retval);
4530 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4533 vam->retval = retval;
4534 vam->result_ready = 1;
4538 vl_api_one_show_xtr_mode_reply_t_handler_json
4539 (vl_api_one_show_xtr_mode_reply_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 vat_json_node_t node;
4545 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4546 vec_add1 (status, 0);
4548 vat_json_init_object (&node);
4549 vat_json_object_add_string_copy (&node, "status", status);
4553 vat_json_print (vam->ofp, &node);
4554 vat_json_free (&node);
4556 vam->retval = ntohl (mp->retval);
4557 vam->result_ready = 1;
4561 vl_api_one_show_pitr_mode_reply_t_handler
4562 (vl_api_one_show_pitr_mode_reply_t * mp)
4564 vat_main_t *vam = &vat_main;
4565 i32 retval = ntohl (mp->retval);
4569 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4572 vam->retval = retval;
4573 vam->result_ready = 1;
4577 vl_api_one_show_pitr_mode_reply_t_handler_json
4578 (vl_api_one_show_pitr_mode_reply_t * mp)
4580 vat_main_t *vam = &vat_main;
4581 vat_json_node_t node;
4584 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4585 vec_add1 (status, 0);
4587 vat_json_init_object (&node);
4588 vat_json_object_add_string_copy (&node, "status", status);
4592 vat_json_print (vam->ofp, &node);
4593 vat_json_free (&node);
4595 vam->retval = ntohl (mp->retval);
4596 vam->result_ready = 1;
4600 vl_api_one_show_petr_mode_reply_t_handler
4601 (vl_api_one_show_petr_mode_reply_t * mp)
4603 vat_main_t *vam = &vat_main;
4604 i32 retval = ntohl (mp->retval);
4608 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4611 vam->retval = retval;
4612 vam->result_ready = 1;
4616 vl_api_one_show_petr_mode_reply_t_handler_json
4617 (vl_api_one_show_petr_mode_reply_t * mp)
4619 vat_main_t *vam = &vat_main;
4620 vat_json_node_t node;
4623 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4624 vec_add1 (status, 0);
4626 vat_json_init_object (&node);
4627 vat_json_object_add_string_copy (&node, "status", status);
4631 vat_json_print (vam->ofp, &node);
4632 vat_json_free (&node);
4634 vam->retval = ntohl (mp->retval);
4635 vam->result_ready = 1;
4639 vl_api_show_one_use_petr_reply_t_handler
4640 (vl_api_show_one_use_petr_reply_t * mp)
4642 vat_main_t *vam = &vat_main;
4643 i32 retval = ntohl (mp->retval);
4647 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4650 print (vam->ofp, "Proxy-ETR address; %U",
4651 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4656 vam->retval = retval;
4657 vam->result_ready = 1;
4661 vl_api_show_one_use_petr_reply_t_handler_json
4662 (vl_api_show_one_use_petr_reply_t * mp)
4664 vat_main_t *vam = &vat_main;
4665 vat_json_node_t node;
4668 struct in6_addr ip6;
4670 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4671 vec_add1 (status, 0);
4673 vat_json_init_object (&node);
4674 vat_json_object_add_string_copy (&node, "status", status);
4679 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4680 vat_json_object_add_ip6 (&node, "address", ip6);
4684 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4685 vat_json_object_add_ip4 (&node, "address", ip4);
4691 vat_json_print (vam->ofp, &node);
4692 vat_json_free (&node);
4694 vam->retval = ntohl (mp->retval);
4695 vam->result_ready = 1;
4699 vl_api_show_one_nsh_mapping_reply_t_handler
4700 (vl_api_show_one_nsh_mapping_reply_t * mp)
4702 vat_main_t *vam = &vat_main;
4703 i32 retval = ntohl (mp->retval);
4707 print (vam->ofp, "%-20s%-16s",
4708 mp->is_set ? "set" : "not-set",
4709 mp->is_set ? (char *) mp->locator_set_name : "");
4712 vam->retval = retval;
4713 vam->result_ready = 1;
4717 vl_api_show_one_nsh_mapping_reply_t_handler_json
4718 (vl_api_show_one_nsh_mapping_reply_t * mp)
4720 vat_main_t *vam = &vat_main;
4721 vat_json_node_t node;
4724 status = format (0, "%s", mp->is_set ? "yes" : "no");
4725 vec_add1 (status, 0);
4727 vat_json_init_object (&node);
4728 vat_json_object_add_string_copy (&node, "is_set", status);
4731 vat_json_object_add_string_copy (&node, "locator_set",
4732 mp->locator_set_name);
4737 vat_json_print (vam->ofp, &node);
4738 vat_json_free (&node);
4740 vam->retval = ntohl (mp->retval);
4741 vam->result_ready = 1;
4745 vl_api_show_one_map_register_ttl_reply_t_handler
4746 (vl_api_show_one_map_register_ttl_reply_t * mp)
4748 vat_main_t *vam = &vat_main;
4749 i32 retval = ntohl (mp->retval);
4751 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4755 print (vam->ofp, "ttl: %u", mp->ttl);
4758 vam->retval = retval;
4759 vam->result_ready = 1;
4763 vl_api_show_one_map_register_ttl_reply_t_handler_json
4764 (vl_api_show_one_map_register_ttl_reply_t * mp)
4766 vat_main_t *vam = &vat_main;
4767 vat_json_node_t node;
4769 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4770 vat_json_init_object (&node);
4771 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4773 vat_json_print (vam->ofp, &node);
4774 vat_json_free (&node);
4776 vam->retval = ntohl (mp->retval);
4777 vam->result_ready = 1;
4781 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4783 vat_main_t *vam = &vat_main;
4784 i32 retval = ntohl (mp->retval);
4788 print (vam->ofp, "%-20s%-16s",
4789 mp->status ? "enabled" : "disabled",
4790 mp->status ? (char *) mp->locator_set_name : "");
4793 vam->retval = retval;
4794 vam->result_ready = 1;
4798 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4800 vat_main_t *vam = &vat_main;
4801 vat_json_node_t node;
4804 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4805 vec_add1 (status, 0);
4807 vat_json_init_object (&node);
4808 vat_json_object_add_string_copy (&node, "status", status);
4811 vat_json_object_add_string_copy (&node, "locator_set",
4812 mp->locator_set_name);
4817 vat_json_print (vam->ofp, &node);
4818 vat_json_free (&node);
4820 vam->retval = ntohl (mp->retval);
4821 vam->result_ready = 1;
4825 format_policer_type (u8 * s, va_list * va)
4827 u32 i = va_arg (*va, u32);
4829 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4830 s = format (s, "1r2c");
4831 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4832 s = format (s, "1r3c");
4833 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4834 s = format (s, "2r3c-2698");
4835 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4836 s = format (s, "2r3c-4115");
4837 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4838 s = format (s, "2r3c-mef5cf1");
4840 s = format (s, "ILLEGAL");
4845 format_policer_rate_type (u8 * s, va_list * va)
4847 u32 i = va_arg (*va, u32);
4849 if (i == SSE2_QOS_RATE_KBPS)
4850 s = format (s, "kbps");
4851 else if (i == SSE2_QOS_RATE_PPS)
4852 s = format (s, "pps");
4854 s = format (s, "ILLEGAL");
4859 format_policer_round_type (u8 * s, va_list * va)
4861 u32 i = va_arg (*va, u32);
4863 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4864 s = format (s, "closest");
4865 else if (i == SSE2_QOS_ROUND_TO_UP)
4866 s = format (s, "up");
4867 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4868 s = format (s, "down");
4870 s = format (s, "ILLEGAL");
4875 format_policer_action_type (u8 * s, va_list * va)
4877 u32 i = va_arg (*va, u32);
4879 if (i == SSE2_QOS_ACTION_DROP)
4880 s = format (s, "drop");
4881 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4882 s = format (s, "transmit");
4883 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4884 s = format (s, "mark-and-transmit");
4886 s = format (s, "ILLEGAL");
4891 format_dscp (u8 * s, va_list * va)
4893 u32 i = va_arg (*va, u32);
4898 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4902 return format (s, "ILLEGAL");
4904 s = format (s, "%s", t);
4909 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4911 vat_main_t *vam = &vat_main;
4912 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4914 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4915 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4917 conform_dscp_str = format (0, "");
4919 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4920 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4922 exceed_dscp_str = format (0, "");
4924 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4925 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4927 violate_dscp_str = format (0, "");
4929 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4930 "rate type %U, round type %U, %s rate, %s color-aware, "
4931 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4932 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4933 "conform action %U%s, exceed action %U%s, violate action %U%s",
4935 format_policer_type, mp->type,
4938 clib_net_to_host_u64 (mp->cb),
4939 clib_net_to_host_u64 (mp->eb),
4940 format_policer_rate_type, mp->rate_type,
4941 format_policer_round_type, mp->round_type,
4942 mp->single_rate ? "single" : "dual",
4943 mp->color_aware ? "is" : "not",
4944 ntohl (mp->cir_tokens_per_period),
4945 ntohl (mp->pir_tokens_per_period),
4947 ntohl (mp->current_limit),
4948 ntohl (mp->current_bucket),
4949 ntohl (mp->extended_limit),
4950 ntohl (mp->extended_bucket),
4951 clib_net_to_host_u64 (mp->last_update_time),
4952 format_policer_action_type, mp->conform_action_type,
4954 format_policer_action_type, mp->exceed_action_type,
4956 format_policer_action_type, mp->violate_action_type,
4959 vec_free (conform_dscp_str);
4960 vec_free (exceed_dscp_str);
4961 vec_free (violate_dscp_str);
4964 static void vl_api_policer_details_t_handler_json
4965 (vl_api_policer_details_t * mp)
4967 vat_main_t *vam = &vat_main;
4968 vat_json_node_t *node;
4969 u8 *rate_type_str, *round_type_str, *type_str;
4970 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4972 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4974 format (0, "%U", format_policer_round_type, mp->round_type);
4975 type_str = format (0, "%U", format_policer_type, mp->type);
4976 conform_action_str = format (0, "%U", format_policer_action_type,
4977 mp->conform_action_type);
4978 exceed_action_str = format (0, "%U", format_policer_action_type,
4979 mp->exceed_action_type);
4980 violate_action_str = format (0, "%U", format_policer_action_type,
4981 mp->violate_action_type);
4983 if (VAT_JSON_ARRAY != vam->json_tree.type)
4985 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4986 vat_json_init_array (&vam->json_tree);
4988 node = vat_json_array_add (&vam->json_tree);
4990 vat_json_init_object (node);
4991 vat_json_object_add_string_copy (node, "name", mp->name);
4992 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4993 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4994 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4995 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4996 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4997 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4998 vat_json_object_add_string_copy (node, "type", type_str);
4999 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
5000 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
5001 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
5002 vat_json_object_add_uint (node, "cir_tokens_per_period",
5003 ntohl (mp->cir_tokens_per_period));
5004 vat_json_object_add_uint (node, "eir_tokens_per_period",
5005 ntohl (mp->pir_tokens_per_period));
5006 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
5007 vat_json_object_add_uint (node, "current_bucket",
5008 ntohl (mp->current_bucket));
5009 vat_json_object_add_uint (node, "extended_limit",
5010 ntohl (mp->extended_limit));
5011 vat_json_object_add_uint (node, "extended_bucket",
5012 ntohl (mp->extended_bucket));
5013 vat_json_object_add_uint (node, "last_update_time",
5014 ntohl (mp->last_update_time));
5015 vat_json_object_add_string_copy (node, "conform_action",
5016 conform_action_str);
5017 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5019 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
5020 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
5021 vec_free (dscp_str);
5023 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
5024 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5026 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
5027 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
5028 vec_free (dscp_str);
5030 vat_json_object_add_string_copy (node, "violate_action",
5031 violate_action_str);
5032 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
5034 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
5035 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
5036 vec_free (dscp_str);
5039 vec_free (rate_type_str);
5040 vec_free (round_type_str);
5041 vec_free (type_str);
5042 vec_free (conform_action_str);
5043 vec_free (exceed_action_str);
5044 vec_free (violate_action_str);
5048 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5051 vat_main_t *vam = &vat_main;
5052 int i, count = ntohl (mp->count);
5055 print (vam->ofp, "classify table ids (%d) : ", count);
5056 for (i = 0; i < count; i++)
5058 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5059 print (vam->ofp, (i < count - 1) ? "," : "");
5061 vam->retval = ntohl (mp->retval);
5062 vam->result_ready = 1;
5066 vl_api_classify_table_ids_reply_t_handler_json
5067 (vl_api_classify_table_ids_reply_t * mp)
5069 vat_main_t *vam = &vat_main;
5070 int i, count = ntohl (mp->count);
5074 vat_json_node_t node;
5076 vat_json_init_object (&node);
5077 for (i = 0; i < count; i++)
5079 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5081 vat_json_print (vam->ofp, &node);
5082 vat_json_free (&node);
5084 vam->retval = ntohl (mp->retval);
5085 vam->result_ready = 1;
5089 vl_api_classify_table_by_interface_reply_t_handler
5090 (vl_api_classify_table_by_interface_reply_t * mp)
5092 vat_main_t *vam = &vat_main;
5095 table_id = ntohl (mp->l2_table_id);
5097 print (vam->ofp, "l2 table id : %d", table_id);
5099 print (vam->ofp, "l2 table id : No input ACL tables configured");
5100 table_id = ntohl (mp->ip4_table_id);
5102 print (vam->ofp, "ip4 table id : %d", table_id);
5104 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5105 table_id = ntohl (mp->ip6_table_id);
5107 print (vam->ofp, "ip6 table id : %d", table_id);
5109 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5110 vam->retval = ntohl (mp->retval);
5111 vam->result_ready = 1;
5115 vl_api_classify_table_by_interface_reply_t_handler_json
5116 (vl_api_classify_table_by_interface_reply_t * mp)
5118 vat_main_t *vam = &vat_main;
5119 vat_json_node_t node;
5121 vat_json_init_object (&node);
5123 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5124 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5125 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5127 vat_json_print (vam->ofp, &node);
5128 vat_json_free (&node);
5130 vam->retval = ntohl (mp->retval);
5131 vam->result_ready = 1;
5134 static void vl_api_policer_add_del_reply_t_handler
5135 (vl_api_policer_add_del_reply_t * mp)
5137 vat_main_t *vam = &vat_main;
5138 i32 retval = ntohl (mp->retval);
5139 if (vam->async_mode)
5141 vam->async_errors += (retval < 0);
5145 vam->retval = retval;
5146 vam->result_ready = 1;
5147 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5149 * Note: this is just barely thread-safe, depends on
5150 * the main thread spinning waiting for an answer...
5152 errmsg ("policer index %d", ntohl (mp->policer_index));
5156 static void vl_api_policer_add_del_reply_t_handler_json
5157 (vl_api_policer_add_del_reply_t * mp)
5159 vat_main_t *vam = &vat_main;
5160 vat_json_node_t node;
5162 vat_json_init_object (&node);
5163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5164 vat_json_object_add_uint (&node, "policer_index",
5165 ntohl (mp->policer_index));
5167 vat_json_print (vam->ofp, &node);
5168 vat_json_free (&node);
5170 vam->retval = ntohl (mp->retval);
5171 vam->result_ready = 1;
5174 /* Format hex dump. */
5176 format_hex_bytes (u8 * s, va_list * va)
5178 u8 *bytes = va_arg (*va, u8 *);
5179 int n_bytes = va_arg (*va, int);
5182 /* Print short or long form depending on byte count. */
5183 uword short_form = n_bytes <= 32;
5184 u32 indent = format_get_indent (s);
5189 for (i = 0; i < n_bytes; i++)
5191 if (!short_form && (i % 32) == 0)
5192 s = format (s, "%08x: ", i);
5193 s = format (s, "%02x", bytes[i]);
5194 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5195 s = format (s, "\n%U", format_white_space, indent);
5202 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5205 vat_main_t *vam = &vat_main;
5206 i32 retval = ntohl (mp->retval);
5209 print (vam->ofp, "classify table info :");
5210 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5211 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5212 ntohl (mp->miss_next_index));
5213 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5214 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5215 ntohl (mp->match_n_vectors));
5216 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5217 ntohl (mp->mask_length));
5219 vam->retval = retval;
5220 vam->result_ready = 1;
5224 vl_api_classify_table_info_reply_t_handler_json
5225 (vl_api_classify_table_info_reply_t * mp)
5227 vat_main_t *vam = &vat_main;
5228 vat_json_node_t node;
5230 i32 retval = ntohl (mp->retval);
5233 vat_json_init_object (&node);
5235 vat_json_object_add_int (&node, "sessions",
5236 ntohl (mp->active_sessions));
5237 vat_json_object_add_int (&node, "nexttbl",
5238 ntohl (mp->next_table_index));
5239 vat_json_object_add_int (&node, "nextnode",
5240 ntohl (mp->miss_next_index));
5241 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5242 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5243 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5244 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5245 ntohl (mp->mask_length), 0);
5246 vat_json_object_add_string_copy (&node, "mask", s);
5248 vat_json_print (vam->ofp, &node);
5249 vat_json_free (&node);
5251 vam->retval = ntohl (mp->retval);
5252 vam->result_ready = 1;
5256 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5259 vat_main_t *vam = &vat_main;
5261 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5262 ntohl (mp->hit_next_index), ntohl (mp->advance),
5263 ntohl (mp->opaque_index));
5264 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5265 ntohl (mp->match_length));
5269 vl_api_classify_session_details_t_handler_json
5270 (vl_api_classify_session_details_t * mp)
5272 vat_main_t *vam = &vat_main;
5273 vat_json_node_t *node = NULL;
5275 if (VAT_JSON_ARRAY != vam->json_tree.type)
5277 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5278 vat_json_init_array (&vam->json_tree);
5280 node = vat_json_array_add (&vam->json_tree);
5282 vat_json_init_object (node);
5283 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5284 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5285 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5287 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5289 vat_json_object_add_string_copy (node, "match", s);
5292 static void vl_api_pg_create_interface_reply_t_handler
5293 (vl_api_pg_create_interface_reply_t * mp)
5295 vat_main_t *vam = &vat_main;
5297 vam->retval = ntohl (mp->retval);
5298 vam->result_ready = 1;
5301 static void vl_api_pg_create_interface_reply_t_handler_json
5302 (vl_api_pg_create_interface_reply_t * mp)
5304 vat_main_t *vam = &vat_main;
5305 vat_json_node_t node;
5307 i32 retval = ntohl (mp->retval);
5310 vat_json_init_object (&node);
5312 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5314 vat_json_print (vam->ofp, &node);
5315 vat_json_free (&node);
5317 vam->retval = ntohl (mp->retval);
5318 vam->result_ready = 1;
5321 static void vl_api_policer_classify_details_t_handler
5322 (vl_api_policer_classify_details_t * mp)
5324 vat_main_t *vam = &vat_main;
5326 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5327 ntohl (mp->table_index));
5330 static void vl_api_policer_classify_details_t_handler_json
5331 (vl_api_policer_classify_details_t * mp)
5333 vat_main_t *vam = &vat_main;
5334 vat_json_node_t *node;
5336 if (VAT_JSON_ARRAY != vam->json_tree.type)
5338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5339 vat_json_init_array (&vam->json_tree);
5341 node = vat_json_array_add (&vam->json_tree);
5343 vat_json_init_object (node);
5344 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5345 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5348 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5349 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5351 vat_main_t *vam = &vat_main;
5352 i32 retval = ntohl (mp->retval);
5353 if (vam->async_mode)
5355 vam->async_errors += (retval < 0);
5359 vam->retval = retval;
5360 vam->sw_if_index = ntohl (mp->sw_if_index);
5361 vam->result_ready = 1;
5363 vam->regenerate_interface_table = 1;
5366 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5367 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5369 vat_main_t *vam = &vat_main;
5370 vat_json_node_t node;
5372 vat_json_init_object (&node);
5373 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5374 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5376 vat_json_print (vam->ofp, &node);
5377 vat_json_free (&node);
5379 vam->retval = ntohl (mp->retval);
5380 vam->result_ready = 1;
5383 static void vl_api_flow_classify_details_t_handler
5384 (vl_api_flow_classify_details_t * mp)
5386 vat_main_t *vam = &vat_main;
5388 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5389 ntohl (mp->table_index));
5392 static void vl_api_flow_classify_details_t_handler_json
5393 (vl_api_flow_classify_details_t * mp)
5395 vat_main_t *vam = &vat_main;
5396 vat_json_node_t *node;
5398 if (VAT_JSON_ARRAY != vam->json_tree.type)
5400 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5401 vat_json_init_array (&vam->json_tree);
5403 node = vat_json_array_add (&vam->json_tree);
5405 vat_json_init_object (node);
5406 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5407 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5410 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5411 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5412 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5413 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5414 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5415 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5416 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5417 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5418 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5419 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5420 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5421 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5422 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5423 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5424 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5425 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5426 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5427 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5428 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5429 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5430 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5431 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5434 * Generate boilerplate reply handlers, which
5435 * dig the return value out of the xxx_reply_t API message,
5436 * stick it into vam->retval, and set vam->result_ready
5438 * Could also do this by pointing N message decode slots at
5439 * a single function, but that could break in subtle ways.
5442 #define foreach_standard_reply_retval_handler \
5443 _(sw_interface_set_flags_reply) \
5444 _(sw_interface_add_del_address_reply) \
5445 _(sw_interface_set_rx_mode_reply) \
5446 _(sw_interface_set_table_reply) \
5447 _(sw_interface_set_mpls_enable_reply) \
5448 _(sw_interface_set_vpath_reply) \
5449 _(sw_interface_set_vxlan_bypass_reply) \
5450 _(sw_interface_set_geneve_bypass_reply) \
5451 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5452 _(sw_interface_set_l2_bridge_reply) \
5453 _(bridge_domain_add_del_reply) \
5454 _(sw_interface_set_l2_xconnect_reply) \
5455 _(l2fib_add_del_reply) \
5456 _(l2fib_flush_int_reply) \
5457 _(l2fib_flush_bd_reply) \
5458 _(ip_add_del_route_reply) \
5459 _(ip_table_add_del_reply) \
5460 _(ip_mroute_add_del_reply) \
5461 _(mpls_route_add_del_reply) \
5462 _(mpls_table_add_del_reply) \
5463 _(mpls_ip_bind_unbind_reply) \
5464 _(bier_route_add_del_reply) \
5465 _(bier_table_add_del_reply) \
5466 _(proxy_arp_add_del_reply) \
5467 _(proxy_arp_intfc_enable_disable_reply) \
5468 _(sw_interface_set_unnumbered_reply) \
5469 _(ip_neighbor_add_del_reply) \
5470 _(oam_add_del_reply) \
5471 _(reset_fib_reply) \
5472 _(dhcp_proxy_config_reply) \
5473 _(dhcp_proxy_set_vss_reply) \
5474 _(dhcp_client_config_reply) \
5475 _(set_ip_flow_hash_reply) \
5476 _(sw_interface_ip6_enable_disable_reply) \
5477 _(sw_interface_ip6_set_link_local_address_reply) \
5478 _(ip6nd_proxy_add_del_reply) \
5479 _(sw_interface_ip6nd_ra_prefix_reply) \
5480 _(sw_interface_ip6nd_ra_config_reply) \
5481 _(set_arp_neighbor_limit_reply) \
5482 _(l2_patch_add_del_reply) \
5483 _(sr_policy_add_reply) \
5484 _(sr_policy_mod_reply) \
5485 _(sr_policy_del_reply) \
5486 _(sr_localsid_add_del_reply) \
5487 _(sr_steering_add_del_reply) \
5488 _(classify_add_del_session_reply) \
5489 _(classify_set_interface_ip_table_reply) \
5490 _(classify_set_interface_l2_tables_reply) \
5491 _(l2tpv3_set_tunnel_cookies_reply) \
5492 _(l2tpv3_interface_enable_disable_reply) \
5493 _(l2tpv3_set_lookup_key_reply) \
5494 _(l2_fib_clear_table_reply) \
5495 _(l2_interface_efp_filter_reply) \
5496 _(l2_interface_vlan_tag_rewrite_reply) \
5497 _(modify_vhost_user_if_reply) \
5498 _(delete_vhost_user_if_reply) \
5499 _(ip_probe_neighbor_reply) \
5500 _(ip_scan_neighbor_enable_disable_reply) \
5501 _(want_ip4_arp_events_reply) \
5502 _(want_ip6_nd_events_reply) \
5503 _(want_l2_macs_events_reply) \
5504 _(input_acl_set_interface_reply) \
5505 _(ipsec_spd_add_del_reply) \
5506 _(ipsec_interface_add_del_spd_reply) \
5507 _(ipsec_spd_add_del_entry_reply) \
5508 _(ipsec_sad_add_del_entry_reply) \
5509 _(ipsec_sa_set_key_reply) \
5510 _(ipsec_tunnel_if_add_del_reply) \
5511 _(ipsec_tunnel_if_set_key_reply) \
5512 _(ipsec_tunnel_if_set_sa_reply) \
5513 _(ikev2_profile_add_del_reply) \
5514 _(ikev2_profile_set_auth_reply) \
5515 _(ikev2_profile_set_id_reply) \
5516 _(ikev2_profile_set_ts_reply) \
5517 _(ikev2_set_local_key_reply) \
5518 _(ikev2_set_responder_reply) \
5519 _(ikev2_set_ike_transforms_reply) \
5520 _(ikev2_set_esp_transforms_reply) \
5521 _(ikev2_set_sa_lifetime_reply) \
5522 _(ikev2_initiate_sa_init_reply) \
5523 _(ikev2_initiate_del_ike_sa_reply) \
5524 _(ikev2_initiate_del_child_sa_reply) \
5525 _(ikev2_initiate_rekey_child_sa_reply) \
5526 _(delete_loopback_reply) \
5527 _(bd_ip_mac_add_del_reply) \
5528 _(map_del_domain_reply) \
5529 _(map_add_del_rule_reply) \
5530 _(want_interface_events_reply) \
5531 _(want_stats_reply) \
5532 _(cop_interface_enable_disable_reply) \
5533 _(cop_whitelist_enable_disable_reply) \
5534 _(sw_interface_clear_stats_reply) \
5535 _(ioam_enable_reply) \
5536 _(ioam_disable_reply) \
5537 _(one_add_del_locator_reply) \
5538 _(one_add_del_local_eid_reply) \
5539 _(one_add_del_remote_mapping_reply) \
5540 _(one_add_del_adjacency_reply) \
5541 _(one_add_del_map_resolver_reply) \
5542 _(one_add_del_map_server_reply) \
5543 _(one_enable_disable_reply) \
5544 _(one_rloc_probe_enable_disable_reply) \
5545 _(one_map_register_enable_disable_reply) \
5546 _(one_map_register_set_ttl_reply) \
5547 _(one_set_transport_protocol_reply) \
5548 _(one_map_register_fallback_threshold_reply) \
5549 _(one_pitr_set_locator_set_reply) \
5550 _(one_map_request_mode_reply) \
5551 _(one_add_del_map_request_itr_rlocs_reply) \
5552 _(one_eid_table_add_del_map_reply) \
5553 _(one_use_petr_reply) \
5554 _(one_stats_enable_disable_reply) \
5555 _(one_add_del_l2_arp_entry_reply) \
5556 _(one_add_del_ndp_entry_reply) \
5557 _(one_stats_flush_reply) \
5558 _(one_enable_disable_xtr_mode_reply) \
5559 _(one_enable_disable_pitr_mode_reply) \
5560 _(one_enable_disable_petr_mode_reply) \
5561 _(gpe_enable_disable_reply) \
5562 _(gpe_set_encap_mode_reply) \
5563 _(gpe_add_del_iface_reply) \
5564 _(gpe_add_del_native_fwd_rpath_reply) \
5565 _(af_packet_delete_reply) \
5566 _(policer_classify_set_interface_reply) \
5567 _(netmap_create_reply) \
5568 _(netmap_delete_reply) \
5569 _(set_ipfix_exporter_reply) \
5570 _(set_ipfix_classify_stream_reply) \
5571 _(ipfix_classify_table_add_del_reply) \
5572 _(flow_classify_set_interface_reply) \
5573 _(sw_interface_span_enable_disable_reply) \
5574 _(pg_capture_reply) \
5575 _(pg_enable_disable_reply) \
5576 _(ip_source_and_port_range_check_add_del_reply) \
5577 _(ip_source_and_port_range_check_interface_add_del_reply)\
5578 _(delete_subif_reply) \
5579 _(l2_interface_pbb_tag_rewrite_reply) \
5581 _(feature_enable_disable_reply) \
5582 _(sw_interface_tag_add_del_reply) \
5583 _(hw_interface_set_mtu_reply) \
5584 _(p2p_ethernet_add_reply) \
5585 _(p2p_ethernet_del_reply) \
5586 _(lldp_config_reply) \
5587 _(sw_interface_set_lldp_reply) \
5588 _(tcp_configure_src_addresses_reply) \
5589 _(dns_enable_disable_reply) \
5590 _(dns_name_server_add_del_reply) \
5591 _(session_rule_add_del_reply) \
5592 _(ip_container_proxy_add_del_reply) \
5593 _(output_acl_set_interface_reply) \
5594 _(qos_record_enable_disable_reply)
5597 static void vl_api_##n##_t_handler \
5598 (vl_api_##n##_t * mp) \
5600 vat_main_t * vam = &vat_main; \
5601 i32 retval = ntohl(mp->retval); \
5602 if (vam->async_mode) { \
5603 vam->async_errors += (retval < 0); \
5605 vam->retval = retval; \
5606 vam->result_ready = 1; \
5609 foreach_standard_reply_retval_handler;
5613 static void vl_api_##n##_t_handler_json \
5614 (vl_api_##n##_t * mp) \
5616 vat_main_t * vam = &vat_main; \
5617 vat_json_node_t node; \
5618 vat_json_init_object(&node); \
5619 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5620 vat_json_print(vam->ofp, &node); \
5621 vam->retval = ntohl(mp->retval); \
5622 vam->result_ready = 1; \
5624 foreach_standard_reply_retval_handler;
5628 * Table of message reply handlers, must include boilerplate handlers
5632 #define foreach_vpe_api_reply_msg \
5633 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5634 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5635 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5636 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5637 _(CONTROL_PING_REPLY, control_ping_reply) \
5638 _(CLI_REPLY, cli_reply) \
5639 _(CLI_INBAND_REPLY, cli_inband_reply) \
5640 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5641 sw_interface_add_del_address_reply) \
5642 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5643 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5644 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5645 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5646 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5647 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5648 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5649 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5650 sw_interface_set_l2_xconnect_reply) \
5651 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5652 sw_interface_set_l2_bridge_reply) \
5653 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5654 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5655 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5656 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5657 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5658 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5659 _(L2_FLAGS_REPLY, l2_flags_reply) \
5660 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5661 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5662 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5663 _(TAP_DELETE_REPLY, tap_delete_reply) \
5664 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5665 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5666 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5667 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5668 _(BOND_CREATE_REPLY, bond_create_reply) \
5669 _(BOND_DELETE_REPLY, bond_delete_reply) \
5670 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5671 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5672 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5673 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5674 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5675 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5676 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5677 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5678 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5679 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5680 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5681 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5682 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5683 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5684 proxy_arp_intfc_enable_disable_reply) \
5685 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5686 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5687 sw_interface_set_unnumbered_reply) \
5688 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5689 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5690 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5691 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5692 _(RESET_FIB_REPLY, reset_fib_reply) \
5693 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5694 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5695 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5696 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5697 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5698 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5699 sw_interface_ip6_enable_disable_reply) \
5700 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5701 sw_interface_ip6_set_link_local_address_reply) \
5702 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5703 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5704 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5705 sw_interface_ip6nd_ra_prefix_reply) \
5706 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5707 sw_interface_ip6nd_ra_config_reply) \
5708 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5709 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5710 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5711 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5712 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5713 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5714 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5715 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5716 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5717 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5718 classify_set_interface_ip_table_reply) \
5719 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5720 classify_set_interface_l2_tables_reply) \
5721 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5722 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5723 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5724 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5725 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5726 l2tpv3_interface_enable_disable_reply) \
5727 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5728 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5729 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5730 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5731 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5732 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5733 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5734 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5735 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5736 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5737 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5738 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5739 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5740 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5741 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5742 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5743 _(SHOW_VERSION_REPLY, show_version_reply) \
5744 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5745 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5746 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5747 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5748 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5749 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5750 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5751 _(IP4_ARP_EVENT, ip4_arp_event) \
5752 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5753 _(IP6_ND_EVENT, ip6_nd_event) \
5754 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5755 _(L2_MACS_EVENT, l2_macs_event) \
5756 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5757 _(IP_ADDRESS_DETAILS, ip_address_details) \
5758 _(IP_DETAILS, ip_details) \
5759 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5760 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5761 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5762 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5763 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5764 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5765 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5766 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5767 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5768 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5769 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5770 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5771 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5772 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5773 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5774 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5775 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5776 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5777 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5778 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5779 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5780 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5781 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5782 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5783 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5784 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5785 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5786 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5787 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5788 _(MAP_RULE_DETAILS, map_rule_details) \
5789 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5790 _(WANT_STATS_REPLY, want_stats_reply) \
5791 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5792 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5793 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5794 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5795 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5796 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5797 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5798 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5799 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5800 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5801 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5802 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5803 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5804 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5805 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5806 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5807 one_map_register_enable_disable_reply) \
5808 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5809 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5810 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5811 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5812 one_map_register_fallback_threshold_reply) \
5813 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5814 one_rloc_probe_enable_disable_reply) \
5815 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5816 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5817 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5818 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5819 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5820 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5821 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5822 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5823 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5824 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5825 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5826 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5827 _(ONE_STATS_DETAILS, one_stats_details) \
5828 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5829 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5830 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5831 show_one_stats_enable_disable_reply) \
5832 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5833 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5834 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5835 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5836 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5837 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5838 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5839 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5840 one_enable_disable_pitr_mode_reply) \
5841 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5842 one_enable_disable_petr_mode_reply) \
5843 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5844 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5845 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5846 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5847 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5848 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5849 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5850 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5851 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5852 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5853 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5854 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5855 gpe_add_del_native_fwd_rpath_reply) \
5856 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5857 gpe_fwd_entry_path_details) \
5858 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5859 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5860 one_add_del_map_request_itr_rlocs_reply) \
5861 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5862 one_get_map_request_itr_rlocs_reply) \
5863 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5864 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5865 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5866 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5867 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5868 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5869 show_one_map_register_state_reply) \
5870 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5871 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5872 show_one_map_register_fallback_threshold_reply) \
5873 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5874 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5875 _(AF_PACKET_DETAILS, af_packet_details) \
5876 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5877 _(POLICER_DETAILS, policer_details) \
5878 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5879 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5880 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5881 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5882 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5883 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5884 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5885 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5886 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5887 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5888 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5889 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5890 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5891 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5892 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5893 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5894 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5895 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5896 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5897 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5898 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5899 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5900 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5901 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5902 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5903 ip_source_and_port_range_check_add_del_reply) \
5904 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5905 ip_source_and_port_range_check_interface_add_del_reply) \
5906 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5907 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5908 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5909 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5910 _(PUNT_REPLY, punt_reply) \
5911 _(IP_FIB_DETAILS, ip_fib_details) \
5912 _(IP6_FIB_DETAILS, ip6_fib_details) \
5913 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5914 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5915 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5916 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5917 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5918 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5919 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5920 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5921 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5922 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5923 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5924 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5925 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5926 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5927 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5928 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5929 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5930 _(SESSION_RULES_DETAILS, session_rules_details) \
5931 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5932 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5933 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
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 nh_addr6;
10762 ip4_address_t nh_addr4;
10763 memset (&nh_addr6, 0, sizeof (ip6_address_t));
10764 memset (&nh_addr4, 0, sizeof (ip4_address_t));
10766 bool nexthop_set = 0;
10770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10772 if (unformat (i, "del"))
10774 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10775 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10777 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10779 else if (unformat (i, "behavior %u", &behavior));
10780 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10781 else if (unformat (i, "fib-table %u", &fib_table));
10782 else if (unformat (i, "end.psp %u", &behavior));
10787 M (SR_LOCALSID_ADD_DEL, mp);
10789 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10792 clib_memcpy (mp->nh_addr6, &nh_addr4, sizeof (mp->nh_addr6));
10793 clib_memcpy (mp->nh_addr4, &nh_addr6, sizeof (mp->nh_addr4));
10795 mp->behavior = behavior;
10796 mp->sw_if_index = ntohl (sw_if_index);
10797 mp->fib_table = ntohl (fib_table);
10798 mp->end_psp = end_psp;
10799 mp->is_del = is_del;
10807 api_ioam_enable (vat_main_t * vam)
10809 unformat_input_t *input = vam->input;
10810 vl_api_ioam_enable_t *mp;
10812 int has_trace_option = 0;
10813 int has_pot_option = 0;
10814 int has_seqno_option = 0;
10815 int has_analyse_option = 0;
10818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10820 if (unformat (input, "trace"))
10821 has_trace_option = 1;
10822 else if (unformat (input, "pot"))
10823 has_pot_option = 1;
10824 else if (unformat (input, "seqno"))
10825 has_seqno_option = 1;
10826 else if (unformat (input, "analyse"))
10827 has_analyse_option = 1;
10831 M (IOAM_ENABLE, mp);
10832 mp->id = htons (id);
10833 mp->seqno = has_seqno_option;
10834 mp->analyse = has_analyse_option;
10835 mp->pot_enable = has_pot_option;
10836 mp->trace_enable = has_trace_option;
10845 api_ioam_disable (vat_main_t * vam)
10847 vl_api_ioam_disable_t *mp;
10850 M (IOAM_DISABLE, mp);
10856 #define foreach_tcp_proto_field \
10860 #define foreach_udp_proto_field \
10864 #define foreach_ip4_proto_field \
10876 u16 src_port, dst_port;
10879 #if VPP_API_TEST_BUILTIN == 0
10881 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10883 u8 **maskp = va_arg (*args, u8 **);
10885 u8 found_something = 0;
10888 #define _(a) u8 a=0;
10889 foreach_tcp_proto_field;
10892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10895 #define _(a) else if (unformat (input, #a)) a=1;
10896 foreach_tcp_proto_field
10902 #define _(a) found_something += a;
10903 foreach_tcp_proto_field;
10906 if (found_something == 0)
10909 vec_validate (mask, sizeof (*tcp) - 1);
10911 tcp = (tcp_header_t *) mask;
10913 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10914 foreach_tcp_proto_field;
10922 unformat_udp_mask (unformat_input_t * input, va_list * args)
10924 u8 **maskp = va_arg (*args, u8 **);
10926 u8 found_something = 0;
10929 #define _(a) u8 a=0;
10930 foreach_udp_proto_field;
10933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10936 #define _(a) else if (unformat (input, #a)) a=1;
10937 foreach_udp_proto_field
10943 #define _(a) found_something += a;
10944 foreach_udp_proto_field;
10947 if (found_something == 0)
10950 vec_validate (mask, sizeof (*udp) - 1);
10952 udp = (udp_header_t *) mask;
10954 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10955 foreach_udp_proto_field;
10963 unformat_l4_mask (unformat_input_t * input, va_list * args)
10965 u8 **maskp = va_arg (*args, u8 **);
10966 u16 src_port = 0, dst_port = 0;
10967 tcpudp_header_t *tcpudp;
10969 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10971 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10973 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10975 else if (unformat (input, "src_port"))
10977 else if (unformat (input, "dst_port"))
10983 if (!src_port && !dst_port)
10987 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10989 tcpudp = (tcpudp_header_t *) mask;
10990 tcpudp->src_port = src_port;
10991 tcpudp->dst_port = dst_port;
10999 unformat_ip4_mask (unformat_input_t * input, va_list * args)
11001 u8 **maskp = va_arg (*args, u8 **);
11003 u8 found_something = 0;
11006 #define _(a) u8 a=0;
11007 foreach_ip4_proto_field;
11013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11015 if (unformat (input, "version"))
11017 else if (unformat (input, "hdr_length"))
11019 else if (unformat (input, "src"))
11021 else if (unformat (input, "dst"))
11023 else if (unformat (input, "proto"))
11026 #define _(a) else if (unformat (input, #a)) a=1;
11027 foreach_ip4_proto_field
11033 #define _(a) found_something += a;
11034 foreach_ip4_proto_field;
11037 if (found_something == 0)
11040 vec_validate (mask, sizeof (*ip) - 1);
11042 ip = (ip4_header_t *) mask;
11044 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11045 foreach_ip4_proto_field;
11048 ip->ip_version_and_header_length = 0;
11051 ip->ip_version_and_header_length |= 0xF0;
11054 ip->ip_version_and_header_length |= 0x0F;
11060 #define foreach_ip6_proto_field \
11063 _(payload_length) \
11068 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11070 u8 **maskp = va_arg (*args, u8 **);
11072 u8 found_something = 0;
11074 u32 ip_version_traffic_class_and_flow_label;
11076 #define _(a) u8 a=0;
11077 foreach_ip6_proto_field;
11080 u8 traffic_class = 0;
11083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11085 if (unformat (input, "version"))
11087 else if (unformat (input, "traffic-class"))
11089 else if (unformat (input, "flow-label"))
11091 else if (unformat (input, "src"))
11093 else if (unformat (input, "dst"))
11095 else if (unformat (input, "proto"))
11098 #define _(a) else if (unformat (input, #a)) a=1;
11099 foreach_ip6_proto_field
11105 #define _(a) found_something += a;
11106 foreach_ip6_proto_field;
11109 if (found_something == 0)
11112 vec_validate (mask, sizeof (*ip) - 1);
11114 ip = (ip6_header_t *) mask;
11116 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11117 foreach_ip6_proto_field;
11120 ip_version_traffic_class_and_flow_label = 0;
11123 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11126 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11129 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11131 ip->ip_version_traffic_class_and_flow_label =
11132 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11139 unformat_l3_mask (unformat_input_t * input, va_list * args)
11141 u8 **maskp = va_arg (*args, u8 **);
11143 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11145 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11147 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11156 unformat_l2_mask (unformat_input_t * input, va_list * args)
11158 u8 **maskp = va_arg (*args, u8 **);
11165 u8 ignore_tag1 = 0;
11166 u8 ignore_tag2 = 0;
11173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11175 if (unformat (input, "src"))
11177 else if (unformat (input, "dst"))
11179 else if (unformat (input, "proto"))
11181 else if (unformat (input, "tag1"))
11183 else if (unformat (input, "tag2"))
11185 else if (unformat (input, "ignore-tag1"))
11187 else if (unformat (input, "ignore-tag2"))
11189 else if (unformat (input, "cos1"))
11191 else if (unformat (input, "cos2"))
11193 else if (unformat (input, "dot1q"))
11195 else if (unformat (input, "dot1ad"))
11200 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11201 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11204 if (tag1 || ignore_tag1 || cos1 || dot1q)
11206 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11209 vec_validate (mask, len - 1);
11212 memset (mask, 0xff, 6);
11215 memset (mask + 6, 0xff, 6);
11217 if (tag2 || dot1ad)
11219 /* inner vlan tag */
11228 mask[21] = mask[20] = 0xff;
11249 mask[16] = mask[17] = 0xff;
11259 mask[12] = mask[13] = 0xff;
11266 unformat_classify_mask (unformat_input_t * input, va_list * args)
11268 u8 **maskp = va_arg (*args, u8 **);
11269 u32 *skipp = va_arg (*args, u32 *);
11270 u32 *matchp = va_arg (*args, u32 *);
11278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11280 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11282 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11284 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11286 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11300 if (mask || l2 || l3 || l4)
11302 if (l2 || l3 || l4)
11304 /* "With a free Ethernet header in every package" */
11306 vec_validate (l2, 13);
11310 vec_append (mask, l3);
11315 vec_append (mask, l4);
11320 /* Scan forward looking for the first significant mask octet */
11321 for (i = 0; i < vec_len (mask); i++)
11325 /* compute (skip, match) params */
11326 *skipp = i / sizeof (u32x4);
11327 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11329 /* Pad mask to an even multiple of the vector size */
11330 while (vec_len (mask) % sizeof (u32x4))
11331 vec_add1 (mask, 0);
11333 match = vec_len (mask) / sizeof (u32x4);
11335 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11337 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11338 if (*tmp || *(tmp + 1))
11343 clib_warning ("BUG: match 0");
11345 _vec_len (mask) = match * sizeof (u32x4);
11355 #endif /* VPP_API_TEST_BUILTIN */
11357 #define foreach_l2_next \
11359 _(ethernet, ETHERNET_INPUT) \
11360 _(ip4, IP4_INPUT) \
11364 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11366 u32 *miss_next_indexp = va_arg (*args, u32 *);
11367 u32 next_index = 0;
11371 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11375 if (unformat (input, "%d", &tmp))
11384 *miss_next_indexp = next_index;
11388 #define foreach_ip_next \
11391 _(rewrite, REWRITE)
11394 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11396 u32 *miss_next_indexp = va_arg (*args, u32 *);
11397 u32 next_index = 0;
11401 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11405 if (unformat (input, "%d", &tmp))
11414 *miss_next_indexp = next_index;
11418 #define foreach_acl_next \
11422 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11424 u32 *miss_next_indexp = va_arg (*args, u32 *);
11425 u32 next_index = 0;
11429 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11433 if (unformat (input, "permit"))
11438 else if (unformat (input, "%d", &tmp))
11447 *miss_next_indexp = next_index;
11452 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11454 u32 *r = va_arg (*args, u32 *);
11456 if (unformat (input, "conform-color"))
11457 *r = POLICE_CONFORM;
11458 else if (unformat (input, "exceed-color"))
11459 *r = POLICE_EXCEED;
11467 api_classify_add_del_table (vat_main_t * vam)
11469 unformat_input_t *i = vam->input;
11470 vl_api_classify_add_del_table_t *mp;
11477 u32 table_index = ~0;
11478 u32 next_table_index = ~0;
11479 u32 miss_next_index = ~0;
11480 u32 memory_size = 32 << 20;
11482 u32 current_data_flag = 0;
11483 int current_data_offset = 0;
11486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11488 if (unformat (i, "del"))
11490 else if (unformat (i, "del-chain"))
11495 else if (unformat (i, "buckets %d", &nbuckets))
11497 else if (unformat (i, "memory_size %d", &memory_size))
11499 else if (unformat (i, "skip %d", &skip))
11501 else if (unformat (i, "match %d", &match))
11503 else if (unformat (i, "table %d", &table_index))
11505 else if (unformat (i, "mask %U", unformat_classify_mask,
11506 &mask, &skip, &match))
11508 else if (unformat (i, "next-table %d", &next_table_index))
11510 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11513 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11516 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11519 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11521 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11527 if (is_add && mask == 0)
11529 errmsg ("Mask required");
11533 if (is_add && skip == ~0)
11535 errmsg ("skip count required");
11539 if (is_add && match == ~0)
11541 errmsg ("match count required");
11545 if (!is_add && table_index == ~0)
11547 errmsg ("table index required for delete");
11551 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11553 mp->is_add = is_add;
11554 mp->del_chain = del_chain;
11555 mp->table_index = ntohl (table_index);
11556 mp->nbuckets = ntohl (nbuckets);
11557 mp->memory_size = ntohl (memory_size);
11558 mp->skip_n_vectors = ntohl (skip);
11559 mp->match_n_vectors = ntohl (match);
11560 mp->next_table_index = ntohl (next_table_index);
11561 mp->miss_next_index = ntohl (miss_next_index);
11562 mp->current_data_flag = ntohl (current_data_flag);
11563 mp->current_data_offset = ntohl (current_data_offset);
11564 clib_memcpy (mp->mask, mask, vec_len (mask));
11573 #if VPP_API_TEST_BUILTIN == 0
11575 unformat_l4_match (unformat_input_t * input, va_list * args)
11577 u8 **matchp = va_arg (*args, u8 **);
11579 u8 *proto_header = 0;
11585 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11587 if (unformat (input, "src_port %d", &src_port))
11589 else if (unformat (input, "dst_port %d", &dst_port))
11595 h.src_port = clib_host_to_net_u16 (src_port);
11596 h.dst_port = clib_host_to_net_u16 (dst_port);
11597 vec_validate (proto_header, sizeof (h) - 1);
11598 memcpy (proto_header, &h, sizeof (h));
11600 *matchp = proto_header;
11606 unformat_ip4_match (unformat_input_t * input, va_list * args)
11608 u8 **matchp = va_arg (*args, u8 **);
11613 int hdr_length = 0;
11614 u32 hdr_length_val;
11615 int src = 0, dst = 0;
11616 ip4_address_t src_val, dst_val;
11623 int fragment_id = 0;
11624 u32 fragment_id_val;
11630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11632 if (unformat (input, "version %d", &version_val))
11634 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11636 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11638 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11640 else if (unformat (input, "proto %d", &proto_val))
11642 else if (unformat (input, "tos %d", &tos_val))
11644 else if (unformat (input, "length %d", &length_val))
11646 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11648 else if (unformat (input, "ttl %d", &ttl_val))
11650 else if (unformat (input, "checksum %d", &checksum_val))
11656 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11657 + ttl + checksum == 0)
11661 * Aligned because we use the real comparison functions
11663 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11665 ip = (ip4_header_t *) match;
11667 /* These are realistically matched in practice */
11669 ip->src_address.as_u32 = src_val.as_u32;
11672 ip->dst_address.as_u32 = dst_val.as_u32;
11675 ip->protocol = proto_val;
11678 /* These are not, but they're included for completeness */
11680 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11683 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11689 ip->length = clib_host_to_net_u16 (length_val);
11695 ip->checksum = clib_host_to_net_u16 (checksum_val);
11702 unformat_ip6_match (unformat_input_t * input, va_list * args)
11704 u8 **matchp = va_arg (*args, u8 **);
11709 u8 traffic_class = 0;
11710 u32 traffic_class_val = 0;
11713 int src = 0, dst = 0;
11714 ip6_address_t src_val, dst_val;
11717 int payload_length = 0;
11718 u32 payload_length_val;
11721 u32 ip_version_traffic_class_and_flow_label;
11723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11725 if (unformat (input, "version %d", &version_val))
11727 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11729 else if (unformat (input, "flow_label %d", &flow_label_val))
11731 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11733 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11735 else if (unformat (input, "proto %d", &proto_val))
11737 else if (unformat (input, "payload_length %d", &payload_length_val))
11738 payload_length = 1;
11739 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11745 if (version + traffic_class + flow_label + src + dst + proto +
11746 payload_length + hop_limit == 0)
11750 * Aligned because we use the real comparison functions
11752 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11754 ip = (ip6_header_t *) match;
11757 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11760 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11763 ip->protocol = proto_val;
11765 ip_version_traffic_class_and_flow_label = 0;
11768 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11771 ip_version_traffic_class_and_flow_label |=
11772 (traffic_class_val & 0xFF) << 20;
11775 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11777 ip->ip_version_traffic_class_and_flow_label =
11778 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11780 if (payload_length)
11781 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11784 ip->hop_limit = hop_limit_val;
11791 unformat_l3_match (unformat_input_t * input, va_list * args)
11793 u8 **matchp = va_arg (*args, u8 **);
11795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11797 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11799 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11808 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11810 u8 *tagp = va_arg (*args, u8 *);
11813 if (unformat (input, "%d", &tag))
11815 tagp[0] = (tag >> 8) & 0x0F;
11816 tagp[1] = tag & 0xFF;
11824 unformat_l2_match (unformat_input_t * input, va_list * args)
11826 u8 **matchp = va_arg (*args, u8 **);
11839 u8 ignore_tag1 = 0;
11840 u8 ignore_tag2 = 0;
11846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11848 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11851 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11853 else if (unformat (input, "proto %U",
11854 unformat_ethernet_type_host_byte_order, &proto_val))
11856 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11858 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11860 else if (unformat (input, "ignore-tag1"))
11862 else if (unformat (input, "ignore-tag2"))
11864 else if (unformat (input, "cos1 %d", &cos1_val))
11866 else if (unformat (input, "cos2 %d", &cos2_val))
11871 if ((src + dst + proto + tag1 + tag2 +
11872 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11875 if (tag1 || ignore_tag1 || cos1)
11877 if (tag2 || ignore_tag2 || cos2)
11880 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11883 clib_memcpy (match, dst_val, 6);
11886 clib_memcpy (match + 6, src_val, 6);
11890 /* inner vlan tag */
11891 match[19] = tag2_val[1];
11892 match[18] = tag2_val[0];
11894 match[18] |= (cos2_val & 0x7) << 5;
11897 match[21] = proto_val & 0xff;
11898 match[20] = proto_val >> 8;
11902 match[15] = tag1_val[1];
11903 match[14] = tag1_val[0];
11906 match[14] |= (cos1_val & 0x7) << 5;
11912 match[15] = tag1_val[1];
11913 match[14] = tag1_val[0];
11916 match[17] = proto_val & 0xff;
11917 match[16] = proto_val >> 8;
11920 match[14] |= (cos1_val & 0x7) << 5;
11926 match[18] |= (cos2_val & 0x7) << 5;
11928 match[14] |= (cos1_val & 0x7) << 5;
11931 match[13] = proto_val & 0xff;
11932 match[12] = proto_val >> 8;
11940 unformat_qos_source (unformat_input_t * input, va_list * args)
11942 int *qs = va_arg (*args, int *);
11944 if (unformat (input, "ip"))
11945 *qs = QOS_SOURCE_IP;
11946 else if (unformat (input, "mpls"))
11947 *qs = QOS_SOURCE_MPLS;
11948 else if (unformat (input, "ext"))
11949 *qs = QOS_SOURCE_EXT;
11950 else if (unformat (input, "vlan"))
11951 *qs = QOS_SOURCE_VLAN;
11960 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11962 u8 **matchp = va_arg (*args, u8 **);
11963 u32 skip_n_vectors = va_arg (*args, u32);
11964 u32 match_n_vectors = va_arg (*args, u32);
11971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11973 if (unformat (input, "hex %U", unformat_hex_string, &match))
11975 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11977 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11979 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11993 if (match || l2 || l3 || l4)
11995 if (l2 || l3 || l4)
11997 /* "Win a free Ethernet header in every packet" */
11999 vec_validate_aligned (l2, 13, sizeof (u32x4));
12003 vec_append_aligned (match, l3, sizeof (u32x4));
12008 vec_append_aligned (match, l4, sizeof (u32x4));
12013 /* Make sure the vector is big enough even if key is all 0's */
12014 vec_validate_aligned
12015 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
12018 /* Set size, include skipped vectors */
12019 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
12030 api_classify_add_del_session (vat_main_t * vam)
12032 unformat_input_t *i = vam->input;
12033 vl_api_classify_add_del_session_t *mp;
12035 u32 table_index = ~0;
12036 u32 hit_next_index = ~0;
12037 u32 opaque_index = ~0;
12040 u32 skip_n_vectors = 0;
12041 u32 match_n_vectors = 0;
12047 * Warning: you have to supply skip_n and match_n
12048 * because the API client cant simply look at the classify
12052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12054 if (unformat (i, "del"))
12056 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12059 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12062 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12065 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12067 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12069 else if (unformat (i, "opaque-index %d", &opaque_index))
12071 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12073 else if (unformat (i, "match_n %d", &match_n_vectors))
12075 else if (unformat (i, "match %U", api_unformat_classify_match,
12076 &match, skip_n_vectors, match_n_vectors))
12078 else if (unformat (i, "advance %d", &advance))
12080 else if (unformat (i, "table-index %d", &table_index))
12082 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12084 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12086 else if (unformat (i, "action %d", &action))
12088 else if (unformat (i, "metadata %d", &metadata))
12094 if (table_index == ~0)
12096 errmsg ("Table index required");
12100 if (is_add && match == 0)
12102 errmsg ("Match value required");
12106 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12108 mp->is_add = is_add;
12109 mp->table_index = ntohl (table_index);
12110 mp->hit_next_index = ntohl (hit_next_index);
12111 mp->opaque_index = ntohl (opaque_index);
12112 mp->advance = ntohl (advance);
12113 mp->action = action;
12114 mp->metadata = ntohl (metadata);
12115 clib_memcpy (mp->match, match, vec_len (match));
12124 api_classify_set_interface_ip_table (vat_main_t * vam)
12126 unformat_input_t *i = vam->input;
12127 vl_api_classify_set_interface_ip_table_t *mp;
12129 int sw_if_index_set;
12130 u32 table_index = ~0;
12134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12137 sw_if_index_set = 1;
12138 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12139 sw_if_index_set = 1;
12140 else if (unformat (i, "table %d", &table_index))
12144 clib_warning ("parse error '%U'", format_unformat_error, i);
12149 if (sw_if_index_set == 0)
12151 errmsg ("missing interface name or sw_if_index");
12156 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12158 mp->sw_if_index = ntohl (sw_if_index);
12159 mp->table_index = ntohl (table_index);
12160 mp->is_ipv6 = is_ipv6;
12168 api_classify_set_interface_l2_tables (vat_main_t * vam)
12170 unformat_input_t *i = vam->input;
12171 vl_api_classify_set_interface_l2_tables_t *mp;
12173 int sw_if_index_set;
12174 u32 ip4_table_index = ~0;
12175 u32 ip6_table_index = ~0;
12176 u32 other_table_index = ~0;
12180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12182 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12183 sw_if_index_set = 1;
12184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12185 sw_if_index_set = 1;
12186 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12188 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12190 else if (unformat (i, "other-table %d", &other_table_index))
12192 else if (unformat (i, "is-input %d", &is_input))
12196 clib_warning ("parse error '%U'", format_unformat_error, i);
12201 if (sw_if_index_set == 0)
12203 errmsg ("missing interface name or sw_if_index");
12208 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12210 mp->sw_if_index = ntohl (sw_if_index);
12211 mp->ip4_table_index = ntohl (ip4_table_index);
12212 mp->ip6_table_index = ntohl (ip6_table_index);
12213 mp->other_table_index = ntohl (other_table_index);
12214 mp->is_input = (u8) is_input;
12222 api_set_ipfix_exporter (vat_main_t * vam)
12224 unformat_input_t *i = vam->input;
12225 vl_api_set_ipfix_exporter_t *mp;
12226 ip4_address_t collector_address;
12227 u8 collector_address_set = 0;
12228 u32 collector_port = ~0;
12229 ip4_address_t src_address;
12230 u8 src_address_set = 0;
12233 u32 template_interval = ~0;
12234 u8 udp_checksum = 0;
12237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12239 if (unformat (i, "collector_address %U", unformat_ip4_address,
12240 &collector_address))
12241 collector_address_set = 1;
12242 else if (unformat (i, "collector_port %d", &collector_port))
12244 else if (unformat (i, "src_address %U", unformat_ip4_address,
12246 src_address_set = 1;
12247 else if (unformat (i, "vrf_id %d", &vrf_id))
12249 else if (unformat (i, "path_mtu %d", &path_mtu))
12251 else if (unformat (i, "template_interval %d", &template_interval))
12253 else if (unformat (i, "udp_checksum"))
12259 if (collector_address_set == 0)
12261 errmsg ("collector_address required");
12265 if (src_address_set == 0)
12267 errmsg ("src_address required");
12271 M (SET_IPFIX_EXPORTER, mp);
12273 memcpy (mp->collector_address, collector_address.data,
12274 sizeof (collector_address.data));
12275 mp->collector_port = htons ((u16) collector_port);
12276 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12277 mp->vrf_id = htonl (vrf_id);
12278 mp->path_mtu = htonl (path_mtu);
12279 mp->template_interval = htonl (template_interval);
12280 mp->udp_checksum = udp_checksum;
12288 api_set_ipfix_classify_stream (vat_main_t * vam)
12290 unformat_input_t *i = vam->input;
12291 vl_api_set_ipfix_classify_stream_t *mp;
12293 u32 src_port = UDP_DST_PORT_ipfix;
12296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12298 if (unformat (i, "domain %d", &domain_id))
12300 else if (unformat (i, "src_port %d", &src_port))
12304 errmsg ("unknown input `%U'", format_unformat_error, i);
12309 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12311 mp->domain_id = htonl (domain_id);
12312 mp->src_port = htons ((u16) src_port);
12320 api_ipfix_classify_table_add_del (vat_main_t * vam)
12322 unformat_input_t *i = vam->input;
12323 vl_api_ipfix_classify_table_add_del_t *mp;
12325 u32 classify_table_index = ~0;
12327 u8 transport_protocol = 255;
12330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12332 if (unformat (i, "add"))
12334 else if (unformat (i, "del"))
12336 else if (unformat (i, "table %d", &classify_table_index))
12338 else if (unformat (i, "ip4"))
12340 else if (unformat (i, "ip6"))
12342 else if (unformat (i, "tcp"))
12343 transport_protocol = 6;
12344 else if (unformat (i, "udp"))
12345 transport_protocol = 17;
12348 errmsg ("unknown input `%U'", format_unformat_error, i);
12355 errmsg ("expecting: add|del");
12358 if (classify_table_index == ~0)
12360 errmsg ("classifier table not specified");
12363 if (ip_version == 0)
12365 errmsg ("IP version not specified");
12369 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12371 mp->is_add = is_add;
12372 mp->table_id = htonl (classify_table_index);
12373 mp->ip_version = ip_version;
12374 mp->transport_protocol = transport_protocol;
12382 api_get_node_index (vat_main_t * vam)
12384 unformat_input_t *i = vam->input;
12385 vl_api_get_node_index_t *mp;
12389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12391 if (unformat (i, "node %s", &name))
12398 errmsg ("node name required");
12401 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12403 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12407 M (GET_NODE_INDEX, mp);
12408 clib_memcpy (mp->node_name, name, vec_len (name));
12417 api_get_next_index (vat_main_t * vam)
12419 unformat_input_t *i = vam->input;
12420 vl_api_get_next_index_t *mp;
12421 u8 *node_name = 0, *next_node_name = 0;
12424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12426 if (unformat (i, "node-name %s", &node_name))
12428 else if (unformat (i, "next-node-name %s", &next_node_name))
12432 if (node_name == 0)
12434 errmsg ("node name required");
12437 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12439 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12443 if (next_node_name == 0)
12445 errmsg ("next node name required");
12448 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12450 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12454 M (GET_NEXT_INDEX, mp);
12455 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12456 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12457 vec_free (node_name);
12458 vec_free (next_node_name);
12466 api_add_node_next (vat_main_t * vam)
12468 unformat_input_t *i = vam->input;
12469 vl_api_add_node_next_t *mp;
12474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12476 if (unformat (i, "node %s", &name))
12478 else if (unformat (i, "next %s", &next))
12485 errmsg ("node name required");
12488 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12490 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12495 errmsg ("next node required");
12498 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12500 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12504 M (ADD_NODE_NEXT, mp);
12505 clib_memcpy (mp->node_name, name, vec_len (name));
12506 clib_memcpy (mp->next_name, next, vec_len (next));
12516 api_l2tpv3_create_tunnel (vat_main_t * vam)
12518 unformat_input_t *i = vam->input;
12519 ip6_address_t client_address, our_address;
12520 int client_address_set = 0;
12521 int our_address_set = 0;
12522 u32 local_session_id = 0;
12523 u32 remote_session_id = 0;
12524 u64 local_cookie = 0;
12525 u64 remote_cookie = 0;
12526 u8 l2_sublayer_present = 0;
12527 vl_api_l2tpv3_create_tunnel_t *mp;
12530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (i, "client_address %U", unformat_ip6_address,
12534 client_address_set = 1;
12535 else if (unformat (i, "our_address %U", unformat_ip6_address,
12537 our_address_set = 1;
12538 else if (unformat (i, "local_session_id %d", &local_session_id))
12540 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12542 else if (unformat (i, "local_cookie %lld", &local_cookie))
12544 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12546 else if (unformat (i, "l2-sublayer-present"))
12547 l2_sublayer_present = 1;
12552 if (client_address_set == 0)
12554 errmsg ("client_address required");
12558 if (our_address_set == 0)
12560 errmsg ("our_address required");
12564 M (L2TPV3_CREATE_TUNNEL, mp);
12566 clib_memcpy (mp->client_address, client_address.as_u8,
12567 sizeof (mp->client_address));
12569 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12571 mp->local_session_id = ntohl (local_session_id);
12572 mp->remote_session_id = ntohl (remote_session_id);
12573 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12574 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12575 mp->l2_sublayer_present = l2_sublayer_present;
12584 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12586 unformat_input_t *i = vam->input;
12588 u8 sw_if_index_set = 0;
12589 u64 new_local_cookie = 0;
12590 u64 new_remote_cookie = 0;
12591 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12596 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12597 sw_if_index_set = 1;
12598 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12599 sw_if_index_set = 1;
12600 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12602 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12608 if (sw_if_index_set == 0)
12610 errmsg ("missing interface name or sw_if_index");
12614 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12616 mp->sw_if_index = ntohl (sw_if_index);
12617 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12618 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12626 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12628 unformat_input_t *i = vam->input;
12629 vl_api_l2tpv3_interface_enable_disable_t *mp;
12631 u8 sw_if_index_set = 0;
12632 u8 enable_disable = 1;
12635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12637 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12638 sw_if_index_set = 1;
12639 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12640 sw_if_index_set = 1;
12641 else if (unformat (i, "enable"))
12642 enable_disable = 1;
12643 else if (unformat (i, "disable"))
12644 enable_disable = 0;
12649 if (sw_if_index_set == 0)
12651 errmsg ("missing interface name or sw_if_index");
12655 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12657 mp->sw_if_index = ntohl (sw_if_index);
12658 mp->enable_disable = enable_disable;
12666 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12668 unformat_input_t *i = vam->input;
12669 vl_api_l2tpv3_set_lookup_key_t *mp;
12673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12675 if (unformat (i, "lookup_v6_src"))
12676 key = L2T_LOOKUP_SRC_ADDRESS;
12677 else if (unformat (i, "lookup_v6_dst"))
12678 key = L2T_LOOKUP_DST_ADDRESS;
12679 else if (unformat (i, "lookup_session_id"))
12680 key = L2T_LOOKUP_SESSION_ID;
12685 if (key == (u8) ~ 0)
12687 errmsg ("l2tp session lookup key unset");
12691 M (L2TPV3_SET_LOOKUP_KEY, mp);
12700 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12701 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12703 vat_main_t *vam = &vat_main;
12705 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12706 format_ip6_address, mp->our_address,
12707 format_ip6_address, mp->client_address,
12708 clib_net_to_host_u32 (mp->sw_if_index));
12711 " local cookies %016llx %016llx remote cookie %016llx",
12712 clib_net_to_host_u64 (mp->local_cookie[0]),
12713 clib_net_to_host_u64 (mp->local_cookie[1]),
12714 clib_net_to_host_u64 (mp->remote_cookie));
12716 print (vam->ofp, " local session-id %d remote session-id %d",
12717 clib_net_to_host_u32 (mp->local_session_id),
12718 clib_net_to_host_u32 (mp->remote_session_id));
12720 print (vam->ofp, " l2 specific sublayer %s\n",
12721 mp->l2_sublayer_present ? "preset" : "absent");
12725 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12726 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12728 vat_main_t *vam = &vat_main;
12729 vat_json_node_t *node = NULL;
12730 struct in6_addr addr;
12732 if (VAT_JSON_ARRAY != vam->json_tree.type)
12734 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12735 vat_json_init_array (&vam->json_tree);
12737 node = vat_json_array_add (&vam->json_tree);
12739 vat_json_init_object (node);
12741 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12742 vat_json_object_add_ip6 (node, "our_address", addr);
12743 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12744 vat_json_object_add_ip6 (node, "client_address", addr);
12746 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12747 vat_json_init_array (lc);
12748 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12749 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12750 vat_json_object_add_uint (node, "remote_cookie",
12751 clib_net_to_host_u64 (mp->remote_cookie));
12753 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12754 vat_json_object_add_uint (node, "local_session_id",
12755 clib_net_to_host_u32 (mp->local_session_id));
12756 vat_json_object_add_uint (node, "remote_session_id",
12757 clib_net_to_host_u32 (mp->remote_session_id));
12758 vat_json_object_add_string_copy (node, "l2_sublayer",
12759 mp->l2_sublayer_present ? (u8 *) "present"
12760 : (u8 *) "absent");
12764 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12766 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12767 vl_api_control_ping_t *mp_ping;
12770 /* Get list of l2tpv3-tunnel interfaces */
12771 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12774 /* Use a control ping for synchronization */
12775 MPING (CONTROL_PING, mp_ping);
12783 static void vl_api_sw_interface_tap_details_t_handler
12784 (vl_api_sw_interface_tap_details_t * mp)
12786 vat_main_t *vam = &vat_main;
12788 print (vam->ofp, "%-16s %d",
12789 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12792 static void vl_api_sw_interface_tap_details_t_handler_json
12793 (vl_api_sw_interface_tap_details_t * mp)
12795 vat_main_t *vam = &vat_main;
12796 vat_json_node_t *node = NULL;
12798 if (VAT_JSON_ARRAY != vam->json_tree.type)
12800 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12801 vat_json_init_array (&vam->json_tree);
12803 node = vat_json_array_add (&vam->json_tree);
12805 vat_json_init_object (node);
12806 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12807 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12811 api_sw_interface_tap_dump (vat_main_t * vam)
12813 vl_api_sw_interface_tap_dump_t *mp;
12814 vl_api_control_ping_t *mp_ping;
12817 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12818 /* Get list of tap interfaces */
12819 M (SW_INTERFACE_TAP_DUMP, mp);
12822 /* Use a control ping for synchronization */
12823 MPING (CONTROL_PING, mp_ping);
12830 static void vl_api_sw_interface_tap_v2_details_t_handler
12831 (vl_api_sw_interface_tap_v2_details_t * mp)
12833 vat_main_t *vam = &vat_main;
12835 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12836 mp->host_ip4_prefix_len);
12837 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12838 mp->host_ip6_prefix_len);
12841 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12842 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12843 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12844 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12845 mp->host_bridge, ip4, ip6);
12851 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12852 (vl_api_sw_interface_tap_v2_details_t * mp)
12854 vat_main_t *vam = &vat_main;
12855 vat_json_node_t *node = NULL;
12857 if (VAT_JSON_ARRAY != vam->json_tree.type)
12859 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12860 vat_json_init_array (&vam->json_tree);
12862 node = vat_json_array_add (&vam->json_tree);
12864 vat_json_init_object (node);
12865 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12866 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12867 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12868 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12869 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12870 vat_json_object_add_string_copy (node, "host_mac_addr",
12871 format (0, "%U", format_ethernet_address,
12872 &mp->host_mac_addr));
12873 vat_json_object_add_string_copy (node, "host_namespace",
12874 mp->host_namespace);
12875 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12876 vat_json_object_add_string_copy (node, "host_ip4_addr",
12877 format (0, "%U/%d", format_ip4_address,
12879 mp->host_ip4_prefix_len));
12880 vat_json_object_add_string_copy (node, "host_ip6_addr",
12881 format (0, "%U/%d", format_ip6_address,
12883 mp->host_ip6_prefix_len));
12888 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12890 vl_api_sw_interface_tap_v2_dump_t *mp;
12891 vl_api_control_ping_t *mp_ping;
12895 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12896 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12897 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12900 /* Get list of tap interfaces */
12901 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12904 /* Use a control ping for synchronization */
12905 MPING (CONTROL_PING, mp_ping);
12913 api_vxlan_offload_rx (vat_main_t * vam)
12915 unformat_input_t *line_input = vam->input;
12916 vl_api_vxlan_offload_rx_t *mp;
12917 u32 hw_if_index = ~0, rx_if_index = ~0;
12921 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12923 if (unformat (line_input, "del"))
12925 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12928 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12930 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12933 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12937 errmsg ("parse error '%U'", format_unformat_error, line_input);
12942 if (hw_if_index == ~0)
12944 errmsg ("no hw interface");
12948 if (rx_if_index == ~0)
12950 errmsg ("no rx tunnel");
12954 M (VXLAN_OFFLOAD_RX, mp);
12956 mp->hw_if_index = ntohl (hw_if_index);
12957 mp->sw_if_index = ntohl (rx_if_index);
12958 mp->enable = is_add;
12965 static uword unformat_vxlan_decap_next
12966 (unformat_input_t * input, va_list * args)
12968 u32 *result = va_arg (*args, u32 *);
12971 if (unformat (input, "l2"))
12972 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12973 else if (unformat (input, "%d", &tmp))
12981 api_vxlan_add_del_tunnel (vat_main_t * vam)
12983 unformat_input_t *line_input = vam->input;
12984 vl_api_vxlan_add_del_tunnel_t *mp;
12985 ip46_address_t src, dst;
12987 u8 ipv4_set = 0, ipv6_set = 0;
12992 u32 mcast_sw_if_index = ~0;
12993 u32 encap_vrf_id = 0;
12994 u32 decap_next_index = ~0;
12998 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12999 memset (&src, 0, sizeof src);
13000 memset (&dst, 0, sizeof dst);
13002 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13004 if (unformat (line_input, "del"))
13006 else if (unformat (line_input, "instance %d", &instance))
13009 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13015 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13021 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13027 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13032 else if (unformat (line_input, "group %U %U",
13033 unformat_ip4_address, &dst.ip4,
13034 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13036 grp_set = dst_set = 1;
13039 else if (unformat (line_input, "group %U",
13040 unformat_ip4_address, &dst.ip4))
13042 grp_set = dst_set = 1;
13045 else if (unformat (line_input, "group %U %U",
13046 unformat_ip6_address, &dst.ip6,
13047 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13049 grp_set = dst_set = 1;
13052 else if (unformat (line_input, "group %U",
13053 unformat_ip6_address, &dst.ip6))
13055 grp_set = dst_set = 1;
13059 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13061 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13063 else if (unformat (line_input, "decap-next %U",
13064 unformat_vxlan_decap_next, &decap_next_index))
13066 else if (unformat (line_input, "vni %d", &vni))
13070 errmsg ("parse error '%U'", format_unformat_error, line_input);
13077 errmsg ("tunnel src address not specified");
13082 errmsg ("tunnel dst address not specified");
13086 if (grp_set && !ip46_address_is_multicast (&dst))
13088 errmsg ("tunnel group address not multicast");
13091 if (grp_set && mcast_sw_if_index == ~0)
13093 errmsg ("tunnel nonexistent multicast device");
13096 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13098 errmsg ("tunnel dst address must be unicast");
13103 if (ipv4_set && ipv6_set)
13105 errmsg ("both IPv4 and IPv6 addresses specified");
13109 if ((vni == 0) || (vni >> 24))
13111 errmsg ("vni not specified or out of range");
13115 M (VXLAN_ADD_DEL_TUNNEL, mp);
13119 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13120 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13124 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13125 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13128 mp->instance = htonl (instance);
13129 mp->encap_vrf_id = ntohl (encap_vrf_id);
13130 mp->decap_next_index = ntohl (decap_next_index);
13131 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13132 mp->vni = ntohl (vni);
13133 mp->is_add = is_add;
13134 mp->is_ipv6 = ipv6_set;
13141 static void vl_api_vxlan_tunnel_details_t_handler
13142 (vl_api_vxlan_tunnel_details_t * mp)
13144 vat_main_t *vam = &vat_main;
13145 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13146 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13148 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13149 ntohl (mp->sw_if_index),
13150 ntohl (mp->instance),
13151 format_ip46_address, &src, IP46_TYPE_ANY,
13152 format_ip46_address, &dst, IP46_TYPE_ANY,
13153 ntohl (mp->encap_vrf_id),
13154 ntohl (mp->decap_next_index), ntohl (mp->vni),
13155 ntohl (mp->mcast_sw_if_index));
13158 static void vl_api_vxlan_tunnel_details_t_handler_json
13159 (vl_api_vxlan_tunnel_details_t * mp)
13161 vat_main_t *vam = &vat_main;
13162 vat_json_node_t *node = NULL;
13164 if (VAT_JSON_ARRAY != vam->json_tree.type)
13166 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13167 vat_json_init_array (&vam->json_tree);
13169 node = vat_json_array_add (&vam->json_tree);
13171 vat_json_init_object (node);
13172 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13174 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13178 struct in6_addr ip6;
13180 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13181 vat_json_object_add_ip6 (node, "src_address", ip6);
13182 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13183 vat_json_object_add_ip6 (node, "dst_address", ip6);
13187 struct in_addr ip4;
13189 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13190 vat_json_object_add_ip4 (node, "src_address", ip4);
13191 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13192 vat_json_object_add_ip4 (node, "dst_address", ip4);
13194 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13195 vat_json_object_add_uint (node, "decap_next_index",
13196 ntohl (mp->decap_next_index));
13197 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13198 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13199 vat_json_object_add_uint (node, "mcast_sw_if_index",
13200 ntohl (mp->mcast_sw_if_index));
13204 api_vxlan_tunnel_dump (vat_main_t * vam)
13206 unformat_input_t *i = vam->input;
13207 vl_api_vxlan_tunnel_dump_t *mp;
13208 vl_api_control_ping_t *mp_ping;
13210 u8 sw_if_index_set = 0;
13213 /* Parse args required to build the message */
13214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13216 if (unformat (i, "sw_if_index %d", &sw_if_index))
13217 sw_if_index_set = 1;
13222 if (sw_if_index_set == 0)
13227 if (!vam->json_output)
13229 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13230 "sw_if_index", "instance", "src_address", "dst_address",
13231 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13234 /* Get list of vxlan-tunnel interfaces */
13235 M (VXLAN_TUNNEL_DUMP, mp);
13237 mp->sw_if_index = htonl (sw_if_index);
13241 /* Use a control ping for synchronization */
13242 MPING (CONTROL_PING, mp_ping);
13249 static uword unformat_geneve_decap_next
13250 (unformat_input_t * input, va_list * args)
13252 u32 *result = va_arg (*args, u32 *);
13255 if (unformat (input, "l2"))
13256 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13257 else if (unformat (input, "%d", &tmp))
13265 api_geneve_add_del_tunnel (vat_main_t * vam)
13267 unformat_input_t *line_input = vam->input;
13268 vl_api_geneve_add_del_tunnel_t *mp;
13269 ip46_address_t src, dst;
13271 u8 ipv4_set = 0, ipv6_set = 0;
13275 u32 mcast_sw_if_index = ~0;
13276 u32 encap_vrf_id = 0;
13277 u32 decap_next_index = ~0;
13281 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13282 memset (&src, 0, sizeof src);
13283 memset (&dst, 0, sizeof dst);
13285 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13287 if (unformat (line_input, "del"))
13290 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13296 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13302 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13308 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13313 else if (unformat (line_input, "group %U %U",
13314 unformat_ip4_address, &dst.ip4,
13315 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13317 grp_set = dst_set = 1;
13320 else if (unformat (line_input, "group %U",
13321 unformat_ip4_address, &dst.ip4))
13323 grp_set = dst_set = 1;
13326 else if (unformat (line_input, "group %U %U",
13327 unformat_ip6_address, &dst.ip6,
13328 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13330 grp_set = dst_set = 1;
13333 else if (unformat (line_input, "group %U",
13334 unformat_ip6_address, &dst.ip6))
13336 grp_set = dst_set = 1;
13340 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13342 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13344 else if (unformat (line_input, "decap-next %U",
13345 unformat_geneve_decap_next, &decap_next_index))
13347 else if (unformat (line_input, "vni %d", &vni))
13351 errmsg ("parse error '%U'", format_unformat_error, line_input);
13358 errmsg ("tunnel src address not specified");
13363 errmsg ("tunnel dst address not specified");
13367 if (grp_set && !ip46_address_is_multicast (&dst))
13369 errmsg ("tunnel group address not multicast");
13372 if (grp_set && mcast_sw_if_index == ~0)
13374 errmsg ("tunnel nonexistent multicast device");
13377 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13379 errmsg ("tunnel dst address must be unicast");
13384 if (ipv4_set && ipv6_set)
13386 errmsg ("both IPv4 and IPv6 addresses specified");
13390 if ((vni == 0) || (vni >> 24))
13392 errmsg ("vni not specified or out of range");
13396 M (GENEVE_ADD_DEL_TUNNEL, mp);
13400 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13401 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13405 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13406 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13408 mp->encap_vrf_id = ntohl (encap_vrf_id);
13409 mp->decap_next_index = ntohl (decap_next_index);
13410 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13411 mp->vni = ntohl (vni);
13412 mp->is_add = is_add;
13413 mp->is_ipv6 = ipv6_set;
13420 static void vl_api_geneve_tunnel_details_t_handler
13421 (vl_api_geneve_tunnel_details_t * mp)
13423 vat_main_t *vam = &vat_main;
13424 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13425 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13427 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13428 ntohl (mp->sw_if_index),
13429 format_ip46_address, &src, IP46_TYPE_ANY,
13430 format_ip46_address, &dst, IP46_TYPE_ANY,
13431 ntohl (mp->encap_vrf_id),
13432 ntohl (mp->decap_next_index), ntohl (mp->vni),
13433 ntohl (mp->mcast_sw_if_index));
13436 static void vl_api_geneve_tunnel_details_t_handler_json
13437 (vl_api_geneve_tunnel_details_t * mp)
13439 vat_main_t *vam = &vat_main;
13440 vat_json_node_t *node = NULL;
13442 if (VAT_JSON_ARRAY != vam->json_tree.type)
13444 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13445 vat_json_init_array (&vam->json_tree);
13447 node = vat_json_array_add (&vam->json_tree);
13449 vat_json_init_object (node);
13450 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13453 struct in6_addr ip6;
13455 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13456 vat_json_object_add_ip6 (node, "src_address", ip6);
13457 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13458 vat_json_object_add_ip6 (node, "dst_address", ip6);
13462 struct in_addr ip4;
13464 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13465 vat_json_object_add_ip4 (node, "src_address", ip4);
13466 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13467 vat_json_object_add_ip4 (node, "dst_address", ip4);
13469 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13470 vat_json_object_add_uint (node, "decap_next_index",
13471 ntohl (mp->decap_next_index));
13472 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13473 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13474 vat_json_object_add_uint (node, "mcast_sw_if_index",
13475 ntohl (mp->mcast_sw_if_index));
13479 api_geneve_tunnel_dump (vat_main_t * vam)
13481 unformat_input_t *i = vam->input;
13482 vl_api_geneve_tunnel_dump_t *mp;
13483 vl_api_control_ping_t *mp_ping;
13485 u8 sw_if_index_set = 0;
13488 /* Parse args required to build the message */
13489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13491 if (unformat (i, "sw_if_index %d", &sw_if_index))
13492 sw_if_index_set = 1;
13497 if (sw_if_index_set == 0)
13502 if (!vam->json_output)
13504 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13505 "sw_if_index", "local_address", "remote_address",
13506 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13509 /* Get list of geneve-tunnel interfaces */
13510 M (GENEVE_TUNNEL_DUMP, mp);
13512 mp->sw_if_index = htonl (sw_if_index);
13516 /* Use a control ping for synchronization */
13517 M (CONTROL_PING, mp_ping);
13525 api_gre_add_del_tunnel (vat_main_t * vam)
13527 unformat_input_t *line_input = vam->input;
13528 vl_api_gre_add_del_tunnel_t *mp;
13529 ip4_address_t src4, dst4;
13530 ip6_address_t src6, dst6;
13534 u8 t_type = GRE_TUNNEL_TYPE_L3;
13537 u32 outer_fib_id = 0;
13538 u32 session_id = 0;
13542 memset (&src4, 0, sizeof src4);
13543 memset (&dst4, 0, sizeof dst4);
13544 memset (&src6, 0, sizeof src6);
13545 memset (&dst6, 0, sizeof dst6);
13547 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13549 if (unformat (line_input, "del"))
13551 else if (unformat (line_input, "instance %d", &instance))
13553 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13558 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13563 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13568 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13573 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13575 else if (unformat (line_input, "teb"))
13576 t_type = GRE_TUNNEL_TYPE_TEB;
13577 else if (unformat (line_input, "erspan %d", &session_id))
13578 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13581 errmsg ("parse error '%U'", format_unformat_error, line_input);
13588 errmsg ("tunnel src address not specified");
13593 errmsg ("tunnel dst address not specified");
13596 if (ipv4_set && ipv6_set)
13598 errmsg ("both IPv4 and IPv6 addresses specified");
13603 M (GRE_ADD_DEL_TUNNEL, mp);
13607 clib_memcpy (&mp->src_address, &src4, 4);
13608 clib_memcpy (&mp->dst_address, &dst4, 4);
13612 clib_memcpy (&mp->src_address, &src6, 16);
13613 clib_memcpy (&mp->dst_address, &dst6, 16);
13615 mp->instance = htonl (instance);
13616 mp->outer_fib_id = htonl (outer_fib_id);
13617 mp->is_add = is_add;
13618 mp->session_id = htons ((u16) session_id);
13619 mp->tunnel_type = t_type;
13620 mp->is_ipv6 = ipv6_set;
13627 static void vl_api_gre_tunnel_details_t_handler
13628 (vl_api_gre_tunnel_details_t * mp)
13630 vat_main_t *vam = &vat_main;
13631 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13632 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13634 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13635 ntohl (mp->sw_if_index),
13636 ntohl (mp->instance),
13637 format_ip46_address, &src, IP46_TYPE_ANY,
13638 format_ip46_address, &dst, IP46_TYPE_ANY,
13639 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13642 static void vl_api_gre_tunnel_details_t_handler_json
13643 (vl_api_gre_tunnel_details_t * mp)
13645 vat_main_t *vam = &vat_main;
13646 vat_json_node_t *node = NULL;
13647 struct in_addr ip4;
13648 struct in6_addr ip6;
13650 if (VAT_JSON_ARRAY != vam->json_tree.type)
13652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13653 vat_json_init_array (&vam->json_tree);
13655 node = vat_json_array_add (&vam->json_tree);
13657 vat_json_init_object (node);
13658 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13659 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13662 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13663 vat_json_object_add_ip4 (node, "src_address", ip4);
13664 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13665 vat_json_object_add_ip4 (node, "dst_address", ip4);
13669 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13670 vat_json_object_add_ip6 (node, "src_address", ip6);
13671 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13672 vat_json_object_add_ip6 (node, "dst_address", ip6);
13674 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13675 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13676 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13677 vat_json_object_add_uint (node, "session_id", mp->session_id);
13681 api_gre_tunnel_dump (vat_main_t * vam)
13683 unformat_input_t *i = vam->input;
13684 vl_api_gre_tunnel_dump_t *mp;
13685 vl_api_control_ping_t *mp_ping;
13687 u8 sw_if_index_set = 0;
13690 /* Parse args required to build the message */
13691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13693 if (unformat (i, "sw_if_index %d", &sw_if_index))
13694 sw_if_index_set = 1;
13699 if (sw_if_index_set == 0)
13704 if (!vam->json_output)
13706 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13707 "sw_if_index", "instance", "src_address", "dst_address",
13708 "tunnel_type", "outer_fib_id", "session_id");
13711 /* Get list of gre-tunnel interfaces */
13712 M (GRE_TUNNEL_DUMP, mp);
13714 mp->sw_if_index = htonl (sw_if_index);
13718 /* Use a control ping for synchronization */
13719 MPING (CONTROL_PING, mp_ping);
13727 api_l2_fib_clear_table (vat_main_t * vam)
13729 // unformat_input_t * i = vam->input;
13730 vl_api_l2_fib_clear_table_t *mp;
13733 M (L2_FIB_CLEAR_TABLE, mp);
13741 api_l2_interface_efp_filter (vat_main_t * vam)
13743 unformat_input_t *i = vam->input;
13744 vl_api_l2_interface_efp_filter_t *mp;
13747 u8 sw_if_index_set = 0;
13750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13753 sw_if_index_set = 1;
13754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13755 sw_if_index_set = 1;
13756 else if (unformat (i, "enable"))
13758 else if (unformat (i, "disable"))
13762 clib_warning ("parse error '%U'", format_unformat_error, i);
13767 if (sw_if_index_set == 0)
13769 errmsg ("missing sw_if_index");
13773 M (L2_INTERFACE_EFP_FILTER, mp);
13775 mp->sw_if_index = ntohl (sw_if_index);
13776 mp->enable_disable = enable;
13783 #define foreach_vtr_op \
13784 _("disable", L2_VTR_DISABLED) \
13785 _("push-1", L2_VTR_PUSH_1) \
13786 _("push-2", L2_VTR_PUSH_2) \
13787 _("pop-1", L2_VTR_POP_1) \
13788 _("pop-2", L2_VTR_POP_2) \
13789 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13790 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13791 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13792 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13795 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13797 unformat_input_t *i = vam->input;
13798 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13800 u8 sw_if_index_set = 0;
13803 u32 push_dot1q = 1;
13808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13810 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13811 sw_if_index_set = 1;
13812 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13813 sw_if_index_set = 1;
13814 else if (unformat (i, "vtr_op %d", &vtr_op))
13816 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13819 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13821 else if (unformat (i, "tag1 %d", &tag1))
13823 else if (unformat (i, "tag2 %d", &tag2))
13827 clib_warning ("parse error '%U'", format_unformat_error, i);
13832 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13834 errmsg ("missing vtr operation or sw_if_index");
13838 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13839 mp->sw_if_index = ntohl (sw_if_index);
13840 mp->vtr_op = ntohl (vtr_op);
13841 mp->push_dot1q = ntohl (push_dot1q);
13842 mp->tag1 = ntohl (tag1);
13843 mp->tag2 = ntohl (tag2);
13851 api_create_vhost_user_if (vat_main_t * vam)
13853 unformat_input_t *i = vam->input;
13854 vl_api_create_vhost_user_if_t *mp;
13857 u8 file_name_set = 0;
13858 u32 custom_dev_instance = ~0;
13860 u8 use_custom_mac = 0;
13864 /* Shut up coverity */
13865 memset (hwaddr, 0, sizeof (hwaddr));
13867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13869 if (unformat (i, "socket %s", &file_name))
13873 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13875 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13876 use_custom_mac = 1;
13877 else if (unformat (i, "server"))
13879 else if (unformat (i, "tag %s", &tag))
13885 if (file_name_set == 0)
13887 errmsg ("missing socket file name");
13891 if (vec_len (file_name) > 255)
13893 errmsg ("socket file name too long");
13896 vec_add1 (file_name, 0);
13898 M (CREATE_VHOST_USER_IF, mp);
13900 mp->is_server = is_server;
13901 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13902 vec_free (file_name);
13903 if (custom_dev_instance != ~0)
13906 mp->custom_dev_instance = ntohl (custom_dev_instance);
13908 mp->use_custom_mac = use_custom_mac;
13909 clib_memcpy (mp->mac_address, hwaddr, 6);
13911 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13920 api_modify_vhost_user_if (vat_main_t * vam)
13922 unformat_input_t *i = vam->input;
13923 vl_api_modify_vhost_user_if_t *mp;
13926 u8 file_name_set = 0;
13927 u32 custom_dev_instance = ~0;
13928 u8 sw_if_index_set = 0;
13929 u32 sw_if_index = (u32) ~ 0;
13932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13935 sw_if_index_set = 1;
13936 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13937 sw_if_index_set = 1;
13938 else if (unformat (i, "socket %s", &file_name))
13942 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13944 else if (unformat (i, "server"))
13950 if (sw_if_index_set == 0)
13952 errmsg ("missing sw_if_index or interface name");
13956 if (file_name_set == 0)
13958 errmsg ("missing socket file name");
13962 if (vec_len (file_name) > 255)
13964 errmsg ("socket file name too long");
13967 vec_add1 (file_name, 0);
13969 M (MODIFY_VHOST_USER_IF, mp);
13971 mp->sw_if_index = ntohl (sw_if_index);
13972 mp->is_server = is_server;
13973 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13974 vec_free (file_name);
13975 if (custom_dev_instance != ~0)
13978 mp->custom_dev_instance = ntohl (custom_dev_instance);
13987 api_delete_vhost_user_if (vat_main_t * vam)
13989 unformat_input_t *i = vam->input;
13990 vl_api_delete_vhost_user_if_t *mp;
13991 u32 sw_if_index = ~0;
13992 u8 sw_if_index_set = 0;
13995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13997 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13998 sw_if_index_set = 1;
13999 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14000 sw_if_index_set = 1;
14005 if (sw_if_index_set == 0)
14007 errmsg ("missing sw_if_index or interface name");
14012 M (DELETE_VHOST_USER_IF, mp);
14014 mp->sw_if_index = ntohl (sw_if_index);
14021 static void vl_api_sw_interface_vhost_user_details_t_handler
14022 (vl_api_sw_interface_vhost_user_details_t * mp)
14024 vat_main_t *vam = &vat_main;
14026 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
14027 (char *) mp->interface_name,
14028 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
14029 clib_net_to_host_u64 (mp->features), mp->is_server,
14030 ntohl (mp->num_regions), (char *) mp->sock_filename);
14031 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
14034 static void vl_api_sw_interface_vhost_user_details_t_handler_json
14035 (vl_api_sw_interface_vhost_user_details_t * mp)
14037 vat_main_t *vam = &vat_main;
14038 vat_json_node_t *node = NULL;
14040 if (VAT_JSON_ARRAY != vam->json_tree.type)
14042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14043 vat_json_init_array (&vam->json_tree);
14045 node = vat_json_array_add (&vam->json_tree);
14047 vat_json_init_object (node);
14048 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14049 vat_json_object_add_string_copy (node, "interface_name",
14050 mp->interface_name);
14051 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
14052 ntohl (mp->virtio_net_hdr_sz));
14053 vat_json_object_add_uint (node, "features",
14054 clib_net_to_host_u64 (mp->features));
14055 vat_json_object_add_uint (node, "is_server", mp->is_server);
14056 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
14057 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
14058 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
14062 api_sw_interface_vhost_user_dump (vat_main_t * vam)
14064 vl_api_sw_interface_vhost_user_dump_t *mp;
14065 vl_api_control_ping_t *mp_ping;
14068 "Interface name idx hdr_sz features server regions filename");
14070 /* Get list of vhost-user interfaces */
14071 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
14074 /* Use a control ping for synchronization */
14075 MPING (CONTROL_PING, mp_ping);
14083 api_show_version (vat_main_t * vam)
14085 vl_api_show_version_t *mp;
14088 M (SHOW_VERSION, mp);
14097 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
14099 unformat_input_t *line_input = vam->input;
14100 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
14101 ip4_address_t local4, remote4;
14102 ip6_address_t local6, remote6;
14104 u8 ipv4_set = 0, ipv6_set = 0;
14108 u32 mcast_sw_if_index = ~0;
14109 u32 encap_vrf_id = 0;
14110 u32 decap_vrf_id = 0;
14116 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14117 memset (&local4, 0, sizeof local4);
14118 memset (&remote4, 0, sizeof remote4);
14119 memset (&local6, 0, sizeof local6);
14120 memset (&remote6, 0, sizeof remote6);
14122 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14124 if (unformat (line_input, "del"))
14126 else if (unformat (line_input, "local %U",
14127 unformat_ip4_address, &local4))
14132 else if (unformat (line_input, "remote %U",
14133 unformat_ip4_address, &remote4))
14138 else if (unformat (line_input, "local %U",
14139 unformat_ip6_address, &local6))
14144 else if (unformat (line_input, "remote %U",
14145 unformat_ip6_address, &remote6))
14150 else if (unformat (line_input, "group %U %U",
14151 unformat_ip4_address, &remote4,
14152 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14154 grp_set = remote_set = 1;
14157 else if (unformat (line_input, "group %U",
14158 unformat_ip4_address, &remote4))
14160 grp_set = remote_set = 1;
14163 else if (unformat (line_input, "group %U %U",
14164 unformat_ip6_address, &remote6,
14165 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14167 grp_set = remote_set = 1;
14170 else if (unformat (line_input, "group %U",
14171 unformat_ip6_address, &remote6))
14173 grp_set = remote_set = 1;
14177 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14179 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14181 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14183 else if (unformat (line_input, "vni %d", &vni))
14185 else if (unformat (line_input, "next-ip4"))
14187 else if (unformat (line_input, "next-ip6"))
14189 else if (unformat (line_input, "next-ethernet"))
14191 else if (unformat (line_input, "next-nsh"))
14195 errmsg ("parse error '%U'", format_unformat_error, line_input);
14200 if (local_set == 0)
14202 errmsg ("tunnel local address not specified");
14205 if (remote_set == 0)
14207 errmsg ("tunnel remote address not specified");
14210 if (grp_set && mcast_sw_if_index == ~0)
14212 errmsg ("tunnel nonexistent multicast device");
14215 if (ipv4_set && ipv6_set)
14217 errmsg ("both IPv4 and IPv6 addresses specified");
14223 errmsg ("vni not specified");
14227 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14232 clib_memcpy (&mp->local, &local6, sizeof (local6));
14233 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14237 clib_memcpy (&mp->local, &local4, sizeof (local4));
14238 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14241 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14242 mp->encap_vrf_id = ntohl (encap_vrf_id);
14243 mp->decap_vrf_id = ntohl (decap_vrf_id);
14244 mp->protocol = protocol;
14245 mp->vni = ntohl (vni);
14246 mp->is_add = is_add;
14247 mp->is_ipv6 = ipv6_set;
14254 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14255 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14257 vat_main_t *vam = &vat_main;
14258 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14259 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14261 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14262 ntohl (mp->sw_if_index),
14263 format_ip46_address, &local, IP46_TYPE_ANY,
14264 format_ip46_address, &remote, IP46_TYPE_ANY,
14265 ntohl (mp->vni), mp->protocol,
14266 ntohl (mp->mcast_sw_if_index),
14267 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14271 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14272 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14274 vat_main_t *vam = &vat_main;
14275 vat_json_node_t *node = NULL;
14276 struct in_addr ip4;
14277 struct in6_addr ip6;
14279 if (VAT_JSON_ARRAY != vam->json_tree.type)
14281 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14282 vat_json_init_array (&vam->json_tree);
14284 node = vat_json_array_add (&vam->json_tree);
14286 vat_json_init_object (node);
14287 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14290 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14291 vat_json_object_add_ip6 (node, "local", ip6);
14292 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14293 vat_json_object_add_ip6 (node, "remote", ip6);
14297 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14298 vat_json_object_add_ip4 (node, "local", ip4);
14299 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14300 vat_json_object_add_ip4 (node, "remote", ip4);
14302 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14303 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14304 vat_json_object_add_uint (node, "mcast_sw_if_index",
14305 ntohl (mp->mcast_sw_if_index));
14306 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14307 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14308 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14312 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14314 unformat_input_t *i = vam->input;
14315 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14316 vl_api_control_ping_t *mp_ping;
14318 u8 sw_if_index_set = 0;
14321 /* Parse args required to build the message */
14322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14324 if (unformat (i, "sw_if_index %d", &sw_if_index))
14325 sw_if_index_set = 1;
14330 if (sw_if_index_set == 0)
14335 if (!vam->json_output)
14337 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14338 "sw_if_index", "local", "remote", "vni",
14339 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14342 /* Get list of vxlan-tunnel interfaces */
14343 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14345 mp->sw_if_index = htonl (sw_if_index);
14349 /* Use a control ping for synchronization */
14350 MPING (CONTROL_PING, mp_ping);
14357 static void vl_api_l2_fib_table_details_t_handler
14358 (vl_api_l2_fib_table_details_t * mp)
14360 vat_main_t *vam = &vat_main;
14362 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14364 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14365 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14369 static void vl_api_l2_fib_table_details_t_handler_json
14370 (vl_api_l2_fib_table_details_t * mp)
14372 vat_main_t *vam = &vat_main;
14373 vat_json_node_t *node = NULL;
14375 if (VAT_JSON_ARRAY != vam->json_tree.type)
14377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14378 vat_json_init_array (&vam->json_tree);
14380 node = vat_json_array_add (&vam->json_tree);
14382 vat_json_init_object (node);
14383 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14384 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14385 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14386 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14387 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14388 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14392 api_l2_fib_table_dump (vat_main_t * vam)
14394 unformat_input_t *i = vam->input;
14395 vl_api_l2_fib_table_dump_t *mp;
14396 vl_api_control_ping_t *mp_ping;
14401 /* Parse args required to build the message */
14402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14404 if (unformat (i, "bd_id %d", &bd_id))
14410 if (bd_id_set == 0)
14412 errmsg ("missing bridge domain");
14416 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14418 /* Get list of l2 fib entries */
14419 M (L2_FIB_TABLE_DUMP, mp);
14421 mp->bd_id = ntohl (bd_id);
14424 /* Use a control ping for synchronization */
14425 MPING (CONTROL_PING, mp_ping);
14434 api_interface_name_renumber (vat_main_t * vam)
14436 unformat_input_t *line_input = vam->input;
14437 vl_api_interface_name_renumber_t *mp;
14438 u32 sw_if_index = ~0;
14439 u32 new_show_dev_instance = ~0;
14442 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14444 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14447 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14449 else if (unformat (line_input, "new_show_dev_instance %d",
14450 &new_show_dev_instance))
14456 if (sw_if_index == ~0)
14458 errmsg ("missing interface name or sw_if_index");
14462 if (new_show_dev_instance == ~0)
14464 errmsg ("missing new_show_dev_instance");
14468 M (INTERFACE_NAME_RENUMBER, mp);
14470 mp->sw_if_index = ntohl (sw_if_index);
14471 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14479 api_ip_probe_neighbor (vat_main_t * vam)
14481 unformat_input_t *i = vam->input;
14482 vl_api_ip_probe_neighbor_t *mp;
14490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14492 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14494 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14496 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14498 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14509 errmsg ("missing interface");
14515 errmsg ("missing addresses");
14519 M (IP_PROBE_NEIGHBOR, mp);
14521 mp->sw_if_index = ntohl (sw_if_index);
14522 mp->is_ipv6 = is_ipv6;
14523 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14531 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14533 unformat_input_t *i = vam->input;
14534 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14535 u8 mode = IP_SCAN_V46_NEIGHBORS;
14536 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (i, "ip4"))
14542 mode = IP_SCAN_V4_NEIGHBORS;
14543 else if (unformat (i, "ip6"))
14544 mode = IP_SCAN_V6_NEIGHBORS;
14545 if (unformat (i, "both"))
14546 mode = IP_SCAN_V46_NEIGHBORS;
14547 else if (unformat (i, "disable"))
14548 mode = IP_SCAN_DISABLED;
14549 else if (unformat (i, "interval %d", &interval))
14551 else if (unformat (i, "max-time %d", &time))
14553 else if (unformat (i, "max-update %d", &update))
14555 else if (unformat (i, "delay %d", &delay))
14557 else if (unformat (i, "stale %d", &stale))
14563 if (interval > 255)
14565 errmsg ("interval cannot exceed 255 minutes.");
14570 errmsg ("max-time cannot exceed 255 usec.");
14575 errmsg ("max-update cannot exceed 255.");
14580 errmsg ("delay cannot exceed 255 msec.");
14585 errmsg ("stale cannot exceed 255 minutes.");
14589 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14591 mp->scan_interval = interval;
14592 mp->max_proc_time = time;
14593 mp->max_update = update;
14594 mp->scan_int_delay = delay;
14595 mp->stale_threshold = stale;
14603 api_want_ip4_arp_events (vat_main_t * vam)
14605 unformat_input_t *line_input = vam->input;
14606 vl_api_want_ip4_arp_events_t *mp;
14607 ip4_address_t address;
14608 int address_set = 0;
14609 u32 enable_disable = 1;
14612 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14614 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14616 else if (unformat (line_input, "del"))
14617 enable_disable = 0;
14622 if (address_set == 0)
14624 errmsg ("missing addresses");
14628 M (WANT_IP4_ARP_EVENTS, mp);
14629 mp->enable_disable = enable_disable;
14630 mp->pid = htonl (getpid ());
14631 mp->address = address.as_u32;
14639 api_want_ip6_nd_events (vat_main_t * vam)
14641 unformat_input_t *line_input = vam->input;
14642 vl_api_want_ip6_nd_events_t *mp;
14643 ip6_address_t address;
14644 int address_set = 0;
14645 u32 enable_disable = 1;
14648 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14650 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14652 else if (unformat (line_input, "del"))
14653 enable_disable = 0;
14658 if (address_set == 0)
14660 errmsg ("missing addresses");
14664 M (WANT_IP6_ND_EVENTS, mp);
14665 mp->enable_disable = enable_disable;
14666 mp->pid = htonl (getpid ());
14667 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14675 api_want_l2_macs_events (vat_main_t * vam)
14677 unformat_input_t *line_input = vam->input;
14678 vl_api_want_l2_macs_events_t *mp;
14679 u8 enable_disable = 1;
14680 u32 scan_delay = 0;
14681 u32 max_macs_in_event = 0;
14682 u32 learn_limit = 0;
14685 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14687 if (unformat (line_input, "learn-limit %d", &learn_limit))
14689 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14691 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14693 else if (unformat (line_input, "disable"))
14694 enable_disable = 0;
14699 M (WANT_L2_MACS_EVENTS, mp);
14700 mp->enable_disable = enable_disable;
14701 mp->pid = htonl (getpid ());
14702 mp->learn_limit = htonl (learn_limit);
14703 mp->scan_delay = (u8) scan_delay;
14704 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14711 api_input_acl_set_interface (vat_main_t * vam)
14713 unformat_input_t *i = vam->input;
14714 vl_api_input_acl_set_interface_t *mp;
14716 int sw_if_index_set;
14717 u32 ip4_table_index = ~0;
14718 u32 ip6_table_index = ~0;
14719 u32 l2_table_index = ~0;
14723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14726 sw_if_index_set = 1;
14727 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14728 sw_if_index_set = 1;
14729 else if (unformat (i, "del"))
14731 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14733 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14735 else if (unformat (i, "l2-table %d", &l2_table_index))
14739 clib_warning ("parse error '%U'", format_unformat_error, i);
14744 if (sw_if_index_set == 0)
14746 errmsg ("missing interface name or sw_if_index");
14750 M (INPUT_ACL_SET_INTERFACE, mp);
14752 mp->sw_if_index = ntohl (sw_if_index);
14753 mp->ip4_table_index = ntohl (ip4_table_index);
14754 mp->ip6_table_index = ntohl (ip6_table_index);
14755 mp->l2_table_index = ntohl (l2_table_index);
14756 mp->is_add = is_add;
14764 api_output_acl_set_interface (vat_main_t * vam)
14766 unformat_input_t *i = vam->input;
14767 vl_api_output_acl_set_interface_t *mp;
14769 int sw_if_index_set;
14770 u32 ip4_table_index = ~0;
14771 u32 ip6_table_index = ~0;
14772 u32 l2_table_index = ~0;
14776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14778 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14779 sw_if_index_set = 1;
14780 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14781 sw_if_index_set = 1;
14782 else if (unformat (i, "del"))
14784 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14786 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14788 else if (unformat (i, "l2-table %d", &l2_table_index))
14792 clib_warning ("parse error '%U'", format_unformat_error, i);
14797 if (sw_if_index_set == 0)
14799 errmsg ("missing interface name or sw_if_index");
14803 M (OUTPUT_ACL_SET_INTERFACE, mp);
14805 mp->sw_if_index = ntohl (sw_if_index);
14806 mp->ip4_table_index = ntohl (ip4_table_index);
14807 mp->ip6_table_index = ntohl (ip6_table_index);
14808 mp->l2_table_index = ntohl (l2_table_index);
14809 mp->is_add = is_add;
14817 api_ip_address_dump (vat_main_t * vam)
14819 unformat_input_t *i = vam->input;
14820 vl_api_ip_address_dump_t *mp;
14821 vl_api_control_ping_t *mp_ping;
14822 u32 sw_if_index = ~0;
14823 u8 sw_if_index_set = 0;
14828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14830 if (unformat (i, "sw_if_index %d", &sw_if_index))
14831 sw_if_index_set = 1;
14833 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14834 sw_if_index_set = 1;
14835 else if (unformat (i, "ipv4"))
14837 else if (unformat (i, "ipv6"))
14843 if (ipv4_set && ipv6_set)
14845 errmsg ("ipv4 and ipv6 flags cannot be both set");
14849 if ((!ipv4_set) && (!ipv6_set))
14851 errmsg ("no ipv4 nor ipv6 flag set");
14855 if (sw_if_index_set == 0)
14857 errmsg ("missing interface name or sw_if_index");
14861 vam->current_sw_if_index = sw_if_index;
14862 vam->is_ipv6 = ipv6_set;
14864 M (IP_ADDRESS_DUMP, mp);
14865 mp->sw_if_index = ntohl (sw_if_index);
14866 mp->is_ipv6 = ipv6_set;
14869 /* Use a control ping for synchronization */
14870 MPING (CONTROL_PING, mp_ping);
14878 api_ip_dump (vat_main_t * vam)
14880 vl_api_ip_dump_t *mp;
14881 vl_api_control_ping_t *mp_ping;
14882 unformat_input_t *in = vam->input;
14889 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14891 if (unformat (in, "ipv4"))
14893 else if (unformat (in, "ipv6"))
14899 if (ipv4_set && ipv6_set)
14901 errmsg ("ipv4 and ipv6 flags cannot be both set");
14905 if ((!ipv4_set) && (!ipv6_set))
14907 errmsg ("no ipv4 nor ipv6 flag set");
14911 is_ipv6 = ipv6_set;
14912 vam->is_ipv6 = is_ipv6;
14914 /* free old data */
14915 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14917 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14919 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14922 mp->is_ipv6 = ipv6_set;
14925 /* Use a control ping for synchronization */
14926 MPING (CONTROL_PING, mp_ping);
14934 api_ipsec_spd_add_del (vat_main_t * vam)
14936 unformat_input_t *i = vam->input;
14937 vl_api_ipsec_spd_add_del_t *mp;
14942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14944 if (unformat (i, "spd_id %d", &spd_id))
14946 else if (unformat (i, "del"))
14950 clib_warning ("parse error '%U'", format_unformat_error, i);
14956 errmsg ("spd_id must be set");
14960 M (IPSEC_SPD_ADD_DEL, mp);
14962 mp->spd_id = ntohl (spd_id);
14963 mp->is_add = is_add;
14971 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14973 unformat_input_t *i = vam->input;
14974 vl_api_ipsec_interface_add_del_spd_t *mp;
14976 u8 sw_if_index_set = 0;
14977 u32 spd_id = (u32) ~ 0;
14981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14983 if (unformat (i, "del"))
14985 else if (unformat (i, "spd_id %d", &spd_id))
14988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14989 sw_if_index_set = 1;
14990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14991 sw_if_index_set = 1;
14994 clib_warning ("parse error '%U'", format_unformat_error, i);
15000 if (spd_id == (u32) ~ 0)
15002 errmsg ("spd_id must be set");
15006 if (sw_if_index_set == 0)
15008 errmsg ("missing interface name or sw_if_index");
15012 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
15014 mp->spd_id = ntohl (spd_id);
15015 mp->sw_if_index = ntohl (sw_if_index);
15016 mp->is_add = is_add;
15024 api_ipsec_spd_add_del_entry (vat_main_t * vam)
15026 unformat_input_t *i = vam->input;
15027 vl_api_ipsec_spd_add_del_entry_t *mp;
15028 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
15029 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
15031 u32 rport_start = 0, rport_stop = (u32) ~ 0;
15032 u32 lport_start = 0, lport_stop = (u32) ~ 0;
15033 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
15034 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
15037 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
15038 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
15039 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
15040 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
15041 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
15042 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
15044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15046 if (unformat (i, "del"))
15048 if (unformat (i, "outbound"))
15050 if (unformat (i, "inbound"))
15052 else if (unformat (i, "spd_id %d", &spd_id))
15054 else if (unformat (i, "sa_id %d", &sa_id))
15056 else if (unformat (i, "priority %d", &priority))
15058 else if (unformat (i, "protocol %d", &protocol))
15060 else if (unformat (i, "lport_start %d", &lport_start))
15062 else if (unformat (i, "lport_stop %d", &lport_stop))
15064 else if (unformat (i, "rport_start %d", &rport_start))
15066 else if (unformat (i, "rport_stop %d", &rport_stop))
15070 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
15076 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
15083 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
15089 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
15096 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
15102 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15109 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15115 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15121 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15123 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15125 clib_warning ("unsupported action: 'resolve'");
15131 clib_warning ("parse error '%U'", format_unformat_error, i);
15137 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15139 mp->spd_id = ntohl (spd_id);
15140 mp->priority = ntohl (priority);
15141 mp->is_outbound = is_outbound;
15143 mp->is_ipv6 = is_ipv6;
15144 if (is_ipv6 || is_ip_any)
15146 clib_memcpy (mp->remote_address_start, &raddr6_start,
15147 sizeof (ip6_address_t));
15148 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15149 sizeof (ip6_address_t));
15150 clib_memcpy (mp->local_address_start, &laddr6_start,
15151 sizeof (ip6_address_t));
15152 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15153 sizeof (ip6_address_t));
15157 clib_memcpy (mp->remote_address_start, &raddr4_start,
15158 sizeof (ip4_address_t));
15159 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15160 sizeof (ip4_address_t));
15161 clib_memcpy (mp->local_address_start, &laddr4_start,
15162 sizeof (ip4_address_t));
15163 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15164 sizeof (ip4_address_t));
15166 mp->protocol = (u8) protocol;
15167 mp->local_port_start = ntohs ((u16) lport_start);
15168 mp->local_port_stop = ntohs ((u16) lport_stop);
15169 mp->remote_port_start = ntohs ((u16) rport_start);
15170 mp->remote_port_stop = ntohs ((u16) rport_stop);
15171 mp->policy = (u8) policy;
15172 mp->sa_id = ntohl (sa_id);
15173 mp->is_add = is_add;
15174 mp->is_ip_any = is_ip_any;
15181 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15183 unformat_input_t *i = vam->input;
15184 vl_api_ipsec_sad_add_del_entry_t *mp;
15185 u32 sad_id = 0, spi = 0;
15186 u8 *ck = 0, *ik = 0;
15189 u8 protocol = IPSEC_PROTOCOL_AH;
15190 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15191 u32 crypto_alg = 0, integ_alg = 0;
15192 ip4_address_t tun_src4;
15193 ip4_address_t tun_dst4;
15194 ip6_address_t tun_src6;
15195 ip6_address_t tun_dst6;
15198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15200 if (unformat (i, "del"))
15202 else if (unformat (i, "sad_id %d", &sad_id))
15204 else if (unformat (i, "spi %d", &spi))
15206 else if (unformat (i, "esp"))
15207 protocol = IPSEC_PROTOCOL_ESP;
15208 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15211 is_tunnel_ipv6 = 0;
15213 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15216 is_tunnel_ipv6 = 0;
15218 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15221 is_tunnel_ipv6 = 1;
15223 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15226 is_tunnel_ipv6 = 1;
15230 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15232 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15233 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15235 clib_warning ("unsupported crypto-alg: '%U'",
15236 format_ipsec_crypto_alg, crypto_alg);
15240 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15244 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15246 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15247 integ_alg >= IPSEC_INTEG_N_ALG)
15249 clib_warning ("unsupported integ-alg: '%U'",
15250 format_ipsec_integ_alg, integ_alg);
15254 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15258 clib_warning ("parse error '%U'", format_unformat_error, i);
15264 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15266 mp->sad_id = ntohl (sad_id);
15267 mp->is_add = is_add;
15268 mp->protocol = protocol;
15269 mp->spi = ntohl (spi);
15270 mp->is_tunnel = is_tunnel;
15271 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15272 mp->crypto_algorithm = crypto_alg;
15273 mp->integrity_algorithm = integ_alg;
15274 mp->crypto_key_length = vec_len (ck);
15275 mp->integrity_key_length = vec_len (ik);
15277 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15278 mp->crypto_key_length = sizeof (mp->crypto_key);
15280 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15281 mp->integrity_key_length = sizeof (mp->integrity_key);
15284 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15286 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15290 if (is_tunnel_ipv6)
15292 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15293 sizeof (ip6_address_t));
15294 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15295 sizeof (ip6_address_t));
15299 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15300 sizeof (ip4_address_t));
15301 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15302 sizeof (ip4_address_t));
15312 api_ipsec_sa_set_key (vat_main_t * vam)
15314 unformat_input_t *i = vam->input;
15315 vl_api_ipsec_sa_set_key_t *mp;
15317 u8 *ck = 0, *ik = 0;
15320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15322 if (unformat (i, "sa_id %d", &sa_id))
15324 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15326 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15330 clib_warning ("parse error '%U'", format_unformat_error, i);
15335 M (IPSEC_SA_SET_KEY, mp);
15337 mp->sa_id = ntohl (sa_id);
15338 mp->crypto_key_length = vec_len (ck);
15339 mp->integrity_key_length = vec_len (ik);
15341 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15342 mp->crypto_key_length = sizeof (mp->crypto_key);
15344 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15345 mp->integrity_key_length = sizeof (mp->integrity_key);
15348 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15350 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15358 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15360 unformat_input_t *i = vam->input;
15361 vl_api_ipsec_tunnel_if_add_del_t *mp;
15362 u32 local_spi = 0, remote_spi = 0;
15363 u32 crypto_alg = 0, integ_alg = 0;
15364 u8 *lck = NULL, *rck = NULL;
15365 u8 *lik = NULL, *rik = NULL;
15366 ip4_address_t local_ip = { {0} };
15367 ip4_address_t remote_ip = { {0} };
15370 u8 anti_replay = 0;
15375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15377 if (unformat (i, "del"))
15379 else if (unformat (i, "esn"))
15381 else if (unformat (i, "anti_replay"))
15383 else if (unformat (i, "local_spi %d", &local_spi))
15385 else if (unformat (i, "remote_spi %d", &remote_spi))
15387 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15389 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15391 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15394 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15396 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15398 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15402 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15404 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15405 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15407 errmsg ("unsupported crypto-alg: '%U'\n",
15408 format_ipsec_crypto_alg, crypto_alg);
15414 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15416 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15417 integ_alg >= IPSEC_INTEG_N_ALG)
15419 errmsg ("unsupported integ-alg: '%U'\n",
15420 format_ipsec_integ_alg, integ_alg);
15424 else if (unformat (i, "instance %u", &instance))
15428 errmsg ("parse error '%U'\n", format_unformat_error, i);
15433 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15435 mp->is_add = is_add;
15437 mp->anti_replay = anti_replay;
15439 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15440 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15442 mp->local_spi = htonl (local_spi);
15443 mp->remote_spi = htonl (remote_spi);
15444 mp->crypto_alg = (u8) crypto_alg;
15446 mp->local_crypto_key_len = 0;
15449 mp->local_crypto_key_len = vec_len (lck);
15450 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15451 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15452 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15455 mp->remote_crypto_key_len = 0;
15458 mp->remote_crypto_key_len = vec_len (rck);
15459 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15460 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15461 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15464 mp->integ_alg = (u8) integ_alg;
15466 mp->local_integ_key_len = 0;
15469 mp->local_integ_key_len = vec_len (lik);
15470 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15471 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15472 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15475 mp->remote_integ_key_len = 0;
15478 mp->remote_integ_key_len = vec_len (rik);
15479 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15480 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15481 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15486 mp->renumber = renumber;
15487 mp->show_instance = ntohl (instance);
15496 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15498 vat_main_t *vam = &vat_main;
15500 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15501 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15502 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15503 "tunnel_src_addr %U tunnel_dst_addr %U "
15504 "salt %u seq_outbound %lu last_seq_inbound %lu "
15505 "replay_window %lu total_data_size %lu\n",
15506 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15508 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15509 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15510 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15511 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15512 mp->tunnel_src_addr,
15513 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15514 mp->tunnel_dst_addr,
15516 clib_net_to_host_u64 (mp->seq_outbound),
15517 clib_net_to_host_u64 (mp->last_seq_inbound),
15518 clib_net_to_host_u64 (mp->replay_window),
15519 clib_net_to_host_u64 (mp->total_data_size));
15522 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15523 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15525 static void vl_api_ipsec_sa_details_t_handler_json
15526 (vl_api_ipsec_sa_details_t * mp)
15528 vat_main_t *vam = &vat_main;
15529 vat_json_node_t *node = NULL;
15530 struct in_addr src_ip4, dst_ip4;
15531 struct in6_addr src_ip6, dst_ip6;
15533 if (VAT_JSON_ARRAY != vam->json_tree.type)
15535 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15536 vat_json_init_array (&vam->json_tree);
15538 node = vat_json_array_add (&vam->json_tree);
15540 vat_json_init_object (node);
15541 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15542 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15543 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15544 vat_json_object_add_uint (node, "proto", mp->protocol);
15545 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15546 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15547 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15548 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15549 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15550 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15551 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15552 mp->crypto_key_len);
15553 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15554 mp->integ_key_len);
15555 if (mp->is_tunnel_ip6)
15557 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15558 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15559 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15560 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15564 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15565 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15566 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15567 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15569 vat_json_object_add_uint (node, "replay_window",
15570 clib_net_to_host_u64 (mp->replay_window));
15571 vat_json_object_add_uint (node, "total_data_size",
15572 clib_net_to_host_u64 (mp->total_data_size));
15577 api_ipsec_sa_dump (vat_main_t * vam)
15579 unformat_input_t *i = vam->input;
15580 vl_api_ipsec_sa_dump_t *mp;
15581 vl_api_control_ping_t *mp_ping;
15585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15587 if (unformat (i, "sa_id %d", &sa_id))
15591 clib_warning ("parse error '%U'", format_unformat_error, i);
15596 M (IPSEC_SA_DUMP, mp);
15598 mp->sa_id = ntohl (sa_id);
15602 /* Use a control ping for synchronization */
15603 M (CONTROL_PING, mp_ping);
15611 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15613 unformat_input_t *i = vam->input;
15614 vl_api_ipsec_tunnel_if_set_key_t *mp;
15615 u32 sw_if_index = ~0;
15616 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15623 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15626 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15627 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15629 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15630 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15631 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15632 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15634 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15635 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15636 else if (unformat (i, "%U", unformat_hex_string, &key))
15640 clib_warning ("parse error '%U'", format_unformat_error, i);
15645 if (sw_if_index == ~0)
15647 errmsg ("interface must be specified");
15651 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15653 errmsg ("key type must be specified");
15659 errmsg ("algorithm must be specified");
15663 if (vec_len (key) == 0)
15665 errmsg ("key must be specified");
15669 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15671 mp->sw_if_index = htonl (sw_if_index);
15673 mp->key_type = key_type;
15674 mp->key_len = vec_len (key);
15675 clib_memcpy (mp->key, key, vec_len (key));
15684 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15686 unformat_input_t *i = vam->input;
15687 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15688 u32 sw_if_index = ~0;
15690 u8 is_outbound = (u8) ~ 0;
15693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15697 else if (unformat (i, "sa_id %d", &sa_id))
15699 else if (unformat (i, "outbound"))
15701 else if (unformat (i, "inbound"))
15705 clib_warning ("parse error '%U'", format_unformat_error, i);
15710 if (sw_if_index == ~0)
15712 errmsg ("interface must be specified");
15718 errmsg ("SA ID must be specified");
15722 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15724 mp->sw_if_index = htonl (sw_if_index);
15725 mp->sa_id = htonl (sa_id);
15726 mp->is_outbound = is_outbound;
15735 api_ikev2_profile_add_del (vat_main_t * vam)
15737 unformat_input_t *i = vam->input;
15738 vl_api_ikev2_profile_add_del_t *mp;
15743 const char *valid_chars = "a-zA-Z0-9_";
15745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15747 if (unformat (i, "del"))
15749 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15750 vec_add1 (name, 0);
15753 errmsg ("parse error '%U'", format_unformat_error, i);
15758 if (!vec_len (name))
15760 errmsg ("profile name must be specified");
15764 if (vec_len (name) > 64)
15766 errmsg ("profile name too long");
15770 M (IKEV2_PROFILE_ADD_DEL, mp);
15772 clib_memcpy (mp->name, name, vec_len (name));
15773 mp->is_add = is_add;
15782 api_ikev2_profile_set_auth (vat_main_t * vam)
15784 unformat_input_t *i = vam->input;
15785 vl_api_ikev2_profile_set_auth_t *mp;
15788 u32 auth_method = 0;
15792 const char *valid_chars = "a-zA-Z0-9_";
15794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15796 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15797 vec_add1 (name, 0);
15798 else if (unformat (i, "auth_method %U",
15799 unformat_ikev2_auth_method, &auth_method))
15801 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15803 else if (unformat (i, "auth_data %v", &data))
15807 errmsg ("parse error '%U'", format_unformat_error, i);
15812 if (!vec_len (name))
15814 errmsg ("profile name must be specified");
15818 if (vec_len (name) > 64)
15820 errmsg ("profile name too long");
15824 if (!vec_len (data))
15826 errmsg ("auth_data must be specified");
15832 errmsg ("auth_method must be specified");
15836 M (IKEV2_PROFILE_SET_AUTH, mp);
15838 mp->is_hex = is_hex;
15839 mp->auth_method = (u8) auth_method;
15840 mp->data_len = vec_len (data);
15841 clib_memcpy (mp->name, name, vec_len (name));
15842 clib_memcpy (mp->data, data, vec_len (data));
15852 api_ikev2_profile_set_id (vat_main_t * vam)
15854 unformat_input_t *i = vam->input;
15855 vl_api_ikev2_profile_set_id_t *mp;
15863 const char *valid_chars = "a-zA-Z0-9_";
15865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15867 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15868 vec_add1 (name, 0);
15869 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15871 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15873 data = vec_new (u8, 4);
15874 clib_memcpy (data, ip4.as_u8, 4);
15876 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15878 else if (unformat (i, "id_data %v", &data))
15880 else if (unformat (i, "local"))
15882 else if (unformat (i, "remote"))
15886 errmsg ("parse error '%U'", format_unformat_error, i);
15891 if (!vec_len (name))
15893 errmsg ("profile name must be specified");
15897 if (vec_len (name) > 64)
15899 errmsg ("profile name too long");
15903 if (!vec_len (data))
15905 errmsg ("id_data must be specified");
15911 errmsg ("id_type must be specified");
15915 M (IKEV2_PROFILE_SET_ID, mp);
15917 mp->is_local = is_local;
15918 mp->id_type = (u8) id_type;
15919 mp->data_len = vec_len (data);
15920 clib_memcpy (mp->name, name, vec_len (name));
15921 clib_memcpy (mp->data, data, vec_len (data));
15931 api_ikev2_profile_set_ts (vat_main_t * vam)
15933 unformat_input_t *i = vam->input;
15934 vl_api_ikev2_profile_set_ts_t *mp;
15937 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15938 ip4_address_t start_addr, end_addr;
15940 const char *valid_chars = "a-zA-Z0-9_";
15943 start_addr.as_u32 = 0;
15944 end_addr.as_u32 = (u32) ~ 0;
15946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15948 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15949 vec_add1 (name, 0);
15950 else if (unformat (i, "protocol %d", &proto))
15952 else if (unformat (i, "start_port %d", &start_port))
15954 else if (unformat (i, "end_port %d", &end_port))
15957 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15959 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15961 else if (unformat (i, "local"))
15963 else if (unformat (i, "remote"))
15967 errmsg ("parse error '%U'", format_unformat_error, i);
15972 if (!vec_len (name))
15974 errmsg ("profile name must be specified");
15978 if (vec_len (name) > 64)
15980 errmsg ("profile name too long");
15984 M (IKEV2_PROFILE_SET_TS, mp);
15986 mp->is_local = is_local;
15987 mp->proto = (u8) proto;
15988 mp->start_port = (u16) start_port;
15989 mp->end_port = (u16) end_port;
15990 mp->start_addr = start_addr.as_u32;
15991 mp->end_addr = end_addr.as_u32;
15992 clib_memcpy (mp->name, name, vec_len (name));
16001 api_ikev2_set_local_key (vat_main_t * vam)
16003 unformat_input_t *i = vam->input;
16004 vl_api_ikev2_set_local_key_t *mp;
16008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16010 if (unformat (i, "file %v", &file))
16011 vec_add1 (file, 0);
16014 errmsg ("parse error '%U'", format_unformat_error, i);
16019 if (!vec_len (file))
16021 errmsg ("RSA key file must be specified");
16025 if (vec_len (file) > 256)
16027 errmsg ("file name too long");
16031 M (IKEV2_SET_LOCAL_KEY, mp);
16033 clib_memcpy (mp->key_file, file, vec_len (file));
16042 api_ikev2_set_responder (vat_main_t * vam)
16044 unformat_input_t *i = vam->input;
16045 vl_api_ikev2_set_responder_t *mp;
16048 u32 sw_if_index = ~0;
16049 ip4_address_t address;
16051 const char *valid_chars = "a-zA-Z0-9_";
16053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16056 (i, "%U interface %d address %U", unformat_token, valid_chars,
16057 &name, &sw_if_index, unformat_ip4_address, &address))
16058 vec_add1 (name, 0);
16061 errmsg ("parse error '%U'", format_unformat_error, i);
16066 if (!vec_len (name))
16068 errmsg ("profile name must be specified");
16072 if (vec_len (name) > 64)
16074 errmsg ("profile name too long");
16078 M (IKEV2_SET_RESPONDER, mp);
16080 clib_memcpy (mp->name, name, vec_len (name));
16083 mp->sw_if_index = sw_if_index;
16084 clib_memcpy (mp->address, &address, sizeof (address));
16092 api_ikev2_set_ike_transforms (vat_main_t * vam)
16094 unformat_input_t *i = vam->input;
16095 vl_api_ikev2_set_ike_transforms_t *mp;
16098 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16100 const char *valid_chars = "a-zA-Z0-9_";
16102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16104 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16105 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16106 vec_add1 (name, 0);
16109 errmsg ("parse error '%U'", format_unformat_error, i);
16114 if (!vec_len (name))
16116 errmsg ("profile name must be specified");
16120 if (vec_len (name) > 64)
16122 errmsg ("profile name too long");
16126 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16128 clib_memcpy (mp->name, name, vec_len (name));
16130 mp->crypto_alg = crypto_alg;
16131 mp->crypto_key_size = crypto_key_size;
16132 mp->integ_alg = integ_alg;
16133 mp->dh_group = dh_group;
16142 api_ikev2_set_esp_transforms (vat_main_t * vam)
16144 unformat_input_t *i = vam->input;
16145 vl_api_ikev2_set_esp_transforms_t *mp;
16148 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16150 const char *valid_chars = "a-zA-Z0-9_";
16152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16154 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16155 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16156 vec_add1 (name, 0);
16159 errmsg ("parse error '%U'", format_unformat_error, i);
16164 if (!vec_len (name))
16166 errmsg ("profile name must be specified");
16170 if (vec_len (name) > 64)
16172 errmsg ("profile name too long");
16176 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16178 clib_memcpy (mp->name, name, vec_len (name));
16180 mp->crypto_alg = crypto_alg;
16181 mp->crypto_key_size = crypto_key_size;
16182 mp->integ_alg = integ_alg;
16183 mp->dh_group = dh_group;
16191 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16193 unformat_input_t *i = vam->input;
16194 vl_api_ikev2_set_sa_lifetime_t *mp;
16197 u64 lifetime, lifetime_maxdata;
16198 u32 lifetime_jitter, handover;
16200 const char *valid_chars = "a-zA-Z0-9_";
16202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16204 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16205 &lifetime, &lifetime_jitter, &handover,
16206 &lifetime_maxdata))
16207 vec_add1 (name, 0);
16210 errmsg ("parse error '%U'", format_unformat_error, i);
16215 if (!vec_len (name))
16217 errmsg ("profile name must be specified");
16221 if (vec_len (name) > 64)
16223 errmsg ("profile name too long");
16227 M (IKEV2_SET_SA_LIFETIME, mp);
16229 clib_memcpy (mp->name, name, vec_len (name));
16231 mp->lifetime = lifetime;
16232 mp->lifetime_jitter = lifetime_jitter;
16233 mp->handover = handover;
16234 mp->lifetime_maxdata = lifetime_maxdata;
16242 api_ikev2_initiate_sa_init (vat_main_t * vam)
16244 unformat_input_t *i = vam->input;
16245 vl_api_ikev2_initiate_sa_init_t *mp;
16249 const char *valid_chars = "a-zA-Z0-9_";
16251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16253 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16254 vec_add1 (name, 0);
16257 errmsg ("parse error '%U'", format_unformat_error, i);
16262 if (!vec_len (name))
16264 errmsg ("profile name must be specified");
16268 if (vec_len (name) > 64)
16270 errmsg ("profile name too long");
16274 M (IKEV2_INITIATE_SA_INIT, mp);
16276 clib_memcpy (mp->name, name, vec_len (name));
16285 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16287 unformat_input_t *i = vam->input;
16288 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16295 if (unformat (i, "%lx", &ispi))
16299 errmsg ("parse error '%U'", format_unformat_error, i);
16304 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16314 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16316 unformat_input_t *i = vam->input;
16317 vl_api_ikev2_initiate_del_child_sa_t *mp;
16322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16324 if (unformat (i, "%x", &ispi))
16328 errmsg ("parse error '%U'", format_unformat_error, i);
16333 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16343 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16345 unformat_input_t *i = vam->input;
16346 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16353 if (unformat (i, "%x", &ispi))
16357 errmsg ("parse error '%U'", format_unformat_error, i);
16362 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16375 api_map_add_domain (vat_main_t * vam)
16377 unformat_input_t *i = vam->input;
16378 vl_api_map_add_domain_t *mp;
16380 ip4_address_t ip4_prefix;
16381 ip6_address_t ip6_prefix;
16382 ip6_address_t ip6_src;
16383 u32 num_m_args = 0;
16384 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16385 0, psid_length = 0;
16386 u8 is_translation = 0;
16388 u32 ip6_src_len = 128;
16391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16393 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16394 &ip4_prefix, &ip4_prefix_len))
16396 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16397 &ip6_prefix, &ip6_prefix_len))
16401 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16404 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16406 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16408 else if (unformat (i, "psid-offset %d", &psid_offset))
16410 else if (unformat (i, "psid-len %d", &psid_length))
16412 else if (unformat (i, "mtu %d", &mtu))
16414 else if (unformat (i, "map-t"))
16415 is_translation = 1;
16418 clib_warning ("parse error '%U'", format_unformat_error, i);
16423 if (num_m_args < 3)
16425 errmsg ("mandatory argument(s) missing");
16429 /* Construct the API message */
16430 M (MAP_ADD_DOMAIN, mp);
16432 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16433 mp->ip4_prefix_len = ip4_prefix_len;
16435 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16436 mp->ip6_prefix_len = ip6_prefix_len;
16438 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16439 mp->ip6_src_prefix_len = ip6_src_len;
16441 mp->ea_bits_len = ea_bits_len;
16442 mp->psid_offset = psid_offset;
16443 mp->psid_length = psid_length;
16444 mp->is_translation = is_translation;
16445 mp->mtu = htons (mtu);
16450 /* Wait for a reply, return good/bad news */
16456 api_map_del_domain (vat_main_t * vam)
16458 unformat_input_t *i = vam->input;
16459 vl_api_map_del_domain_t *mp;
16461 u32 num_m_args = 0;
16465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16467 if (unformat (i, "index %d", &index))
16471 clib_warning ("parse error '%U'", format_unformat_error, i);
16476 if (num_m_args != 1)
16478 errmsg ("mandatory argument(s) missing");
16482 /* Construct the API message */
16483 M (MAP_DEL_DOMAIN, mp);
16485 mp->index = ntohl (index);
16490 /* Wait for a reply, return good/bad news */
16496 api_map_add_del_rule (vat_main_t * vam)
16498 unformat_input_t *i = vam->input;
16499 vl_api_map_add_del_rule_t *mp;
16501 ip6_address_t ip6_dst;
16502 u32 num_m_args = 0, index, psid = 0;
16505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16507 if (unformat (i, "index %d", &index))
16509 else if (unformat (i, "psid %d", &psid))
16511 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16513 else if (unformat (i, "del"))
16519 clib_warning ("parse error '%U'", format_unformat_error, i);
16524 /* Construct the API message */
16525 M (MAP_ADD_DEL_RULE, mp);
16527 mp->index = ntohl (index);
16528 mp->is_add = is_add;
16529 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16530 mp->psid = ntohs (psid);
16535 /* Wait for a reply, return good/bad news */
16541 api_map_domain_dump (vat_main_t * vam)
16543 vl_api_map_domain_dump_t *mp;
16544 vl_api_control_ping_t *mp_ping;
16547 /* Construct the API message */
16548 M (MAP_DOMAIN_DUMP, mp);
16553 /* Use a control ping for synchronization */
16554 MPING (CONTROL_PING, mp_ping);
16562 api_map_rule_dump (vat_main_t * vam)
16564 unformat_input_t *i = vam->input;
16565 vl_api_map_rule_dump_t *mp;
16566 vl_api_control_ping_t *mp_ping;
16567 u32 domain_index = ~0;
16570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16572 if (unformat (i, "index %u", &domain_index))
16578 if (domain_index == ~0)
16580 clib_warning ("parse error: domain index expected");
16584 /* Construct the API message */
16585 M (MAP_RULE_DUMP, mp);
16587 mp->domain_index = htonl (domain_index);
16592 /* Use a control ping for synchronization */
16593 MPING (CONTROL_PING, mp_ping);
16600 static void vl_api_map_add_domain_reply_t_handler
16601 (vl_api_map_add_domain_reply_t * mp)
16603 vat_main_t *vam = &vat_main;
16604 i32 retval = ntohl (mp->retval);
16606 if (vam->async_mode)
16608 vam->async_errors += (retval < 0);
16612 vam->retval = retval;
16613 vam->result_ready = 1;
16617 static void vl_api_map_add_domain_reply_t_handler_json
16618 (vl_api_map_add_domain_reply_t * mp)
16620 vat_main_t *vam = &vat_main;
16621 vat_json_node_t node;
16623 vat_json_init_object (&node);
16624 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16625 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16627 vat_json_print (vam->ofp, &node);
16628 vat_json_free (&node);
16630 vam->retval = ntohl (mp->retval);
16631 vam->result_ready = 1;
16635 api_get_first_msg_id (vat_main_t * vam)
16637 vl_api_get_first_msg_id_t *mp;
16638 unformat_input_t *i = vam->input;
16643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16645 if (unformat (i, "client %s", &name))
16653 errmsg ("missing client name");
16656 vec_add1 (name, 0);
16658 if (vec_len (name) > 63)
16660 errmsg ("client name too long");
16664 M (GET_FIRST_MSG_ID, mp);
16665 clib_memcpy (mp->name, name, vec_len (name));
16672 api_cop_interface_enable_disable (vat_main_t * vam)
16674 unformat_input_t *line_input = vam->input;
16675 vl_api_cop_interface_enable_disable_t *mp;
16676 u32 sw_if_index = ~0;
16677 u8 enable_disable = 1;
16680 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16682 if (unformat (line_input, "disable"))
16683 enable_disable = 0;
16684 if (unformat (line_input, "enable"))
16685 enable_disable = 1;
16686 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16687 vam, &sw_if_index))
16689 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16695 if (sw_if_index == ~0)
16697 errmsg ("missing interface name or sw_if_index");
16701 /* Construct the API message */
16702 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16703 mp->sw_if_index = ntohl (sw_if_index);
16704 mp->enable_disable = enable_disable;
16708 /* Wait for the reply */
16714 api_cop_whitelist_enable_disable (vat_main_t * vam)
16716 unformat_input_t *line_input = vam->input;
16717 vl_api_cop_whitelist_enable_disable_t *mp;
16718 u32 sw_if_index = ~0;
16719 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16723 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16725 if (unformat (line_input, "ip4"))
16727 else if (unformat (line_input, "ip6"))
16729 else if (unformat (line_input, "default"))
16731 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16732 vam, &sw_if_index))
16734 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16736 else if (unformat (line_input, "fib-id %d", &fib_id))
16742 if (sw_if_index == ~0)
16744 errmsg ("missing interface name or sw_if_index");
16748 /* Construct the API message */
16749 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16750 mp->sw_if_index = ntohl (sw_if_index);
16751 mp->fib_id = ntohl (fib_id);
16754 mp->default_cop = default_cop;
16758 /* Wait for the reply */
16764 api_get_node_graph (vat_main_t * vam)
16766 vl_api_get_node_graph_t *mp;
16769 M (GET_NODE_GRAPH, mp);
16773 /* Wait for the reply */
16779 /** Used for parsing LISP eids */
16780 typedef CLIB_PACKED(struct{
16781 u8 addr[16]; /**< eid address */
16782 u32 len; /**< prefix length if IP */
16783 u8 type; /**< type of eid */
16788 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16790 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16792 memset (a, 0, sizeof (a[0]));
16794 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16796 a->type = 0; /* ipv4 type */
16798 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16800 a->type = 1; /* ipv6 type */
16802 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16804 a->type = 2; /* mac type */
16806 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16808 a->type = 3; /* NSH type */
16809 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16810 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16817 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16826 lisp_eid_size_vat (u8 type)
16843 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16845 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16849 api_one_add_del_locator_set (vat_main_t * vam)
16851 unformat_input_t *input = vam->input;
16852 vl_api_one_add_del_locator_set_t *mp;
16854 u8 *locator_set_name = NULL;
16855 u8 locator_set_name_set = 0;
16856 vl_api_local_locator_t locator, *locators = 0;
16857 u32 sw_if_index, priority, weight;
16861 /* Parse args required to build the message */
16862 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16864 if (unformat (input, "del"))
16868 else if (unformat (input, "locator-set %s", &locator_set_name))
16870 locator_set_name_set = 1;
16872 else if (unformat (input, "sw_if_index %u p %u w %u",
16873 &sw_if_index, &priority, &weight))
16875 locator.sw_if_index = htonl (sw_if_index);
16876 locator.priority = priority;
16877 locator.weight = weight;
16878 vec_add1 (locators, locator);
16882 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16883 &sw_if_index, &priority, &weight))
16885 locator.sw_if_index = htonl (sw_if_index);
16886 locator.priority = priority;
16887 locator.weight = weight;
16888 vec_add1 (locators, locator);
16894 if (locator_set_name_set == 0)
16896 errmsg ("missing locator-set name");
16897 vec_free (locators);
16901 if (vec_len (locator_set_name) > 64)
16903 errmsg ("locator-set name too long");
16904 vec_free (locator_set_name);
16905 vec_free (locators);
16908 vec_add1 (locator_set_name, 0);
16910 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16912 /* Construct the API message */
16913 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16915 mp->is_add = is_add;
16916 clib_memcpy (mp->locator_set_name, locator_set_name,
16917 vec_len (locator_set_name));
16918 vec_free (locator_set_name);
16920 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16922 clib_memcpy (mp->locators, locators, data_len);
16923 vec_free (locators);
16928 /* Wait for a reply... */
16933 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16936 api_one_add_del_locator (vat_main_t * vam)
16938 unformat_input_t *input = vam->input;
16939 vl_api_one_add_del_locator_t *mp;
16940 u32 tmp_if_index = ~0;
16941 u32 sw_if_index = ~0;
16942 u8 sw_if_index_set = 0;
16943 u8 sw_if_index_if_name_set = 0;
16945 u8 priority_set = 0;
16949 u8 *locator_set_name = NULL;
16950 u8 locator_set_name_set = 0;
16953 /* Parse args required to build the message */
16954 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16956 if (unformat (input, "del"))
16960 else if (unformat (input, "locator-set %s", &locator_set_name))
16962 locator_set_name_set = 1;
16964 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16967 sw_if_index_if_name_set = 1;
16968 sw_if_index = tmp_if_index;
16970 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16972 sw_if_index_set = 1;
16973 sw_if_index = tmp_if_index;
16975 else if (unformat (input, "p %d", &priority))
16979 else if (unformat (input, "w %d", &weight))
16987 if (locator_set_name_set == 0)
16989 errmsg ("missing locator-set name");
16993 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16995 errmsg ("missing sw_if_index");
16996 vec_free (locator_set_name);
17000 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
17002 errmsg ("cannot use both params interface name and sw_if_index");
17003 vec_free (locator_set_name);
17007 if (priority_set == 0)
17009 errmsg ("missing locator-set priority");
17010 vec_free (locator_set_name);
17014 if (weight_set == 0)
17016 errmsg ("missing locator-set weight");
17017 vec_free (locator_set_name);
17021 if (vec_len (locator_set_name) > 64)
17023 errmsg ("locator-set name too long");
17024 vec_free (locator_set_name);
17027 vec_add1 (locator_set_name, 0);
17029 /* Construct the API message */
17030 M (ONE_ADD_DEL_LOCATOR, mp);
17032 mp->is_add = is_add;
17033 mp->sw_if_index = ntohl (sw_if_index);
17034 mp->priority = priority;
17035 mp->weight = weight;
17036 clib_memcpy (mp->locator_set_name, locator_set_name,
17037 vec_len (locator_set_name));
17038 vec_free (locator_set_name);
17043 /* Wait for a reply... */
17048 #define api_lisp_add_del_locator api_one_add_del_locator
17051 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
17053 u32 *key_id = va_arg (*args, u32 *);
17056 if (unformat (input, "%s", &s))
17058 if (!strcmp ((char *) s, "sha1"))
17059 key_id[0] = HMAC_SHA_1_96;
17060 else if (!strcmp ((char *) s, "sha256"))
17061 key_id[0] = HMAC_SHA_256_128;
17064 clib_warning ("invalid key_id: '%s'", s);
17065 key_id[0] = HMAC_NO_KEY;
17076 api_one_add_del_local_eid (vat_main_t * vam)
17078 unformat_input_t *input = vam->input;
17079 vl_api_one_add_del_local_eid_t *mp;
17082 lisp_eid_vat_t _eid, *eid = &_eid;
17083 u8 *locator_set_name = 0;
17084 u8 locator_set_name_set = 0;
17090 /* Parse args required to build the message */
17091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17093 if (unformat (input, "del"))
17097 else if (unformat (input, "vni %d", &vni))
17101 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17105 else if (unformat (input, "locator-set %s", &locator_set_name))
17107 locator_set_name_set = 1;
17109 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17111 else if (unformat (input, "secret-key %_%v%_", &key))
17117 if (locator_set_name_set == 0)
17119 errmsg ("missing locator-set name");
17125 errmsg ("EID address not set!");
17126 vec_free (locator_set_name);
17130 if (key && (0 == key_id))
17132 errmsg ("invalid key_id!");
17136 if (vec_len (key) > 64)
17138 errmsg ("key too long");
17143 if (vec_len (locator_set_name) > 64)
17145 errmsg ("locator-set name too long");
17146 vec_free (locator_set_name);
17149 vec_add1 (locator_set_name, 0);
17151 /* Construct the API message */
17152 M (ONE_ADD_DEL_LOCAL_EID, mp);
17154 mp->is_add = is_add;
17155 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17156 mp->eid_type = eid->type;
17157 mp->prefix_len = eid->len;
17158 mp->vni = clib_host_to_net_u32 (vni);
17159 mp->key_id = clib_host_to_net_u16 (key_id);
17160 clib_memcpy (mp->locator_set_name, locator_set_name,
17161 vec_len (locator_set_name));
17162 clib_memcpy (mp->key, key, vec_len (key));
17164 vec_free (locator_set_name);
17170 /* Wait for a reply... */
17175 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17178 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17180 u32 dp_table = 0, vni = 0;;
17181 unformat_input_t *input = vam->input;
17182 vl_api_gpe_add_del_fwd_entry_t *mp;
17184 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17185 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17186 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17187 u32 action = ~0, w;
17188 ip4_address_t rmt_rloc4, lcl_rloc4;
17189 ip6_address_t rmt_rloc6, lcl_rloc6;
17190 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17193 memset (&rloc, 0, sizeof (rloc));
17195 /* Parse args required to build the message */
17196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17198 if (unformat (input, "del"))
17200 else if (unformat (input, "add"))
17202 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17206 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17210 else if (unformat (input, "vrf %d", &dp_table))
17212 else if (unformat (input, "bd %d", &dp_table))
17214 else if (unformat (input, "vni %d", &vni))
17216 else if (unformat (input, "w %d", &w))
17220 errmsg ("No RLOC configured for setting priority/weight!");
17223 curr_rloc->weight = w;
17225 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17226 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17230 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17232 vec_add1 (lcl_locs, rloc);
17234 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17235 vec_add1 (rmt_locs, rloc);
17236 /* weight saved in rmt loc */
17237 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17239 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17240 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17243 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17245 vec_add1 (lcl_locs, rloc);
17247 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17248 vec_add1 (rmt_locs, rloc);
17249 /* weight saved in rmt loc */
17250 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17252 else if (unformat (input, "action %d", &action))
17258 clib_warning ("parse error '%U'", format_unformat_error, input);
17265 errmsg ("remote eid addresses not set");
17269 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17271 errmsg ("eid types don't match");
17275 if (0 == rmt_locs && (u32) ~ 0 == action)
17277 errmsg ("action not set for negative mapping");
17281 /* Construct the API message */
17282 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17283 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17285 mp->is_add = is_add;
17286 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17287 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17288 mp->eid_type = rmt_eid->type;
17289 mp->dp_table = clib_host_to_net_u32 (dp_table);
17290 mp->vni = clib_host_to_net_u32 (vni);
17291 mp->rmt_len = rmt_eid->len;
17292 mp->lcl_len = lcl_eid->len;
17293 mp->action = action;
17295 if (0 != rmt_locs && 0 != lcl_locs)
17297 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17298 clib_memcpy (mp->locs, lcl_locs,
17299 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17301 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17302 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17303 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17305 vec_free (lcl_locs);
17306 vec_free (rmt_locs);
17311 /* Wait for a reply... */
17317 api_one_add_del_map_server (vat_main_t * vam)
17319 unformat_input_t *input = vam->input;
17320 vl_api_one_add_del_map_server_t *mp;
17324 ip4_address_t ipv4;
17325 ip6_address_t ipv6;
17328 /* Parse args required to build the message */
17329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17331 if (unformat (input, "del"))
17335 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17339 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17347 if (ipv4_set && ipv6_set)
17349 errmsg ("both eid v4 and v6 addresses set");
17353 if (!ipv4_set && !ipv6_set)
17355 errmsg ("eid addresses not set");
17359 /* Construct the API message */
17360 M (ONE_ADD_DEL_MAP_SERVER, mp);
17362 mp->is_add = is_add;
17366 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17371 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17377 /* Wait for a reply... */
17382 #define api_lisp_add_del_map_server api_one_add_del_map_server
17385 api_one_add_del_map_resolver (vat_main_t * vam)
17387 unformat_input_t *input = vam->input;
17388 vl_api_one_add_del_map_resolver_t *mp;
17392 ip4_address_t ipv4;
17393 ip6_address_t ipv6;
17396 /* Parse args required to build the message */
17397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17399 if (unformat (input, "del"))
17403 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17407 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17415 if (ipv4_set && ipv6_set)
17417 errmsg ("both eid v4 and v6 addresses set");
17421 if (!ipv4_set && !ipv6_set)
17423 errmsg ("eid addresses not set");
17427 /* Construct the API message */
17428 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17430 mp->is_add = is_add;
17434 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17439 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17445 /* Wait for a reply... */
17450 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17453 api_lisp_gpe_enable_disable (vat_main_t * vam)
17455 unformat_input_t *input = vam->input;
17456 vl_api_gpe_enable_disable_t *mp;
17461 /* Parse args required to build the message */
17462 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17464 if (unformat (input, "enable"))
17469 else if (unformat (input, "disable"))
17480 errmsg ("Value not set");
17484 /* Construct the API message */
17485 M (GPE_ENABLE_DISABLE, mp);
17492 /* Wait for a reply... */
17498 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17500 unformat_input_t *input = vam->input;
17501 vl_api_one_rloc_probe_enable_disable_t *mp;
17506 /* Parse args required to build the message */
17507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17509 if (unformat (input, "enable"))
17514 else if (unformat (input, "disable"))
17522 errmsg ("Value not set");
17526 /* Construct the API message */
17527 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17529 mp->is_enabled = is_en;
17534 /* Wait for a reply... */
17539 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17542 api_one_map_register_enable_disable (vat_main_t * vam)
17544 unformat_input_t *input = vam->input;
17545 vl_api_one_map_register_enable_disable_t *mp;
17550 /* Parse args required to build the message */
17551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17553 if (unformat (input, "enable"))
17558 else if (unformat (input, "disable"))
17566 errmsg ("Value not set");
17570 /* Construct the API message */
17571 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17573 mp->is_enabled = is_en;
17578 /* Wait for a reply... */
17583 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17586 api_one_enable_disable (vat_main_t * vam)
17588 unformat_input_t *input = vam->input;
17589 vl_api_one_enable_disable_t *mp;
17594 /* Parse args required to build the message */
17595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17597 if (unformat (input, "enable"))
17602 else if (unformat (input, "disable"))
17612 errmsg ("Value not set");
17616 /* Construct the API message */
17617 M (ONE_ENABLE_DISABLE, mp);
17624 /* Wait for a reply... */
17629 #define api_lisp_enable_disable api_one_enable_disable
17632 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17634 unformat_input_t *input = vam->input;
17635 vl_api_one_enable_disable_xtr_mode_t *mp;
17640 /* Parse args required to build the message */
17641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17643 if (unformat (input, "enable"))
17648 else if (unformat (input, "disable"))
17658 errmsg ("Value not set");
17662 /* Construct the API message */
17663 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17670 /* Wait for a reply... */
17676 api_one_show_xtr_mode (vat_main_t * vam)
17678 vl_api_one_show_xtr_mode_t *mp;
17681 /* Construct the API message */
17682 M (ONE_SHOW_XTR_MODE, mp);
17687 /* Wait for a reply... */
17693 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17695 unformat_input_t *input = vam->input;
17696 vl_api_one_enable_disable_pitr_mode_t *mp;
17701 /* Parse args required to build the message */
17702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17704 if (unformat (input, "enable"))
17709 else if (unformat (input, "disable"))
17719 errmsg ("Value not set");
17723 /* Construct the API message */
17724 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17731 /* Wait for a reply... */
17737 api_one_show_pitr_mode (vat_main_t * vam)
17739 vl_api_one_show_pitr_mode_t *mp;
17742 /* Construct the API message */
17743 M (ONE_SHOW_PITR_MODE, mp);
17748 /* Wait for a reply... */
17754 api_one_enable_disable_petr_mode (vat_main_t * vam)
17756 unformat_input_t *input = vam->input;
17757 vl_api_one_enable_disable_petr_mode_t *mp;
17762 /* Parse args required to build the message */
17763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17765 if (unformat (input, "enable"))
17770 else if (unformat (input, "disable"))
17780 errmsg ("Value not set");
17784 /* Construct the API message */
17785 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17792 /* Wait for a reply... */
17798 api_one_show_petr_mode (vat_main_t * vam)
17800 vl_api_one_show_petr_mode_t *mp;
17803 /* Construct the API message */
17804 M (ONE_SHOW_PETR_MODE, mp);
17809 /* Wait for a reply... */
17815 api_show_one_map_register_state (vat_main_t * vam)
17817 vl_api_show_one_map_register_state_t *mp;
17820 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17825 /* wait for reply */
17830 #define api_show_lisp_map_register_state api_show_one_map_register_state
17833 api_show_one_rloc_probe_state (vat_main_t * vam)
17835 vl_api_show_one_rloc_probe_state_t *mp;
17838 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17843 /* wait for reply */
17848 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17851 api_one_add_del_ndp_entry (vat_main_t * vam)
17853 vl_api_one_add_del_ndp_entry_t *mp;
17854 unformat_input_t *input = vam->input;
17859 u8 mac[6] = { 0, };
17860 u8 ip6[16] = { 0, };
17864 /* Parse args required to build the message */
17865 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17867 if (unformat (input, "del"))
17869 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17871 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17873 else if (unformat (input, "bd %d", &bd))
17877 errmsg ("parse error '%U'", format_unformat_error, input);
17882 if (!bd_set || !ip_set || (!mac_set && is_add))
17884 errmsg ("Missing BD, IP or MAC!");
17888 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17889 mp->is_add = is_add;
17890 clib_memcpy (mp->mac, mac, 6);
17891 mp->bd = clib_host_to_net_u32 (bd);
17892 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17897 /* wait for reply */
17903 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17905 vl_api_one_add_del_l2_arp_entry_t *mp;
17906 unformat_input_t *input = vam->input;
17911 u8 mac[6] = { 0, };
17912 u32 ip4 = 0, bd = ~0;
17915 /* Parse args required to build the message */
17916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17918 if (unformat (input, "del"))
17920 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17922 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17924 else if (unformat (input, "bd %d", &bd))
17928 errmsg ("parse error '%U'", format_unformat_error, input);
17933 if (!bd_set || !ip_set || (!mac_set && is_add))
17935 errmsg ("Missing BD, IP or MAC!");
17939 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17940 mp->is_add = is_add;
17941 clib_memcpy (mp->mac, mac, 6);
17942 mp->bd = clib_host_to_net_u32 (bd);
17948 /* wait for reply */
17954 api_one_ndp_bd_get (vat_main_t * vam)
17956 vl_api_one_ndp_bd_get_t *mp;
17959 M (ONE_NDP_BD_GET, mp);
17964 /* wait for reply */
17970 api_one_ndp_entries_get (vat_main_t * vam)
17972 vl_api_one_ndp_entries_get_t *mp;
17973 unformat_input_t *input = vam->input;
17978 /* Parse args required to build the message */
17979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17981 if (unformat (input, "bd %d", &bd))
17985 errmsg ("parse error '%U'", format_unformat_error, input);
17992 errmsg ("Expected bridge domain!");
17996 M (ONE_NDP_ENTRIES_GET, mp);
17997 mp->bd = clib_host_to_net_u32 (bd);
18002 /* wait for reply */
18008 api_one_l2_arp_bd_get (vat_main_t * vam)
18010 vl_api_one_l2_arp_bd_get_t *mp;
18013 M (ONE_L2_ARP_BD_GET, mp);
18018 /* wait for reply */
18024 api_one_l2_arp_entries_get (vat_main_t * vam)
18026 vl_api_one_l2_arp_entries_get_t *mp;
18027 unformat_input_t *input = vam->input;
18032 /* Parse args required to build the message */
18033 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18035 if (unformat (input, "bd %d", &bd))
18039 errmsg ("parse error '%U'", format_unformat_error, input);
18046 errmsg ("Expected bridge domain!");
18050 M (ONE_L2_ARP_ENTRIES_GET, mp);
18051 mp->bd = clib_host_to_net_u32 (bd);
18056 /* wait for reply */
18062 api_one_stats_enable_disable (vat_main_t * vam)
18064 vl_api_one_stats_enable_disable_t *mp;
18065 unformat_input_t *input = vam->input;
18070 /* Parse args required to build the message */
18071 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18073 if (unformat (input, "enable"))
18078 else if (unformat (input, "disable"))
18088 errmsg ("Value not set");
18092 M (ONE_STATS_ENABLE_DISABLE, mp);
18098 /* wait for reply */
18104 api_show_one_stats_enable_disable (vat_main_t * vam)
18106 vl_api_show_one_stats_enable_disable_t *mp;
18109 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18114 /* wait for reply */
18120 api_show_one_map_request_mode (vat_main_t * vam)
18122 vl_api_show_one_map_request_mode_t *mp;
18125 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18130 /* wait for reply */
18135 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18138 api_one_map_request_mode (vat_main_t * vam)
18140 unformat_input_t *input = vam->input;
18141 vl_api_one_map_request_mode_t *mp;
18145 /* Parse args required to build the message */
18146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18148 if (unformat (input, "dst-only"))
18150 else if (unformat (input, "src-dst"))
18154 errmsg ("parse error '%U'", format_unformat_error, input);
18159 M (ONE_MAP_REQUEST_MODE, mp);
18166 /* wait for reply */
18171 #define api_lisp_map_request_mode api_one_map_request_mode
18174 * Enable/disable ONE proxy ITR.
18176 * @param vam vpp API test context
18177 * @return return code
18180 api_one_pitr_set_locator_set (vat_main_t * vam)
18182 u8 ls_name_set = 0;
18183 unformat_input_t *input = vam->input;
18184 vl_api_one_pitr_set_locator_set_t *mp;
18189 /* Parse args required to build the message */
18190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18192 if (unformat (input, "del"))
18194 else if (unformat (input, "locator-set %s", &ls_name))
18198 errmsg ("parse error '%U'", format_unformat_error, input);
18205 errmsg ("locator-set name not set!");
18209 M (ONE_PITR_SET_LOCATOR_SET, mp);
18211 mp->is_add = is_add;
18212 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18213 vec_free (ls_name);
18218 /* wait for reply */
18223 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18226 api_one_nsh_set_locator_set (vat_main_t * vam)
18228 u8 ls_name_set = 0;
18229 unformat_input_t *input = vam->input;
18230 vl_api_one_nsh_set_locator_set_t *mp;
18235 /* Parse args required to build the message */
18236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18238 if (unformat (input, "del"))
18240 else if (unformat (input, "ls %s", &ls_name))
18244 errmsg ("parse error '%U'", format_unformat_error, input);
18249 if (!ls_name_set && is_add)
18251 errmsg ("locator-set name not set!");
18255 M (ONE_NSH_SET_LOCATOR_SET, mp);
18257 mp->is_add = is_add;
18258 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18259 vec_free (ls_name);
18264 /* wait for reply */
18270 api_show_one_pitr (vat_main_t * vam)
18272 vl_api_show_one_pitr_t *mp;
18275 if (!vam->json_output)
18277 print (vam->ofp, "%=20s", "lisp status:");
18280 M (SHOW_ONE_PITR, mp);
18284 /* Wait for a reply... */
18289 #define api_show_lisp_pitr api_show_one_pitr
18292 api_one_use_petr (vat_main_t * vam)
18294 unformat_input_t *input = vam->input;
18295 vl_api_one_use_petr_t *mp;
18300 memset (&ip, 0, sizeof (ip));
18302 /* Parse args required to build the message */
18303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18305 if (unformat (input, "disable"))
18308 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18311 ip_addr_version (&ip) = IP4;
18314 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18317 ip_addr_version (&ip) = IP6;
18321 errmsg ("parse error '%U'", format_unformat_error, input);
18326 M (ONE_USE_PETR, mp);
18328 mp->is_add = is_add;
18331 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18333 clib_memcpy (mp->address, &ip, 4);
18335 clib_memcpy (mp->address, &ip, 16);
18341 /* wait for reply */
18346 #define api_lisp_use_petr api_one_use_petr
18349 api_show_one_nsh_mapping (vat_main_t * vam)
18351 vl_api_show_one_use_petr_t *mp;
18354 if (!vam->json_output)
18356 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18359 M (SHOW_ONE_NSH_MAPPING, mp);
18363 /* Wait for a reply... */
18369 api_show_one_use_petr (vat_main_t * vam)
18371 vl_api_show_one_use_petr_t *mp;
18374 if (!vam->json_output)
18376 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18379 M (SHOW_ONE_USE_PETR, mp);
18383 /* Wait for a reply... */
18388 #define api_show_lisp_use_petr api_show_one_use_petr
18391 * Add/delete mapping between vni and vrf
18394 api_one_eid_table_add_del_map (vat_main_t * vam)
18396 unformat_input_t *input = vam->input;
18397 vl_api_one_eid_table_add_del_map_t *mp;
18398 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18399 u32 vni, vrf, bd_index;
18402 /* Parse args required to build the message */
18403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18405 if (unformat (input, "del"))
18407 else if (unformat (input, "vrf %d", &vrf))
18409 else if (unformat (input, "bd_index %d", &bd_index))
18411 else if (unformat (input, "vni %d", &vni))
18417 if (!vni_set || (!vrf_set && !bd_index_set))
18419 errmsg ("missing arguments!");
18423 if (vrf_set && bd_index_set)
18425 errmsg ("error: both vrf and bd entered!");
18429 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18431 mp->is_add = is_add;
18432 mp->vni = htonl (vni);
18433 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18434 mp->is_l2 = bd_index_set;
18439 /* wait for reply */
18444 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18447 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18449 u32 *action = va_arg (*args, u32 *);
18452 if (unformat (input, "%s", &s))
18454 if (!strcmp ((char *) s, "no-action"))
18456 else if (!strcmp ((char *) s, "natively-forward"))
18458 else if (!strcmp ((char *) s, "send-map-request"))
18460 else if (!strcmp ((char *) s, "drop"))
18464 clib_warning ("invalid action: '%s'", s);
18476 * Add/del remote mapping to/from ONE control plane
18478 * @param vam vpp API test context
18479 * @return return code
18482 api_one_add_del_remote_mapping (vat_main_t * vam)
18484 unformat_input_t *input = vam->input;
18485 vl_api_one_add_del_remote_mapping_t *mp;
18487 lisp_eid_vat_t _eid, *eid = &_eid;
18488 lisp_eid_vat_t _seid, *seid = &_seid;
18489 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18490 u32 action = ~0, p, w, data_len;
18491 ip4_address_t rloc4;
18492 ip6_address_t rloc6;
18493 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18496 memset (&rloc, 0, sizeof (rloc));
18498 /* Parse args required to build the message */
18499 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18501 if (unformat (input, "del-all"))
18505 else if (unformat (input, "del"))
18509 else if (unformat (input, "add"))
18513 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18517 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18521 else if (unformat (input, "vni %d", &vni))
18525 else if (unformat (input, "p %d w %d", &p, &w))
18529 errmsg ("No RLOC configured for setting priority/weight!");
18532 curr_rloc->priority = p;
18533 curr_rloc->weight = w;
18535 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18538 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18539 vec_add1 (rlocs, rloc);
18540 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18542 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18545 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18546 vec_add1 (rlocs, rloc);
18547 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18549 else if (unformat (input, "action %U",
18550 unformat_negative_mapping_action, &action))
18556 clib_warning ("parse error '%U'", format_unformat_error, input);
18563 errmsg ("missing params!");
18567 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18569 errmsg ("no action set for negative map-reply!");
18573 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18575 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18576 mp->is_add = is_add;
18577 mp->vni = htonl (vni);
18578 mp->action = (u8) action;
18579 mp->is_src_dst = seid_set;
18580 mp->eid_len = eid->len;
18581 mp->seid_len = seid->len;
18582 mp->del_all = del_all;
18583 mp->eid_type = eid->type;
18584 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18585 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18587 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18588 clib_memcpy (mp->rlocs, rlocs, data_len);
18594 /* Wait for a reply... */
18599 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18602 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18603 * forwarding entries in data-plane accordingly.
18605 * @param vam vpp API test context
18606 * @return return code
18609 api_one_add_del_adjacency (vat_main_t * vam)
18611 unformat_input_t *input = vam->input;
18612 vl_api_one_add_del_adjacency_t *mp;
18614 ip4_address_t leid4, reid4;
18615 ip6_address_t leid6, reid6;
18616 u8 reid_mac[6] = { 0 };
18617 u8 leid_mac[6] = { 0 };
18618 u8 reid_type, leid_type;
18619 u32 leid_len = 0, reid_len = 0, len;
18623 leid_type = reid_type = (u8) ~ 0;
18625 /* Parse args required to build the message */
18626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18628 if (unformat (input, "del"))
18632 else if (unformat (input, "add"))
18636 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18639 reid_type = 0; /* ipv4 */
18642 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18645 reid_type = 1; /* ipv6 */
18648 else if (unformat (input, "reid %U", unformat_ethernet_address,
18651 reid_type = 2; /* mac */
18653 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18656 leid_type = 0; /* ipv4 */
18659 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18662 leid_type = 1; /* ipv6 */
18665 else if (unformat (input, "leid %U", unformat_ethernet_address,
18668 leid_type = 2; /* mac */
18670 else if (unformat (input, "vni %d", &vni))
18676 errmsg ("parse error '%U'", format_unformat_error, input);
18681 if ((u8) ~ 0 == reid_type)
18683 errmsg ("missing params!");
18687 if (leid_type != reid_type)
18689 errmsg ("remote and local EIDs are of different types!");
18693 M (ONE_ADD_DEL_ADJACENCY, mp);
18694 mp->is_add = is_add;
18695 mp->vni = htonl (vni);
18696 mp->leid_len = leid_len;
18697 mp->reid_len = reid_len;
18698 mp->eid_type = reid_type;
18700 switch (mp->eid_type)
18703 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18704 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18707 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18708 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18711 clib_memcpy (mp->leid, leid_mac, 6);
18712 clib_memcpy (mp->reid, reid_mac, 6);
18715 errmsg ("unknown EID type %d!", mp->eid_type);
18722 /* Wait for a reply... */
18727 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18730 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18732 u32 *mode = va_arg (*args, u32 *);
18734 if (unformat (input, "lisp"))
18736 else if (unformat (input, "vxlan"))
18745 api_gpe_get_encap_mode (vat_main_t * vam)
18747 vl_api_gpe_get_encap_mode_t *mp;
18750 /* Construct the API message */
18751 M (GPE_GET_ENCAP_MODE, mp);
18756 /* Wait for a reply... */
18762 api_gpe_set_encap_mode (vat_main_t * vam)
18764 unformat_input_t *input = vam->input;
18765 vl_api_gpe_set_encap_mode_t *mp;
18769 /* Parse args required to build the message */
18770 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18772 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18778 /* Construct the API message */
18779 M (GPE_SET_ENCAP_MODE, mp);
18786 /* Wait for a reply... */
18792 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18794 unformat_input_t *input = vam->input;
18795 vl_api_gpe_add_del_iface_t *mp;
18796 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18797 u32 dp_table = 0, vni = 0;
18800 /* Parse args required to build the message */
18801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18803 if (unformat (input, "up"))
18808 else if (unformat (input, "down"))
18813 else if (unformat (input, "table_id %d", &dp_table))
18817 else if (unformat (input, "bd_id %d", &dp_table))
18822 else if (unformat (input, "vni %d", &vni))
18830 if (action_set == 0)
18832 errmsg ("Action not set");
18835 if (dp_table_set == 0 || vni_set == 0)
18837 errmsg ("vni and dp_table must be set");
18841 /* Construct the API message */
18842 M (GPE_ADD_DEL_IFACE, mp);
18844 mp->is_add = is_add;
18845 mp->dp_table = clib_host_to_net_u32 (dp_table);
18847 mp->vni = clib_host_to_net_u32 (vni);
18852 /* Wait for a reply... */
18858 api_one_map_register_fallback_threshold (vat_main_t * vam)
18860 unformat_input_t *input = vam->input;
18861 vl_api_one_map_register_fallback_threshold_t *mp;
18866 /* Parse args required to build the message */
18867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18869 if (unformat (input, "%u", &value))
18873 clib_warning ("parse error '%U'", format_unformat_error, input);
18880 errmsg ("fallback threshold value is missing!");
18884 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18885 mp->value = clib_host_to_net_u32 (value);
18890 /* Wait for a reply... */
18896 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18898 vl_api_show_one_map_register_fallback_threshold_t *mp;
18901 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18906 /* Wait for a reply... */
18912 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18914 u32 *proto = va_arg (*args, u32 *);
18916 if (unformat (input, "udp"))
18918 else if (unformat (input, "api"))
18927 api_one_set_transport_protocol (vat_main_t * vam)
18929 unformat_input_t *input = vam->input;
18930 vl_api_one_set_transport_protocol_t *mp;
18935 /* Parse args required to build the message */
18936 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18938 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18942 clib_warning ("parse error '%U'", format_unformat_error, input);
18949 errmsg ("Transport protocol missing!");
18953 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18954 mp->protocol = (u8) protocol;
18959 /* Wait for a reply... */
18965 api_one_get_transport_protocol (vat_main_t * vam)
18967 vl_api_one_get_transport_protocol_t *mp;
18970 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18975 /* Wait for a reply... */
18981 api_one_map_register_set_ttl (vat_main_t * vam)
18983 unformat_input_t *input = vam->input;
18984 vl_api_one_map_register_set_ttl_t *mp;
18989 /* Parse args required to build the message */
18990 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18992 if (unformat (input, "%u", &ttl))
18996 clib_warning ("parse error '%U'", format_unformat_error, input);
19003 errmsg ("TTL value missing!");
19007 M (ONE_MAP_REGISTER_SET_TTL, mp);
19008 mp->ttl = clib_host_to_net_u32 (ttl);
19013 /* Wait for a reply... */
19019 api_show_one_map_register_ttl (vat_main_t * vam)
19021 vl_api_show_one_map_register_ttl_t *mp;
19024 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
19029 /* Wait for a reply... */
19035 * Add/del map request itr rlocs from ONE control plane and updates
19037 * @param vam vpp API test context
19038 * @return return code
19041 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
19043 unformat_input_t *input = vam->input;
19044 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
19045 u8 *locator_set_name = 0;
19046 u8 locator_set_name_set = 0;
19050 /* Parse args required to build the message */
19051 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19053 if (unformat (input, "del"))
19057 else if (unformat (input, "%_%v%_", &locator_set_name))
19059 locator_set_name_set = 1;
19063 clib_warning ("parse error '%U'", format_unformat_error, input);
19068 if (is_add && !locator_set_name_set)
19070 errmsg ("itr-rloc is not set!");
19074 if (is_add && vec_len (locator_set_name) > 64)
19076 errmsg ("itr-rloc locator-set name too long");
19077 vec_free (locator_set_name);
19081 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
19082 mp->is_add = is_add;
19085 clib_memcpy (mp->locator_set_name, locator_set_name,
19086 vec_len (locator_set_name));
19090 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
19092 vec_free (locator_set_name);
19097 /* Wait for a reply... */
19102 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
19105 api_one_locator_dump (vat_main_t * vam)
19107 unformat_input_t *input = vam->input;
19108 vl_api_one_locator_dump_t *mp;
19109 vl_api_control_ping_t *mp_ping;
19110 u8 is_index_set = 0, is_name_set = 0;
19115 /* Parse args required to build the message */
19116 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19118 if (unformat (input, "ls_name %_%v%_", &ls_name))
19122 else if (unformat (input, "ls_index %d", &ls_index))
19128 errmsg ("parse error '%U'", format_unformat_error, input);
19133 if (!is_index_set && !is_name_set)
19135 errmsg ("error: expected one of index or name!");
19139 if (is_index_set && is_name_set)
19141 errmsg ("error: only one param expected!");
19145 if (vec_len (ls_name) > 62)
19147 errmsg ("error: locator set name too long!");
19151 if (!vam->json_output)
19153 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19156 M (ONE_LOCATOR_DUMP, mp);
19157 mp->is_index_set = is_index_set;
19160 mp->ls_index = clib_host_to_net_u32 (ls_index);
19163 vec_add1 (ls_name, 0);
19164 strncpy ((char *) mp->ls_name, (char *) ls_name,
19165 sizeof (mp->ls_name) - 1);
19171 /* Use a control ping for synchronization */
19172 MPING (CONTROL_PING, mp_ping);
19175 /* Wait for a reply... */
19180 #define api_lisp_locator_dump api_one_locator_dump
19183 api_one_locator_set_dump (vat_main_t * vam)
19185 vl_api_one_locator_set_dump_t *mp;
19186 vl_api_control_ping_t *mp_ping;
19187 unformat_input_t *input = vam->input;
19191 /* Parse args required to build the message */
19192 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19194 if (unformat (input, "local"))
19198 else if (unformat (input, "remote"))
19204 errmsg ("parse error '%U'", format_unformat_error, input);
19209 if (!vam->json_output)
19211 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19214 M (ONE_LOCATOR_SET_DUMP, mp);
19216 mp->filter = filter;
19221 /* Use a control ping for synchronization */
19222 MPING (CONTROL_PING, mp_ping);
19225 /* Wait for a reply... */
19230 #define api_lisp_locator_set_dump api_one_locator_set_dump
19233 api_one_eid_table_map_dump (vat_main_t * vam)
19237 unformat_input_t *input = vam->input;
19238 vl_api_one_eid_table_map_dump_t *mp;
19239 vl_api_control_ping_t *mp_ping;
19242 /* Parse args required to build the message */
19243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19245 if (unformat (input, "l2"))
19250 else if (unformat (input, "l3"))
19257 errmsg ("parse error '%U'", format_unformat_error, input);
19264 errmsg ("expected one of 'l2' or 'l3' parameter!");
19268 if (!vam->json_output)
19270 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19273 M (ONE_EID_TABLE_MAP_DUMP, mp);
19279 /* Use a control ping for synchronization */
19280 MPING (CONTROL_PING, mp_ping);
19283 /* Wait for a reply... */
19288 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19291 api_one_eid_table_vni_dump (vat_main_t * vam)
19293 vl_api_one_eid_table_vni_dump_t *mp;
19294 vl_api_control_ping_t *mp_ping;
19297 if (!vam->json_output)
19299 print (vam->ofp, "VNI");
19302 M (ONE_EID_TABLE_VNI_DUMP, mp);
19307 /* Use a control ping for synchronization */
19308 MPING (CONTROL_PING, mp_ping);
19311 /* Wait for a reply... */
19316 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19319 api_one_eid_table_dump (vat_main_t * vam)
19321 unformat_input_t *i = vam->input;
19322 vl_api_one_eid_table_dump_t *mp;
19323 vl_api_control_ping_t *mp_ping;
19324 struct in_addr ip4;
19325 struct in6_addr ip6;
19327 u8 eid_type = ~0, eid_set = 0;
19328 u32 prefix_length = ~0, t, vni = 0;
19331 lisp_nsh_api_t nsh;
19333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19335 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19341 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19347 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19352 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19357 else if (unformat (i, "vni %d", &t))
19361 else if (unformat (i, "local"))
19365 else if (unformat (i, "remote"))
19371 errmsg ("parse error '%U'", format_unformat_error, i);
19376 if (!vam->json_output)
19378 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19379 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19382 M (ONE_EID_TABLE_DUMP, mp);
19384 mp->filter = filter;
19388 mp->vni = htonl (vni);
19389 mp->eid_type = eid_type;
19393 mp->prefix_length = prefix_length;
19394 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19397 mp->prefix_length = prefix_length;
19398 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19401 clib_memcpy (mp->eid, mac, sizeof (mac));
19404 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19407 errmsg ("unknown EID type %d!", eid_type);
19415 /* Use a control ping for synchronization */
19416 MPING (CONTROL_PING, mp_ping);
19419 /* Wait for a reply... */
19424 #define api_lisp_eid_table_dump api_one_eid_table_dump
19427 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19429 unformat_input_t *i = vam->input;
19430 vl_api_gpe_fwd_entries_get_t *mp;
19435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19437 if (unformat (i, "vni %d", &vni))
19443 errmsg ("parse error '%U'", format_unformat_error, i);
19450 errmsg ("vni not set!");
19454 if (!vam->json_output)
19456 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19460 M (GPE_FWD_ENTRIES_GET, mp);
19461 mp->vni = clib_host_to_net_u32 (vni);
19466 /* Wait for a reply... */
19471 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19472 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19473 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19474 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19475 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19476 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19477 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19478 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19481 api_one_adjacencies_get (vat_main_t * vam)
19483 unformat_input_t *i = vam->input;
19484 vl_api_one_adjacencies_get_t *mp;
19489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19491 if (unformat (i, "vni %d", &vni))
19497 errmsg ("parse error '%U'", format_unformat_error, i);
19504 errmsg ("vni not set!");
19508 if (!vam->json_output)
19510 print (vam->ofp, "%s %40s", "leid", "reid");
19513 M (ONE_ADJACENCIES_GET, mp);
19514 mp->vni = clib_host_to_net_u32 (vni);
19519 /* Wait for a reply... */
19524 #define api_lisp_adjacencies_get api_one_adjacencies_get
19527 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19529 unformat_input_t *i = vam->input;
19530 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19532 u8 ip_family_set = 0, is_ip4 = 1;
19534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19536 if (unformat (i, "ip4"))
19541 else if (unformat (i, "ip6"))
19548 errmsg ("parse error '%U'", format_unformat_error, i);
19553 if (!ip_family_set)
19555 errmsg ("ip family not set!");
19559 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19560 mp->is_ip4 = is_ip4;
19565 /* Wait for a reply... */
19571 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19573 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19576 if (!vam->json_output)
19578 print (vam->ofp, "VNIs");
19581 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19586 /* Wait for a reply... */
19592 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19594 unformat_input_t *i = vam->input;
19595 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19597 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19598 struct in_addr ip4;
19599 struct in6_addr ip6;
19600 u32 table_id = 0, nh_sw_if_index = ~0;
19602 memset (&ip4, 0, sizeof (ip4));
19603 memset (&ip6, 0, sizeof (ip6));
19605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19607 if (unformat (i, "del"))
19609 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19610 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19615 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19616 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19621 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19625 nh_sw_if_index = ~0;
19627 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19631 nh_sw_if_index = ~0;
19633 else if (unformat (i, "table %d", &table_id))
19637 errmsg ("parse error '%U'", format_unformat_error, i);
19644 errmsg ("nh addr not set!");
19648 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19649 mp->is_add = is_add;
19650 mp->table_id = clib_host_to_net_u32 (table_id);
19651 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19652 mp->is_ip4 = is_ip4;
19654 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19656 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19661 /* Wait for a reply... */
19667 api_one_map_server_dump (vat_main_t * vam)
19669 vl_api_one_map_server_dump_t *mp;
19670 vl_api_control_ping_t *mp_ping;
19673 if (!vam->json_output)
19675 print (vam->ofp, "%=20s", "Map server");
19678 M (ONE_MAP_SERVER_DUMP, mp);
19682 /* Use a control ping for synchronization */
19683 MPING (CONTROL_PING, mp_ping);
19686 /* Wait for a reply... */
19691 #define api_lisp_map_server_dump api_one_map_server_dump
19694 api_one_map_resolver_dump (vat_main_t * vam)
19696 vl_api_one_map_resolver_dump_t *mp;
19697 vl_api_control_ping_t *mp_ping;
19700 if (!vam->json_output)
19702 print (vam->ofp, "%=20s", "Map resolver");
19705 M (ONE_MAP_RESOLVER_DUMP, mp);
19709 /* Use a control ping for synchronization */
19710 MPING (CONTROL_PING, mp_ping);
19713 /* Wait for a reply... */
19718 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19721 api_one_stats_flush (vat_main_t * vam)
19723 vl_api_one_stats_flush_t *mp;
19726 M (ONE_STATS_FLUSH, mp);
19733 api_one_stats_dump (vat_main_t * vam)
19735 vl_api_one_stats_dump_t *mp;
19736 vl_api_control_ping_t *mp_ping;
19739 M (ONE_STATS_DUMP, mp);
19743 /* Use a control ping for synchronization */
19744 MPING (CONTROL_PING, mp_ping);
19747 /* Wait for a reply... */
19753 api_show_one_status (vat_main_t * vam)
19755 vl_api_show_one_status_t *mp;
19758 if (!vam->json_output)
19760 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19763 M (SHOW_ONE_STATUS, mp);
19766 /* Wait for a reply... */
19771 #define api_show_lisp_status api_show_one_status
19774 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19776 vl_api_gpe_fwd_entry_path_dump_t *mp;
19777 vl_api_control_ping_t *mp_ping;
19778 unformat_input_t *i = vam->input;
19779 u32 fwd_entry_index = ~0;
19782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19784 if (unformat (i, "index %d", &fwd_entry_index))
19790 if (~0 == fwd_entry_index)
19792 errmsg ("no index specified!");
19796 if (!vam->json_output)
19798 print (vam->ofp, "first line");
19801 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19805 /* Use a control ping for synchronization */
19806 MPING (CONTROL_PING, mp_ping);
19809 /* Wait for a reply... */
19815 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19817 vl_api_one_get_map_request_itr_rlocs_t *mp;
19820 if (!vam->json_output)
19822 print (vam->ofp, "%=20s", "itr-rlocs:");
19825 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19828 /* Wait for a reply... */
19833 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19836 api_af_packet_create (vat_main_t * vam)
19838 unformat_input_t *i = vam->input;
19839 vl_api_af_packet_create_t *mp;
19840 u8 *host_if_name = 0;
19842 u8 random_hw_addr = 1;
19845 memset (hw_addr, 0, sizeof (hw_addr));
19847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19849 if (unformat (i, "name %s", &host_if_name))
19850 vec_add1 (host_if_name, 0);
19851 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19852 random_hw_addr = 0;
19857 if (!vec_len (host_if_name))
19859 errmsg ("host-interface name must be specified");
19863 if (vec_len (host_if_name) > 64)
19865 errmsg ("host-interface name too long");
19869 M (AF_PACKET_CREATE, mp);
19871 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19872 clib_memcpy (mp->hw_addr, hw_addr, 6);
19873 mp->use_random_hw_addr = random_hw_addr;
19874 vec_free (host_if_name);
19882 fprintf (vam->ofp ? vam->ofp : stderr,
19883 " new sw_if_index = %d\n", vam->sw_if_index);
19890 api_af_packet_delete (vat_main_t * vam)
19892 unformat_input_t *i = vam->input;
19893 vl_api_af_packet_delete_t *mp;
19894 u8 *host_if_name = 0;
19897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19899 if (unformat (i, "name %s", &host_if_name))
19900 vec_add1 (host_if_name, 0);
19905 if (!vec_len (host_if_name))
19907 errmsg ("host-interface name must be specified");
19911 if (vec_len (host_if_name) > 64)
19913 errmsg ("host-interface name too long");
19917 M (AF_PACKET_DELETE, mp);
19919 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19920 vec_free (host_if_name);
19927 static void vl_api_af_packet_details_t_handler
19928 (vl_api_af_packet_details_t * mp)
19930 vat_main_t *vam = &vat_main;
19932 print (vam->ofp, "%-16s %d",
19933 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19936 static void vl_api_af_packet_details_t_handler_json
19937 (vl_api_af_packet_details_t * mp)
19939 vat_main_t *vam = &vat_main;
19940 vat_json_node_t *node = NULL;
19942 if (VAT_JSON_ARRAY != vam->json_tree.type)
19944 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19945 vat_json_init_array (&vam->json_tree);
19947 node = vat_json_array_add (&vam->json_tree);
19949 vat_json_init_object (node);
19950 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19951 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19955 api_af_packet_dump (vat_main_t * vam)
19957 vl_api_af_packet_dump_t *mp;
19958 vl_api_control_ping_t *mp_ping;
19961 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19962 /* Get list of tap interfaces */
19963 M (AF_PACKET_DUMP, mp);
19966 /* Use a control ping for synchronization */
19967 MPING (CONTROL_PING, mp_ping);
19975 api_policer_add_del (vat_main_t * vam)
19977 unformat_input_t *i = vam->input;
19978 vl_api_policer_add_del_t *mp;
19988 u8 color_aware = 0;
19989 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19992 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19993 conform_action.dscp = 0;
19994 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19995 exceed_action.dscp = 0;
19996 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19997 violate_action.dscp = 0;
19999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20001 if (unformat (i, "del"))
20003 else if (unformat (i, "name %s", &name))
20004 vec_add1 (name, 0);
20005 else if (unformat (i, "cir %u", &cir))
20007 else if (unformat (i, "eir %u", &eir))
20009 else if (unformat (i, "cb %u", &cb))
20011 else if (unformat (i, "eb %u", &eb))
20013 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
20016 else if (unformat (i, "round_type %U", unformat_policer_round_type,
20019 else if (unformat (i, "type %U", unformat_policer_type, &type))
20021 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
20024 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
20027 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
20030 else if (unformat (i, "color-aware"))
20036 if (!vec_len (name))
20038 errmsg ("policer name must be specified");
20042 if (vec_len (name) > 64)
20044 errmsg ("policer name too long");
20048 M (POLICER_ADD_DEL, mp);
20050 clib_memcpy (mp->name, name, vec_len (name));
20052 mp->is_add = is_add;
20053 mp->cir = ntohl (cir);
20054 mp->eir = ntohl (eir);
20055 mp->cb = clib_net_to_host_u64 (cb);
20056 mp->eb = clib_net_to_host_u64 (eb);
20057 mp->rate_type = rate_type;
20058 mp->round_type = round_type;
20060 mp->conform_action_type = conform_action.action_type;
20061 mp->conform_dscp = conform_action.dscp;
20062 mp->exceed_action_type = exceed_action.action_type;
20063 mp->exceed_dscp = exceed_action.dscp;
20064 mp->violate_action_type = violate_action.action_type;
20065 mp->violate_dscp = violate_action.dscp;
20066 mp->color_aware = color_aware;
20074 api_policer_dump (vat_main_t * vam)
20076 unformat_input_t *i = vam->input;
20077 vl_api_policer_dump_t *mp;
20078 vl_api_control_ping_t *mp_ping;
20079 u8 *match_name = 0;
20080 u8 match_name_valid = 0;
20083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20085 if (unformat (i, "name %s", &match_name))
20087 vec_add1 (match_name, 0);
20088 match_name_valid = 1;
20094 M (POLICER_DUMP, mp);
20095 mp->match_name_valid = match_name_valid;
20096 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
20097 vec_free (match_name);
20101 /* Use a control ping for synchronization */
20102 MPING (CONTROL_PING, mp_ping);
20105 /* Wait for a reply... */
20111 api_policer_classify_set_interface (vat_main_t * vam)
20113 unformat_input_t *i = vam->input;
20114 vl_api_policer_classify_set_interface_t *mp;
20116 int sw_if_index_set;
20117 u32 ip4_table_index = ~0;
20118 u32 ip6_table_index = ~0;
20119 u32 l2_table_index = ~0;
20123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20125 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20126 sw_if_index_set = 1;
20127 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20128 sw_if_index_set = 1;
20129 else if (unformat (i, "del"))
20131 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20133 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20135 else if (unformat (i, "l2-table %d", &l2_table_index))
20139 clib_warning ("parse error '%U'", format_unformat_error, i);
20144 if (sw_if_index_set == 0)
20146 errmsg ("missing interface name or sw_if_index");
20150 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20152 mp->sw_if_index = ntohl (sw_if_index);
20153 mp->ip4_table_index = ntohl (ip4_table_index);
20154 mp->ip6_table_index = ntohl (ip6_table_index);
20155 mp->l2_table_index = ntohl (l2_table_index);
20156 mp->is_add = is_add;
20164 api_policer_classify_dump (vat_main_t * vam)
20166 unformat_input_t *i = vam->input;
20167 vl_api_policer_classify_dump_t *mp;
20168 vl_api_control_ping_t *mp_ping;
20169 u8 type = POLICER_CLASSIFY_N_TABLES;
20172 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20176 errmsg ("classify table type must be specified");
20180 if (!vam->json_output)
20182 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20185 M (POLICER_CLASSIFY_DUMP, mp);
20190 /* Use a control ping for synchronization */
20191 MPING (CONTROL_PING, mp_ping);
20194 /* Wait for a reply... */
20200 api_netmap_create (vat_main_t * vam)
20202 unformat_input_t *i = vam->input;
20203 vl_api_netmap_create_t *mp;
20206 u8 random_hw_addr = 1;
20211 memset (hw_addr, 0, sizeof (hw_addr));
20213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20215 if (unformat (i, "name %s", &if_name))
20216 vec_add1 (if_name, 0);
20217 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20218 random_hw_addr = 0;
20219 else if (unformat (i, "pipe"))
20221 else if (unformat (i, "master"))
20223 else if (unformat (i, "slave"))
20229 if (!vec_len (if_name))
20231 errmsg ("interface name must be specified");
20235 if (vec_len (if_name) > 64)
20237 errmsg ("interface name too long");
20241 M (NETMAP_CREATE, mp);
20243 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20244 clib_memcpy (mp->hw_addr, hw_addr, 6);
20245 mp->use_random_hw_addr = random_hw_addr;
20246 mp->is_pipe = is_pipe;
20247 mp->is_master = is_master;
20248 vec_free (if_name);
20256 api_netmap_delete (vat_main_t * vam)
20258 unformat_input_t *i = vam->input;
20259 vl_api_netmap_delete_t *mp;
20263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20265 if (unformat (i, "name %s", &if_name))
20266 vec_add1 (if_name, 0);
20271 if (!vec_len (if_name))
20273 errmsg ("interface name must be specified");
20277 if (vec_len (if_name) > 64)
20279 errmsg ("interface name too long");
20283 M (NETMAP_DELETE, mp);
20285 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20286 vec_free (if_name);
20294 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20296 if (fp->afi == IP46_TYPE_IP6)
20298 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20299 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20300 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20301 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20302 format_ip6_address, fp->next_hop);
20303 else if (fp->afi == IP46_TYPE_IP4)
20305 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20306 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20307 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20308 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20309 format_ip4_address, fp->next_hop);
20313 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20314 vl_api_fib_path_t * fp)
20316 struct in_addr ip4;
20317 struct in6_addr ip6;
20319 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20320 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20321 vat_json_object_add_uint (node, "is_local", fp->is_local);
20322 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20323 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20324 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20325 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20326 if (fp->afi == IP46_TYPE_IP4)
20328 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20329 vat_json_object_add_ip4 (node, "next_hop", ip4);
20331 else if (fp->afi == IP46_TYPE_IP6)
20333 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20334 vat_json_object_add_ip6 (node, "next_hop", ip6);
20339 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20341 vat_main_t *vam = &vat_main;
20342 int count = ntohl (mp->mt_count);
20343 vl_api_fib_path_t *fp;
20346 print (vam->ofp, "[%d]: sw_if_index %d via:",
20347 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20349 for (i = 0; i < count; i++)
20351 vl_api_mpls_fib_path_print (vam, fp);
20355 print (vam->ofp, "");
20358 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20359 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20362 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20364 vat_main_t *vam = &vat_main;
20365 vat_json_node_t *node = NULL;
20366 int count = ntohl (mp->mt_count);
20367 vl_api_fib_path_t *fp;
20370 if (VAT_JSON_ARRAY != vam->json_tree.type)
20372 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20373 vat_json_init_array (&vam->json_tree);
20375 node = vat_json_array_add (&vam->json_tree);
20377 vat_json_init_object (node);
20378 vat_json_object_add_uint (node, "tunnel_index",
20379 ntohl (mp->mt_tunnel_index));
20380 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20382 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20385 for (i = 0; i < count; i++)
20387 vl_api_mpls_fib_path_json_print (node, fp);
20393 api_mpls_tunnel_dump (vat_main_t * vam)
20395 vl_api_mpls_tunnel_dump_t *mp;
20396 vl_api_control_ping_t *mp_ping;
20400 /* Parse args required to build the message */
20401 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20403 if (!unformat (vam->input, "tunnel_index %d", &index))
20410 print (vam->ofp, " tunnel_index %d", index);
20412 M (MPLS_TUNNEL_DUMP, mp);
20413 mp->tunnel_index = htonl (index);
20416 /* Use a control ping for synchronization */
20417 MPING (CONTROL_PING, mp_ping);
20424 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20425 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20429 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20431 vat_main_t *vam = &vat_main;
20432 int count = ntohl (mp->count);
20433 vl_api_fib_path_t *fp;
20437 "table-id %d, label %u, ess_bit %u",
20438 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20440 for (i = 0; i < count; i++)
20442 vl_api_mpls_fib_path_print (vam, fp);
20447 static void vl_api_mpls_fib_details_t_handler_json
20448 (vl_api_mpls_fib_details_t * mp)
20450 vat_main_t *vam = &vat_main;
20451 int count = ntohl (mp->count);
20452 vat_json_node_t *node = NULL;
20453 vl_api_fib_path_t *fp;
20456 if (VAT_JSON_ARRAY != vam->json_tree.type)
20458 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20459 vat_json_init_array (&vam->json_tree);
20461 node = vat_json_array_add (&vam->json_tree);
20463 vat_json_init_object (node);
20464 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20465 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20466 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20467 vat_json_object_add_uint (node, "path_count", count);
20469 for (i = 0; i < count; i++)
20471 vl_api_mpls_fib_path_json_print (node, fp);
20477 api_mpls_fib_dump (vat_main_t * vam)
20479 vl_api_mpls_fib_dump_t *mp;
20480 vl_api_control_ping_t *mp_ping;
20483 M (MPLS_FIB_DUMP, mp);
20486 /* Use a control ping for synchronization */
20487 MPING (CONTROL_PING, mp_ping);
20494 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20495 #define vl_api_ip_fib_details_t_print vl_noop_handler
20498 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20500 vat_main_t *vam = &vat_main;
20501 int count = ntohl (mp->count);
20502 vl_api_fib_path_t *fp;
20506 "table-id %d, prefix %U/%d",
20507 ntohl (mp->table_id), format_ip4_address, mp->address,
20508 mp->address_length);
20510 for (i = 0; i < count; i++)
20512 if (fp->afi == IP46_TYPE_IP6)
20514 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20515 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20516 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20517 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20518 format_ip6_address, fp->next_hop);
20519 else if (fp->afi == IP46_TYPE_IP4)
20521 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20522 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20523 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20524 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20525 format_ip4_address, fp->next_hop);
20530 static void vl_api_ip_fib_details_t_handler_json
20531 (vl_api_ip_fib_details_t * mp)
20533 vat_main_t *vam = &vat_main;
20534 int count = ntohl (mp->count);
20535 vat_json_node_t *node = NULL;
20536 struct in_addr ip4;
20537 struct in6_addr ip6;
20538 vl_api_fib_path_t *fp;
20541 if (VAT_JSON_ARRAY != vam->json_tree.type)
20543 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20544 vat_json_init_array (&vam->json_tree);
20546 node = vat_json_array_add (&vam->json_tree);
20548 vat_json_init_object (node);
20549 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20550 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20551 vat_json_object_add_ip4 (node, "prefix", ip4);
20552 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20553 vat_json_object_add_uint (node, "path_count", count);
20555 for (i = 0; i < count; i++)
20557 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20558 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20559 vat_json_object_add_uint (node, "is_local", fp->is_local);
20560 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20561 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20562 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20563 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20564 if (fp->afi == IP46_TYPE_IP4)
20566 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20567 vat_json_object_add_ip4 (node, "next_hop", ip4);
20569 else if (fp->afi == IP46_TYPE_IP6)
20571 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20572 vat_json_object_add_ip6 (node, "next_hop", ip6);
20578 api_ip_fib_dump (vat_main_t * vam)
20580 vl_api_ip_fib_dump_t *mp;
20581 vl_api_control_ping_t *mp_ping;
20584 M (IP_FIB_DUMP, mp);
20587 /* Use a control ping for synchronization */
20588 MPING (CONTROL_PING, mp_ping);
20596 api_ip_mfib_dump (vat_main_t * vam)
20598 vl_api_ip_mfib_dump_t *mp;
20599 vl_api_control_ping_t *mp_ping;
20602 M (IP_MFIB_DUMP, mp);
20605 /* Use a control ping for synchronization */
20606 MPING (CONTROL_PING, mp_ping);
20613 static void vl_api_ip_neighbor_details_t_handler
20614 (vl_api_ip_neighbor_details_t * mp)
20616 vat_main_t *vam = &vat_main;
20618 print (vam->ofp, "%c %U %U",
20619 (mp->is_static) ? 'S' : 'D',
20620 format_ethernet_address, &mp->mac_address,
20621 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20625 static void vl_api_ip_neighbor_details_t_handler_json
20626 (vl_api_ip_neighbor_details_t * mp)
20629 vat_main_t *vam = &vat_main;
20630 vat_json_node_t *node;
20631 struct in_addr ip4;
20632 struct in6_addr ip6;
20634 if (VAT_JSON_ARRAY != vam->json_tree.type)
20636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20637 vat_json_init_array (&vam->json_tree);
20639 node = vat_json_array_add (&vam->json_tree);
20641 vat_json_init_object (node);
20642 vat_json_object_add_string_copy (node, "flag",
20643 (mp->is_static) ? (u8 *) "static" : (u8 *)
20646 vat_json_object_add_string_copy (node, "link_layer",
20647 format (0, "%U", format_ethernet_address,
20648 &mp->mac_address));
20652 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20653 vat_json_object_add_ip6 (node, "ip_address", ip6);
20657 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20658 vat_json_object_add_ip4 (node, "ip_address", ip4);
20663 api_ip_neighbor_dump (vat_main_t * vam)
20665 unformat_input_t *i = vam->input;
20666 vl_api_ip_neighbor_dump_t *mp;
20667 vl_api_control_ping_t *mp_ping;
20669 u32 sw_if_index = ~0;
20672 /* Parse args required to build the message */
20673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20679 else if (unformat (i, "ip6"))
20685 if (sw_if_index == ~0)
20687 errmsg ("missing interface name or sw_if_index");
20691 M (IP_NEIGHBOR_DUMP, mp);
20692 mp->is_ipv6 = (u8) is_ipv6;
20693 mp->sw_if_index = ntohl (sw_if_index);
20696 /* Use a control ping for synchronization */
20697 MPING (CONTROL_PING, mp_ping);
20704 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20705 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20708 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20710 vat_main_t *vam = &vat_main;
20711 int count = ntohl (mp->count);
20712 vl_api_fib_path_t *fp;
20716 "table-id %d, prefix %U/%d",
20717 ntohl (mp->table_id), format_ip6_address, mp->address,
20718 mp->address_length);
20720 for (i = 0; i < count; i++)
20722 if (fp->afi == IP46_TYPE_IP6)
20724 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20725 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20726 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20727 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20728 format_ip6_address, fp->next_hop);
20729 else if (fp->afi == IP46_TYPE_IP4)
20731 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20732 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20733 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20734 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20735 format_ip4_address, fp->next_hop);
20740 static void vl_api_ip6_fib_details_t_handler_json
20741 (vl_api_ip6_fib_details_t * mp)
20743 vat_main_t *vam = &vat_main;
20744 int count = ntohl (mp->count);
20745 vat_json_node_t *node = NULL;
20746 struct in_addr ip4;
20747 struct in6_addr ip6;
20748 vl_api_fib_path_t *fp;
20751 if (VAT_JSON_ARRAY != vam->json_tree.type)
20753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20754 vat_json_init_array (&vam->json_tree);
20756 node = vat_json_array_add (&vam->json_tree);
20758 vat_json_init_object (node);
20759 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20760 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20761 vat_json_object_add_ip6 (node, "prefix", ip6);
20762 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20763 vat_json_object_add_uint (node, "path_count", count);
20765 for (i = 0; i < count; i++)
20767 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20768 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20769 vat_json_object_add_uint (node, "is_local", fp->is_local);
20770 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20771 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20772 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20773 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20774 if (fp->afi == IP46_TYPE_IP4)
20776 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20777 vat_json_object_add_ip4 (node, "next_hop", ip4);
20779 else if (fp->afi == IP46_TYPE_IP6)
20781 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20782 vat_json_object_add_ip6 (node, "next_hop", ip6);
20788 api_ip6_fib_dump (vat_main_t * vam)
20790 vl_api_ip6_fib_dump_t *mp;
20791 vl_api_control_ping_t *mp_ping;
20794 M (IP6_FIB_DUMP, mp);
20797 /* Use a control ping for synchronization */
20798 MPING (CONTROL_PING, mp_ping);
20806 api_ip6_mfib_dump (vat_main_t * vam)
20808 vl_api_ip6_mfib_dump_t *mp;
20809 vl_api_control_ping_t *mp_ping;
20812 M (IP6_MFIB_DUMP, mp);
20815 /* Use a control ping for synchronization */
20816 MPING (CONTROL_PING, mp_ping);
20824 api_classify_table_ids (vat_main_t * vam)
20826 vl_api_classify_table_ids_t *mp;
20829 /* Construct the API message */
20830 M (CLASSIFY_TABLE_IDS, mp);
20839 api_classify_table_by_interface (vat_main_t * vam)
20841 unformat_input_t *input = vam->input;
20842 vl_api_classify_table_by_interface_t *mp;
20844 u32 sw_if_index = ~0;
20846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20848 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20850 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20855 if (sw_if_index == ~0)
20857 errmsg ("missing interface name or sw_if_index");
20861 /* Construct the API message */
20862 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20864 mp->sw_if_index = ntohl (sw_if_index);
20872 api_classify_table_info (vat_main_t * vam)
20874 unformat_input_t *input = vam->input;
20875 vl_api_classify_table_info_t *mp;
20879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20881 if (unformat (input, "table_id %d", &table_id))
20886 if (table_id == ~0)
20888 errmsg ("missing table id");
20892 /* Construct the API message */
20893 M (CLASSIFY_TABLE_INFO, mp);
20895 mp->table_id = ntohl (table_id);
20903 api_classify_session_dump (vat_main_t * vam)
20905 unformat_input_t *input = vam->input;
20906 vl_api_classify_session_dump_t *mp;
20907 vl_api_control_ping_t *mp_ping;
20911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20913 if (unformat (input, "table_id %d", &table_id))
20918 if (table_id == ~0)
20920 errmsg ("missing table id");
20924 /* Construct the API message */
20925 M (CLASSIFY_SESSION_DUMP, mp);
20927 mp->table_id = ntohl (table_id);
20930 /* Use a control ping for synchronization */
20931 MPING (CONTROL_PING, mp_ping);
20939 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20941 vat_main_t *vam = &vat_main;
20943 print (vam->ofp, "collector_address %U, collector_port %d, "
20944 "src_address %U, vrf_id %d, path_mtu %u, "
20945 "template_interval %u, udp_checksum %d",
20946 format_ip4_address, mp->collector_address,
20947 ntohs (mp->collector_port),
20948 format_ip4_address, mp->src_address,
20949 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20950 ntohl (mp->template_interval), mp->udp_checksum);
20953 vam->result_ready = 1;
20957 vl_api_ipfix_exporter_details_t_handler_json
20958 (vl_api_ipfix_exporter_details_t * mp)
20960 vat_main_t *vam = &vat_main;
20961 vat_json_node_t node;
20962 struct in_addr collector_address;
20963 struct in_addr src_address;
20965 vat_json_init_object (&node);
20966 clib_memcpy (&collector_address, &mp->collector_address,
20967 sizeof (collector_address));
20968 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20969 vat_json_object_add_uint (&node, "collector_port",
20970 ntohs (mp->collector_port));
20971 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20972 vat_json_object_add_ip4 (&node, "src_address", src_address);
20973 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20974 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20975 vat_json_object_add_uint (&node, "template_interval",
20976 ntohl (mp->template_interval));
20977 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20979 vat_json_print (vam->ofp, &node);
20980 vat_json_free (&node);
20982 vam->result_ready = 1;
20986 api_ipfix_exporter_dump (vat_main_t * vam)
20988 vl_api_ipfix_exporter_dump_t *mp;
20991 /* Construct the API message */
20992 M (IPFIX_EXPORTER_DUMP, mp);
21001 api_ipfix_classify_stream_dump (vat_main_t * vam)
21003 vl_api_ipfix_classify_stream_dump_t *mp;
21006 /* Construct the API message */
21007 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
21018 vl_api_ipfix_classify_stream_details_t_handler
21019 (vl_api_ipfix_classify_stream_details_t * mp)
21021 vat_main_t *vam = &vat_main;
21022 print (vam->ofp, "domain_id %d, src_port %d",
21023 ntohl (mp->domain_id), ntohs (mp->src_port));
21025 vam->result_ready = 1;
21029 vl_api_ipfix_classify_stream_details_t_handler_json
21030 (vl_api_ipfix_classify_stream_details_t * mp)
21032 vat_main_t *vam = &vat_main;
21033 vat_json_node_t node;
21035 vat_json_init_object (&node);
21036 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
21037 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
21039 vat_json_print (vam->ofp, &node);
21040 vat_json_free (&node);
21042 vam->result_ready = 1;
21046 api_ipfix_classify_table_dump (vat_main_t * vam)
21048 vl_api_ipfix_classify_table_dump_t *mp;
21049 vl_api_control_ping_t *mp_ping;
21052 if (!vam->json_output)
21054 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
21055 "transport_protocol");
21058 /* Construct the API message */
21059 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
21064 /* Use a control ping for synchronization */
21065 MPING (CONTROL_PING, mp_ping);
21073 vl_api_ipfix_classify_table_details_t_handler
21074 (vl_api_ipfix_classify_table_details_t * mp)
21076 vat_main_t *vam = &vat_main;
21077 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
21078 mp->transport_protocol);
21082 vl_api_ipfix_classify_table_details_t_handler_json
21083 (vl_api_ipfix_classify_table_details_t * mp)
21085 vat_json_node_t *node = NULL;
21086 vat_main_t *vam = &vat_main;
21088 if (VAT_JSON_ARRAY != vam->json_tree.type)
21090 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21091 vat_json_init_array (&vam->json_tree);
21094 node = vat_json_array_add (&vam->json_tree);
21095 vat_json_init_object (node);
21097 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
21098 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
21099 vat_json_object_add_uint (node, "transport_protocol",
21100 mp->transport_protocol);
21104 api_sw_interface_span_enable_disable (vat_main_t * vam)
21106 unformat_input_t *i = vam->input;
21107 vl_api_sw_interface_span_enable_disable_t *mp;
21108 u32 src_sw_if_index = ~0;
21109 u32 dst_sw_if_index = ~0;
21114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21117 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21119 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21123 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21125 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21127 else if (unformat (i, "disable"))
21129 else if (unformat (i, "rx"))
21131 else if (unformat (i, "tx"))
21133 else if (unformat (i, "both"))
21135 else if (unformat (i, "l2"))
21141 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21143 mp->sw_if_index_from = htonl (src_sw_if_index);
21144 mp->sw_if_index_to = htonl (dst_sw_if_index);
21154 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21157 vat_main_t *vam = &vat_main;
21158 u8 *sw_if_from_name = 0;
21159 u8 *sw_if_to_name = 0;
21160 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21161 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21162 char *states[] = { "none", "rx", "tx", "both" };
21166 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21168 if ((u32) p->value[0] == sw_if_index_from)
21170 sw_if_from_name = (u8 *)(p->key);
21174 if ((u32) p->value[0] == sw_if_index_to)
21176 sw_if_to_name = (u8 *)(p->key);
21177 if (sw_if_from_name)
21182 print (vam->ofp, "%20s => %20s (%s) %s",
21183 sw_if_from_name, sw_if_to_name, states[mp->state],
21184 mp->is_l2 ? "l2" : "device");
21188 vl_api_sw_interface_span_details_t_handler_json
21189 (vl_api_sw_interface_span_details_t * mp)
21191 vat_main_t *vam = &vat_main;
21192 vat_json_node_t *node = NULL;
21193 u8 *sw_if_from_name = 0;
21194 u8 *sw_if_to_name = 0;
21195 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21196 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21200 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21202 if ((u32) p->value[0] == sw_if_index_from)
21204 sw_if_from_name = (u8 *)(p->key);
21208 if ((u32) p->value[0] == sw_if_index_to)
21210 sw_if_to_name = (u8 *)(p->key);
21211 if (sw_if_from_name)
21217 if (VAT_JSON_ARRAY != vam->json_tree.type)
21219 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21220 vat_json_init_array (&vam->json_tree);
21222 node = vat_json_array_add (&vam->json_tree);
21224 vat_json_init_object (node);
21225 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21226 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21227 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21228 if (0 != sw_if_to_name)
21230 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21232 vat_json_object_add_uint (node, "state", mp->state);
21233 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21237 api_sw_interface_span_dump (vat_main_t * vam)
21239 unformat_input_t *input = vam->input;
21240 vl_api_sw_interface_span_dump_t *mp;
21241 vl_api_control_ping_t *mp_ping;
21245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21247 if (unformat (input, "l2"))
21253 M (SW_INTERFACE_SPAN_DUMP, mp);
21257 /* Use a control ping for synchronization */
21258 MPING (CONTROL_PING, mp_ping);
21266 api_pg_create_interface (vat_main_t * vam)
21268 unformat_input_t *input = vam->input;
21269 vl_api_pg_create_interface_t *mp;
21273 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21275 if (unformat (input, "if_id %d", &if_id))
21282 errmsg ("missing pg interface index");
21286 /* Construct the API message */
21287 M (PG_CREATE_INTERFACE, mp);
21289 mp->interface_id = ntohl (if_id);
21297 api_pg_capture (vat_main_t * vam)
21299 unformat_input_t *input = vam->input;
21300 vl_api_pg_capture_t *mp;
21305 u8 pcap_file_set = 0;
21308 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21310 if (unformat (input, "if_id %d", &if_id))
21312 else if (unformat (input, "pcap %s", &pcap_file))
21314 else if (unformat (input, "count %d", &count))
21316 else if (unformat (input, "disable"))
21323 errmsg ("missing pg interface index");
21326 if (pcap_file_set > 0)
21328 if (vec_len (pcap_file) > 255)
21330 errmsg ("pcap file name is too long");
21335 u32 name_len = vec_len (pcap_file);
21336 /* Construct the API message */
21337 M (PG_CAPTURE, mp);
21339 mp->interface_id = ntohl (if_id);
21340 mp->is_enabled = enable;
21341 mp->count = ntohl (count);
21342 mp->pcap_name_length = ntohl (name_len);
21343 if (pcap_file_set != 0)
21345 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21347 vec_free (pcap_file);
21355 api_pg_enable_disable (vat_main_t * vam)
21357 unformat_input_t *input = vam->input;
21358 vl_api_pg_enable_disable_t *mp;
21361 u8 stream_name_set = 0;
21362 u8 *stream_name = 0;
21364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21366 if (unformat (input, "stream %s", &stream_name))
21367 stream_name_set = 1;
21368 else if (unformat (input, "disable"))
21374 if (stream_name_set > 0)
21376 if (vec_len (stream_name) > 255)
21378 errmsg ("stream name too long");
21383 u32 name_len = vec_len (stream_name);
21384 /* Construct the API message */
21385 M (PG_ENABLE_DISABLE, mp);
21387 mp->is_enabled = enable;
21388 if (stream_name_set != 0)
21390 mp->stream_name_length = ntohl (name_len);
21391 clib_memcpy (mp->stream_name, stream_name, name_len);
21393 vec_free (stream_name);
21401 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21403 unformat_input_t *input = vam->input;
21404 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21406 u16 *low_ports = 0;
21407 u16 *high_ports = 0;
21410 ip4_address_t ip4_addr;
21411 ip6_address_t ip6_addr;
21420 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21422 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21428 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21433 else if (unformat (input, "vrf %d", &vrf_id))
21435 else if (unformat (input, "del"))
21437 else if (unformat (input, "port %d", &tmp))
21439 if (tmp == 0 || tmp > 65535)
21441 errmsg ("port %d out of range", tmp);
21445 this_hi = this_low + 1;
21446 vec_add1 (low_ports, this_low);
21447 vec_add1 (high_ports, this_hi);
21449 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21451 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21453 errmsg ("incorrect range parameters");
21457 /* Note: in debug CLI +1 is added to high before
21458 passing to real fn that does "the work"
21459 (ip_source_and_port_range_check_add_del).
21460 This fn is a wrapper around the binary API fn a
21461 control plane will call, which expects this increment
21462 to have occurred. Hence letting the binary API control
21463 plane fn do the increment for consistency between VAT
21464 and other control planes.
21467 vec_add1 (low_ports, this_low);
21468 vec_add1 (high_ports, this_hi);
21474 if (prefix_set == 0)
21476 errmsg ("<address>/<mask> not specified");
21482 errmsg ("VRF ID required, not specified");
21489 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21493 if (vec_len (low_ports) == 0)
21495 errmsg ("At least one port or port range required");
21499 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21501 mp->is_add = is_add;
21506 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21511 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21514 mp->mask_length = length;
21515 mp->number_of_ranges = vec_len (low_ports);
21517 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21518 vec_free (low_ports);
21520 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21521 vec_free (high_ports);
21523 mp->vrf_id = ntohl (vrf_id);
21531 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21533 unformat_input_t *input = vam->input;
21534 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21535 u32 sw_if_index = ~0;
21537 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21538 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21542 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21544 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21546 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21548 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21550 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21552 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21554 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21556 else if (unformat (input, "del"))
21562 if (sw_if_index == ~0)
21564 errmsg ("Interface required but not specified");
21570 errmsg ("VRF ID required but not specified");
21574 if (tcp_out_vrf_id == 0
21575 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21578 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21582 /* Construct the API message */
21583 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21585 mp->sw_if_index = ntohl (sw_if_index);
21586 mp->is_add = is_add;
21587 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21588 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21589 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21590 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21595 /* Wait for a reply... */
21601 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21603 unformat_input_t *i = vam->input;
21604 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21605 u32 local_sa_id = 0;
21606 u32 remote_sa_id = 0;
21607 ip4_address_t src_address;
21608 ip4_address_t dst_address;
21612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21614 if (unformat (i, "local_sa %d", &local_sa_id))
21616 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21618 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21620 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21622 else if (unformat (i, "del"))
21626 clib_warning ("parse error '%U'", format_unformat_error, i);
21631 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21633 mp->local_sa_id = ntohl (local_sa_id);
21634 mp->remote_sa_id = ntohl (remote_sa_id);
21635 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21636 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21637 mp->is_add = is_add;
21645 api_punt (vat_main_t * vam)
21647 unformat_input_t *i = vam->input;
21655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21657 if (unformat (i, "ip %d", &ipv))
21659 else if (unformat (i, "protocol %d", &protocol))
21661 else if (unformat (i, "port %d", &port))
21663 else if (unformat (i, "del"))
21667 clib_warning ("parse error '%U'", format_unformat_error, i);
21674 mp->is_add = (u8) is_add;
21675 mp->ipv = (u8) ipv;
21676 mp->l4_protocol = (u8) protocol;
21677 mp->l4_port = htons ((u16) port);
21684 static void vl_api_ipsec_gre_tunnel_details_t_handler
21685 (vl_api_ipsec_gre_tunnel_details_t * mp)
21687 vat_main_t *vam = &vat_main;
21689 print (vam->ofp, "%11d%15U%15U%14d%14d",
21690 ntohl (mp->sw_if_index),
21691 format_ip4_address, &mp->src_address,
21692 format_ip4_address, &mp->dst_address,
21693 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21696 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21697 (vl_api_ipsec_gre_tunnel_details_t * mp)
21699 vat_main_t *vam = &vat_main;
21700 vat_json_node_t *node = NULL;
21701 struct in_addr ip4;
21703 if (VAT_JSON_ARRAY != vam->json_tree.type)
21705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21706 vat_json_init_array (&vam->json_tree);
21708 node = vat_json_array_add (&vam->json_tree);
21710 vat_json_init_object (node);
21711 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21712 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21713 vat_json_object_add_ip4 (node, "src_address", ip4);
21714 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21715 vat_json_object_add_ip4 (node, "dst_address", ip4);
21716 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21717 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21721 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21723 unformat_input_t *i = vam->input;
21724 vl_api_ipsec_gre_tunnel_dump_t *mp;
21725 vl_api_control_ping_t *mp_ping;
21727 u8 sw_if_index_set = 0;
21730 /* Parse args required to build the message */
21731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21733 if (unformat (i, "sw_if_index %d", &sw_if_index))
21734 sw_if_index_set = 1;
21739 if (sw_if_index_set == 0)
21744 if (!vam->json_output)
21746 print (vam->ofp, "%11s%15s%15s%14s%14s",
21747 "sw_if_index", "src_address", "dst_address",
21748 "local_sa_id", "remote_sa_id");
21751 /* Get list of gre-tunnel interfaces */
21752 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21754 mp->sw_if_index = htonl (sw_if_index);
21758 /* Use a control ping for synchronization */
21759 MPING (CONTROL_PING, mp_ping);
21767 api_delete_subif (vat_main_t * vam)
21769 unformat_input_t *i = vam->input;
21770 vl_api_delete_subif_t *mp;
21771 u32 sw_if_index = ~0;
21774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21778 if (unformat (i, "sw_if_index %d", &sw_if_index))
21784 if (sw_if_index == ~0)
21786 errmsg ("missing sw_if_index");
21790 /* Construct the API message */
21791 M (DELETE_SUBIF, mp);
21792 mp->sw_if_index = ntohl (sw_if_index);
21799 #define foreach_pbb_vtr_op \
21800 _("disable", L2_VTR_DISABLED) \
21801 _("pop", L2_VTR_POP_2) \
21802 _("push", L2_VTR_PUSH_2)
21805 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21807 unformat_input_t *i = vam->input;
21808 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21809 u32 sw_if_index = ~0, vtr_op = ~0;
21810 u16 outer_tag = ~0;
21811 u8 dmac[6], smac[6];
21812 u8 dmac_set = 0, smac_set = 0;
21818 /* Shut up coverity */
21819 memset (dmac, 0, sizeof (dmac));
21820 memset (smac, 0, sizeof (smac));
21822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21824 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21826 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21828 else if (unformat (i, "vtr_op %d", &vtr_op))
21830 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21833 else if (unformat (i, "translate_pbb_stag"))
21835 if (unformat (i, "%d", &tmp))
21837 vtr_op = L2_VTR_TRANSLATE_2_1;
21843 ("translate_pbb_stag operation requires outer tag definition");
21847 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21849 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21851 else if (unformat (i, "sid %d", &sid))
21853 else if (unformat (i, "vlanid %d", &tmp))
21857 clib_warning ("parse error '%U'", format_unformat_error, i);
21862 if ((sw_if_index == ~0) || (vtr_op == ~0))
21864 errmsg ("missing sw_if_index or vtr operation");
21867 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21868 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21871 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21875 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21876 mp->sw_if_index = ntohl (sw_if_index);
21877 mp->vtr_op = ntohl (vtr_op);
21878 mp->outer_tag = ntohs (outer_tag);
21879 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21880 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21881 mp->b_vlanid = ntohs (vlanid);
21882 mp->i_sid = ntohl (sid);
21890 api_flow_classify_set_interface (vat_main_t * vam)
21892 unformat_input_t *i = vam->input;
21893 vl_api_flow_classify_set_interface_t *mp;
21895 int sw_if_index_set;
21896 u32 ip4_table_index = ~0;
21897 u32 ip6_table_index = ~0;
21901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21904 sw_if_index_set = 1;
21905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21906 sw_if_index_set = 1;
21907 else if (unformat (i, "del"))
21909 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21911 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21915 clib_warning ("parse error '%U'", format_unformat_error, i);
21920 if (sw_if_index_set == 0)
21922 errmsg ("missing interface name or sw_if_index");
21926 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21928 mp->sw_if_index = ntohl (sw_if_index);
21929 mp->ip4_table_index = ntohl (ip4_table_index);
21930 mp->ip6_table_index = ntohl (ip6_table_index);
21931 mp->is_add = is_add;
21939 api_flow_classify_dump (vat_main_t * vam)
21941 unformat_input_t *i = vam->input;
21942 vl_api_flow_classify_dump_t *mp;
21943 vl_api_control_ping_t *mp_ping;
21944 u8 type = FLOW_CLASSIFY_N_TABLES;
21947 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21951 errmsg ("classify table type must be specified");
21955 if (!vam->json_output)
21957 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21960 M (FLOW_CLASSIFY_DUMP, mp);
21965 /* Use a control ping for synchronization */
21966 MPING (CONTROL_PING, mp_ping);
21969 /* Wait for a reply... */
21975 api_feature_enable_disable (vat_main_t * vam)
21977 unformat_input_t *i = vam->input;
21978 vl_api_feature_enable_disable_t *mp;
21980 u8 *feature_name = 0;
21981 u32 sw_if_index = ~0;
21985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21987 if (unformat (i, "arc_name %s", &arc_name))
21989 else if (unformat (i, "feature_name %s", &feature_name))
21992 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21994 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21996 else if (unformat (i, "disable"))
22004 errmsg ("missing arc name");
22007 if (vec_len (arc_name) > 63)
22009 errmsg ("arc name too long");
22012 if (feature_name == 0)
22014 errmsg ("missing feature name");
22017 if (vec_len (feature_name) > 63)
22019 errmsg ("feature name too long");
22022 if (sw_if_index == ~0)
22024 errmsg ("missing interface name or sw_if_index");
22028 /* Construct the API message */
22029 M (FEATURE_ENABLE_DISABLE, mp);
22030 mp->sw_if_index = ntohl (sw_if_index);
22031 mp->enable = enable;
22032 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
22033 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
22034 vec_free (arc_name);
22035 vec_free (feature_name);
22043 api_sw_interface_tag_add_del (vat_main_t * vam)
22045 unformat_input_t *i = vam->input;
22046 vl_api_sw_interface_tag_add_del_t *mp;
22047 u32 sw_if_index = ~0;
22052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22054 if (unformat (i, "tag %s", &tag))
22056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22060 else if (unformat (i, "del"))
22066 if (sw_if_index == ~0)
22068 errmsg ("missing interface name or sw_if_index");
22072 if (enable && (tag == 0))
22074 errmsg ("no tag specified");
22078 /* Construct the API message */
22079 M (SW_INTERFACE_TAG_ADD_DEL, mp);
22080 mp->sw_if_index = ntohl (sw_if_index);
22081 mp->is_add = enable;
22083 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
22091 static void vl_api_l2_xconnect_details_t_handler
22092 (vl_api_l2_xconnect_details_t * mp)
22094 vat_main_t *vam = &vat_main;
22096 print (vam->ofp, "%15d%15d",
22097 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
22100 static void vl_api_l2_xconnect_details_t_handler_json
22101 (vl_api_l2_xconnect_details_t * mp)
22103 vat_main_t *vam = &vat_main;
22104 vat_json_node_t *node = NULL;
22106 if (VAT_JSON_ARRAY != vam->json_tree.type)
22108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22109 vat_json_init_array (&vam->json_tree);
22111 node = vat_json_array_add (&vam->json_tree);
22113 vat_json_init_object (node);
22114 vat_json_object_add_uint (node, "rx_sw_if_index",
22115 ntohl (mp->rx_sw_if_index));
22116 vat_json_object_add_uint (node, "tx_sw_if_index",
22117 ntohl (mp->tx_sw_if_index));
22121 api_l2_xconnect_dump (vat_main_t * vam)
22123 vl_api_l2_xconnect_dump_t *mp;
22124 vl_api_control_ping_t *mp_ping;
22127 if (!vam->json_output)
22129 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22132 M (L2_XCONNECT_DUMP, mp);
22136 /* Use a control ping for synchronization */
22137 MPING (CONTROL_PING, mp_ping);
22145 api_hw_interface_set_mtu (vat_main_t * vam)
22147 unformat_input_t *i = vam->input;
22148 vl_api_hw_interface_set_mtu_t *mp;
22149 u32 sw_if_index = ~0;
22153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22155 if (unformat (i, "mtu %d", &mtu))
22157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22165 if (sw_if_index == ~0)
22167 errmsg ("missing interface name or sw_if_index");
22173 errmsg ("no mtu specified");
22177 /* Construct the API message */
22178 M (HW_INTERFACE_SET_MTU, mp);
22179 mp->sw_if_index = ntohl (sw_if_index);
22180 mp->mtu = ntohs ((u16) mtu);
22188 api_p2p_ethernet_add (vat_main_t * vam)
22190 unformat_input_t *i = vam->input;
22191 vl_api_p2p_ethernet_add_t *mp;
22192 u32 parent_if_index = ~0;
22198 memset (remote_mac, 0, sizeof (remote_mac));
22199 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22201 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22203 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22207 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22209 else if (unformat (i, "sub_id %d", &sub_id))
22213 clib_warning ("parse error '%U'", format_unformat_error, i);
22218 if (parent_if_index == ~0)
22220 errmsg ("missing interface name or sw_if_index");
22225 errmsg ("missing remote mac address");
22230 errmsg ("missing sub-interface id");
22234 M (P2P_ETHERNET_ADD, mp);
22235 mp->parent_if_index = ntohl (parent_if_index);
22236 mp->subif_id = ntohl (sub_id);
22237 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22245 api_p2p_ethernet_del (vat_main_t * vam)
22247 unformat_input_t *i = vam->input;
22248 vl_api_p2p_ethernet_del_t *mp;
22249 u32 parent_if_index = ~0;
22254 memset (remote_mac, 0, sizeof (remote_mac));
22255 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22257 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22259 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22263 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22267 clib_warning ("parse error '%U'", format_unformat_error, i);
22272 if (parent_if_index == ~0)
22274 errmsg ("missing interface name or sw_if_index");
22279 errmsg ("missing remote mac address");
22283 M (P2P_ETHERNET_DEL, mp);
22284 mp->parent_if_index = ntohl (parent_if_index);
22285 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22293 api_lldp_config (vat_main_t * vam)
22295 unformat_input_t *i = vam->input;
22296 vl_api_lldp_config_t *mp;
22298 int tx_interval = 0;
22299 u8 *sys_name = NULL;
22302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22304 if (unformat (i, "system-name %s", &sys_name))
22306 else if (unformat (i, "tx-hold %d", &tx_hold))
22308 else if (unformat (i, "tx-interval %d", &tx_interval))
22312 clib_warning ("parse error '%U'", format_unformat_error, i);
22317 vec_add1 (sys_name, 0);
22319 M (LLDP_CONFIG, mp);
22320 mp->tx_hold = htonl (tx_hold);
22321 mp->tx_interval = htonl (tx_interval);
22322 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22323 vec_free (sys_name);
22331 api_sw_interface_set_lldp (vat_main_t * vam)
22333 unformat_input_t *i = vam->input;
22334 vl_api_sw_interface_set_lldp_t *mp;
22335 u32 sw_if_index = ~0;
22337 u8 *port_desc = NULL, *mgmt_oid = NULL;
22338 ip4_address_t ip4_addr;
22339 ip6_address_t ip6_addr;
22342 memset (&ip4_addr, 0, sizeof (ip4_addr));
22343 memset (&ip6_addr, 0, sizeof (ip6_addr));
22345 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22347 if (unformat (i, "disable"))
22350 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22352 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22354 else if (unformat (i, "port-desc %s", &port_desc))
22356 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22358 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22360 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22366 if (sw_if_index == ~0)
22368 errmsg ("missing interface name or sw_if_index");
22372 /* Construct the API message */
22373 vec_add1 (port_desc, 0);
22374 vec_add1 (mgmt_oid, 0);
22375 M (SW_INTERFACE_SET_LLDP, mp);
22376 mp->sw_if_index = ntohl (sw_if_index);
22377 mp->enable = enable;
22378 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22379 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22380 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22381 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22382 vec_free (port_desc);
22383 vec_free (mgmt_oid);
22391 api_tcp_configure_src_addresses (vat_main_t * vam)
22393 vl_api_tcp_configure_src_addresses_t *mp;
22394 unformat_input_t *i = vam->input;
22395 ip4_address_t v4first, v4last;
22396 ip6_address_t v6first, v6last;
22401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22403 if (unformat (i, "%U - %U",
22404 unformat_ip4_address, &v4first,
22405 unformat_ip4_address, &v4last))
22409 errmsg ("one range per message (range already set)");
22414 else if (unformat (i, "%U - %U",
22415 unformat_ip6_address, &v6first,
22416 unformat_ip6_address, &v6last))
22420 errmsg ("one range per message (range already set)");
22425 else if (unformat (i, "vrf %d", &vrf_id))
22431 if (range_set == 0)
22433 errmsg ("address range not set");
22437 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22438 mp->vrf_id = ntohl (vrf_id);
22440 if (range_set == 2)
22443 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22444 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22449 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22450 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22457 static void vl_api_app_namespace_add_del_reply_t_handler
22458 (vl_api_app_namespace_add_del_reply_t * mp)
22460 vat_main_t *vam = &vat_main;
22461 i32 retval = ntohl (mp->retval);
22462 if (vam->async_mode)
22464 vam->async_errors += (retval < 0);
22468 vam->retval = retval;
22470 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22471 vam->result_ready = 1;
22475 static void vl_api_app_namespace_add_del_reply_t_handler_json
22476 (vl_api_app_namespace_add_del_reply_t * mp)
22478 vat_main_t *vam = &vat_main;
22479 vat_json_node_t node;
22481 vat_json_init_object (&node);
22482 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22483 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22485 vat_json_print (vam->ofp, &node);
22486 vat_json_free (&node);
22488 vam->retval = ntohl (mp->retval);
22489 vam->result_ready = 1;
22493 api_app_namespace_add_del (vat_main_t * vam)
22495 vl_api_app_namespace_add_del_t *mp;
22496 unformat_input_t *i = vam->input;
22497 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22498 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22504 if (unformat (i, "id %_%v%_", &ns_id))
22506 else if (unformat (i, "secret %lu", &secret))
22508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22509 sw_if_index_set = 1;
22510 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22512 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22517 if (!ns_id || !secret_set || !sw_if_index_set)
22519 errmsg ("namespace id, secret and sw_if_index must be set");
22522 if (vec_len (ns_id) > 64)
22524 errmsg ("namespace id too long");
22527 M (APP_NAMESPACE_ADD_DEL, mp);
22529 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22530 mp->namespace_id_len = vec_len (ns_id);
22531 mp->secret = clib_host_to_net_u64 (secret);
22532 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22533 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22534 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22542 api_sock_init_shm (vat_main_t * vam)
22544 #if VPP_API_TEST_BUILTIN == 0
22545 unformat_input_t *i = vam->input;
22546 vl_api_shm_elem_config_t *config = 0;
22547 u64 size = 64 << 20;
22550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22552 if (unformat (i, "size %U", unformat_memory_size, &size))
22559 * Canned custom ring allocator config.
22560 * Should probably parse all of this
22562 vec_validate (config, 6);
22563 config[0].type = VL_API_VLIB_RING;
22564 config[0].size = 256;
22565 config[0].count = 32;
22567 config[1].type = VL_API_VLIB_RING;
22568 config[1].size = 1024;
22569 config[1].count = 16;
22571 config[2].type = VL_API_VLIB_RING;
22572 config[2].size = 4096;
22573 config[2].count = 2;
22575 config[3].type = VL_API_CLIENT_RING;
22576 config[3].size = 256;
22577 config[3].count = 32;
22579 config[4].type = VL_API_CLIENT_RING;
22580 config[4].size = 1024;
22581 config[4].count = 16;
22583 config[5].type = VL_API_CLIENT_RING;
22584 config[5].size = 4096;
22585 config[5].count = 2;
22587 config[6].type = VL_API_QUEUE;
22588 config[6].count = 128;
22589 config[6].size = sizeof (uword);
22591 rv = vl_socket_client_init_shm (config);
22593 vam->client_index_invalid = 1;
22601 api_dns_enable_disable (vat_main_t * vam)
22603 unformat_input_t *line_input = vam->input;
22604 vl_api_dns_enable_disable_t *mp;
22605 u8 enable_disable = 1;
22608 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22610 if (unformat (line_input, "disable"))
22611 enable_disable = 0;
22612 if (unformat (line_input, "enable"))
22613 enable_disable = 1;
22618 /* Construct the API message */
22619 M (DNS_ENABLE_DISABLE, mp);
22620 mp->enable = enable_disable;
22624 /* Wait for the reply */
22630 api_dns_resolve_name (vat_main_t * vam)
22632 unformat_input_t *line_input = vam->input;
22633 vl_api_dns_resolve_name_t *mp;
22637 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22639 if (unformat (line_input, "%s", &name))
22645 if (vec_len (name) > 127)
22647 errmsg ("name too long");
22651 /* Construct the API message */
22652 M (DNS_RESOLVE_NAME, mp);
22653 memcpy (mp->name, name, vec_len (name));
22658 /* Wait for the reply */
22664 api_dns_resolve_ip (vat_main_t * vam)
22666 unformat_input_t *line_input = vam->input;
22667 vl_api_dns_resolve_ip_t *mp;
22669 ip4_address_t addr4;
22670 ip6_address_t addr6;
22673 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22675 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22677 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22685 errmsg ("missing address");
22689 /* Construct the API message */
22690 M (DNS_RESOLVE_IP, mp);
22691 mp->is_ip6 = is_ip6;
22693 memcpy (mp->address, &addr6, sizeof (addr6));
22695 memcpy (mp->address, &addr4, sizeof (addr4));
22699 /* Wait for the reply */
22705 api_dns_name_server_add_del (vat_main_t * vam)
22707 unformat_input_t *i = vam->input;
22708 vl_api_dns_name_server_add_del_t *mp;
22710 ip6_address_t ip6_server;
22711 ip4_address_t ip4_server;
22716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22718 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22720 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22722 else if (unformat (i, "del"))
22726 clib_warning ("parse error '%U'", format_unformat_error, i);
22731 if (ip4_set && ip6_set)
22733 errmsg ("Only one server address allowed per message");
22736 if ((ip4_set + ip6_set) == 0)
22738 errmsg ("Server address required");
22742 /* Construct the API message */
22743 M (DNS_NAME_SERVER_ADD_DEL, mp);
22747 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22752 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22756 mp->is_add = is_add;
22761 /* Wait for a reply, return good/bad news */
22767 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22769 vat_main_t *vam = &vat_main;
22774 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22775 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22776 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22777 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22778 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22779 clib_net_to_host_u32 (mp->action_index), mp->tag);
22784 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22785 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22786 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22787 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22788 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22789 clib_net_to_host_u32 (mp->action_index), mp->tag);
22794 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22797 vat_main_t *vam = &vat_main;
22798 vat_json_node_t *node = NULL;
22799 struct in6_addr ip6;
22800 struct in_addr ip4;
22802 if (VAT_JSON_ARRAY != vam->json_tree.type)
22804 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22805 vat_json_init_array (&vam->json_tree);
22807 node = vat_json_array_add (&vam->json_tree);
22808 vat_json_init_object (node);
22810 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22811 vat_json_object_add_uint (node, "appns_index",
22812 clib_net_to_host_u32 (mp->appns_index));
22813 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22814 vat_json_object_add_uint (node, "scope", mp->scope);
22815 vat_json_object_add_uint (node, "action_index",
22816 clib_net_to_host_u32 (mp->action_index));
22817 vat_json_object_add_uint (node, "lcl_port",
22818 clib_net_to_host_u16 (mp->lcl_port));
22819 vat_json_object_add_uint (node, "rmt_port",
22820 clib_net_to_host_u16 (mp->rmt_port));
22821 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22822 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22823 vat_json_object_add_string_copy (node, "tag", mp->tag);
22826 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22827 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22828 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22829 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22833 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22834 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22835 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22836 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22841 api_session_rule_add_del (vat_main_t * vam)
22843 vl_api_session_rule_add_del_t *mp;
22844 unformat_input_t *i = vam->input;
22845 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22846 u32 appns_index = 0, scope = 0;
22847 ip4_address_t lcl_ip4, rmt_ip4;
22848 ip6_address_t lcl_ip6, rmt_ip6;
22849 u8 is_ip4 = 1, conn_set = 0;
22850 u8 is_add = 1, *tag = 0;
22853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22855 if (unformat (i, "del"))
22857 else if (unformat (i, "add"))
22859 else if (unformat (i, "proto tcp"))
22861 else if (unformat (i, "proto udp"))
22863 else if (unformat (i, "appns %d", &appns_index))
22865 else if (unformat (i, "scope %d", &scope))
22867 else if (unformat (i, "tag %_%v%_", &tag))
22871 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22872 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22880 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22881 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22887 else if (unformat (i, "action %d", &action))
22892 if (proto == ~0 || !conn_set || action == ~0)
22894 errmsg ("transport proto, connection and action must be set");
22900 errmsg ("scope should be 0-3");
22904 M (SESSION_RULE_ADD_DEL, mp);
22906 mp->is_ip4 = is_ip4;
22907 mp->transport_proto = proto;
22908 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22909 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22910 mp->lcl_plen = lcl_plen;
22911 mp->rmt_plen = rmt_plen;
22912 mp->action_index = clib_host_to_net_u32 (action);
22913 mp->appns_index = clib_host_to_net_u32 (appns_index);
22915 mp->is_add = is_add;
22918 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22919 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22923 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22924 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22928 clib_memcpy (mp->tag, tag, vec_len (tag));
22938 api_session_rules_dump (vat_main_t * vam)
22940 vl_api_session_rules_dump_t *mp;
22941 vl_api_control_ping_t *mp_ping;
22944 if (!vam->json_output)
22946 print (vam->ofp, "%=20s", "Session Rules");
22949 M (SESSION_RULES_DUMP, mp);
22953 /* Use a control ping for synchronization */
22954 MPING (CONTROL_PING, mp_ping);
22957 /* Wait for a reply... */
22963 api_ip_container_proxy_add_del (vat_main_t * vam)
22965 vl_api_ip_container_proxy_add_del_t *mp;
22966 unformat_input_t *i = vam->input;
22967 u32 plen = ~0, sw_if_index = ~0;
22974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22976 if (unformat (i, "del"))
22978 else if (unformat (i, "add"))
22980 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22985 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22990 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22995 if (sw_if_index == ~0 || plen == ~0)
22997 errmsg ("address and sw_if_index must be set");
23001 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
23003 mp->is_ip4 = is_ip4;
23004 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
23006 mp->is_add = is_add;
23008 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
23010 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
23018 api_qos_record_enable_disable (vat_main_t * vam)
23020 unformat_input_t *i = vam->input;
23021 vl_api_qos_record_enable_disable_t *mp;
23022 u32 sw_if_index, qs = 0xff;
23023 u8 sw_if_index_set = 0;
23027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23030 sw_if_index_set = 1;
23031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23032 sw_if_index_set = 1;
23033 else if (unformat (i, "%U", unformat_qos_source, &qs))
23035 else if (unformat (i, "disable"))
23039 clib_warning ("parse error '%U'", format_unformat_error, i);
23044 if (sw_if_index_set == 0)
23046 errmsg ("missing interface name or sw_if_index");
23051 errmsg ("input location must be specified");
23055 M (QOS_RECORD_ENABLE_DISABLE, mp);
23057 mp->sw_if_index = ntohl (sw_if_index);
23058 mp->input_source = qs;
23059 mp->enable = enable;
23068 q_or_quit (vat_main_t * vam)
23070 #if VPP_API_TEST_BUILTIN == 0
23071 longjmp (vam->jump_buf, 1);
23073 return 0; /* not so much */
23077 q (vat_main_t * vam)
23079 return q_or_quit (vam);
23083 quit (vat_main_t * vam)
23085 return q_or_quit (vam);
23089 comment (vat_main_t * vam)
23095 statseg (vat_main_t * vam)
23097 ssvm_private_t *ssvmp = &vam->stat_segment;
23098 ssvm_shared_header_t *shared_header = ssvmp->sh;
23099 vlib_counter_t **counters;
23100 u64 thread0_index1_packets;
23101 u64 thread0_index1_bytes;
23102 f64 vector_rate, input_rate;
23105 uword *counter_vector_by_name;
23106 if (vam->stat_segment_lockp == 0)
23108 errmsg ("Stat segment not mapped...");
23112 /* look up "/if/rx for sw_if_index 1 as a test */
23114 clib_spinlock_lock (vam->stat_segment_lockp);
23116 counter_vector_by_name = (uword *) shared_header->opaque[1];
23118 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23121 clib_spinlock_unlock (vam->stat_segment_lockp);
23122 errmsg ("/if/tx not found?");
23126 /* Fish per-thread vector of combined counters from shared memory */
23127 counters = (vlib_counter_t **) p[0];
23129 if (vec_len (counters[0]) < 2)
23131 clib_spinlock_unlock (vam->stat_segment_lockp);
23132 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23136 /* Read thread 0 sw_if_index 1 counter */
23137 thread0_index1_packets = counters[0][1].packets;
23138 thread0_index1_bytes = counters[0][1].bytes;
23140 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23143 clib_spinlock_unlock (vam->stat_segment_lockp);
23144 errmsg ("vector_rate not found?");
23148 vector_rate = *(f64 *) (p[0]);
23149 p = hash_get_mem (counter_vector_by_name, "input_rate");
23152 clib_spinlock_unlock (vam->stat_segment_lockp);
23153 errmsg ("input_rate not found?");
23156 input_rate = *(f64 *) (p[0]);
23158 clib_spinlock_unlock (vam->stat_segment_lockp);
23160 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23161 vector_rate, input_rate);
23162 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23163 thread0_index1_packets, thread0_index1_bytes);
23169 cmd_cmp (void *a1, void *a2)
23174 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23178 help (vat_main_t * vam)
23183 unformat_input_t *i = vam->input;
23186 if (unformat (i, "%s", &name))
23190 vec_add1 (name, 0);
23192 hs = hash_get_mem (vam->help_by_name, name);
23194 print (vam->ofp, "usage: %s %s", name, hs[0]);
23196 print (vam->ofp, "No such msg / command '%s'", name);
23201 print (vam->ofp, "Help is available for the following:");
23204 hash_foreach_pair (p, vam->function_by_name,
23206 vec_add1 (cmds, (u8 *)(p->key));
23210 vec_sort_with_function (cmds, cmd_cmp);
23212 for (j = 0; j < vec_len (cmds); j++)
23213 print (vam->ofp, "%s", cmds[j]);
23220 set (vat_main_t * vam)
23222 u8 *name = 0, *value = 0;
23223 unformat_input_t *i = vam->input;
23225 if (unformat (i, "%s", &name))
23227 /* The input buffer is a vector, not a string. */
23228 value = vec_dup (i->buffer);
23229 vec_delete (value, i->index, 0);
23230 /* Almost certainly has a trailing newline */
23231 if (value[vec_len (value) - 1] == '\n')
23232 value[vec_len (value) - 1] = 0;
23233 /* Make sure it's a proper string, one way or the other */
23234 vec_add1 (value, 0);
23235 (void) clib_macro_set_value (&vam->macro_main,
23236 (char *) name, (char *) value);
23239 errmsg ("usage: set <name> <value>");
23247 unset (vat_main_t * vam)
23251 if (unformat (vam->input, "%s", &name))
23252 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23253 errmsg ("unset: %s wasn't set", name);
23266 macro_sort_cmp (void *a1, void *a2)
23268 macro_sort_t *s1 = a1;
23269 macro_sort_t *s2 = a2;
23271 return strcmp ((char *) (s1->name), (char *) (s2->name));
23275 dump_macro_table (vat_main_t * vam)
23277 macro_sort_t *sort_me = 0, *sm;
23282 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23284 vec_add2 (sort_me, sm, 1);
23285 sm->name = (u8 *)(p->key);
23286 sm->value = (u8 *) (p->value[0]);
23290 vec_sort_with_function (sort_me, macro_sort_cmp);
23292 if (vec_len (sort_me))
23293 print (vam->ofp, "%-15s%s", "Name", "Value");
23295 print (vam->ofp, "The macro table is empty...");
23297 for (i = 0; i < vec_len (sort_me); i++)
23298 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23303 dump_node_table (vat_main_t * vam)
23306 vlib_node_t *node, *next_node;
23308 if (vec_len (vam->graph_nodes) == 0)
23310 print (vam->ofp, "Node table empty, issue get_node_graph...");
23314 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
23316 node = vam->graph_nodes[0][i];
23317 print (vam->ofp, "[%d] %s", i, node->name);
23318 for (j = 0; j < vec_len (node->next_nodes); j++)
23320 if (node->next_nodes[j] != ~0)
23322 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23323 print (vam->ofp, " [%d] %s", j, next_node->name);
23331 value_sort_cmp (void *a1, void *a2)
23333 name_sort_t *n1 = a1;
23334 name_sort_t *n2 = a2;
23336 if (n1->value < n2->value)
23338 if (n1->value > n2->value)
23345 dump_msg_api_table (vat_main_t * vam)
23347 api_main_t *am = &api_main;
23348 name_sort_t *nses = 0, *ns;
23353 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23355 vec_add2 (nses, ns, 1);
23356 ns->name = (u8 *)(hp->key);
23357 ns->value = (u32) hp->value[0];
23361 vec_sort_with_function (nses, value_sort_cmp);
23363 for (i = 0; i < vec_len (nses); i++)
23364 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23370 get_msg_id (vat_main_t * vam)
23375 if (unformat (vam->input, "%s", &name_and_crc))
23377 message_index = vl_msg_api_get_msg_index (name_and_crc);
23378 if (message_index == ~0)
23380 print (vam->ofp, " '%s' not found", name_and_crc);
23383 print (vam->ofp, " '%s' has message index %d",
23384 name_and_crc, message_index);
23387 errmsg ("name_and_crc required...");
23392 search_node_table (vat_main_t * vam)
23394 unformat_input_t *line_input = vam->input;
23397 vlib_node_t *node, *next_node;
23400 if (vam->graph_node_index_by_name == 0)
23402 print (vam->ofp, "Node table empty, issue get_node_graph...");
23406 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23408 if (unformat (line_input, "%s", &node_to_find))
23410 vec_add1 (node_to_find, 0);
23411 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23414 print (vam->ofp, "%s not found...", node_to_find);
23417 node = vam->graph_nodes[0][p[0]];
23418 print (vam->ofp, "[%d] %s", p[0], node->name);
23419 for (j = 0; j < vec_len (node->next_nodes); j++)
23421 if (node->next_nodes[j] != ~0)
23423 next_node = vam->graph_nodes[0][node->next_nodes[j]];
23424 print (vam->ofp, " [%d] %s", j, next_node->name);
23431 clib_warning ("parse error '%U'", format_unformat_error,
23437 vec_free (node_to_find);
23446 script (vat_main_t * vam)
23448 #if (VPP_API_TEST_BUILTIN==0)
23450 char *save_current_file;
23451 unformat_input_t save_input;
23452 jmp_buf save_jump_buf;
23453 u32 save_line_number;
23455 FILE *new_fp, *save_ifp;
23457 if (unformat (vam->input, "%s", &s))
23459 new_fp = fopen ((char *) s, "r");
23462 errmsg ("Couldn't open script file %s", s);
23469 errmsg ("Missing script name");
23473 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23474 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23475 save_ifp = vam->ifp;
23476 save_line_number = vam->input_line_number;
23477 save_current_file = (char *) vam->current_file;
23479 vam->input_line_number = 0;
23481 vam->current_file = s;
23484 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23485 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23486 vam->ifp = save_ifp;
23487 vam->input_line_number = save_line_number;
23488 vam->current_file = (u8 *) save_current_file;
23493 clib_warning ("use the exec command...");
23499 echo (vat_main_t * vam)
23501 print (vam->ofp, "%v", vam->input->buffer);
23505 /* List of API message constructors, CLI names map to api_xxx */
23506 #define foreach_vpe_api_msg \
23507 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23508 _(sw_interface_dump,"") \
23509 _(sw_interface_set_flags, \
23510 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23511 _(sw_interface_add_del_address, \
23512 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23513 _(sw_interface_set_rx_mode, \
23514 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23515 _(sw_interface_set_table, \
23516 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23517 _(sw_interface_set_mpls_enable, \
23518 "<intfc> | sw_if_index [disable | dis]") \
23519 _(sw_interface_set_vpath, \
23520 "<intfc> | sw_if_index <id> enable | disable") \
23521 _(sw_interface_set_vxlan_bypass, \
23522 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23523 _(sw_interface_set_geneve_bypass, \
23524 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23525 _(sw_interface_set_l2_xconnect, \
23526 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23527 "enable | disable") \
23528 _(sw_interface_set_l2_bridge, \
23529 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23530 "[shg <split-horizon-group>] [bvi]\n" \
23531 "enable | disable") \
23532 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23533 _(bridge_domain_add_del, \
23534 "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") \
23535 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23537 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23538 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23539 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23541 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23543 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23545 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23547 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23549 "<vpp-if-name> | sw_if_index <id>") \
23550 _(sw_interface_tap_dump, "") \
23552 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23554 "<vpp-if-name> | sw_if_index <id>") \
23555 _(sw_interface_tap_v2_dump, "") \
23557 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23558 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23560 "<vpp-if-name> | sw_if_index <id>") \
23562 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23563 _(bond_detach_slave, \
23564 "sw_if_index <n>") \
23565 _(sw_interface_bond_dump, "") \
23566 _(sw_interface_slave_dump, \
23567 "<vpp-if-name> | sw_if_index <id>") \
23568 _(ip_table_add_del, \
23569 "table-id <n> [ipv6]\n") \
23570 _(ip_add_del_route, \
23571 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23572 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23573 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23574 "[multipath] [count <n>]") \
23575 _(ip_mroute_add_del, \
23576 "<src> <grp>/<mask> [table-id <n>]\n" \
23577 "[<intfc> | sw_if_index <id>] [local] [del]") \
23578 _(mpls_table_add_del, \
23579 "table-id <n>\n") \
23580 _(mpls_route_add_del, \
23581 "<label> <eos> via <addr> [table-id <n>]\n" \
23582 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23583 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23584 "[multipath] [count <n>]") \
23585 _(mpls_ip_bind_unbind, \
23586 "<label> <addr/len>") \
23587 _(mpls_tunnel_add_del, \
23588 " via <addr> [table-id <n>]\n" \
23589 "sw_if_index <id>] [l2] [del]") \
23590 _(bier_table_add_del, \
23591 "<label> <sub-domain> <set> <bsl> [del]") \
23592 _(bier_route_add_del, \
23593 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23594 "[<intfc> | sw_if_index <id>]" \
23595 "[weight <n>] [del] [multipath]") \
23596 _(proxy_arp_add_del, \
23597 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23598 _(proxy_arp_intfc_enable_disable, \
23599 "<intfc> | sw_if_index <id> enable | disable") \
23600 _(sw_interface_set_unnumbered, \
23601 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23602 _(ip_neighbor_add_del, \
23603 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23604 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23605 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23606 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23607 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23608 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23609 "[outer_vlan_id_any][inner_vlan_id_any]") \
23610 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23611 _(reset_fib, "vrf <n> [ipv6]") \
23612 _(dhcp_proxy_config, \
23613 "svr <v46-address> src <v46-address>\n" \
23614 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23615 _(dhcp_proxy_set_vss, \
23616 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23617 _(dhcp_proxy_dump, "ip6") \
23618 _(dhcp_client_config, \
23619 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23620 _(set_ip_flow_hash, \
23621 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23622 _(sw_interface_ip6_enable_disable, \
23623 "<intfc> | sw_if_index <id> enable | disable") \
23624 _(sw_interface_ip6_set_link_local_address, \
23625 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23626 _(ip6nd_proxy_add_del, \
23627 "<intfc> | sw_if_index <id> <ip6-address>") \
23628 _(ip6nd_proxy_dump, "") \
23629 _(sw_interface_ip6nd_ra_prefix, \
23630 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23631 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23632 "[nolink] [isno]") \
23633 _(sw_interface_ip6nd_ra_config, \
23634 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23635 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23636 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23637 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23638 _(l2_patch_add_del, \
23639 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23640 "enable | disable") \
23641 _(sr_localsid_add_del, \
23642 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23643 "fib-table <num> (end.psp) sw_if_index <num>") \
23644 _(classify_add_del_table, \
23645 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23646 " [del] [del-chain] mask <mask-value>\n" \
23647 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23648 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23649 _(classify_add_del_session, \
23650 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23651 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23652 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23653 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23654 _(classify_set_interface_ip_table, \
23655 "<intfc> | sw_if_index <nn> table <nn>") \
23656 _(classify_set_interface_l2_tables, \
23657 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23658 " [other-table <nn>]") \
23659 _(get_node_index, "node <node-name") \
23660 _(add_node_next, "node <node-name> next <next-node-name>") \
23661 _(l2tpv3_create_tunnel, \
23662 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23663 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23664 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23665 _(l2tpv3_set_tunnel_cookies, \
23666 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23667 "[new_remote_cookie <nn>]\n") \
23668 _(l2tpv3_interface_enable_disable, \
23669 "<intfc> | sw_if_index <nn> enable | disable") \
23670 _(l2tpv3_set_lookup_key, \
23671 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23672 _(sw_if_l2tpv3_tunnel_dump, "") \
23673 _(vxlan_offload_rx, \
23674 "hw { <interface name> | hw_if_index <nn>} " \
23675 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
23676 _(vxlan_add_del_tunnel, \
23677 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23678 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23679 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23680 _(geneve_add_del_tunnel, \
23681 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23682 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23683 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23684 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23685 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23686 _(gre_add_del_tunnel, \
23687 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23688 "[teb | erspan <session-id>] [del]") \
23689 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23690 _(l2_fib_clear_table, "") \
23691 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23692 _(l2_interface_vlan_tag_rewrite, \
23693 "<intfc> | sw_if_index <nn> \n" \
23694 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23695 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23696 _(create_vhost_user_if, \
23697 "socket <filename> [server] [renumber <dev_instance>] " \
23698 "[mac <mac_address>]") \
23699 _(modify_vhost_user_if, \
23700 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23701 "[server] [renumber <dev_instance>]") \
23702 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23703 _(sw_interface_vhost_user_dump, "") \
23704 _(show_version, "") \
23705 _(vxlan_gpe_add_del_tunnel, \
23706 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23707 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23708 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23709 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23710 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23711 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23712 _(interface_name_renumber, \
23713 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23714 _(input_acl_set_interface, \
23715 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23716 " [l2-table <nn>] [del]") \
23717 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23718 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23719 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23720 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23721 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23722 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23723 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23724 _(ip_dump, "ipv4 | ipv6") \
23725 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23726 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23728 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23729 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23730 " integ_alg <alg> integ_key <hex>") \
23731 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23732 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23733 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23734 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23735 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23736 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23737 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23738 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23739 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23740 " [instance <n>]") \
23741 _(ipsec_sa_dump, "[sa_id <n>]") \
23742 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23743 " <alg> <hex>\n") \
23744 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23745 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23746 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23747 "(auth_data 0x<data> | auth_data <data>)") \
23748 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23749 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23750 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23751 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23752 "(local|remote)") \
23753 _(ikev2_set_local_key, "file <absolute_file_path>") \
23754 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23755 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23756 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23757 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23758 _(ikev2_initiate_sa_init, "<profile_name>") \
23759 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23760 _(ikev2_initiate_del_child_sa, "<ispi>") \
23761 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23762 _(delete_loopback,"sw_if_index <nn>") \
23763 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23764 _(map_add_domain, \
23765 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23766 "ip6-src <ip6addr> " \
23767 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23768 _(map_del_domain, "index <n>") \
23769 _(map_add_del_rule, \
23770 "index <n> psid <n> dst <ip6addr> [del]") \
23771 _(map_domain_dump, "") \
23772 _(map_rule_dump, "index <map-domain>") \
23773 _(want_interface_events, "enable|disable") \
23774 _(want_stats,"enable|disable") \
23775 _(get_first_msg_id, "client <name>") \
23776 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23777 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23778 "fib-id <nn> [ip4][ip6][default]") \
23779 _(get_node_graph, " ") \
23780 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23781 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23782 _(ioam_disable, "") \
23783 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23784 " sw_if_index <sw_if_index> p <priority> " \
23785 "w <weight>] [del]") \
23786 _(one_add_del_locator, "locator-set <locator_name> " \
23787 "iface <intf> | sw_if_index <sw_if_index> " \
23788 "p <priority> w <weight> [del]") \
23789 _(one_add_del_local_eid,"vni <vni> eid " \
23790 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23791 "locator-set <locator_name> [del]" \
23792 "[key-id sha1|sha256 secret-key <secret-key>]")\
23793 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23794 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23795 _(one_enable_disable, "enable|disable") \
23796 _(one_map_register_enable_disable, "enable|disable") \
23797 _(one_map_register_fallback_threshold, "<value>") \
23798 _(one_rloc_probe_enable_disable, "enable|disable") \
23799 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23801 "rloc <locator> p <prio> " \
23802 "w <weight> [rloc <loc> ... ] " \
23803 "action <action> [del-all]") \
23804 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23806 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23807 _(one_use_petr, "ip-address> | disable") \
23808 _(one_map_request_mode, "src-dst|dst-only") \
23809 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23810 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23811 _(one_locator_set_dump, "[local | remote]") \
23812 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23813 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23814 "[local] | [remote]") \
23815 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23816 _(one_ndp_bd_get, "") \
23817 _(one_ndp_entries_get, "bd <bridge-domain>") \
23818 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23819 _(one_l2_arp_bd_get, "") \
23820 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23821 _(one_stats_enable_disable, "enable|disalbe") \
23822 _(show_one_stats_enable_disable, "") \
23823 _(one_eid_table_vni_dump, "") \
23824 _(one_eid_table_map_dump, "l2|l3") \
23825 _(one_map_resolver_dump, "") \
23826 _(one_map_server_dump, "") \
23827 _(one_adjacencies_get, "vni <vni>") \
23828 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23829 _(show_one_rloc_probe_state, "") \
23830 _(show_one_map_register_state, "") \
23831 _(show_one_status, "") \
23832 _(one_stats_dump, "") \
23833 _(one_stats_flush, "") \
23834 _(one_get_map_request_itr_rlocs, "") \
23835 _(one_map_register_set_ttl, "<ttl>") \
23836 _(one_set_transport_protocol, "udp|api") \
23837 _(one_get_transport_protocol, "") \
23838 _(one_enable_disable_xtr_mode, "enable|disable") \
23839 _(one_show_xtr_mode, "") \
23840 _(one_enable_disable_pitr_mode, "enable|disable") \
23841 _(one_show_pitr_mode, "") \
23842 _(one_enable_disable_petr_mode, "enable|disable") \
23843 _(one_show_petr_mode, "") \
23844 _(show_one_nsh_mapping, "") \
23845 _(show_one_pitr, "") \
23846 _(show_one_use_petr, "") \
23847 _(show_one_map_request_mode, "") \
23848 _(show_one_map_register_ttl, "") \
23849 _(show_one_map_register_fallback_threshold, "") \
23850 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23851 " sw_if_index <sw_if_index> p <priority> " \
23852 "w <weight>] [del]") \
23853 _(lisp_add_del_locator, "locator-set <locator_name> " \
23854 "iface <intf> | sw_if_index <sw_if_index> " \
23855 "p <priority> w <weight> [del]") \
23856 _(lisp_add_del_local_eid,"vni <vni> eid " \
23857 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23858 "locator-set <locator_name> [del]" \
23859 "[key-id sha1|sha256 secret-key <secret-key>]") \
23860 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23861 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23862 _(lisp_enable_disable, "enable|disable") \
23863 _(lisp_map_register_enable_disable, "enable|disable") \
23864 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23865 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23867 "rloc <locator> p <prio> " \
23868 "w <weight> [rloc <loc> ... ] " \
23869 "action <action> [del-all]") \
23870 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23872 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23873 _(lisp_use_petr, "<ip-address> | disable") \
23874 _(lisp_map_request_mode, "src-dst|dst-only") \
23875 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23876 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23877 _(lisp_locator_set_dump, "[local | remote]") \
23878 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23879 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23880 "[local] | [remote]") \
23881 _(lisp_eid_table_vni_dump, "") \
23882 _(lisp_eid_table_map_dump, "l2|l3") \
23883 _(lisp_map_resolver_dump, "") \
23884 _(lisp_map_server_dump, "") \
23885 _(lisp_adjacencies_get, "vni <vni>") \
23886 _(gpe_fwd_entry_vnis_get, "") \
23887 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23888 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23889 "[table <table-id>]") \
23890 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23891 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23892 _(gpe_set_encap_mode, "lisp|vxlan") \
23893 _(gpe_get_encap_mode, "") \
23894 _(lisp_gpe_add_del_iface, "up|down") \
23895 _(lisp_gpe_enable_disable, "enable|disable") \
23896 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23897 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23898 _(show_lisp_rloc_probe_state, "") \
23899 _(show_lisp_map_register_state, "") \
23900 _(show_lisp_status, "") \
23901 _(lisp_get_map_request_itr_rlocs, "") \
23902 _(show_lisp_pitr, "") \
23903 _(show_lisp_use_petr, "") \
23904 _(show_lisp_map_request_mode, "") \
23905 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23906 _(af_packet_delete, "name <host interface name>") \
23907 _(af_packet_dump, "") \
23908 _(policer_add_del, "name <policer name> <params> [del]") \
23909 _(policer_dump, "[name <policer name>]") \
23910 _(policer_classify_set_interface, \
23911 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23912 " [l2-table <nn>] [del]") \
23913 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23914 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23915 "[master|slave]") \
23916 _(netmap_delete, "name <interface name>") \
23917 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23918 _(mpls_fib_dump, "") \
23919 _(classify_table_ids, "") \
23920 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23921 _(classify_table_info, "table_id <nn>") \
23922 _(classify_session_dump, "table_id <nn>") \
23923 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23924 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23925 "[template_interval <nn>] [udp_checksum]") \
23926 _(ipfix_exporter_dump, "") \
23927 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23928 _(ipfix_classify_stream_dump, "") \
23929 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23930 _(ipfix_classify_table_dump, "") \
23931 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23932 _(sw_interface_span_dump, "[l2]") \
23933 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23934 _(pg_create_interface, "if_id <nn>") \
23935 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23936 _(pg_enable_disable, "[stream <id>] disable") \
23937 _(ip_source_and_port_range_check_add_del, \
23938 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23939 _(ip_source_and_port_range_check_interface_add_del, \
23940 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23941 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23942 _(ipsec_gre_add_del_tunnel, \
23943 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23944 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23945 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23946 _(l2_interface_pbb_tag_rewrite, \
23947 "<intfc> | sw_if_index <nn> \n" \
23948 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23949 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23950 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23951 _(flow_classify_set_interface, \
23952 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23953 _(flow_classify_dump, "type [ip4|ip6]") \
23954 _(ip_fib_dump, "") \
23955 _(ip_mfib_dump, "") \
23956 _(ip6_fib_dump, "") \
23957 _(ip6_mfib_dump, "") \
23958 _(feature_enable_disable, "arc_name <arc_name> " \
23959 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23960 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23962 _(l2_xconnect_dump, "") \
23963 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23964 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23965 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23966 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23967 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23968 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23969 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23970 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23971 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23972 _(sock_init_shm, "size <nnn>") \
23973 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23974 _(dns_enable_disable, "[enable][disable]") \
23975 _(dns_name_server_add_del, "<ip-address> [del]") \
23976 _(dns_resolve_name, "<hostname>") \
23977 _(dns_resolve_ip, "<ip4|ip6>") \
23978 _(dns_name_server_add_del, "<ip-address> [del]") \
23979 _(dns_resolve_name, "<hostname>") \
23980 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23981 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23982 _(session_rules_dump, "") \
23983 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23984 _(output_acl_set_interface, \
23985 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23986 " [l2-table <nn>] [del]") \
23987 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23989 /* List of command functions, CLI names map directly to functions */
23990 #define foreach_cli_function \
23991 _(comment, "usage: comment <ignore-rest-of-line>") \
23992 _(dump_interface_table, "usage: dump_interface_table") \
23993 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23994 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23995 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23996 _(dump_stats_table, "usage: dump_stats_table") \
23997 _(dump_macro_table, "usage: dump_macro_table ") \
23998 _(dump_node_table, "usage: dump_node_table") \
23999 _(dump_msg_api_table, "usage: dump_msg_api_table") \
24000 _(get_msg_id, "usage: get_msg_id name_and_crc") \
24001 _(echo, "usage: echo <message>") \
24002 _(exec, "usage: exec <vpe-debug-CLI-command>") \
24003 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
24004 _(help, "usage: help") \
24005 _(q, "usage: quit") \
24006 _(quit, "usage: quit") \
24007 _(search_node_table, "usage: search_node_table <name>...") \
24008 _(set, "usage: set <variable-name> <value>") \
24009 _(script, "usage: script <file-name>") \
24010 _(statseg, "usage: statseg"); \
24011 _(unset, "usage: unset <variable-name>")
24014 static void vl_api_##n##_t_handler_uni \
24015 (vl_api_##n##_t * mp) \
24017 vat_main_t * vam = &vat_main; \
24018 if (vam->json_output) { \
24019 vl_api_##n##_t_handler_json(mp); \
24021 vl_api_##n##_t_handler(mp); \
24024 foreach_vpe_api_reply_msg;
24025 #if VPP_API_TEST_BUILTIN == 0
24026 foreach_standalone_reply_msg;
24031 vat_api_hookup (vat_main_t * vam)
24034 vl_msg_api_set_handlers(VL_API_##N, #n, \
24035 vl_api_##n##_t_handler_uni, \
24037 vl_api_##n##_t_endian, \
24038 vl_api_##n##_t_print, \
24039 sizeof(vl_api_##n##_t), 1);
24040 foreach_vpe_api_reply_msg;
24041 #if VPP_API_TEST_BUILTIN == 0
24042 foreach_standalone_reply_msg;
24046 #if (VPP_API_TEST_BUILTIN==0)
24047 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24049 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24051 vam->function_by_name = hash_create_string (0, sizeof (uword));
24053 vam->help_by_name = hash_create_string (0, sizeof (uword));
24056 /* API messages we can send */
24057 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24058 foreach_vpe_api_msg;
24062 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24063 foreach_vpe_api_msg;
24066 /* CLI functions */
24067 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24068 foreach_cli_function;
24072 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24073 foreach_cli_function;
24077 #if VPP_API_TEST_BUILTIN
24078 static clib_error_t *
24079 vat_api_hookup_shim (vlib_main_t * vm)
24081 vat_api_hookup (&vat_main);
24085 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24089 * fd.io coding-style-patch-verification: ON
24092 * eval: (c-set-style "gnu")