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);
180 /* Parse an IP4 address %d.%d.%d.%d. */
182 unformat_ip4_address (unformat_input_t * input, va_list * args)
184 u8 *result = va_arg (*args, u8 *);
187 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
190 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
202 unformat_ethernet_address (unformat_input_t * input, va_list * args)
204 u8 *result = va_arg (*args, u8 *);
207 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
208 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
212 for (i = 0; i < 6; i++)
213 if (a[i] >= (1 << 8))
216 for (i = 0; i < 6; i++)
222 /* Returns ethernet type as an int in host byte order. */
224 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
227 u16 *result = va_arg (*args, u16 *);
231 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
233 if (type >= (1 << 16))
241 /* Parse an IP6 address. */
243 unformat_ip6_address (unformat_input_t * input, va_list * args)
245 ip6_address_t *result = va_arg (*args, ip6_address_t *);
247 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
248 uword c, n_colon, double_colon_index;
250 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
251 double_colon_index = ARRAY_LEN (hex_quads);
252 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
255 if (c >= '0' && c <= '9')
257 else if (c >= 'a' && c <= 'f')
258 hex_digit = c + 10 - 'a';
259 else if (c >= 'A' && c <= 'F')
260 hex_digit = c + 10 - 'A';
261 else if (c == ':' && n_colon < 2)
265 unformat_put_input (input);
269 /* Too many hex quads. */
270 if (n_hex_quads >= ARRAY_LEN (hex_quads))
275 hex_quad = (hex_quad << 4) | hex_digit;
277 /* Hex quad must fit in 16 bits. */
278 if (n_hex_digits >= 4)
285 /* Save position of :: */
288 /* More than one :: ? */
289 if (double_colon_index < ARRAY_LEN (hex_quads))
291 double_colon_index = n_hex_quads;
294 if (n_colon > 0 && n_hex_digits > 0)
296 hex_quads[n_hex_quads++] = hex_quad;
302 if (n_hex_digits > 0)
303 hex_quads[n_hex_quads++] = hex_quad;
308 /* Expand :: to appropriate number of zero hex quads. */
309 if (double_colon_index < ARRAY_LEN (hex_quads))
311 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
313 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
314 hex_quads[n_zero + i] = hex_quads[i];
316 for (i = 0; i < n_zero; i++)
317 hex_quads[double_colon_index + i] = 0;
319 n_hex_quads = ARRAY_LEN (hex_quads);
322 /* Too few hex quads given. */
323 if (n_hex_quads < ARRAY_LEN (hex_quads))
326 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
327 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
334 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
336 u32 *r = va_arg (*args, u32 *);
339 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
340 foreach_ipsec_policy_action
348 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
350 u32 *r = va_arg (*args, u32 *);
353 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
354 foreach_ipsec_crypto_alg
362 format_ipsec_crypto_alg (u8 * s, va_list * args)
364 u32 i = va_arg (*args, u32);
369 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
370 foreach_ipsec_crypto_alg
373 return format (s, "unknown");
375 return format (s, "%s", t);
379 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
381 u32 *r = va_arg (*args, u32 *);
384 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
385 foreach_ipsec_integ_alg
393 format_ipsec_integ_alg (u8 * s, va_list * args)
395 u32 i = va_arg (*args, u32);
400 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
401 foreach_ipsec_integ_alg
404 return format (s, "unknown");
406 return format (s, "%s", t);
410 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
412 u32 *r = va_arg (*args, u32 *);
415 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
416 foreach_ikev2_auth_method
424 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
426 u32 *r = va_arg (*args, u32 *);
429 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
430 foreach_ikev2_id_type
436 #else /* VPP_API_TEST_BUILTIN == 1 */
438 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
440 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
441 vnet_main_t *vnm = vnet_get_main ();
442 u32 *result = va_arg (*args, u32 *);
445 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
448 *result = sw_if_index;
451 #endif /* VPP_API_TEST_BUILTIN */
454 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
456 u8 *r = va_arg (*args, u8 *);
458 if (unformat (input, "kbps"))
459 *r = SSE2_QOS_RATE_KBPS;
460 else if (unformat (input, "pps"))
461 *r = SSE2_QOS_RATE_PPS;
468 unformat_policer_round_type (unformat_input_t * input, va_list * args)
470 u8 *r = va_arg (*args, u8 *);
472 if (unformat (input, "closest"))
473 *r = SSE2_QOS_ROUND_TO_CLOSEST;
474 else if (unformat (input, "up"))
475 *r = SSE2_QOS_ROUND_TO_UP;
476 else if (unformat (input, "down"))
477 *r = SSE2_QOS_ROUND_TO_DOWN;
484 unformat_policer_type (unformat_input_t * input, va_list * args)
486 u8 *r = va_arg (*args, u8 *);
488 if (unformat (input, "1r2c"))
489 *r = SSE2_QOS_POLICER_TYPE_1R2C;
490 else if (unformat (input, "1r3c"))
491 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
492 else if (unformat (input, "2r3c-2698"))
493 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
494 else if (unformat (input, "2r3c-4115"))
495 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
496 else if (unformat (input, "2r3c-mef5cf1"))
497 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
504 unformat_dscp (unformat_input_t * input, va_list * va)
506 u8 *r = va_arg (*va, u8 *);
509 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
518 unformat_policer_action_type (unformat_input_t * input, va_list * va)
520 sse2_qos_pol_action_params_st *a
521 = va_arg (*va, sse2_qos_pol_action_params_st *);
523 if (unformat (input, "drop"))
524 a->action_type = SSE2_QOS_ACTION_DROP;
525 else if (unformat (input, "transmit"))
526 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
527 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
528 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
535 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
537 u32 *r = va_arg (*va, u32 *);
540 if (unformat (input, "ip4"))
541 tid = POLICER_CLASSIFY_TABLE_IP4;
542 else if (unformat (input, "ip6"))
543 tid = POLICER_CLASSIFY_TABLE_IP6;
544 else if (unformat (input, "l2"))
545 tid = POLICER_CLASSIFY_TABLE_L2;
554 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
556 u32 *r = va_arg (*va, u32 *);
559 if (unformat (input, "ip4"))
560 tid = FLOW_CLASSIFY_TABLE_IP4;
561 else if (unformat (input, "ip6"))
562 tid = FLOW_CLASSIFY_TABLE_IP6;
570 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
571 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
572 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
573 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
575 #if (VPP_API_TEST_BUILTIN==0)
577 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
579 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
580 mfib_itf_attribute_t attr;
583 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
585 if (unformat (input, mfib_itf_flag_long_names[attr]))
586 *iflags |= (1 << attr);
588 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
590 if (unformat (input, mfib_itf_flag_names[attr]))
591 *iflags |= (1 << attr);
594 return (old == *iflags ? 0 : 1);
598 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
600 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
601 mfib_entry_attribute_t attr;
604 FOR_EACH_MFIB_ATTRIBUTE (attr)
606 if (unformat (input, mfib_flag_long_names[attr]))
607 *eflags |= (1 << attr);
609 FOR_EACH_MFIB_ATTRIBUTE (attr)
611 if (unformat (input, mfib_flag_names[attr]))
612 *eflags |= (1 << attr);
615 return (old == *eflags ? 0 : 1);
619 format_ip4_address (u8 * s, va_list * args)
621 u8 *a = va_arg (*args, u8 *);
622 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
626 format_ip6_address (u8 * s, va_list * args)
628 ip6_address_t *a = va_arg (*args, ip6_address_t *);
629 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
631 i_max_n_zero = ARRAY_LEN (a->as_u16);
633 i_first_zero = i_max_n_zero;
635 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
637 u32 is_zero = a->as_u16[i] == 0;
638 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
644 if ((!is_zero && n_zeros > max_n_zeros)
645 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
647 i_max_n_zero = i_first_zero;
648 max_n_zeros = n_zeros;
649 i_first_zero = ARRAY_LEN (a->as_u16);
654 last_double_colon = 0;
655 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
657 if (i == i_max_n_zero && max_n_zeros > 1)
659 s = format (s, "::");
660 i += max_n_zeros - 1;
661 last_double_colon = 1;
665 s = format (s, "%s%x",
666 (last_double_colon || i == 0) ? "" : ":",
667 clib_net_to_host_u16 (a->as_u16[i]));
668 last_double_colon = 0;
675 /* Format an IP46 address. */
677 format_ip46_address (u8 * s, va_list * args)
679 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
680 ip46_type_t type = va_arg (*args, ip46_type_t);
686 is_ip4 = ip46_address_is_ip4 (ip46);
697 format (s, "%U", format_ip4_address, &ip46->ip4) :
698 format (s, "%U", format_ip6_address, &ip46->ip6);
702 format_ethernet_address (u8 * s, va_list * args)
704 u8 *a = va_arg (*args, u8 *);
706 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
707 a[0], a[1], a[2], a[3], a[4], a[5]);
712 increment_v4_address (ip4_address_t * a)
716 v = ntohl (a->as_u32) + 1;
717 a->as_u32 = ntohl (v);
721 increment_v6_address (ip6_address_t * a)
725 v0 = clib_net_to_host_u64 (a->as_u64[0]);
726 v1 = clib_net_to_host_u64 (a->as_u64[1]);
731 a->as_u64[0] = clib_net_to_host_u64 (v0);
732 a->as_u64[1] = clib_net_to_host_u64 (v1);
736 increment_mac_address (u8 * mac)
738 u64 tmp = *((u64 *) mac);
739 tmp = clib_net_to_host_u64 (tmp);
740 tmp += 1 << 16; /* skip unused (least significant) octets */
741 tmp = clib_host_to_net_u64 (tmp);
743 clib_memcpy (mac, &tmp, 6);
746 static void vl_api_create_loopback_reply_t_handler
747 (vl_api_create_loopback_reply_t * mp)
749 vat_main_t *vam = &vat_main;
750 i32 retval = ntohl (mp->retval);
752 vam->retval = retval;
753 vam->regenerate_interface_table = 1;
754 vam->sw_if_index = ntohl (mp->sw_if_index);
755 vam->result_ready = 1;
758 static void vl_api_create_loopback_reply_t_handler_json
759 (vl_api_create_loopback_reply_t * mp)
761 vat_main_t *vam = &vat_main;
762 vat_json_node_t node;
764 vat_json_init_object (&node);
765 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
766 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
768 vat_json_print (vam->ofp, &node);
769 vat_json_free (&node);
770 vam->retval = ntohl (mp->retval);
771 vam->result_ready = 1;
774 static void vl_api_create_loopback_instance_reply_t_handler
775 (vl_api_create_loopback_instance_reply_t * mp)
777 vat_main_t *vam = &vat_main;
778 i32 retval = ntohl (mp->retval);
780 vam->retval = retval;
781 vam->regenerate_interface_table = 1;
782 vam->sw_if_index = ntohl (mp->sw_if_index);
783 vam->result_ready = 1;
786 static void vl_api_create_loopback_instance_reply_t_handler_json
787 (vl_api_create_loopback_instance_reply_t * mp)
789 vat_main_t *vam = &vat_main;
790 vat_json_node_t node;
792 vat_json_init_object (&node);
793 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
794 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
796 vat_json_print (vam->ofp, &node);
797 vat_json_free (&node);
798 vam->retval = ntohl (mp->retval);
799 vam->result_ready = 1;
802 static void vl_api_af_packet_create_reply_t_handler
803 (vl_api_af_packet_create_reply_t * mp)
805 vat_main_t *vam = &vat_main;
806 i32 retval = ntohl (mp->retval);
808 vam->retval = retval;
809 vam->regenerate_interface_table = 1;
810 vam->sw_if_index = ntohl (mp->sw_if_index);
811 vam->result_ready = 1;
814 static void vl_api_af_packet_create_reply_t_handler_json
815 (vl_api_af_packet_create_reply_t * mp)
817 vat_main_t *vam = &vat_main;
818 vat_json_node_t node;
820 vat_json_init_object (&node);
821 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
822 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
824 vat_json_print (vam->ofp, &node);
825 vat_json_free (&node);
827 vam->retval = ntohl (mp->retval);
828 vam->result_ready = 1;
831 static void vl_api_create_vlan_subif_reply_t_handler
832 (vl_api_create_vlan_subif_reply_t * mp)
834 vat_main_t *vam = &vat_main;
835 i32 retval = ntohl (mp->retval);
837 vam->retval = retval;
838 vam->regenerate_interface_table = 1;
839 vam->sw_if_index = ntohl (mp->sw_if_index);
840 vam->result_ready = 1;
843 static void vl_api_create_vlan_subif_reply_t_handler_json
844 (vl_api_create_vlan_subif_reply_t * mp)
846 vat_main_t *vam = &vat_main;
847 vat_json_node_t node;
849 vat_json_init_object (&node);
850 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
851 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
853 vat_json_print (vam->ofp, &node);
854 vat_json_free (&node);
856 vam->retval = ntohl (mp->retval);
857 vam->result_ready = 1;
860 static void vl_api_create_subif_reply_t_handler
861 (vl_api_create_subif_reply_t * mp)
863 vat_main_t *vam = &vat_main;
864 i32 retval = ntohl (mp->retval);
866 vam->retval = retval;
867 vam->regenerate_interface_table = 1;
868 vam->sw_if_index = ntohl (mp->sw_if_index);
869 vam->result_ready = 1;
872 static void vl_api_create_subif_reply_t_handler_json
873 (vl_api_create_subif_reply_t * mp)
875 vat_main_t *vam = &vat_main;
876 vat_json_node_t node;
878 vat_json_init_object (&node);
879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
880 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
882 vat_json_print (vam->ofp, &node);
883 vat_json_free (&node);
885 vam->retval = ntohl (mp->retval);
886 vam->result_ready = 1;
889 static void vl_api_interface_name_renumber_reply_t_handler
890 (vl_api_interface_name_renumber_reply_t * mp)
892 vat_main_t *vam = &vat_main;
893 i32 retval = ntohl (mp->retval);
895 vam->retval = retval;
896 vam->regenerate_interface_table = 1;
897 vam->result_ready = 1;
900 static void vl_api_interface_name_renumber_reply_t_handler_json
901 (vl_api_interface_name_renumber_reply_t * mp)
903 vat_main_t *vam = &vat_main;
904 vat_json_node_t node;
906 vat_json_init_object (&node);
907 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
909 vat_json_print (vam->ofp, &node);
910 vat_json_free (&node);
912 vam->retval = ntohl (mp->retval);
913 vam->result_ready = 1;
917 * Special-case: build the interface table, maintain
918 * the next loopback sw_if_index vbl.
920 static void vl_api_sw_interface_details_t_handler
921 (vl_api_sw_interface_details_t * mp)
923 vat_main_t *vam = &vat_main;
924 u8 *s = format (0, "%s%c", mp->interface_name, 0);
926 hash_set_mem (vam->sw_if_index_by_interface_name, s,
927 ntohl (mp->sw_if_index));
929 /* In sub interface case, fill the sub interface table entry */
930 if (mp->sw_if_index != mp->sup_sw_if_index)
932 sw_interface_subif_t *sub = NULL;
934 vec_add2 (vam->sw_if_subif_table, sub, 1);
936 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
937 strncpy ((char *) sub->interface_name, (char *) s,
938 vec_len (sub->interface_name));
939 sub->sw_if_index = ntohl (mp->sw_if_index);
940 sub->sub_id = ntohl (mp->sub_id);
942 sub->sub_dot1ad = mp->sub_dot1ad;
943 sub->sub_number_of_tags = mp->sub_number_of_tags;
944 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
945 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
946 sub->sub_exact_match = mp->sub_exact_match;
947 sub->sub_default = mp->sub_default;
948 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
949 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
951 /* vlan tag rewrite */
952 sub->vtr_op = ntohl (mp->vtr_op);
953 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
954 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
955 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
959 static void vl_api_sw_interface_details_t_handler_json
960 (vl_api_sw_interface_details_t * mp)
962 vat_main_t *vam = &vat_main;
963 vat_json_node_t *node = NULL;
965 if (VAT_JSON_ARRAY != vam->json_tree.type)
967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
968 vat_json_init_array (&vam->json_tree);
970 node = vat_json_array_add (&vam->json_tree);
972 vat_json_init_object (node);
973 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
974 vat_json_object_add_uint (node, "sup_sw_if_index",
975 ntohl (mp->sup_sw_if_index));
976 vat_json_object_add_uint (node, "l2_address_length",
977 ntohl (mp->l2_address_length));
978 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
979 sizeof (mp->l2_address));
980 vat_json_object_add_string_copy (node, "interface_name",
982 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
983 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
984 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
985 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
986 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
987 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
988 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
989 vat_json_object_add_uint (node, "sub_number_of_tags",
990 mp->sub_number_of_tags);
991 vat_json_object_add_uint (node, "sub_outer_vlan_id",
992 ntohs (mp->sub_outer_vlan_id));
993 vat_json_object_add_uint (node, "sub_inner_vlan_id",
994 ntohs (mp->sub_inner_vlan_id));
995 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
996 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
997 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
998 mp->sub_outer_vlan_id_any);
999 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1000 mp->sub_inner_vlan_id_any);
1001 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1002 vat_json_object_add_uint (node, "vtr_push_dot1q",
1003 ntohl (mp->vtr_push_dot1q));
1004 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1005 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1008 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1010 format_ethernet_address,
1012 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1014 format_ethernet_address,
1016 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1017 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1021 #if VPP_API_TEST_BUILTIN == 0
1022 static void vl_api_sw_interface_event_t_handler
1023 (vl_api_sw_interface_event_t * mp)
1025 vat_main_t *vam = &vat_main;
1026 if (vam->interface_event_display)
1027 errmsg ("interface flags: sw_if_index %d %s %s",
1028 ntohl (mp->sw_if_index),
1029 mp->admin_up_down ? "admin-up" : "admin-down",
1030 mp->link_up_down ? "link-up" : "link-down");
1034 static void vl_api_sw_interface_event_t_handler_json
1035 (vl_api_sw_interface_event_t * mp)
1037 /* JSON output not supported */
1041 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1043 vat_main_t *vam = &vat_main;
1044 i32 retval = ntohl (mp->retval);
1046 vam->retval = retval;
1047 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1048 vam->result_ready = 1;
1052 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1054 vat_main_t *vam = &vat_main;
1055 vat_json_node_t node;
1056 api_main_t *am = &api_main;
1060 vat_json_init_object (&node);
1061 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1062 vat_json_object_add_uint (&node, "reply_in_shmem",
1063 ntohl (mp->reply_in_shmem));
1064 /* Toss the shared-memory original... */
1065 pthread_mutex_lock (&am->vlib_rp->mutex);
1066 oldheap = svm_push_data_heap (am->vlib_rp);
1068 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1071 svm_pop_heap (oldheap);
1072 pthread_mutex_unlock (&am->vlib_rp->mutex);
1074 vat_json_print (vam->ofp, &node);
1075 vat_json_free (&node);
1077 vam->retval = ntohl (mp->retval);
1078 vam->result_ready = 1;
1082 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1084 vat_main_t *vam = &vat_main;
1085 i32 retval = ntohl (mp->retval);
1086 u32 length = ntohl (mp->length);
1088 vec_reset_length (vam->cmd_reply);
1090 vam->retval = retval;
1093 vec_validate (vam->cmd_reply, length);
1094 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1095 vam->cmd_reply[length] = 0;
1097 vam->result_ready = 1;
1101 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1103 vat_main_t *vam = &vat_main;
1104 vat_json_node_t node;
1106 vec_reset_length (vam->cmd_reply);
1108 vat_json_init_object (&node);
1109 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1110 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1112 vat_json_print (vam->ofp, &node);
1113 vat_json_free (&node);
1115 vam->retval = ntohl (mp->retval);
1116 vam->result_ready = 1;
1119 static void vl_api_classify_add_del_table_reply_t_handler
1120 (vl_api_classify_add_del_table_reply_t * mp)
1122 vat_main_t *vam = &vat_main;
1123 i32 retval = ntohl (mp->retval);
1124 if (vam->async_mode)
1126 vam->async_errors += (retval < 0);
1130 vam->retval = retval;
1132 ((mp->new_table_index != 0xFFFFFFFF) ||
1133 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1134 (mp->match_n_vectors != 0xFFFFFFFF)))
1136 * Note: this is just barely thread-safe, depends on
1137 * the main thread spinning waiting for an answer...
1139 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1140 ntohl (mp->new_table_index),
1141 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1142 vam->result_ready = 1;
1146 static void vl_api_classify_add_del_table_reply_t_handler_json
1147 (vl_api_classify_add_del_table_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 vat_json_node_t node;
1152 vat_json_init_object (&node);
1153 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1154 vat_json_object_add_uint (&node, "new_table_index",
1155 ntohl (mp->new_table_index));
1156 vat_json_object_add_uint (&node, "skip_n_vectors",
1157 ntohl (mp->skip_n_vectors));
1158 vat_json_object_add_uint (&node, "match_n_vectors",
1159 ntohl (mp->match_n_vectors));
1161 vat_json_print (vam->ofp, &node);
1162 vat_json_free (&node);
1164 vam->retval = ntohl (mp->retval);
1165 vam->result_ready = 1;
1168 static void vl_api_get_node_index_reply_t_handler
1169 (vl_api_get_node_index_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 i32 retval = ntohl (mp->retval);
1173 if (vam->async_mode)
1175 vam->async_errors += (retval < 0);
1179 vam->retval = retval;
1181 errmsg ("node index %d", ntohl (mp->node_index));
1182 vam->result_ready = 1;
1186 static void vl_api_get_node_index_reply_t_handler_json
1187 (vl_api_get_node_index_reply_t * mp)
1189 vat_main_t *vam = &vat_main;
1190 vat_json_node_t node;
1192 vat_json_init_object (&node);
1193 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1194 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1196 vat_json_print (vam->ofp, &node);
1197 vat_json_free (&node);
1199 vam->retval = ntohl (mp->retval);
1200 vam->result_ready = 1;
1203 static void vl_api_get_next_index_reply_t_handler
1204 (vl_api_get_next_index_reply_t * mp)
1206 vat_main_t *vam = &vat_main;
1207 i32 retval = ntohl (mp->retval);
1208 if (vam->async_mode)
1210 vam->async_errors += (retval < 0);
1214 vam->retval = retval;
1216 errmsg ("next node index %d", ntohl (mp->next_index));
1217 vam->result_ready = 1;
1221 static void vl_api_get_next_index_reply_t_handler_json
1222 (vl_api_get_next_index_reply_t * mp)
1224 vat_main_t *vam = &vat_main;
1225 vat_json_node_t node;
1227 vat_json_init_object (&node);
1228 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1229 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1231 vat_json_print (vam->ofp, &node);
1232 vat_json_free (&node);
1234 vam->retval = ntohl (mp->retval);
1235 vam->result_ready = 1;
1238 static void vl_api_add_node_next_reply_t_handler
1239 (vl_api_add_node_next_reply_t * mp)
1241 vat_main_t *vam = &vat_main;
1242 i32 retval = ntohl (mp->retval);
1243 if (vam->async_mode)
1245 vam->async_errors += (retval < 0);
1249 vam->retval = retval;
1251 errmsg ("next index %d", ntohl (mp->next_index));
1252 vam->result_ready = 1;
1256 static void vl_api_add_node_next_reply_t_handler_json
1257 (vl_api_add_node_next_reply_t * mp)
1259 vat_main_t *vam = &vat_main;
1260 vat_json_node_t node;
1262 vat_json_init_object (&node);
1263 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1264 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1266 vat_json_print (vam->ofp, &node);
1267 vat_json_free (&node);
1269 vam->retval = ntohl (mp->retval);
1270 vam->result_ready = 1;
1273 static void vl_api_show_version_reply_t_handler
1274 (vl_api_show_version_reply_t * mp)
1276 vat_main_t *vam = &vat_main;
1277 i32 retval = ntohl (mp->retval);
1281 errmsg (" program: %s", mp->program);
1282 errmsg (" version: %s", mp->version);
1283 errmsg (" build date: %s", mp->build_date);
1284 errmsg ("build directory: %s", mp->build_directory);
1286 vam->retval = retval;
1287 vam->result_ready = 1;
1290 static void vl_api_show_version_reply_t_handler_json
1291 (vl_api_show_version_reply_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 vat_json_node_t node;
1296 vat_json_init_object (&node);
1297 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1298 vat_json_object_add_string_copy (&node, "program", mp->program);
1299 vat_json_object_add_string_copy (&node, "version", mp->version);
1300 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1301 vat_json_object_add_string_copy (&node, "build_directory",
1302 mp->build_directory);
1304 vat_json_print (vam->ofp, &node);
1305 vat_json_free (&node);
1307 vam->retval = ntohl (mp->retval);
1308 vam->result_ready = 1;
1312 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1314 u32 sw_if_index = ntohl (mp->sw_if_index);
1315 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1316 mp->mac_ip ? "mac/ip binding" : "address resolution",
1317 ntohl (mp->pid), format_ip4_address, &mp->address,
1318 format_ethernet_address, mp->new_mac, sw_if_index);
1322 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1324 /* JSON output not supported */
1328 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1330 u32 sw_if_index = ntohl (mp->sw_if_index);
1331 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1332 mp->mac_ip ? "mac/ip binding" : "address resolution",
1333 ntohl (mp->pid), format_ip6_address, mp->address,
1334 format_ethernet_address, mp->new_mac, sw_if_index);
1338 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1340 /* JSON output not supported */
1344 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1346 u32 n_macs = ntohl (mp->n_macs);
1347 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1348 ntohl (mp->pid), mp->client_index, n_macs);
1350 for (i = 0; i < n_macs; i++)
1352 vl_api_mac_entry_t *mac = &mp->mac[i];
1353 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1354 i + 1, ntohl (mac->sw_if_index),
1355 format_ethernet_address, mac->mac_addr, mac->action);
1362 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1364 /* JSON output not supported */
1367 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1368 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1371 * Special-case: build the bridge domain table, maintain
1372 * the next bd id vbl.
1374 static void vl_api_bridge_domain_details_t_handler
1375 (vl_api_bridge_domain_details_t * mp)
1377 vat_main_t *vam = &vat_main;
1378 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1381 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1382 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1384 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1385 ntohl (mp->bd_id), mp->learn, mp->forward,
1386 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1390 vl_api_bridge_domain_sw_if_t *sw_ifs;
1391 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1394 sw_ifs = mp->sw_if_details;
1395 for (i = 0; i < n_sw_ifs; i++)
1401 sw_if_index = ntohl (sw_ifs->sw_if_index);
1404 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1406 if ((u32) p->value[0] == sw_if_index)
1408 sw_if_name = (u8 *)(p->key);
1413 print (vam->ofp, "%7d %3d %s", sw_if_index,
1414 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1415 "sw_if_index not found!");
1422 static void vl_api_bridge_domain_details_t_handler_json
1423 (vl_api_bridge_domain_details_t * mp)
1425 vat_main_t *vam = &vat_main;
1426 vat_json_node_t *node, *array = NULL;
1427 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1429 if (VAT_JSON_ARRAY != vam->json_tree.type)
1431 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1432 vat_json_init_array (&vam->json_tree);
1434 node = vat_json_array_add (&vam->json_tree);
1436 vat_json_init_object (node);
1437 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1438 vat_json_object_add_uint (node, "flood", mp->flood);
1439 vat_json_object_add_uint (node, "forward", mp->forward);
1440 vat_json_object_add_uint (node, "learn", mp->learn);
1441 vat_json_object_add_uint (node, "bvi_sw_if_index",
1442 ntohl (mp->bvi_sw_if_index));
1443 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1444 array = vat_json_object_add (node, "sw_if");
1445 vat_json_init_array (array);
1451 vl_api_bridge_domain_sw_if_t *sw_ifs;
1454 sw_ifs = mp->sw_if_details;
1455 for (i = 0; i < n_sw_ifs; i++)
1457 node = vat_json_array_add (array);
1458 vat_json_init_object (node);
1459 vat_json_object_add_uint (node, "sw_if_index",
1460 ntohl (sw_ifs->sw_if_index));
1461 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1467 static void vl_api_control_ping_reply_t_handler
1468 (vl_api_control_ping_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 i32 retval = ntohl (mp->retval);
1472 if (vam->async_mode)
1474 vam->async_errors += (retval < 0);
1478 vam->retval = retval;
1479 vam->result_ready = 1;
1481 if (vam->socket_client_main)
1482 vam->socket_client_main->control_pings_outstanding--;
1485 static void vl_api_control_ping_reply_t_handler_json
1486 (vl_api_control_ping_reply_t * mp)
1488 vat_main_t *vam = &vat_main;
1489 i32 retval = ntohl (mp->retval);
1491 if (VAT_JSON_NONE != vam->json_tree.type)
1493 vat_json_print (vam->ofp, &vam->json_tree);
1494 vat_json_free (&vam->json_tree);
1495 vam->json_tree.type = VAT_JSON_NONE;
1500 vat_json_init_array (&vam->json_tree);
1501 vat_json_print (vam->ofp, &vam->json_tree);
1502 vam->json_tree.type = VAT_JSON_NONE;
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 vl_api_bridge_domain_set_mac_age_reply_t_handler
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 i32 retval = ntohl (mp->retval);
1515 if (vam->async_mode)
1517 vam->async_errors += (retval < 0);
1521 vam->retval = retval;
1522 vam->result_ready = 1;
1526 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1527 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 vat_json_node_t node;
1532 vat_json_init_object (&node);
1533 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1535 vat_json_print (vam->ofp, &node);
1536 vat_json_free (&node);
1538 vam->retval = ntohl (mp->retval);
1539 vam->result_ready = 1;
1543 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 i32 retval = ntohl (mp->retval);
1547 if (vam->async_mode)
1549 vam->async_errors += (retval < 0);
1553 vam->retval = retval;
1554 vam->result_ready = 1;
1558 static void vl_api_l2_flags_reply_t_handler_json
1559 (vl_api_l2_flags_reply_t * mp)
1561 vat_main_t *vam = &vat_main;
1562 vat_json_node_t node;
1564 vat_json_init_object (&node);
1565 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1566 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1567 ntohl (mp->resulting_feature_bitmap));
1569 vat_json_print (vam->ofp, &node);
1570 vat_json_free (&node);
1572 vam->retval = ntohl (mp->retval);
1573 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 i32 retval = ntohl (mp->retval);
1581 if (vam->async_mode)
1583 vam->async_errors += (retval < 0);
1587 vam->retval = retval;
1588 vam->result_ready = 1;
1592 static void vl_api_bridge_flags_reply_t_handler_json
1593 (vl_api_bridge_flags_reply_t * mp)
1595 vat_main_t *vam = &vat_main;
1596 vat_json_node_t node;
1598 vat_json_init_object (&node);
1599 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1600 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1601 ntohl (mp->resulting_feature_bitmap));
1603 vat_json_print (vam->ofp, &node);
1604 vat_json_free (&node);
1606 vam->retval = ntohl (mp->retval);
1607 vam->result_ready = 1;
1610 static void vl_api_tap_connect_reply_t_handler
1611 (vl_api_tap_connect_reply_t * mp)
1613 vat_main_t *vam = &vat_main;
1614 i32 retval = ntohl (mp->retval);
1615 if (vam->async_mode)
1617 vam->async_errors += (retval < 0);
1621 vam->retval = retval;
1622 vam->sw_if_index = ntohl (mp->sw_if_index);
1623 vam->result_ready = 1;
1628 static void vl_api_tap_connect_reply_t_handler_json
1629 (vl_api_tap_connect_reply_t * mp)
1631 vat_main_t *vam = &vat_main;
1632 vat_json_node_t node;
1634 vat_json_init_object (&node);
1635 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1636 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1638 vat_json_print (vam->ofp, &node);
1639 vat_json_free (&node);
1641 vam->retval = ntohl (mp->retval);
1642 vam->result_ready = 1;
1647 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1649 vat_main_t *vam = &vat_main;
1650 i32 retval = ntohl (mp->retval);
1651 if (vam->async_mode)
1653 vam->async_errors += (retval < 0);
1657 vam->retval = retval;
1658 vam->sw_if_index = ntohl (mp->sw_if_index);
1659 vam->result_ready = 1;
1663 static void vl_api_tap_modify_reply_t_handler_json
1664 (vl_api_tap_modify_reply_t * mp)
1666 vat_main_t *vam = &vat_main;
1667 vat_json_node_t node;
1669 vat_json_init_object (&node);
1670 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1671 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1673 vat_json_print (vam->ofp, &node);
1674 vat_json_free (&node);
1676 vam->retval = ntohl (mp->retval);
1677 vam->result_ready = 1;
1681 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 i32 retval = ntohl (mp->retval);
1685 if (vam->async_mode)
1687 vam->async_errors += (retval < 0);
1691 vam->retval = retval;
1692 vam->result_ready = 1;
1696 static void vl_api_tap_delete_reply_t_handler_json
1697 (vl_api_tap_delete_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 vat_json_node_t node;
1702 vat_json_init_object (&node);
1703 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1705 vat_json_print (vam->ofp, &node);
1706 vat_json_free (&node);
1708 vam->retval = ntohl (mp->retval);
1709 vam->result_ready = 1;
1713 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 i32 retval = ntohl (mp->retval);
1717 if (vam->async_mode)
1719 vam->async_errors += (retval < 0);
1723 vam->retval = retval;
1724 vam->sw_if_index = ntohl (mp->sw_if_index);
1725 vam->result_ready = 1;
1730 static void vl_api_tap_create_v2_reply_t_handler_json
1731 (vl_api_tap_create_v2_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 vat_json_node_t node;
1736 vat_json_init_object (&node);
1737 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1738 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1740 vat_json_print (vam->ofp, &node);
1741 vat_json_free (&node);
1743 vam->retval = ntohl (mp->retval);
1744 vam->result_ready = 1;
1749 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1751 vat_main_t *vam = &vat_main;
1752 i32 retval = ntohl (mp->retval);
1753 if (vam->async_mode)
1755 vam->async_errors += (retval < 0);
1759 vam->retval = retval;
1760 vam->result_ready = 1;
1764 static void vl_api_tap_delete_v2_reply_t_handler_json
1765 (vl_api_tap_delete_v2_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 vat_json_node_t node;
1770 vat_json_init_object (&node);
1771 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1773 vat_json_print (vam->ofp, &node);
1774 vat_json_free (&node);
1776 vam->retval = ntohl (mp->retval);
1777 vam->result_ready = 1;
1781 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 i32 retval = ntohl (mp->retval);
1786 if (vam->async_mode)
1788 vam->async_errors += (retval < 0);
1792 vam->retval = retval;
1793 vam->sw_if_index = ntohl (mp->sw_if_index);
1794 vam->result_ready = 1;
1798 static void vl_api_bond_create_reply_t_handler_json
1799 (vl_api_bond_create_reply_t * mp)
1801 vat_main_t *vam = &vat_main;
1802 vat_json_node_t node;
1804 vat_json_init_object (&node);
1805 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1806 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1808 vat_json_print (vam->ofp, &node);
1809 vat_json_free (&node);
1811 vam->retval = ntohl (mp->retval);
1812 vam->result_ready = 1;
1816 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1821 if (vam->async_mode)
1823 vam->async_errors += (retval < 0);
1827 vam->retval = retval;
1828 vam->result_ready = 1;
1832 static void vl_api_bond_delete_reply_t_handler_json
1833 (vl_api_bond_delete_reply_t * mp)
1835 vat_main_t *vam = &vat_main;
1836 vat_json_node_t node;
1838 vat_json_init_object (&node);
1839 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1841 vat_json_print (vam->ofp, &node);
1842 vat_json_free (&node);
1844 vam->retval = ntohl (mp->retval);
1845 vam->result_ready = 1;
1849 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1851 vat_main_t *vam = &vat_main;
1852 i32 retval = ntohl (mp->retval);
1854 if (vam->async_mode)
1856 vam->async_errors += (retval < 0);
1860 vam->retval = retval;
1861 vam->result_ready = 1;
1865 static void vl_api_bond_enslave_reply_t_handler_json
1866 (vl_api_bond_enslave_reply_t * mp)
1868 vat_main_t *vam = &vat_main;
1869 vat_json_node_t node;
1871 vat_json_init_object (&node);
1872 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1874 vat_json_print (vam->ofp, &node);
1875 vat_json_free (&node);
1877 vam->retval = ntohl (mp->retval);
1878 vam->result_ready = 1;
1882 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1885 vat_main_t *vam = &vat_main;
1886 i32 retval = ntohl (mp->retval);
1888 if (vam->async_mode)
1890 vam->async_errors += (retval < 0);
1894 vam->retval = retval;
1895 vam->result_ready = 1;
1899 static void vl_api_bond_detach_slave_reply_t_handler_json
1900 (vl_api_bond_detach_slave_reply_t * mp)
1902 vat_main_t *vam = &vat_main;
1903 vat_json_node_t node;
1905 vat_json_init_object (&node);
1906 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1908 vat_json_print (vam->ofp, &node);
1909 vat_json_free (&node);
1911 vam->retval = ntohl (mp->retval);
1912 vam->result_ready = 1;
1915 static void vl_api_sw_interface_bond_details_t_handler
1916 (vl_api_sw_interface_bond_details_t * mp)
1918 vat_main_t *vam = &vat_main;
1921 "%-16s %-12d %-12U %-13U %-14u %-14u",
1922 mp->interface_name, ntohl (mp->sw_if_index),
1923 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1924 ntohl (mp->active_slaves), ntohl (mp->slaves));
1927 static void vl_api_sw_interface_bond_details_t_handler_json
1928 (vl_api_sw_interface_bond_details_t * mp)
1930 vat_main_t *vam = &vat_main;
1931 vat_json_node_t *node = NULL;
1933 if (VAT_JSON_ARRAY != vam->json_tree.type)
1935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1936 vat_json_init_array (&vam->json_tree);
1938 node = vat_json_array_add (&vam->json_tree);
1940 vat_json_init_object (node);
1941 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1942 vat_json_object_add_string_copy (node, "interface_name",
1943 mp->interface_name);
1944 vat_json_object_add_uint (node, "mode", mp->mode);
1945 vat_json_object_add_uint (node, "load_balance", mp->lb);
1946 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
1947 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
1951 api_sw_interface_bond_dump (vat_main_t * vam)
1953 vl_api_sw_interface_bond_dump_t *mp;
1954 vl_api_control_ping_t *mp_ping;
1958 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
1959 "interface name", "sw_if_index", "mode", "load balance",
1960 "active slaves", "slaves");
1962 /* Get list of bond interfaces */
1963 M (SW_INTERFACE_BOND_DUMP, mp);
1966 /* Use a control ping for synchronization */
1967 MPING (CONTROL_PING, mp_ping);
1974 static void vl_api_sw_interface_slave_details_t_handler
1975 (vl_api_sw_interface_slave_details_t * mp)
1977 vat_main_t *vam = &vat_main;
1980 "%-25s %-12d %-12d %d", mp->interface_name,
1981 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
1984 static void vl_api_sw_interface_slave_details_t_handler_json
1985 (vl_api_sw_interface_slave_details_t * mp)
1987 vat_main_t *vam = &vat_main;
1988 vat_json_node_t *node = NULL;
1990 if (VAT_JSON_ARRAY != vam->json_tree.type)
1992 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1993 vat_json_init_array (&vam->json_tree);
1995 node = vat_json_array_add (&vam->json_tree);
1997 vat_json_init_object (node);
1998 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1999 vat_json_object_add_string_copy (node, "interface_name",
2000 mp->interface_name);
2001 vat_json_object_add_uint (node, "passive", mp->is_passive);
2002 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2006 api_sw_interface_slave_dump (vat_main_t * vam)
2008 unformat_input_t *i = vam->input;
2009 vl_api_sw_interface_slave_dump_t *mp;
2010 vl_api_control_ping_t *mp_ping;
2011 u32 sw_if_index = ~0;
2012 u8 sw_if_index_set = 0;
2015 /* Parse args required to build the message */
2016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2019 sw_if_index_set = 1;
2020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2021 sw_if_index_set = 1;
2026 if (sw_if_index_set == 0)
2028 errmsg ("missing vpp interface name. ");
2033 "\n%-25s %-12s %-12s %s",
2034 "slave interface name", "sw_if_index", "passive", "long_timeout");
2036 /* Get list of bond interfaces */
2037 M (SW_INTERFACE_SLAVE_DUMP, mp);
2038 mp->sw_if_index = ntohl (sw_if_index);
2041 /* Use a control ping for synchronization */
2042 MPING (CONTROL_PING, mp_ping);
2049 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2050 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2052 vat_main_t *vam = &vat_main;
2053 i32 retval = ntohl (mp->retval);
2054 if (vam->async_mode)
2056 vam->async_errors += (retval < 0);
2060 vam->retval = retval;
2061 vam->result_ready = 1;
2065 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2066 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2068 vat_main_t *vam = &vat_main;
2069 vat_json_node_t node;
2071 vat_json_init_object (&node);
2072 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2073 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2074 ntohl (mp->sw_if_index));
2076 vat_json_print (vam->ofp, &node);
2077 vat_json_free (&node);
2079 vam->retval = ntohl (mp->retval);
2080 vam->result_ready = 1;
2083 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2084 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2086 vat_main_t *vam = &vat_main;
2087 i32 retval = ntohl (mp->retval);
2088 if (vam->async_mode)
2090 vam->async_errors += (retval < 0);
2094 vam->retval = retval;
2095 vam->sw_if_index = ntohl (mp->sw_if_index);
2096 vam->result_ready = 1;
2100 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2101 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2103 vat_main_t *vam = &vat_main;
2104 vat_json_node_t node;
2106 vat_json_init_object (&node);
2107 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2108 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2110 vat_json_print (vam->ofp, &node);
2111 vat_json_free (&node);
2113 vam->retval = ntohl (mp->retval);
2114 vam->result_ready = 1;
2117 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2118 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2120 vat_main_t *vam = &vat_main;
2121 i32 retval = ntohl (mp->retval);
2122 if (vam->async_mode)
2124 vam->async_errors += (retval < 0);
2128 vam->retval = retval;
2129 vam->result_ready = 1;
2133 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2134 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2136 vat_main_t *vam = &vat_main;
2137 vat_json_node_t node;
2139 vat_json_init_object (&node);
2140 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2141 vat_json_object_add_uint (&node, "fwd_entry_index",
2142 clib_net_to_host_u32 (mp->fwd_entry_index));
2144 vat_json_print (vam->ofp, &node);
2145 vat_json_free (&node);
2147 vam->retval = ntohl (mp->retval);
2148 vam->result_ready = 1;
2152 format_lisp_transport_protocol (u8 * s, va_list * args)
2154 u32 proto = va_arg (*args, u32);
2159 return format (s, "udp");
2161 return format (s, "api");
2168 static void vl_api_one_get_transport_protocol_reply_t_handler
2169 (vl_api_one_get_transport_protocol_reply_t * mp)
2171 vat_main_t *vam = &vat_main;
2172 i32 retval = ntohl (mp->retval);
2173 if (vam->async_mode)
2175 vam->async_errors += (retval < 0);
2179 u32 proto = mp->protocol;
2180 print (vam->ofp, "Transport protocol: %U",
2181 format_lisp_transport_protocol, proto);
2182 vam->retval = retval;
2183 vam->result_ready = 1;
2187 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2188 (vl_api_one_get_transport_protocol_reply_t * mp)
2190 vat_main_t *vam = &vat_main;
2191 vat_json_node_t node;
2194 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2197 vat_json_init_object (&node);
2198 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2199 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2202 vat_json_print (vam->ofp, &node);
2203 vat_json_free (&node);
2205 vam->retval = ntohl (mp->retval);
2206 vam->result_ready = 1;
2209 static void vl_api_one_add_del_locator_set_reply_t_handler
2210 (vl_api_one_add_del_locator_set_reply_t * mp)
2212 vat_main_t *vam = &vat_main;
2213 i32 retval = ntohl (mp->retval);
2214 if (vam->async_mode)
2216 vam->async_errors += (retval < 0);
2220 vam->retval = retval;
2221 vam->result_ready = 1;
2225 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2226 (vl_api_one_add_del_locator_set_reply_t * mp)
2228 vat_main_t *vam = &vat_main;
2229 vat_json_node_t node;
2231 vat_json_init_object (&node);
2232 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2233 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2235 vat_json_print (vam->ofp, &node);
2236 vat_json_free (&node);
2238 vam->retval = ntohl (mp->retval);
2239 vam->result_ready = 1;
2242 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2243 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2245 vat_main_t *vam = &vat_main;
2246 i32 retval = ntohl (mp->retval);
2247 if (vam->async_mode)
2249 vam->async_errors += (retval < 0);
2253 vam->retval = retval;
2254 vam->sw_if_index = ntohl (mp->sw_if_index);
2255 vam->result_ready = 1;
2257 vam->regenerate_interface_table = 1;
2260 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2261 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2263 vat_main_t *vam = &vat_main;
2264 vat_json_node_t node;
2266 vat_json_init_object (&node);
2267 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2268 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2270 vat_json_print (vam->ofp, &node);
2271 vat_json_free (&node);
2273 vam->retval = ntohl (mp->retval);
2274 vam->result_ready = 1;
2277 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2278 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2280 vat_main_t *vam = &vat_main;
2281 i32 retval = ntohl (mp->retval);
2282 if (vam->async_mode)
2284 vam->async_errors += (retval < 0);
2288 vam->retval = retval;
2289 vam->sw_if_index = ntohl (mp->sw_if_index);
2290 vam->result_ready = 1;
2294 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2295 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2297 vat_main_t *vam = &vat_main;
2298 vat_json_node_t node;
2300 vat_json_init_object (&node);
2301 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2302 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2304 vat_json_print (vam->ofp, &node);
2305 vat_json_free (&node);
2307 vam->retval = ntohl (mp->retval);
2308 vam->result_ready = 1;
2311 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2312 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2314 vat_main_t *vam = &vat_main;
2315 i32 retval = ntohl (mp->retval);
2316 if (vam->async_mode)
2318 vam->async_errors += (retval < 0);
2322 vam->retval = retval;
2323 vam->sw_if_index = ntohl (mp->sw_if_index);
2324 vam->result_ready = 1;
2326 vam->regenerate_interface_table = 1;
2329 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2330 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2332 vat_main_t *vam = &vat_main;
2333 vat_json_node_t node;
2335 vat_json_init_object (&node);
2336 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2337 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2339 vat_json_print (vam->ofp, &node);
2340 vat_json_free (&node);
2342 vam->retval = ntohl (mp->retval);
2343 vam->result_ready = 1;
2346 static void vl_api_gre_add_del_tunnel_reply_t_handler
2347 (vl_api_gre_add_del_tunnel_reply_t * mp)
2349 vat_main_t *vam = &vat_main;
2350 i32 retval = ntohl (mp->retval);
2351 if (vam->async_mode)
2353 vam->async_errors += (retval < 0);
2357 vam->retval = retval;
2358 vam->sw_if_index = ntohl (mp->sw_if_index);
2359 vam->result_ready = 1;
2363 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2364 (vl_api_gre_add_del_tunnel_reply_t * mp)
2366 vat_main_t *vam = &vat_main;
2367 vat_json_node_t node;
2369 vat_json_init_object (&node);
2370 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2371 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2373 vat_json_print (vam->ofp, &node);
2374 vat_json_free (&node);
2376 vam->retval = ntohl (mp->retval);
2377 vam->result_ready = 1;
2380 static void vl_api_create_vhost_user_if_reply_t_handler
2381 (vl_api_create_vhost_user_if_reply_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 i32 retval = ntohl (mp->retval);
2385 if (vam->async_mode)
2387 vam->async_errors += (retval < 0);
2391 vam->retval = retval;
2392 vam->sw_if_index = ntohl (mp->sw_if_index);
2393 vam->result_ready = 1;
2395 vam->regenerate_interface_table = 1;
2398 static void vl_api_create_vhost_user_if_reply_t_handler_json
2399 (vl_api_create_vhost_user_if_reply_t * mp)
2401 vat_main_t *vam = &vat_main;
2402 vat_json_node_t node;
2404 vat_json_init_object (&node);
2405 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2406 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2408 vat_json_print (vam->ofp, &node);
2409 vat_json_free (&node);
2411 vam->retval = ntohl (mp->retval);
2412 vam->result_ready = 1;
2415 static void vl_api_dns_resolve_name_reply_t_handler
2416 (vl_api_dns_resolve_name_reply_t * mp)
2418 vat_main_t *vam = &vat_main;
2419 i32 retval = ntohl (mp->retval);
2420 if (vam->async_mode)
2422 vam->async_errors += (retval < 0);
2426 vam->retval = retval;
2427 vam->result_ready = 1;
2432 clib_warning ("ip4 address %U", format_ip4_address,
2433 (ip4_address_t *) mp->ip4_address);
2435 clib_warning ("ip6 address %U", format_ip6_address,
2436 (ip6_address_t *) mp->ip6_address);
2439 clib_warning ("retval %d", retval);
2443 static void vl_api_dns_resolve_name_reply_t_handler_json
2444 (vl_api_dns_resolve_name_reply_t * mp)
2446 clib_warning ("not implemented");
2449 static void vl_api_dns_resolve_ip_reply_t_handler
2450 (vl_api_dns_resolve_ip_reply_t * mp)
2452 vat_main_t *vam = &vat_main;
2453 i32 retval = ntohl (mp->retval);
2454 if (vam->async_mode)
2456 vam->async_errors += (retval < 0);
2460 vam->retval = retval;
2461 vam->result_ready = 1;
2465 clib_warning ("canonical name %s", mp->name);
2468 clib_warning ("retval %d", retval);
2472 static void vl_api_dns_resolve_ip_reply_t_handler_json
2473 (vl_api_dns_resolve_ip_reply_t * mp)
2475 clib_warning ("not implemented");
2479 static void vl_api_ip_address_details_t_handler
2480 (vl_api_ip_address_details_t * mp)
2482 vat_main_t *vam = &vat_main;
2483 static ip_address_details_t empty_ip_address_details = { {0} };
2484 ip_address_details_t *address = NULL;
2485 ip_details_t *current_ip_details = NULL;
2486 ip_details_t *details = NULL;
2488 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2490 if (!details || vam->current_sw_if_index >= vec_len (details)
2491 || !details[vam->current_sw_if_index].present)
2493 errmsg ("ip address details arrived but not stored");
2494 errmsg ("ip_dump should be called first");
2498 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2500 #define addresses (current_ip_details->addr)
2502 vec_validate_init_empty (addresses, vec_len (addresses),
2503 empty_ip_address_details);
2505 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2507 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2508 address->prefix_length = mp->prefix_length;
2512 static void vl_api_ip_address_details_t_handler_json
2513 (vl_api_ip_address_details_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 vat_json_node_t *node = NULL;
2517 struct in6_addr ip6;
2520 if (VAT_JSON_ARRAY != vam->json_tree.type)
2522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2523 vat_json_init_array (&vam->json_tree);
2525 node = vat_json_array_add (&vam->json_tree);
2527 vat_json_init_object (node);
2530 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2531 vat_json_object_add_ip6 (node, "ip", ip6);
2535 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2536 vat_json_object_add_ip4 (node, "ip", ip4);
2538 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2542 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 static ip_details_t empty_ip_details = { 0 };
2546 ip_details_t *ip = NULL;
2547 u32 sw_if_index = ~0;
2549 sw_if_index = ntohl (mp->sw_if_index);
2551 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2552 sw_if_index, empty_ip_details);
2554 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2561 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2563 vat_main_t *vam = &vat_main;
2565 if (VAT_JSON_ARRAY != vam->json_tree.type)
2567 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2568 vat_json_init_array (&vam->json_tree);
2570 vat_json_array_add_uint (&vam->json_tree,
2571 clib_net_to_host_u32 (mp->sw_if_index));
2574 static void vl_api_map_domain_details_t_handler_json
2575 (vl_api_map_domain_details_t * mp)
2577 vat_json_node_t *node = NULL;
2578 vat_main_t *vam = &vat_main;
2579 struct in6_addr ip6;
2582 if (VAT_JSON_ARRAY != vam->json_tree.type)
2584 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2585 vat_json_init_array (&vam->json_tree);
2588 node = vat_json_array_add (&vam->json_tree);
2589 vat_json_init_object (node);
2591 vat_json_object_add_uint (node, "domain_index",
2592 clib_net_to_host_u32 (mp->domain_index));
2593 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2594 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2595 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2596 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2597 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2598 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2599 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2600 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2601 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2602 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2603 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2604 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2605 vat_json_object_add_uint (node, "flags", mp->flags);
2606 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2607 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2610 static void vl_api_map_domain_details_t_handler
2611 (vl_api_map_domain_details_t * mp)
2613 vat_main_t *vam = &vat_main;
2615 if (mp->is_translation)
2618 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2619 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2620 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2621 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2622 clib_net_to_host_u32 (mp->domain_index));
2627 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2628 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2629 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2630 format_ip6_address, mp->ip6_src,
2631 clib_net_to_host_u32 (mp->domain_index));
2633 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2634 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2635 mp->is_translation ? "map-t" : "");
2638 static void vl_api_map_rule_details_t_handler_json
2639 (vl_api_map_rule_details_t * mp)
2641 struct in6_addr ip6;
2642 vat_json_node_t *node = NULL;
2643 vat_main_t *vam = &vat_main;
2645 if (VAT_JSON_ARRAY != vam->json_tree.type)
2647 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2648 vat_json_init_array (&vam->json_tree);
2651 node = vat_json_array_add (&vam->json_tree);
2652 vat_json_init_object (node);
2654 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2655 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2656 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2660 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2662 vat_main_t *vam = &vat_main;
2663 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2664 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2668 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2670 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2671 "router_addr %U host_mac %U",
2672 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2674 format_ip4_address, &mp->lease.host_address,
2675 format_ip4_address, &mp->lease.router_address,
2676 format_ethernet_address, mp->lease.host_mac);
2679 static void vl_api_dhcp_compl_event_t_handler_json
2680 (vl_api_dhcp_compl_event_t * mp)
2682 /* JSON output not supported */
2686 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2689 vat_main_t *vam = &vat_main;
2690 static u64 default_counter = 0;
2692 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2694 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2695 sw_if_index, default_counter);
2696 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2700 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2701 interface_counter_t counter)
2703 vat_main_t *vam = &vat_main;
2704 static interface_counter_t default_counter = { 0, };
2706 vec_validate_init_empty (vam->combined_interface_counters,
2707 vnet_counter_type, NULL);
2708 vec_validate_init_empty (vam->combined_interface_counters
2709 [vnet_counter_type], sw_if_index, default_counter);
2710 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2713 static void vl_api_vnet_interface_simple_counters_t_handler
2714 (vl_api_vnet_interface_simple_counters_t * mp)
2719 static void vl_api_vnet_interface_combined_counters_t_handler
2720 (vl_api_vnet_interface_combined_counters_t * mp)
2725 static void vl_api_vnet_interface_simple_counters_t_handler_json
2726 (vl_api_vnet_interface_simple_counters_t * mp)
2731 u32 first_sw_if_index;
2734 count = ntohl (mp->count);
2735 first_sw_if_index = ntohl (mp->first_sw_if_index);
2737 v_packets = (u64 *) & mp->data;
2738 for (i = 0; i < count; i++)
2740 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2741 set_simple_interface_counter (mp->vnet_counter_type,
2742 first_sw_if_index + i, packets);
2747 static void vl_api_vnet_interface_combined_counters_t_handler_json
2748 (vl_api_vnet_interface_combined_counters_t * mp)
2750 interface_counter_t counter;
2752 u32 first_sw_if_index;
2756 count = ntohl (mp->count);
2757 first_sw_if_index = ntohl (mp->first_sw_if_index);
2759 v = (vlib_counter_t *) & mp->data;
2760 for (i = 0; i < count; i++)
2763 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2765 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2766 set_combined_interface_counter (mp->vnet_counter_type,
2767 first_sw_if_index + i, counter);
2773 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2775 vat_main_t *vam = &vat_main;
2778 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2780 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2789 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2791 vat_main_t *vam = &vat_main;
2794 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2796 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2804 static void vl_api_vnet_ip4_fib_counters_t_handler
2805 (vl_api_vnet_ip4_fib_counters_t * mp)
2810 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2811 (vl_api_vnet_ip4_fib_counters_t * mp)
2813 vat_main_t *vam = &vat_main;
2814 vl_api_ip4_fib_counter_t *v;
2815 ip4_fib_counter_t *counter;
2822 vrf_id = ntohl (mp->vrf_id);
2823 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2824 if (~0 == vrf_index)
2826 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2827 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2828 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2829 vec_validate (vam->ip4_fib_counters, vrf_index);
2830 vam->ip4_fib_counters[vrf_index] = NULL;
2833 vec_free (vam->ip4_fib_counters[vrf_index]);
2834 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2835 count = ntohl (mp->count);
2836 for (i = 0; i < count; i++)
2838 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2839 counter = &vam->ip4_fib_counters[vrf_index][i];
2840 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2841 counter->address = ip4;
2842 counter->address_length = v->address_length;
2843 counter->packets = clib_net_to_host_u64 (v->packets);
2844 counter->bytes = clib_net_to_host_u64 (v->bytes);
2849 static void vl_api_vnet_ip4_nbr_counters_t_handler
2850 (vl_api_vnet_ip4_nbr_counters_t * mp)
2855 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2856 (vl_api_vnet_ip4_nbr_counters_t * mp)
2858 vat_main_t *vam = &vat_main;
2859 vl_api_ip4_nbr_counter_t *v;
2860 ip4_nbr_counter_t *counter;
2865 sw_if_index = ntohl (mp->sw_if_index);
2866 count = ntohl (mp->count);
2867 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2870 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2872 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2873 for (i = 0; i < count; i++)
2875 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2876 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2877 counter->address.s_addr = v->address;
2878 counter->packets = clib_net_to_host_u64 (v->packets);
2879 counter->bytes = clib_net_to_host_u64 (v->bytes);
2880 counter->linkt = v->link_type;
2885 static void vl_api_vnet_ip6_fib_counters_t_handler
2886 (vl_api_vnet_ip6_fib_counters_t * mp)
2891 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2892 (vl_api_vnet_ip6_fib_counters_t * mp)
2894 vat_main_t *vam = &vat_main;
2895 vl_api_ip6_fib_counter_t *v;
2896 ip6_fib_counter_t *counter;
2897 struct in6_addr ip6;
2903 vrf_id = ntohl (mp->vrf_id);
2904 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2905 if (~0 == vrf_index)
2907 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2908 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2909 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2910 vec_validate (vam->ip6_fib_counters, vrf_index);
2911 vam->ip6_fib_counters[vrf_index] = NULL;
2914 vec_free (vam->ip6_fib_counters[vrf_index]);
2915 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2916 count = ntohl (mp->count);
2917 for (i = 0; i < count; i++)
2919 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2920 counter = &vam->ip6_fib_counters[vrf_index][i];
2921 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2922 counter->address = ip6;
2923 counter->address_length = v->address_length;
2924 counter->packets = clib_net_to_host_u64 (v->packets);
2925 counter->bytes = clib_net_to_host_u64 (v->bytes);
2930 static void vl_api_vnet_ip6_nbr_counters_t_handler
2931 (vl_api_vnet_ip6_nbr_counters_t * mp)
2936 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2937 (vl_api_vnet_ip6_nbr_counters_t * mp)
2939 vat_main_t *vam = &vat_main;
2940 vl_api_ip6_nbr_counter_t *v;
2941 ip6_nbr_counter_t *counter;
2942 struct in6_addr ip6;
2947 sw_if_index = ntohl (mp->sw_if_index);
2948 count = ntohl (mp->count);
2949 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2952 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2954 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2955 for (i = 0; i < count; i++)
2957 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2958 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2959 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2960 counter->address = ip6;
2961 counter->packets = clib_net_to_host_u64 (v->packets);
2962 counter->bytes = clib_net_to_host_u64 (v->bytes);
2967 static void vl_api_get_first_msg_id_reply_t_handler
2968 (vl_api_get_first_msg_id_reply_t * mp)
2970 vat_main_t *vam = &vat_main;
2971 i32 retval = ntohl (mp->retval);
2973 if (vam->async_mode)
2975 vam->async_errors += (retval < 0);
2979 vam->retval = retval;
2980 vam->result_ready = 1;
2984 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2988 static void vl_api_get_first_msg_id_reply_t_handler_json
2989 (vl_api_get_first_msg_id_reply_t * mp)
2991 vat_main_t *vam = &vat_main;
2992 vat_json_node_t node;
2994 vat_json_init_object (&node);
2995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2996 vat_json_object_add_uint (&node, "first_msg_id",
2997 (uint) ntohs (mp->first_msg_id));
2999 vat_json_print (vam->ofp, &node);
3000 vat_json_free (&node);
3002 vam->retval = ntohl (mp->retval);
3003 vam->result_ready = 1;
3006 static void vl_api_get_node_graph_reply_t_handler
3007 (vl_api_get_node_graph_reply_t * mp)
3009 vat_main_t *vam = &vat_main;
3010 api_main_t *am = &api_main;
3011 i32 retval = ntohl (mp->retval);
3012 u8 *pvt_copy, *reply;
3017 if (vam->async_mode)
3019 vam->async_errors += (retval < 0);
3023 vam->retval = retval;
3024 vam->result_ready = 1;
3027 /* "Should never happen..." */
3031 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3032 pvt_copy = vec_dup (reply);
3034 /* Toss the shared-memory original... */
3035 pthread_mutex_lock (&am->vlib_rp->mutex);
3036 oldheap = svm_push_data_heap (am->vlib_rp);
3040 svm_pop_heap (oldheap);
3041 pthread_mutex_unlock (&am->vlib_rp->mutex);
3043 if (vam->graph_nodes)
3045 hash_free (vam->graph_node_index_by_name);
3047 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3049 node = vam->graph_nodes[i];
3050 vec_free (node->name);
3051 vec_free (node->next_nodes);
3054 vec_free (vam->graph_nodes);
3057 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3058 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3059 vec_free (pvt_copy);
3061 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3063 node = vam->graph_nodes[i];
3064 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3068 static void vl_api_get_node_graph_reply_t_handler_json
3069 (vl_api_get_node_graph_reply_t * mp)
3071 vat_main_t *vam = &vat_main;
3072 api_main_t *am = &api_main;
3074 vat_json_node_t node;
3077 /* $$$$ make this real? */
3078 vat_json_init_object (&node);
3079 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3080 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3082 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3084 /* Toss the shared-memory original... */
3085 pthread_mutex_lock (&am->vlib_rp->mutex);
3086 oldheap = svm_push_data_heap (am->vlib_rp);
3090 svm_pop_heap (oldheap);
3091 pthread_mutex_unlock (&am->vlib_rp->mutex);
3093 vat_json_print (vam->ofp, &node);
3094 vat_json_free (&node);
3096 vam->retval = ntohl (mp->retval);
3097 vam->result_ready = 1;
3101 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3103 vat_main_t *vam = &vat_main;
3108 s = format (s, "%=16d%=16d%=16d",
3109 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3113 s = format (s, "%=16U%=16d%=16d",
3114 mp->is_ipv6 ? format_ip6_address :
3116 mp->ip_address, mp->priority, mp->weight);
3119 print (vam->ofp, "%v", s);
3124 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3126 vat_main_t *vam = &vat_main;
3127 vat_json_node_t *node = NULL;
3128 struct in6_addr ip6;
3131 if (VAT_JSON_ARRAY != vam->json_tree.type)
3133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3134 vat_json_init_array (&vam->json_tree);
3136 node = vat_json_array_add (&vam->json_tree);
3137 vat_json_init_object (node);
3139 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3140 vat_json_object_add_uint (node, "priority", mp->priority);
3141 vat_json_object_add_uint (node, "weight", mp->weight);
3144 vat_json_object_add_uint (node, "sw_if_index",
3145 clib_net_to_host_u32 (mp->sw_if_index));
3150 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3151 vat_json_object_add_ip6 (node, "address", ip6);
3155 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3156 vat_json_object_add_ip4 (node, "address", ip4);
3162 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3165 vat_main_t *vam = &vat_main;
3168 ls_name = format (0, "%s", mp->ls_name);
3170 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3176 vl_api_one_locator_set_details_t_handler_json
3177 (vl_api_one_locator_set_details_t * mp)
3179 vat_main_t *vam = &vat_main;
3180 vat_json_node_t *node = 0;
3183 ls_name = format (0, "%s", mp->ls_name);
3184 vec_add1 (ls_name, 0);
3186 if (VAT_JSON_ARRAY != vam->json_tree.type)
3188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3189 vat_json_init_array (&vam->json_tree);
3191 node = vat_json_array_add (&vam->json_tree);
3193 vat_json_init_object (node);
3194 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3195 vat_json_object_add_uint (node, "ls_index",
3196 clib_net_to_host_u32 (mp->ls_index));
3204 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3207 unformat_nsh_address (unformat_input_t * input, va_list * args)
3209 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3210 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3214 format_nsh_address_vat (u8 * s, va_list * args)
3216 nsh_t *a = va_arg (*args, nsh_t *);
3217 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3221 format_lisp_flat_eid (u8 * s, va_list * args)
3223 u32 type = va_arg (*args, u32);
3224 u8 *eid = va_arg (*args, u8 *);
3225 u32 eid_len = va_arg (*args, u32);
3230 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3232 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3234 return format (s, "%U", format_ethernet_address, eid);
3236 return format (s, "%U", format_nsh_address_vat, eid);
3242 format_lisp_eid_vat (u8 * s, va_list * args)
3244 u32 type = va_arg (*args, u32);
3245 u8 *eid = va_arg (*args, u8 *);
3246 u32 eid_len = va_arg (*args, u32);
3247 u8 *seid = va_arg (*args, u8 *);
3248 u32 seid_len = va_arg (*args, u32);
3249 u32 is_src_dst = va_arg (*args, u32);
3252 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3254 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3260 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 u8 *s = 0, *eid = 0;
3265 if (~0 == mp->locator_set_index)
3266 s = format (0, "action: %d", mp->action);
3268 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3270 eid = format (0, "%U", format_lisp_eid_vat,
3274 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3277 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3278 clib_net_to_host_u32 (mp->vni),
3280 mp->is_local ? "local" : "remote",
3281 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3282 clib_net_to_host_u16 (mp->key_id), mp->key);
3289 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3292 vat_main_t *vam = &vat_main;
3293 vat_json_node_t *node = 0;
3296 if (VAT_JSON_ARRAY != vam->json_tree.type)
3298 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3299 vat_json_init_array (&vam->json_tree);
3301 node = vat_json_array_add (&vam->json_tree);
3303 vat_json_init_object (node);
3304 if (~0 == mp->locator_set_index)
3305 vat_json_object_add_uint (node, "action", mp->action);
3307 vat_json_object_add_uint (node, "locator_set_index",
3308 clib_net_to_host_u32 (mp->locator_set_index));
3310 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3311 if (mp->eid_type == 3)
3313 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3314 vat_json_init_object (nsh_json);
3315 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3316 vat_json_object_add_uint (nsh_json, "spi",
3317 clib_net_to_host_u32 (nsh->spi));
3318 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3322 eid = format (0, "%U", format_lisp_eid_vat,
3326 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3328 vat_json_object_add_string_copy (node, "eid", eid);
3331 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3332 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3333 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3337 vat_json_object_add_uint (node, "key_id",
3338 clib_net_to_host_u16 (mp->key_id));
3339 vat_json_object_add_string_copy (node, "key", mp->key);
3344 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3346 vat_main_t *vam = &vat_main;
3347 u8 *seid = 0, *deid = 0;
3348 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3350 deid = format (0, "%U", format_lisp_eid_vat,
3351 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3353 seid = format (0, "%U", format_lisp_eid_vat,
3354 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3360 format_ip_address_fcn = format_ip4_address;
3362 format_ip_address_fcn = format_ip6_address;
3365 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3366 clib_net_to_host_u32 (mp->vni),
3368 format_ip_address_fcn, mp->lloc,
3369 format_ip_address_fcn, mp->rloc,
3370 clib_net_to_host_u32 (mp->pkt_count),
3371 clib_net_to_host_u32 (mp->bytes));
3378 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3380 struct in6_addr ip6;
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t *node = 0;
3384 u8 *deid = 0, *seid = 0;
3386 if (VAT_JSON_ARRAY != vam->json_tree.type)
3388 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3389 vat_json_init_array (&vam->json_tree);
3391 node = vat_json_array_add (&vam->json_tree);
3393 vat_json_init_object (node);
3394 deid = format (0, "%U", format_lisp_eid_vat,
3395 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3397 seid = format (0, "%U", format_lisp_eid_vat,
3398 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3403 vat_json_object_add_string_copy (node, "seid", seid);
3404 vat_json_object_add_string_copy (node, "deid", deid);
3405 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3409 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3410 vat_json_object_add_ip4 (node, "lloc", ip4);
3411 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3412 vat_json_object_add_ip4 (node, "rloc", ip4);
3416 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3417 vat_json_object_add_ip6 (node, "lloc", ip6);
3418 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3419 vat_json_object_add_ip6 (node, "rloc", ip6);
3421 vat_json_object_add_uint (node, "pkt_count",
3422 clib_net_to_host_u32 (mp->pkt_count));
3423 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3430 vl_api_one_eid_table_map_details_t_handler
3431 (vl_api_one_eid_table_map_details_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 u8 *line = format (0, "%=10d%=10d",
3436 clib_net_to_host_u32 (mp->vni),
3437 clib_net_to_host_u32 (mp->dp_table));
3438 print (vam->ofp, "%v", line);
3443 vl_api_one_eid_table_map_details_t_handler_json
3444 (vl_api_one_eid_table_map_details_t * mp)
3446 vat_main_t *vam = &vat_main;
3447 vat_json_node_t *node = NULL;
3449 if (VAT_JSON_ARRAY != vam->json_tree.type)
3451 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3452 vat_json_init_array (&vam->json_tree);
3454 node = vat_json_array_add (&vam->json_tree);
3455 vat_json_init_object (node);
3456 vat_json_object_add_uint (node, "dp_table",
3457 clib_net_to_host_u32 (mp->dp_table));
3458 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3462 vl_api_one_eid_table_vni_details_t_handler
3463 (vl_api_one_eid_table_vni_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3467 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3468 print (vam->ofp, "%v", line);
3473 vl_api_one_eid_table_vni_details_t_handler_json
3474 (vl_api_one_eid_table_vni_details_t * mp)
3476 vat_main_t *vam = &vat_main;
3477 vat_json_node_t *node = NULL;
3479 if (VAT_JSON_ARRAY != vam->json_tree.type)
3481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3482 vat_json_init_array (&vam->json_tree);
3484 node = vat_json_array_add (&vam->json_tree);
3485 vat_json_init_object (node);
3486 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3490 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3491 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3493 vat_main_t *vam = &vat_main;
3494 int retval = clib_net_to_host_u32 (mp->retval);
3496 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3497 print (vam->ofp, "fallback threshold value: %d", mp->value);
3499 vam->retval = retval;
3500 vam->result_ready = 1;
3504 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3505 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3507 vat_main_t *vam = &vat_main;
3508 vat_json_node_t _node, *node = &_node;
3509 int retval = clib_net_to_host_u32 (mp->retval);
3511 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3512 vat_json_init_object (node);
3513 vat_json_object_add_uint (node, "value", mp->value);
3515 vat_json_print (vam->ofp, node);
3516 vat_json_free (node);
3518 vam->retval = retval;
3519 vam->result_ready = 1;
3523 vl_api_show_one_map_register_state_reply_t_handler
3524 (vl_api_show_one_map_register_state_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3527 int retval = clib_net_to_host_u32 (mp->retval);
3529 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3531 vam->retval = retval;
3532 vam->result_ready = 1;
3536 vl_api_show_one_map_register_state_reply_t_handler_json
3537 (vl_api_show_one_map_register_state_reply_t * mp)
3539 vat_main_t *vam = &vat_main;
3540 vat_json_node_t _node, *node = &_node;
3541 int retval = clib_net_to_host_u32 (mp->retval);
3543 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3545 vat_json_init_object (node);
3546 vat_json_object_add_string_copy (node, "state", s);
3548 vat_json_print (vam->ofp, node);
3549 vat_json_free (node);
3551 vam->retval = retval;
3552 vam->result_ready = 1;
3557 vl_api_show_one_rloc_probe_state_reply_t_handler
3558 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3560 vat_main_t *vam = &vat_main;
3561 int retval = clib_net_to_host_u32 (mp->retval);
3566 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3568 vam->retval = retval;
3569 vam->result_ready = 1;
3573 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3574 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3576 vat_main_t *vam = &vat_main;
3577 vat_json_node_t _node, *node = &_node;
3578 int retval = clib_net_to_host_u32 (mp->retval);
3580 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3581 vat_json_init_object (node);
3582 vat_json_object_add_string_copy (node, "state", s);
3584 vat_json_print (vam->ofp, node);
3585 vat_json_free (node);
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3593 vl_api_show_one_stats_enable_disable_reply_t_handler
3594 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3596 vat_main_t *vam = &vat_main;
3597 int retval = clib_net_to_host_u32 (mp->retval);
3602 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3604 vam->retval = retval;
3605 vam->result_ready = 1;
3609 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3610 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3612 vat_main_t *vam = &vat_main;
3613 vat_json_node_t _node, *node = &_node;
3614 int retval = clib_net_to_host_u32 (mp->retval);
3616 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3617 vat_json_init_object (node);
3618 vat_json_object_add_string_copy (node, "state", s);
3620 vat_json_print (vam->ofp, node);
3621 vat_json_free (node);
3623 vam->retval = retval;
3624 vam->result_ready = 1;
3629 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3631 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3632 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3633 e->vni = clib_net_to_host_u32 (e->vni);
3637 gpe_fwd_entries_get_reply_t_net_to_host
3638 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3642 mp->count = clib_net_to_host_u32 (mp->count);
3643 for (i = 0; i < mp->count; i++)
3645 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3650 format_gpe_encap_mode (u8 * s, va_list * args)
3652 u32 mode = va_arg (*args, u32);
3657 return format (s, "lisp");
3659 return format (s, "vxlan");
3665 vl_api_gpe_get_encap_mode_reply_t_handler
3666 (vl_api_gpe_get_encap_mode_reply_t * mp)
3668 vat_main_t *vam = &vat_main;
3670 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3671 vam->retval = ntohl (mp->retval);
3672 vam->result_ready = 1;
3676 vl_api_gpe_get_encap_mode_reply_t_handler_json
3677 (vl_api_gpe_get_encap_mode_reply_t * mp)
3679 vat_main_t *vam = &vat_main;
3680 vat_json_node_t node;
3682 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3683 vec_add1 (encap_mode, 0);
3685 vat_json_init_object (&node);
3686 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3688 vec_free (encap_mode);
3689 vat_json_print (vam->ofp, &node);
3690 vat_json_free (&node);
3692 vam->retval = ntohl (mp->retval);
3693 vam->result_ready = 1;
3697 vl_api_gpe_fwd_entry_path_details_t_handler
3698 (vl_api_gpe_fwd_entry_path_details_t * mp)
3700 vat_main_t *vam = &vat_main;
3701 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3703 if (mp->lcl_loc.is_ip4)
3704 format_ip_address_fcn = format_ip4_address;
3706 format_ip_address_fcn = format_ip6_address;
3708 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3709 format_ip_address_fcn, &mp->lcl_loc,
3710 format_ip_address_fcn, &mp->rmt_loc);
3714 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3716 struct in6_addr ip6;
3721 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3722 vat_json_object_add_ip4 (n, "address", ip4);
3726 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3727 vat_json_object_add_ip6 (n, "address", ip6);
3729 vat_json_object_add_uint (n, "weight", loc->weight);
3733 vl_api_gpe_fwd_entry_path_details_t_handler_json
3734 (vl_api_gpe_fwd_entry_path_details_t * mp)
3736 vat_main_t *vam = &vat_main;
3737 vat_json_node_t *node = NULL;
3738 vat_json_node_t *loc_node;
3740 if (VAT_JSON_ARRAY != vam->json_tree.type)
3742 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3743 vat_json_init_array (&vam->json_tree);
3745 node = vat_json_array_add (&vam->json_tree);
3746 vat_json_init_object (node);
3748 loc_node = vat_json_object_add (node, "local_locator");
3749 vat_json_init_object (loc_node);
3750 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3752 loc_node = vat_json_object_add (node, "remote_locator");
3753 vat_json_init_object (loc_node);
3754 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3758 vl_api_gpe_fwd_entries_get_reply_t_handler
3759 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3761 vat_main_t *vam = &vat_main;
3763 int retval = clib_net_to_host_u32 (mp->retval);
3764 vl_api_gpe_fwd_entry_t *e;
3769 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3771 for (i = 0; i < mp->count; i++)
3773 e = &mp->entries[i];
3774 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3775 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3776 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3780 vam->retval = retval;
3781 vam->result_ready = 1;
3785 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3786 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3789 vat_main_t *vam = &vat_main;
3790 vat_json_node_t *e = 0, root;
3792 int retval = clib_net_to_host_u32 (mp->retval);
3793 vl_api_gpe_fwd_entry_t *fwd;
3798 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3799 vat_json_init_array (&root);
3801 for (i = 0; i < mp->count; i++)
3803 e = vat_json_array_add (&root);
3804 fwd = &mp->entries[i];
3806 vat_json_init_object (e);
3807 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3808 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3809 vat_json_object_add_int (e, "vni", fwd->vni);
3810 vat_json_object_add_int (e, "action", fwd->action);
3812 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3813 fwd->leid_prefix_len);
3815 vat_json_object_add_string_copy (e, "leid", s);
3818 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3819 fwd->reid_prefix_len);
3821 vat_json_object_add_string_copy (e, "reid", s);
3825 vat_json_print (vam->ofp, &root);
3826 vat_json_free (&root);
3829 vam->retval = retval;
3830 vam->result_ready = 1;
3834 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3835 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3837 vat_main_t *vam = &vat_main;
3839 int retval = clib_net_to_host_u32 (mp->retval);
3840 vl_api_gpe_native_fwd_rpath_t *r;
3845 n = clib_net_to_host_u32 (mp->count);
3847 for (i = 0; i < n; i++)
3849 r = &mp->entries[i];
3850 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3851 clib_net_to_host_u32 (r->fib_index),
3852 clib_net_to_host_u32 (r->nh_sw_if_index),
3853 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3862 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3863 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3866 vat_json_node_t root, *e;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3869 vl_api_gpe_native_fwd_rpath_t *r;
3875 n = clib_net_to_host_u32 (mp->count);
3876 vat_json_init_array (&root);
3878 for (i = 0; i < n; i++)
3880 e = vat_json_array_add (&root);
3881 vat_json_init_object (e);
3882 r = &mp->entries[i];
3884 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3887 vat_json_object_add_string_copy (e, "ip4", s);
3890 vat_json_object_add_uint (e, "fib_index",
3891 clib_net_to_host_u32 (r->fib_index));
3892 vat_json_object_add_uint (e, "nh_sw_if_index",
3893 clib_net_to_host_u32 (r->nh_sw_if_index));
3896 vat_json_print (vam->ofp, &root);
3897 vat_json_free (&root);
3900 vam->retval = retval;
3901 vam->result_ready = 1;
3905 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3906 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3908 vat_main_t *vam = &vat_main;
3910 int retval = clib_net_to_host_u32 (mp->retval);
3915 n = clib_net_to_host_u32 (mp->count);
3917 for (i = 0; i < n; i++)
3918 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3921 vam->retval = retval;
3922 vam->result_ready = 1;
3926 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3927 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3929 vat_main_t *vam = &vat_main;
3930 vat_json_node_t root;
3932 int retval = clib_net_to_host_u32 (mp->retval);
3937 n = clib_net_to_host_u32 (mp->count);
3938 vat_json_init_array (&root);
3940 for (i = 0; i < n; i++)
3941 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3943 vat_json_print (vam->ofp, &root);
3944 vat_json_free (&root);
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_one_ndp_entries_get_reply_t_handler
3953 (vl_api_one_ndp_entries_get_reply_t * mp)
3955 vat_main_t *vam = &vat_main;
3957 int retval = clib_net_to_host_u32 (mp->retval);
3962 n = clib_net_to_host_u32 (mp->count);
3964 for (i = 0; i < n; i++)
3965 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3966 format_ethernet_address, mp->entries[i].mac);
3969 vam->retval = retval;
3970 vam->result_ready = 1;
3974 vl_api_one_ndp_entries_get_reply_t_handler_json
3975 (vl_api_one_ndp_entries_get_reply_t * mp)
3978 vat_main_t *vam = &vat_main;
3979 vat_json_node_t *e = 0, root;
3981 int retval = clib_net_to_host_u32 (mp->retval);
3982 vl_api_one_ndp_entry_t *arp_entry;
3987 n = clib_net_to_host_u32 (mp->count);
3988 vat_json_init_array (&root);
3990 for (i = 0; i < n; i++)
3992 e = vat_json_array_add (&root);
3993 arp_entry = &mp->entries[i];
3995 vat_json_init_object (e);
3996 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3999 vat_json_object_add_string_copy (e, "mac", s);
4002 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4004 vat_json_object_add_string_copy (e, "ip6", s);
4008 vat_json_print (vam->ofp, &root);
4009 vat_json_free (&root);
4012 vam->retval = retval;
4013 vam->result_ready = 1;
4017 vl_api_one_l2_arp_entries_get_reply_t_handler
4018 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4020 vat_main_t *vam = &vat_main;
4022 int retval = clib_net_to_host_u32 (mp->retval);
4027 n = clib_net_to_host_u32 (mp->count);
4029 for (i = 0; i < n; i++)
4030 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4031 format_ethernet_address, mp->entries[i].mac);
4034 vam->retval = retval;
4035 vam->result_ready = 1;
4039 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4040 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4043 vat_main_t *vam = &vat_main;
4044 vat_json_node_t *e = 0, root;
4046 int retval = clib_net_to_host_u32 (mp->retval);
4047 vl_api_one_l2_arp_entry_t *arp_entry;
4052 n = clib_net_to_host_u32 (mp->count);
4053 vat_json_init_array (&root);
4055 for (i = 0; i < n; i++)
4057 e = vat_json_array_add (&root);
4058 arp_entry = &mp->entries[i];
4060 vat_json_init_object (e);
4061 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4064 vat_json_object_add_string_copy (e, "mac", s);
4067 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4069 vat_json_object_add_string_copy (e, "ip4", s);
4073 vat_json_print (vam->ofp, &root);
4074 vat_json_free (&root);
4077 vam->retval = retval;
4078 vam->result_ready = 1;
4082 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4084 vat_main_t *vam = &vat_main;
4086 int retval = clib_net_to_host_u32 (mp->retval);
4091 n = clib_net_to_host_u32 (mp->count);
4093 for (i = 0; i < n; i++)
4095 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4099 vam->retval = retval;
4100 vam->result_ready = 1;
4104 vl_api_one_ndp_bd_get_reply_t_handler_json
4105 (vl_api_one_ndp_bd_get_reply_t * mp)
4107 vat_main_t *vam = &vat_main;
4108 vat_json_node_t root;
4110 int retval = clib_net_to_host_u32 (mp->retval);
4115 n = clib_net_to_host_u32 (mp->count);
4116 vat_json_init_array (&root);
4118 for (i = 0; i < n; i++)
4120 vat_json_array_add_uint (&root,
4121 clib_net_to_host_u32 (mp->bridge_domains[i]));
4124 vat_json_print (vam->ofp, &root);
4125 vat_json_free (&root);
4128 vam->retval = retval;
4129 vam->result_ready = 1;
4133 vl_api_one_l2_arp_bd_get_reply_t_handler
4134 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4136 vat_main_t *vam = &vat_main;
4138 int retval = clib_net_to_host_u32 (mp->retval);
4143 n = clib_net_to_host_u32 (mp->count);
4145 for (i = 0; i < n; i++)
4147 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4151 vam->retval = retval;
4152 vam->result_ready = 1;
4156 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4157 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4159 vat_main_t *vam = &vat_main;
4160 vat_json_node_t root;
4162 int retval = clib_net_to_host_u32 (mp->retval);
4167 n = clib_net_to_host_u32 (mp->count);
4168 vat_json_init_array (&root);
4170 for (i = 0; i < n; i++)
4172 vat_json_array_add_uint (&root,
4173 clib_net_to_host_u32 (mp->bridge_domains[i]));
4176 vat_json_print (vam->ofp, &root);
4177 vat_json_free (&root);
4180 vam->retval = retval;
4181 vam->result_ready = 1;
4185 vl_api_one_adjacencies_get_reply_t_handler
4186 (vl_api_one_adjacencies_get_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4190 int retval = clib_net_to_host_u32 (mp->retval);
4191 vl_api_one_adjacency_t *a;
4196 n = clib_net_to_host_u32 (mp->count);
4198 for (i = 0; i < n; i++)
4200 a = &mp->adjacencies[i];
4201 print (vam->ofp, "%U %40U",
4202 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4203 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4207 vam->retval = retval;
4208 vam->result_ready = 1;
4212 vl_api_one_adjacencies_get_reply_t_handler_json
4213 (vl_api_one_adjacencies_get_reply_t * mp)
4216 vat_main_t *vam = &vat_main;
4217 vat_json_node_t *e = 0, root;
4219 int retval = clib_net_to_host_u32 (mp->retval);
4220 vl_api_one_adjacency_t *a;
4225 n = clib_net_to_host_u32 (mp->count);
4226 vat_json_init_array (&root);
4228 for (i = 0; i < n; i++)
4230 e = vat_json_array_add (&root);
4231 a = &mp->adjacencies[i];
4233 vat_json_init_object (e);
4234 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4235 a->leid_prefix_len);
4237 vat_json_object_add_string_copy (e, "leid", s);
4240 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4241 a->reid_prefix_len);
4243 vat_json_object_add_string_copy (e, "reid", s);
4247 vat_json_print (vam->ofp, &root);
4248 vat_json_free (&root);
4251 vam->retval = retval;
4252 vam->result_ready = 1;
4256 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4258 vat_main_t *vam = &vat_main;
4260 print (vam->ofp, "%=20U",
4261 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4266 vl_api_one_map_server_details_t_handler_json
4267 (vl_api_one_map_server_details_t * mp)
4269 vat_main_t *vam = &vat_main;
4270 vat_json_node_t *node = NULL;
4271 struct in6_addr ip6;
4274 if (VAT_JSON_ARRAY != vam->json_tree.type)
4276 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4277 vat_json_init_array (&vam->json_tree);
4279 node = vat_json_array_add (&vam->json_tree);
4281 vat_json_init_object (node);
4284 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4285 vat_json_object_add_ip6 (node, "map-server", ip6);
4289 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4290 vat_json_object_add_ip4 (node, "map-server", ip4);
4295 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4298 vat_main_t *vam = &vat_main;
4300 print (vam->ofp, "%=20U",
4301 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4306 vl_api_one_map_resolver_details_t_handler_json
4307 (vl_api_one_map_resolver_details_t * mp)
4309 vat_main_t *vam = &vat_main;
4310 vat_json_node_t *node = NULL;
4311 struct in6_addr ip6;
4314 if (VAT_JSON_ARRAY != vam->json_tree.type)
4316 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4317 vat_json_init_array (&vam->json_tree);
4319 node = vat_json_array_add (&vam->json_tree);
4321 vat_json_init_object (node);
4324 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4325 vat_json_object_add_ip6 (node, "map resolver", ip6);
4329 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4330 vat_json_object_add_ip4 (node, "map resolver", ip4);
4335 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4337 vat_main_t *vam = &vat_main;
4338 i32 retval = ntohl (mp->retval);
4342 print (vam->ofp, "feature: %s\ngpe: %s",
4343 mp->feature_status ? "enabled" : "disabled",
4344 mp->gpe_status ? "enabled" : "disabled");
4347 vam->retval = retval;
4348 vam->result_ready = 1;
4352 vl_api_show_one_status_reply_t_handler_json
4353 (vl_api_show_one_status_reply_t * mp)
4355 vat_main_t *vam = &vat_main;
4356 vat_json_node_t node;
4357 u8 *gpe_status = NULL;
4358 u8 *feature_status = NULL;
4360 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4361 feature_status = format (0, "%s",
4362 mp->feature_status ? "enabled" : "disabled");
4363 vec_add1 (gpe_status, 0);
4364 vec_add1 (feature_status, 0);
4366 vat_json_init_object (&node);
4367 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4368 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4370 vec_free (gpe_status);
4371 vec_free (feature_status);
4373 vat_json_print (vam->ofp, &node);
4374 vat_json_free (&node);
4376 vam->retval = ntohl (mp->retval);
4377 vam->result_ready = 1;
4381 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4382 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4384 vat_main_t *vam = &vat_main;
4385 i32 retval = ntohl (mp->retval);
4389 print (vam->ofp, "%=20s", mp->locator_set_name);
4392 vam->retval = retval;
4393 vam->result_ready = 1;
4397 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4398 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4400 vat_main_t *vam = &vat_main;
4401 vat_json_node_t *node = NULL;
4403 if (VAT_JSON_ARRAY != vam->json_tree.type)
4405 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4406 vat_json_init_array (&vam->json_tree);
4408 node = vat_json_array_add (&vam->json_tree);
4410 vat_json_init_object (node);
4411 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4413 vat_json_print (vam->ofp, node);
4414 vat_json_free (node);
4416 vam->retval = ntohl (mp->retval);
4417 vam->result_ready = 1;
4421 format_lisp_map_request_mode (u8 * s, va_list * args)
4423 u32 mode = va_arg (*args, u32);
4428 return format (0, "dst-only");
4430 return format (0, "src-dst");
4436 vl_api_show_one_map_request_mode_reply_t_handler
4437 (vl_api_show_one_map_request_mode_reply_t * mp)
4439 vat_main_t *vam = &vat_main;
4440 i32 retval = ntohl (mp->retval);
4444 u32 mode = mp->mode;
4445 print (vam->ofp, "map_request_mode: %U",
4446 format_lisp_map_request_mode, mode);
4449 vam->retval = retval;
4450 vam->result_ready = 1;
4454 vl_api_show_one_map_request_mode_reply_t_handler_json
4455 (vl_api_show_one_map_request_mode_reply_t * mp)
4457 vat_main_t *vam = &vat_main;
4458 vat_json_node_t node;
4463 s = format (0, "%U", format_lisp_map_request_mode, mode);
4466 vat_json_init_object (&node);
4467 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4468 vat_json_print (vam->ofp, &node);
4469 vat_json_free (&node);
4472 vam->retval = ntohl (mp->retval);
4473 vam->result_ready = 1;
4477 vl_api_one_show_xtr_mode_reply_t_handler
4478 (vl_api_one_show_xtr_mode_reply_t * mp)
4480 vat_main_t *vam = &vat_main;
4481 i32 retval = ntohl (mp->retval);
4485 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4488 vam->retval = retval;
4489 vam->result_ready = 1;
4493 vl_api_one_show_xtr_mode_reply_t_handler_json
4494 (vl_api_one_show_xtr_mode_reply_t * mp)
4496 vat_main_t *vam = &vat_main;
4497 vat_json_node_t node;
4500 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4501 vec_add1 (status, 0);
4503 vat_json_init_object (&node);
4504 vat_json_object_add_string_copy (&node, "status", status);
4508 vat_json_print (vam->ofp, &node);
4509 vat_json_free (&node);
4511 vam->retval = ntohl (mp->retval);
4512 vam->result_ready = 1;
4516 vl_api_one_show_pitr_mode_reply_t_handler
4517 (vl_api_one_show_pitr_mode_reply_t * mp)
4519 vat_main_t *vam = &vat_main;
4520 i32 retval = ntohl (mp->retval);
4524 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4527 vam->retval = retval;
4528 vam->result_ready = 1;
4532 vl_api_one_show_pitr_mode_reply_t_handler_json
4533 (vl_api_one_show_pitr_mode_reply_t * mp)
4535 vat_main_t *vam = &vat_main;
4536 vat_json_node_t node;
4539 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4540 vec_add1 (status, 0);
4542 vat_json_init_object (&node);
4543 vat_json_object_add_string_copy (&node, "status", status);
4547 vat_json_print (vam->ofp, &node);
4548 vat_json_free (&node);
4550 vam->retval = ntohl (mp->retval);
4551 vam->result_ready = 1;
4555 vl_api_one_show_petr_mode_reply_t_handler
4556 (vl_api_one_show_petr_mode_reply_t * mp)
4558 vat_main_t *vam = &vat_main;
4559 i32 retval = ntohl (mp->retval);
4563 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4566 vam->retval = retval;
4567 vam->result_ready = 1;
4571 vl_api_one_show_petr_mode_reply_t_handler_json
4572 (vl_api_one_show_petr_mode_reply_t * mp)
4574 vat_main_t *vam = &vat_main;
4575 vat_json_node_t node;
4578 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4579 vec_add1 (status, 0);
4581 vat_json_init_object (&node);
4582 vat_json_object_add_string_copy (&node, "status", status);
4586 vat_json_print (vam->ofp, &node);
4587 vat_json_free (&node);
4589 vam->retval = ntohl (mp->retval);
4590 vam->result_ready = 1;
4594 vl_api_show_one_use_petr_reply_t_handler
4595 (vl_api_show_one_use_petr_reply_t * mp)
4597 vat_main_t *vam = &vat_main;
4598 i32 retval = ntohl (mp->retval);
4602 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4605 print (vam->ofp, "Proxy-ETR address; %U",
4606 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4611 vam->retval = retval;
4612 vam->result_ready = 1;
4616 vl_api_show_one_use_petr_reply_t_handler_json
4617 (vl_api_show_one_use_petr_reply_t * mp)
4619 vat_main_t *vam = &vat_main;
4620 vat_json_node_t node;
4623 struct in6_addr ip6;
4625 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4626 vec_add1 (status, 0);
4628 vat_json_init_object (&node);
4629 vat_json_object_add_string_copy (&node, "status", status);
4634 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4635 vat_json_object_add_ip6 (&node, "address", ip6);
4639 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4640 vat_json_object_add_ip4 (&node, "address", ip4);
4646 vat_json_print (vam->ofp, &node);
4647 vat_json_free (&node);
4649 vam->retval = ntohl (mp->retval);
4650 vam->result_ready = 1;
4654 vl_api_show_one_nsh_mapping_reply_t_handler
4655 (vl_api_show_one_nsh_mapping_reply_t * mp)
4657 vat_main_t *vam = &vat_main;
4658 i32 retval = ntohl (mp->retval);
4662 print (vam->ofp, "%-20s%-16s",
4663 mp->is_set ? "set" : "not-set",
4664 mp->is_set ? (char *) mp->locator_set_name : "");
4667 vam->retval = retval;
4668 vam->result_ready = 1;
4672 vl_api_show_one_nsh_mapping_reply_t_handler_json
4673 (vl_api_show_one_nsh_mapping_reply_t * mp)
4675 vat_main_t *vam = &vat_main;
4676 vat_json_node_t node;
4679 status = format (0, "%s", mp->is_set ? "yes" : "no");
4680 vec_add1 (status, 0);
4682 vat_json_init_object (&node);
4683 vat_json_object_add_string_copy (&node, "is_set", status);
4686 vat_json_object_add_string_copy (&node, "locator_set",
4687 mp->locator_set_name);
4692 vat_json_print (vam->ofp, &node);
4693 vat_json_free (&node);
4695 vam->retval = ntohl (mp->retval);
4696 vam->result_ready = 1;
4700 vl_api_show_one_map_register_ttl_reply_t_handler
4701 (vl_api_show_one_map_register_ttl_reply_t * mp)
4703 vat_main_t *vam = &vat_main;
4704 i32 retval = ntohl (mp->retval);
4706 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4710 print (vam->ofp, "ttl: %u", mp->ttl);
4713 vam->retval = retval;
4714 vam->result_ready = 1;
4718 vl_api_show_one_map_register_ttl_reply_t_handler_json
4719 (vl_api_show_one_map_register_ttl_reply_t * mp)
4721 vat_main_t *vam = &vat_main;
4722 vat_json_node_t node;
4724 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4725 vat_json_init_object (&node);
4726 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4728 vat_json_print (vam->ofp, &node);
4729 vat_json_free (&node);
4731 vam->retval = ntohl (mp->retval);
4732 vam->result_ready = 1;
4736 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4738 vat_main_t *vam = &vat_main;
4739 i32 retval = ntohl (mp->retval);
4743 print (vam->ofp, "%-20s%-16s",
4744 mp->status ? "enabled" : "disabled",
4745 mp->status ? (char *) mp->locator_set_name : "");
4748 vam->retval = retval;
4749 vam->result_ready = 1;
4753 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4755 vat_main_t *vam = &vat_main;
4756 vat_json_node_t node;
4759 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4760 vec_add1 (status, 0);
4762 vat_json_init_object (&node);
4763 vat_json_object_add_string_copy (&node, "status", status);
4766 vat_json_object_add_string_copy (&node, "locator_set",
4767 mp->locator_set_name);
4772 vat_json_print (vam->ofp, &node);
4773 vat_json_free (&node);
4775 vam->retval = ntohl (mp->retval);
4776 vam->result_ready = 1;
4780 format_policer_type (u8 * s, va_list * va)
4782 u32 i = va_arg (*va, u32);
4784 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4785 s = format (s, "1r2c");
4786 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4787 s = format (s, "1r3c");
4788 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4789 s = format (s, "2r3c-2698");
4790 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4791 s = format (s, "2r3c-4115");
4792 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4793 s = format (s, "2r3c-mef5cf1");
4795 s = format (s, "ILLEGAL");
4800 format_policer_rate_type (u8 * s, va_list * va)
4802 u32 i = va_arg (*va, u32);
4804 if (i == SSE2_QOS_RATE_KBPS)
4805 s = format (s, "kbps");
4806 else if (i == SSE2_QOS_RATE_PPS)
4807 s = format (s, "pps");
4809 s = format (s, "ILLEGAL");
4814 format_policer_round_type (u8 * s, va_list * va)
4816 u32 i = va_arg (*va, u32);
4818 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4819 s = format (s, "closest");
4820 else if (i == SSE2_QOS_ROUND_TO_UP)
4821 s = format (s, "up");
4822 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4823 s = format (s, "down");
4825 s = format (s, "ILLEGAL");
4830 format_policer_action_type (u8 * s, va_list * va)
4832 u32 i = va_arg (*va, u32);
4834 if (i == SSE2_QOS_ACTION_DROP)
4835 s = format (s, "drop");
4836 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4837 s = format (s, "transmit");
4838 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4839 s = format (s, "mark-and-transmit");
4841 s = format (s, "ILLEGAL");
4846 format_dscp (u8 * s, va_list * va)
4848 u32 i = va_arg (*va, u32);
4853 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4857 return format (s, "ILLEGAL");
4859 s = format (s, "%s", t);
4864 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4866 vat_main_t *vam = &vat_main;
4867 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4869 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4870 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4872 conform_dscp_str = format (0, "");
4874 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4875 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4877 exceed_dscp_str = format (0, "");
4879 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4880 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4882 violate_dscp_str = format (0, "");
4884 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4885 "rate type %U, round type %U, %s rate, %s color-aware, "
4886 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4887 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4888 "conform action %U%s, exceed action %U%s, violate action %U%s",
4890 format_policer_type, mp->type,
4893 clib_net_to_host_u64 (mp->cb),
4894 clib_net_to_host_u64 (mp->eb),
4895 format_policer_rate_type, mp->rate_type,
4896 format_policer_round_type, mp->round_type,
4897 mp->single_rate ? "single" : "dual",
4898 mp->color_aware ? "is" : "not",
4899 ntohl (mp->cir_tokens_per_period),
4900 ntohl (mp->pir_tokens_per_period),
4902 ntohl (mp->current_limit),
4903 ntohl (mp->current_bucket),
4904 ntohl (mp->extended_limit),
4905 ntohl (mp->extended_bucket),
4906 clib_net_to_host_u64 (mp->last_update_time),
4907 format_policer_action_type, mp->conform_action_type,
4909 format_policer_action_type, mp->exceed_action_type,
4911 format_policer_action_type, mp->violate_action_type,
4914 vec_free (conform_dscp_str);
4915 vec_free (exceed_dscp_str);
4916 vec_free (violate_dscp_str);
4919 static void vl_api_policer_details_t_handler_json
4920 (vl_api_policer_details_t * mp)
4922 vat_main_t *vam = &vat_main;
4923 vat_json_node_t *node;
4924 u8 *rate_type_str, *round_type_str, *type_str;
4925 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4927 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4929 format (0, "%U", format_policer_round_type, mp->round_type);
4930 type_str = format (0, "%U", format_policer_type, mp->type);
4931 conform_action_str = format (0, "%U", format_policer_action_type,
4932 mp->conform_action_type);
4933 exceed_action_str = format (0, "%U", format_policer_action_type,
4934 mp->exceed_action_type);
4935 violate_action_str = format (0, "%U", format_policer_action_type,
4936 mp->violate_action_type);
4938 if (VAT_JSON_ARRAY != vam->json_tree.type)
4940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4941 vat_json_init_array (&vam->json_tree);
4943 node = vat_json_array_add (&vam->json_tree);
4945 vat_json_init_object (node);
4946 vat_json_object_add_string_copy (node, "name", mp->name);
4947 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4948 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4949 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4950 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4951 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4952 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4953 vat_json_object_add_string_copy (node, "type", type_str);
4954 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4955 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4956 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4957 vat_json_object_add_uint (node, "cir_tokens_per_period",
4958 ntohl (mp->cir_tokens_per_period));
4959 vat_json_object_add_uint (node, "eir_tokens_per_period",
4960 ntohl (mp->pir_tokens_per_period));
4961 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4962 vat_json_object_add_uint (node, "current_bucket",
4963 ntohl (mp->current_bucket));
4964 vat_json_object_add_uint (node, "extended_limit",
4965 ntohl (mp->extended_limit));
4966 vat_json_object_add_uint (node, "extended_bucket",
4967 ntohl (mp->extended_bucket));
4968 vat_json_object_add_uint (node, "last_update_time",
4969 ntohl (mp->last_update_time));
4970 vat_json_object_add_string_copy (node, "conform_action",
4971 conform_action_str);
4972 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4974 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4975 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4976 vec_free (dscp_str);
4978 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4979 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4981 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4982 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4983 vec_free (dscp_str);
4985 vat_json_object_add_string_copy (node, "violate_action",
4986 violate_action_str);
4987 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4989 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4990 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4991 vec_free (dscp_str);
4994 vec_free (rate_type_str);
4995 vec_free (round_type_str);
4996 vec_free (type_str);
4997 vec_free (conform_action_str);
4998 vec_free (exceed_action_str);
4999 vec_free (violate_action_str);
5003 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5006 vat_main_t *vam = &vat_main;
5007 int i, count = ntohl (mp->count);
5010 print (vam->ofp, "classify table ids (%d) : ", count);
5011 for (i = 0; i < count; i++)
5013 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5014 print (vam->ofp, (i < count - 1) ? "," : "");
5016 vam->retval = ntohl (mp->retval);
5017 vam->result_ready = 1;
5021 vl_api_classify_table_ids_reply_t_handler_json
5022 (vl_api_classify_table_ids_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 int i, count = ntohl (mp->count);
5029 vat_json_node_t node;
5031 vat_json_init_object (&node);
5032 for (i = 0; i < count; i++)
5034 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5036 vat_json_print (vam->ofp, &node);
5037 vat_json_free (&node);
5039 vam->retval = ntohl (mp->retval);
5040 vam->result_ready = 1;
5044 vl_api_classify_table_by_interface_reply_t_handler
5045 (vl_api_classify_table_by_interface_reply_t * mp)
5047 vat_main_t *vam = &vat_main;
5050 table_id = ntohl (mp->l2_table_id);
5052 print (vam->ofp, "l2 table id : %d", table_id);
5054 print (vam->ofp, "l2 table id : No input ACL tables configured");
5055 table_id = ntohl (mp->ip4_table_id);
5057 print (vam->ofp, "ip4 table id : %d", table_id);
5059 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5060 table_id = ntohl (mp->ip6_table_id);
5062 print (vam->ofp, "ip6 table id : %d", table_id);
5064 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5065 vam->retval = ntohl (mp->retval);
5066 vam->result_ready = 1;
5070 vl_api_classify_table_by_interface_reply_t_handler_json
5071 (vl_api_classify_table_by_interface_reply_t * mp)
5073 vat_main_t *vam = &vat_main;
5074 vat_json_node_t node;
5076 vat_json_init_object (&node);
5078 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5079 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5080 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5082 vat_json_print (vam->ofp, &node);
5083 vat_json_free (&node);
5085 vam->retval = ntohl (mp->retval);
5086 vam->result_ready = 1;
5089 static void vl_api_policer_add_del_reply_t_handler
5090 (vl_api_policer_add_del_reply_t * mp)
5092 vat_main_t *vam = &vat_main;
5093 i32 retval = ntohl (mp->retval);
5094 if (vam->async_mode)
5096 vam->async_errors += (retval < 0);
5100 vam->retval = retval;
5101 vam->result_ready = 1;
5102 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5104 * Note: this is just barely thread-safe, depends on
5105 * the main thread spinning waiting for an answer...
5107 errmsg ("policer index %d", ntohl (mp->policer_index));
5111 static void vl_api_policer_add_del_reply_t_handler_json
5112 (vl_api_policer_add_del_reply_t * mp)
5114 vat_main_t *vam = &vat_main;
5115 vat_json_node_t node;
5117 vat_json_init_object (&node);
5118 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5119 vat_json_object_add_uint (&node, "policer_index",
5120 ntohl (mp->policer_index));
5122 vat_json_print (vam->ofp, &node);
5123 vat_json_free (&node);
5125 vam->retval = ntohl (mp->retval);
5126 vam->result_ready = 1;
5129 /* Format hex dump. */
5131 format_hex_bytes (u8 * s, va_list * va)
5133 u8 *bytes = va_arg (*va, u8 *);
5134 int n_bytes = va_arg (*va, int);
5137 /* Print short or long form depending on byte count. */
5138 uword short_form = n_bytes <= 32;
5139 u32 indent = format_get_indent (s);
5144 for (i = 0; i < n_bytes; i++)
5146 if (!short_form && (i % 32) == 0)
5147 s = format (s, "%08x: ", i);
5148 s = format (s, "%02x", bytes[i]);
5149 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5150 s = format (s, "\n%U", format_white_space, indent);
5157 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5160 vat_main_t *vam = &vat_main;
5161 i32 retval = ntohl (mp->retval);
5164 print (vam->ofp, "classify table info :");
5165 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5166 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5167 ntohl (mp->miss_next_index));
5168 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5169 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5170 ntohl (mp->match_n_vectors));
5171 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5172 ntohl (mp->mask_length));
5174 vam->retval = retval;
5175 vam->result_ready = 1;
5179 vl_api_classify_table_info_reply_t_handler_json
5180 (vl_api_classify_table_info_reply_t * mp)
5182 vat_main_t *vam = &vat_main;
5183 vat_json_node_t node;
5185 i32 retval = ntohl (mp->retval);
5188 vat_json_init_object (&node);
5190 vat_json_object_add_int (&node, "sessions",
5191 ntohl (mp->active_sessions));
5192 vat_json_object_add_int (&node, "nexttbl",
5193 ntohl (mp->next_table_index));
5194 vat_json_object_add_int (&node, "nextnode",
5195 ntohl (mp->miss_next_index));
5196 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5197 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5198 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5199 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5200 ntohl (mp->mask_length), 0);
5201 vat_json_object_add_string_copy (&node, "mask", s);
5203 vat_json_print (vam->ofp, &node);
5204 vat_json_free (&node);
5206 vam->retval = ntohl (mp->retval);
5207 vam->result_ready = 1;
5211 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5214 vat_main_t *vam = &vat_main;
5216 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5217 ntohl (mp->hit_next_index), ntohl (mp->advance),
5218 ntohl (mp->opaque_index));
5219 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5220 ntohl (mp->match_length));
5224 vl_api_classify_session_details_t_handler_json
5225 (vl_api_classify_session_details_t * mp)
5227 vat_main_t *vam = &vat_main;
5228 vat_json_node_t *node = NULL;
5230 if (VAT_JSON_ARRAY != vam->json_tree.type)
5232 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5233 vat_json_init_array (&vam->json_tree);
5235 node = vat_json_array_add (&vam->json_tree);
5237 vat_json_init_object (node);
5238 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5239 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5240 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5242 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5244 vat_json_object_add_string_copy (node, "match", s);
5247 static void vl_api_pg_create_interface_reply_t_handler
5248 (vl_api_pg_create_interface_reply_t * mp)
5250 vat_main_t *vam = &vat_main;
5252 vam->retval = ntohl (mp->retval);
5253 vam->result_ready = 1;
5256 static void vl_api_pg_create_interface_reply_t_handler_json
5257 (vl_api_pg_create_interface_reply_t * mp)
5259 vat_main_t *vam = &vat_main;
5260 vat_json_node_t node;
5262 i32 retval = ntohl (mp->retval);
5265 vat_json_init_object (&node);
5267 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5269 vat_json_print (vam->ofp, &node);
5270 vat_json_free (&node);
5272 vam->retval = ntohl (mp->retval);
5273 vam->result_ready = 1;
5276 static void vl_api_policer_classify_details_t_handler
5277 (vl_api_policer_classify_details_t * mp)
5279 vat_main_t *vam = &vat_main;
5281 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5282 ntohl (mp->table_index));
5285 static void vl_api_policer_classify_details_t_handler_json
5286 (vl_api_policer_classify_details_t * mp)
5288 vat_main_t *vam = &vat_main;
5289 vat_json_node_t *node;
5291 if (VAT_JSON_ARRAY != vam->json_tree.type)
5293 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5294 vat_json_init_array (&vam->json_tree);
5296 node = vat_json_array_add (&vam->json_tree);
5298 vat_json_init_object (node);
5299 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5300 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5303 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5304 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5306 vat_main_t *vam = &vat_main;
5307 i32 retval = ntohl (mp->retval);
5308 if (vam->async_mode)
5310 vam->async_errors += (retval < 0);
5314 vam->retval = retval;
5315 vam->sw_if_index = ntohl (mp->sw_if_index);
5316 vam->result_ready = 1;
5318 vam->regenerate_interface_table = 1;
5321 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5322 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5324 vat_main_t *vam = &vat_main;
5325 vat_json_node_t node;
5327 vat_json_init_object (&node);
5328 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5329 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5331 vat_json_print (vam->ofp, &node);
5332 vat_json_free (&node);
5334 vam->retval = ntohl (mp->retval);
5335 vam->result_ready = 1;
5338 static void vl_api_flow_classify_details_t_handler
5339 (vl_api_flow_classify_details_t * mp)
5341 vat_main_t *vam = &vat_main;
5343 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5344 ntohl (mp->table_index));
5347 static void vl_api_flow_classify_details_t_handler_json
5348 (vl_api_flow_classify_details_t * mp)
5350 vat_main_t *vam = &vat_main;
5351 vat_json_node_t *node;
5353 if (VAT_JSON_ARRAY != vam->json_tree.type)
5355 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5356 vat_json_init_array (&vam->json_tree);
5358 node = vat_json_array_add (&vam->json_tree);
5360 vat_json_init_object (node);
5361 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5362 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5365 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5366 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5367 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5368 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5369 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5370 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5371 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5372 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5373 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5374 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5375 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5376 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5377 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5378 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5379 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5380 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5381 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5382 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5383 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5384 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5385 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5386 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5389 * Generate boilerplate reply handlers, which
5390 * dig the return value out of the xxx_reply_t API message,
5391 * stick it into vam->retval, and set vam->result_ready
5393 * Could also do this by pointing N message decode slots at
5394 * a single function, but that could break in subtle ways.
5397 #define foreach_standard_reply_retval_handler \
5398 _(sw_interface_set_flags_reply) \
5399 _(sw_interface_add_del_address_reply) \
5400 _(sw_interface_set_rx_mode_reply) \
5401 _(sw_interface_set_table_reply) \
5402 _(sw_interface_set_mpls_enable_reply) \
5403 _(sw_interface_set_vpath_reply) \
5404 _(sw_interface_set_vxlan_bypass_reply) \
5405 _(sw_interface_set_geneve_bypass_reply) \
5406 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5407 _(sw_interface_set_l2_bridge_reply) \
5408 _(bridge_domain_add_del_reply) \
5409 _(sw_interface_set_l2_xconnect_reply) \
5410 _(l2fib_add_del_reply) \
5411 _(l2fib_flush_int_reply) \
5412 _(l2fib_flush_bd_reply) \
5413 _(ip_add_del_route_reply) \
5414 _(ip_table_add_del_reply) \
5415 _(ip_mroute_add_del_reply) \
5416 _(mpls_route_add_del_reply) \
5417 _(mpls_table_add_del_reply) \
5418 _(mpls_ip_bind_unbind_reply) \
5419 _(bier_route_add_del_reply) \
5420 _(bier_table_add_del_reply) \
5421 _(proxy_arp_add_del_reply) \
5422 _(proxy_arp_intfc_enable_disable_reply) \
5423 _(sw_interface_set_unnumbered_reply) \
5424 _(ip_neighbor_add_del_reply) \
5425 _(oam_add_del_reply) \
5426 _(reset_fib_reply) \
5427 _(dhcp_proxy_config_reply) \
5428 _(dhcp_proxy_set_vss_reply) \
5429 _(dhcp_client_config_reply) \
5430 _(set_ip_flow_hash_reply) \
5431 _(sw_interface_ip6_enable_disable_reply) \
5432 _(sw_interface_ip6_set_link_local_address_reply) \
5433 _(ip6nd_proxy_add_del_reply) \
5434 _(sw_interface_ip6nd_ra_prefix_reply) \
5435 _(sw_interface_ip6nd_ra_config_reply) \
5436 _(set_arp_neighbor_limit_reply) \
5437 _(l2_patch_add_del_reply) \
5438 _(sr_policy_add_reply) \
5439 _(sr_policy_mod_reply) \
5440 _(sr_policy_del_reply) \
5441 _(sr_localsid_add_del_reply) \
5442 _(sr_steering_add_del_reply) \
5443 _(classify_add_del_session_reply) \
5444 _(classify_set_interface_ip_table_reply) \
5445 _(classify_set_interface_l2_tables_reply) \
5446 _(l2tpv3_set_tunnel_cookies_reply) \
5447 _(l2tpv3_interface_enable_disable_reply) \
5448 _(l2tpv3_set_lookup_key_reply) \
5449 _(l2_fib_clear_table_reply) \
5450 _(l2_interface_efp_filter_reply) \
5451 _(l2_interface_vlan_tag_rewrite_reply) \
5452 _(modify_vhost_user_if_reply) \
5453 _(delete_vhost_user_if_reply) \
5454 _(ip_probe_neighbor_reply) \
5455 _(ip_scan_neighbor_enable_disable_reply) \
5456 _(want_ip4_arp_events_reply) \
5457 _(want_ip6_nd_events_reply) \
5458 _(want_l2_macs_events_reply) \
5459 _(input_acl_set_interface_reply) \
5460 _(ipsec_spd_add_del_reply) \
5461 _(ipsec_interface_add_del_spd_reply) \
5462 _(ipsec_spd_add_del_entry_reply) \
5463 _(ipsec_sad_add_del_entry_reply) \
5464 _(ipsec_sa_set_key_reply) \
5465 _(ipsec_tunnel_if_add_del_reply) \
5466 _(ipsec_tunnel_if_set_key_reply) \
5467 _(ipsec_tunnel_if_set_sa_reply) \
5468 _(ikev2_profile_add_del_reply) \
5469 _(ikev2_profile_set_auth_reply) \
5470 _(ikev2_profile_set_id_reply) \
5471 _(ikev2_profile_set_ts_reply) \
5472 _(ikev2_set_local_key_reply) \
5473 _(ikev2_set_responder_reply) \
5474 _(ikev2_set_ike_transforms_reply) \
5475 _(ikev2_set_esp_transforms_reply) \
5476 _(ikev2_set_sa_lifetime_reply) \
5477 _(ikev2_initiate_sa_init_reply) \
5478 _(ikev2_initiate_del_ike_sa_reply) \
5479 _(ikev2_initiate_del_child_sa_reply) \
5480 _(ikev2_initiate_rekey_child_sa_reply) \
5481 _(delete_loopback_reply) \
5482 _(bd_ip_mac_add_del_reply) \
5483 _(map_del_domain_reply) \
5484 _(map_add_del_rule_reply) \
5485 _(want_interface_events_reply) \
5486 _(want_stats_reply) \
5487 _(cop_interface_enable_disable_reply) \
5488 _(cop_whitelist_enable_disable_reply) \
5489 _(sw_interface_clear_stats_reply) \
5490 _(ioam_enable_reply) \
5491 _(ioam_disable_reply) \
5492 _(one_add_del_locator_reply) \
5493 _(one_add_del_local_eid_reply) \
5494 _(one_add_del_remote_mapping_reply) \
5495 _(one_add_del_adjacency_reply) \
5496 _(one_add_del_map_resolver_reply) \
5497 _(one_add_del_map_server_reply) \
5498 _(one_enable_disable_reply) \
5499 _(one_rloc_probe_enable_disable_reply) \
5500 _(one_map_register_enable_disable_reply) \
5501 _(one_map_register_set_ttl_reply) \
5502 _(one_set_transport_protocol_reply) \
5503 _(one_map_register_fallback_threshold_reply) \
5504 _(one_pitr_set_locator_set_reply) \
5505 _(one_map_request_mode_reply) \
5506 _(one_add_del_map_request_itr_rlocs_reply) \
5507 _(one_eid_table_add_del_map_reply) \
5508 _(one_use_petr_reply) \
5509 _(one_stats_enable_disable_reply) \
5510 _(one_add_del_l2_arp_entry_reply) \
5511 _(one_add_del_ndp_entry_reply) \
5512 _(one_stats_flush_reply) \
5513 _(one_enable_disable_xtr_mode_reply) \
5514 _(one_enable_disable_pitr_mode_reply) \
5515 _(one_enable_disable_petr_mode_reply) \
5516 _(gpe_enable_disable_reply) \
5517 _(gpe_set_encap_mode_reply) \
5518 _(gpe_add_del_iface_reply) \
5519 _(gpe_add_del_native_fwd_rpath_reply) \
5520 _(af_packet_delete_reply) \
5521 _(policer_classify_set_interface_reply) \
5522 _(netmap_create_reply) \
5523 _(netmap_delete_reply) \
5524 _(set_ipfix_exporter_reply) \
5525 _(set_ipfix_classify_stream_reply) \
5526 _(ipfix_classify_table_add_del_reply) \
5527 _(flow_classify_set_interface_reply) \
5528 _(sw_interface_span_enable_disable_reply) \
5529 _(pg_capture_reply) \
5530 _(pg_enable_disable_reply) \
5531 _(ip_source_and_port_range_check_add_del_reply) \
5532 _(ip_source_and_port_range_check_interface_add_del_reply)\
5533 _(delete_subif_reply) \
5534 _(l2_interface_pbb_tag_rewrite_reply) \
5536 _(feature_enable_disable_reply) \
5537 _(sw_interface_tag_add_del_reply) \
5538 _(hw_interface_set_mtu_reply) \
5539 _(p2p_ethernet_add_reply) \
5540 _(p2p_ethernet_del_reply) \
5541 _(lldp_config_reply) \
5542 _(sw_interface_set_lldp_reply) \
5543 _(tcp_configure_src_addresses_reply) \
5544 _(dns_enable_disable_reply) \
5545 _(dns_name_server_add_del_reply) \
5546 _(session_rule_add_del_reply) \
5547 _(ip_container_proxy_add_del_reply) \
5548 _(output_acl_set_interface_reply) \
5549 _(qos_record_enable_disable_reply)
5552 static void vl_api_##n##_t_handler \
5553 (vl_api_##n##_t * mp) \
5555 vat_main_t * vam = &vat_main; \
5556 i32 retval = ntohl(mp->retval); \
5557 if (vam->async_mode) { \
5558 vam->async_errors += (retval < 0); \
5560 vam->retval = retval; \
5561 vam->result_ready = 1; \
5564 foreach_standard_reply_retval_handler;
5568 static void vl_api_##n##_t_handler_json \
5569 (vl_api_##n##_t * mp) \
5571 vat_main_t * vam = &vat_main; \
5572 vat_json_node_t node; \
5573 vat_json_init_object(&node); \
5574 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5575 vat_json_print(vam->ofp, &node); \
5576 vam->retval = ntohl(mp->retval); \
5577 vam->result_ready = 1; \
5579 foreach_standard_reply_retval_handler;
5583 * Table of message reply handlers, must include boilerplate handlers
5587 #define foreach_vpe_api_reply_msg \
5588 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5589 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5590 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5591 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5592 _(CONTROL_PING_REPLY, control_ping_reply) \
5593 _(CLI_REPLY, cli_reply) \
5594 _(CLI_INBAND_REPLY, cli_inband_reply) \
5595 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5596 sw_interface_add_del_address_reply) \
5597 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5598 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5599 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5600 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5601 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5602 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5603 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5604 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5605 sw_interface_set_l2_xconnect_reply) \
5606 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5607 sw_interface_set_l2_bridge_reply) \
5608 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5609 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5610 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5611 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5612 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5613 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5614 _(L2_FLAGS_REPLY, l2_flags_reply) \
5615 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5616 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5617 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5618 _(TAP_DELETE_REPLY, tap_delete_reply) \
5619 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5620 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5621 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5622 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5623 _(BOND_CREATE_REPLY, bond_create_reply) \
5624 _(BOND_DELETE_REPLY, bond_delete_reply) \
5625 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5626 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5627 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5628 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5629 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5630 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5631 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5632 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5633 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5634 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5635 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5636 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5637 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5638 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5639 proxy_arp_intfc_enable_disable_reply) \
5640 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5641 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5642 sw_interface_set_unnumbered_reply) \
5643 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5644 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5645 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5646 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5647 _(RESET_FIB_REPLY, reset_fib_reply) \
5648 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5649 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5650 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5651 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5652 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5653 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5654 sw_interface_ip6_enable_disable_reply) \
5655 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5656 sw_interface_ip6_set_link_local_address_reply) \
5657 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5658 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5659 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5660 sw_interface_ip6nd_ra_prefix_reply) \
5661 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5662 sw_interface_ip6nd_ra_config_reply) \
5663 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5664 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5665 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5666 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5667 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5668 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5669 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5670 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5671 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5672 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5673 classify_set_interface_ip_table_reply) \
5674 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5675 classify_set_interface_l2_tables_reply) \
5676 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5677 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5678 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5679 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5680 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5681 l2tpv3_interface_enable_disable_reply) \
5682 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5683 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5684 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5685 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5686 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5687 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5688 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5689 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5690 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5691 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5692 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5693 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5694 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5695 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5696 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5697 _(SHOW_VERSION_REPLY, show_version_reply) \
5698 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5699 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5700 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5701 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5702 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5703 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5704 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5705 _(IP4_ARP_EVENT, ip4_arp_event) \
5706 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5707 _(IP6_ND_EVENT, ip6_nd_event) \
5708 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5709 _(L2_MACS_EVENT, l2_macs_event) \
5710 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5711 _(IP_ADDRESS_DETAILS, ip_address_details) \
5712 _(IP_DETAILS, ip_details) \
5713 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5714 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5715 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5716 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5717 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5718 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5719 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5720 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5721 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5722 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5723 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5724 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5725 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5726 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5727 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5728 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5729 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5730 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5731 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5732 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5733 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5734 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5735 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5736 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5737 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5738 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5739 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5740 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5741 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5742 _(MAP_RULE_DETAILS, map_rule_details) \
5743 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5744 _(WANT_STATS_REPLY, want_stats_reply) \
5745 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5746 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5747 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5748 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5749 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5750 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5751 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5752 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5753 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5754 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5755 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5756 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5757 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5758 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5759 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5760 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5761 one_map_register_enable_disable_reply) \
5762 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5763 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5764 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5765 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5766 one_map_register_fallback_threshold_reply) \
5767 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5768 one_rloc_probe_enable_disable_reply) \
5769 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5770 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5771 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5772 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5773 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5774 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5775 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5776 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5777 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5778 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5779 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5780 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5781 _(ONE_STATS_DETAILS, one_stats_details) \
5782 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5783 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5784 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5785 show_one_stats_enable_disable_reply) \
5786 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5787 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5788 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5789 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5790 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5791 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5792 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5793 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5794 one_enable_disable_pitr_mode_reply) \
5795 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5796 one_enable_disable_petr_mode_reply) \
5797 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5798 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5799 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5800 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5801 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5802 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5803 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5804 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5805 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5806 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5807 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5808 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5809 gpe_add_del_native_fwd_rpath_reply) \
5810 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5811 gpe_fwd_entry_path_details) \
5812 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5813 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5814 one_add_del_map_request_itr_rlocs_reply) \
5815 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5816 one_get_map_request_itr_rlocs_reply) \
5817 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5818 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5819 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5820 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5821 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5822 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5823 show_one_map_register_state_reply) \
5824 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5825 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5826 show_one_map_register_fallback_threshold_reply) \
5827 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5828 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5829 _(AF_PACKET_DETAILS, af_packet_details) \
5830 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5831 _(POLICER_DETAILS, policer_details) \
5832 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5833 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5834 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5835 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5836 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5837 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5838 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5839 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5840 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5841 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5842 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5843 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5844 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5845 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5846 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5847 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5848 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5849 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5850 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5851 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5852 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5853 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5854 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5855 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5856 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5857 ip_source_and_port_range_check_add_del_reply) \
5858 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5859 ip_source_and_port_range_check_interface_add_del_reply) \
5860 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5861 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5862 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5863 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5864 _(PUNT_REPLY, punt_reply) \
5865 _(IP_FIB_DETAILS, ip_fib_details) \
5866 _(IP6_FIB_DETAILS, ip6_fib_details) \
5867 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5868 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5869 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5870 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5871 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5872 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5873 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5874 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5875 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5876 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5877 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5878 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5879 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5880 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5881 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5882 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5883 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5884 _(SESSION_RULES_DETAILS, session_rules_details) \
5885 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5886 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5887 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5888 _(MAP_STATS_SEGMENT_REPLY, map_stats_segment_reply)
5890 #define foreach_standalone_reply_msg \
5891 _(SW_INTERFACE_EVENT, sw_interface_event) \
5892 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5893 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5894 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5895 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5896 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5897 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5905 #define STR_VTR_OP_CASE(op) \
5906 case L2_VTR_ ## op: \
5910 str_vtr_op (u32 vtr_op)
5914 STR_VTR_OP_CASE (DISABLED);
5915 STR_VTR_OP_CASE (PUSH_1);
5916 STR_VTR_OP_CASE (PUSH_2);
5917 STR_VTR_OP_CASE (POP_1);
5918 STR_VTR_OP_CASE (POP_2);
5919 STR_VTR_OP_CASE (TRANSLATE_1_1);
5920 STR_VTR_OP_CASE (TRANSLATE_1_2);
5921 STR_VTR_OP_CASE (TRANSLATE_2_1);
5922 STR_VTR_OP_CASE (TRANSLATE_2_2);
5929 dump_sub_interface_table (vat_main_t * vam)
5931 const sw_interface_subif_t *sub = NULL;
5933 if (vam->json_output)
5936 ("JSON output supported only for VPE API calls and dump_stats_table");
5941 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5942 "Interface", "sw_if_index",
5943 "sub id", "dot1ad", "tags", "outer id",
5944 "inner id", "exact", "default", "outer any", "inner any");
5946 vec_foreach (sub, vam->sw_if_subif_table)
5949 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5950 sub->interface_name,
5952 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5953 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5954 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5955 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5956 if (sub->vtr_op != L2_VTR_DISABLED)
5959 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5960 "tag1: %d tag2: %d ]",
5961 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5962 sub->vtr_tag1, sub->vtr_tag2);
5970 name_sort_cmp (void *a1, void *a2)
5972 name_sort_t *n1 = a1;
5973 name_sort_t *n2 = a2;
5975 return strcmp ((char *) n1->name, (char *) n2->name);
5979 dump_interface_table (vat_main_t * vam)
5982 name_sort_t *nses = 0, *ns;
5984 if (vam->json_output)
5987 ("JSON output supported only for VPE API calls and dump_stats_table");
5992 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5994 vec_add2 (nses, ns, 1);
5995 ns->name = (u8 *)(p->key);
5996 ns->value = (u32) p->value[0];
6000 vec_sort_with_function (nses, name_sort_cmp);
6002 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6003 vec_foreach (ns, nses)
6005 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6012 dump_ip_table (vat_main_t * vam, int is_ipv6)
6014 const ip_details_t *det = NULL;
6015 const ip_address_details_t *address = NULL;
6018 print (vam->ofp, "%-12s", "sw_if_index");
6020 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6027 print (vam->ofp, "%-12d", i);
6028 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6033 vec_foreach (address, det->addr)
6037 is_ipv6 ? format_ip6_address : format_ip4_address,
6038 address->ip, address->prefix_length);
6046 dump_ipv4_table (vat_main_t * vam)
6048 if (vam->json_output)
6051 ("JSON output supported only for VPE API calls and dump_stats_table");
6055 return dump_ip_table (vam, 0);
6059 dump_ipv6_table (vat_main_t * vam)
6061 if (vam->json_output)
6064 ("JSON output supported only for VPE API calls and dump_stats_table");
6068 return dump_ip_table (vam, 1);
6072 counter_type_to_str (u8 counter_type, u8 is_combined)
6076 switch (counter_type)
6078 case VNET_INTERFACE_COUNTER_DROP:
6080 case VNET_INTERFACE_COUNTER_PUNT:
6082 case VNET_INTERFACE_COUNTER_IP4:
6084 case VNET_INTERFACE_COUNTER_IP6:
6086 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6088 case VNET_INTERFACE_COUNTER_RX_MISS:
6090 case VNET_INTERFACE_COUNTER_RX_ERROR:
6092 case VNET_INTERFACE_COUNTER_TX_ERROR:
6095 return "INVALID-COUNTER-TYPE";
6100 switch (counter_type)
6102 case VNET_INTERFACE_COUNTER_RX:
6104 case VNET_INTERFACE_COUNTER_TX:
6107 return "INVALID-COUNTER-TYPE";
6113 dump_stats_table (vat_main_t * vam)
6115 vat_json_node_t node;
6116 vat_json_node_t *msg_array;
6117 vat_json_node_t *msg;
6118 vat_json_node_t *counter_array;
6119 vat_json_node_t *counter;
6120 interface_counter_t c;
6122 ip4_fib_counter_t *c4;
6123 ip6_fib_counter_t *c6;
6124 ip4_nbr_counter_t *n4;
6125 ip6_nbr_counter_t *n6;
6128 if (!vam->json_output)
6130 clib_warning ("dump_stats_table supported only in JSON format");
6134 vat_json_init_object (&node);
6136 /* interface counters */
6137 msg_array = vat_json_object_add (&node, "interface_counters");
6138 vat_json_init_array (msg_array);
6139 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6141 msg = vat_json_array_add (msg_array);
6142 vat_json_init_object (msg);
6143 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6144 (u8 *) counter_type_to_str (i, 0));
6145 vat_json_object_add_int (msg, "is_combined", 0);
6146 counter_array = vat_json_object_add (msg, "data");
6147 vat_json_init_array (counter_array);
6148 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6150 packets = vam->simple_interface_counters[i][j];
6151 vat_json_array_add_uint (counter_array, packets);
6154 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6156 msg = vat_json_array_add (msg_array);
6157 vat_json_init_object (msg);
6158 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6159 (u8 *) counter_type_to_str (i, 1));
6160 vat_json_object_add_int (msg, "is_combined", 1);
6161 counter_array = vat_json_object_add (msg, "data");
6162 vat_json_init_array (counter_array);
6163 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6165 c = vam->combined_interface_counters[i][j];
6166 counter = vat_json_array_add (counter_array);
6167 vat_json_init_object (counter);
6168 vat_json_object_add_uint (counter, "packets", c.packets);
6169 vat_json_object_add_uint (counter, "bytes", c.bytes);
6173 /* ip4 fib counters */
6174 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6175 vat_json_init_array (msg_array);
6176 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6178 msg = vat_json_array_add (msg_array);
6179 vat_json_init_object (msg);
6180 vat_json_object_add_uint (msg, "vrf_id",
6181 vam->ip4_fib_counters_vrf_id_by_index[i]);
6182 counter_array = vat_json_object_add (msg, "c");
6183 vat_json_init_array (counter_array);
6184 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6186 counter = vat_json_array_add (counter_array);
6187 vat_json_init_object (counter);
6188 c4 = &vam->ip4_fib_counters[i][j];
6189 vat_json_object_add_ip4 (counter, "address", c4->address);
6190 vat_json_object_add_uint (counter, "address_length",
6191 c4->address_length);
6192 vat_json_object_add_uint (counter, "packets", c4->packets);
6193 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6197 /* ip6 fib counters */
6198 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6199 vat_json_init_array (msg_array);
6200 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6202 msg = vat_json_array_add (msg_array);
6203 vat_json_init_object (msg);
6204 vat_json_object_add_uint (msg, "vrf_id",
6205 vam->ip6_fib_counters_vrf_id_by_index[i]);
6206 counter_array = vat_json_object_add (msg, "c");
6207 vat_json_init_array (counter_array);
6208 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6210 counter = vat_json_array_add (counter_array);
6211 vat_json_init_object (counter);
6212 c6 = &vam->ip6_fib_counters[i][j];
6213 vat_json_object_add_ip6 (counter, "address", c6->address);
6214 vat_json_object_add_uint (counter, "address_length",
6215 c6->address_length);
6216 vat_json_object_add_uint (counter, "packets", c6->packets);
6217 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6221 /* ip4 nbr counters */
6222 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6223 vat_json_init_array (msg_array);
6224 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6226 msg = vat_json_array_add (msg_array);
6227 vat_json_init_object (msg);
6228 vat_json_object_add_uint (msg, "sw_if_index", i);
6229 counter_array = vat_json_object_add (msg, "c");
6230 vat_json_init_array (counter_array);
6231 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6233 counter = vat_json_array_add (counter_array);
6234 vat_json_init_object (counter);
6235 n4 = &vam->ip4_nbr_counters[i][j];
6236 vat_json_object_add_ip4 (counter, "address", n4->address);
6237 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6238 vat_json_object_add_uint (counter, "packets", n4->packets);
6239 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6243 /* ip6 nbr counters */
6244 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6245 vat_json_init_array (msg_array);
6246 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6248 msg = vat_json_array_add (msg_array);
6249 vat_json_init_object (msg);
6250 vat_json_object_add_uint (msg, "sw_if_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_nbr_counters[i]); j++)
6255 counter = vat_json_array_add (counter_array);
6256 vat_json_init_object (counter);
6257 n6 = &vam->ip6_nbr_counters[i][j];
6258 vat_json_object_add_ip6 (counter, "address", n6->address);
6259 vat_json_object_add_uint (counter, "packets", n6->packets);
6260 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6264 vat_json_print (vam->ofp, &node);
6265 vat_json_free (&node);
6271 * Pass CLI buffers directly in the CLI_INBAND API message,
6272 * instead of an additional shared memory area.
6275 exec_inband (vat_main_t * vam)
6277 vl_api_cli_inband_t *mp;
6278 unformat_input_t *i = vam->input;
6281 if (vec_len (i->buffer) == 0)
6284 if (vam->exec_mode == 0 && unformat (i, "mode"))
6289 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6296 * In order for the CLI command to work, it
6297 * must be a vector ending in \n, not a C-string ending
6300 u32 len = vec_len (vam->input->buffer);
6301 M2 (CLI_INBAND, mp, len);
6302 clib_memcpy (mp->cmd, vam->input->buffer, len);
6303 mp->length = htonl (len);
6307 /* json responses may or may not include a useful reply... */
6308 if (vec_len (vam->cmd_reply))
6309 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6314 exec (vat_main_t * vam)
6316 return exec_inband (vam);
6320 api_create_loopback (vat_main_t * vam)
6322 unformat_input_t *i = vam->input;
6323 vl_api_create_loopback_t *mp;
6324 vl_api_create_loopback_instance_t *mp_lbi;
6327 u8 is_specified = 0;
6328 u32 user_instance = 0;
6331 memset (mac_address, 0, sizeof (mac_address));
6333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6335 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6337 if (unformat (i, "instance %d", &user_instance))
6345 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6346 mp_lbi->is_specified = is_specified;
6348 mp_lbi->user_instance = htonl (user_instance);
6350 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6355 /* Construct the API message */
6356 M (CREATE_LOOPBACK, mp);
6358 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6367 api_delete_loopback (vat_main_t * vam)
6369 unformat_input_t *i = vam->input;
6370 vl_api_delete_loopback_t *mp;
6371 u32 sw_if_index = ~0;
6374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6376 if (unformat (i, "sw_if_index %d", &sw_if_index))
6382 if (sw_if_index == ~0)
6384 errmsg ("missing sw_if_index");
6388 /* Construct the API message */
6389 M (DELETE_LOOPBACK, mp);
6390 mp->sw_if_index = ntohl (sw_if_index);
6398 api_want_stats (vat_main_t * vam)
6400 unformat_input_t *i = vam->input;
6401 vl_api_want_stats_t *mp;
6405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6407 if (unformat (i, "enable"))
6409 else if (unformat (i, "disable"))
6417 errmsg ("missing enable|disable");
6422 mp->enable_disable = enable;
6430 api_want_interface_events (vat_main_t * vam)
6432 unformat_input_t *i = vam->input;
6433 vl_api_want_interface_events_t *mp;
6437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6439 if (unformat (i, "enable"))
6441 else if (unformat (i, "disable"))
6449 errmsg ("missing enable|disable");
6453 M (WANT_INTERFACE_EVENTS, mp);
6454 mp->enable_disable = enable;
6456 vam->interface_event_display = enable;
6464 /* Note: non-static, called once to set up the initial intfc table */
6466 api_sw_interface_dump (vat_main_t * vam)
6468 vl_api_sw_interface_dump_t *mp;
6469 vl_api_control_ping_t *mp_ping;
6471 name_sort_t *nses = 0, *ns;
6472 sw_interface_subif_t *sub = NULL;
6475 /* Toss the old name table */
6477 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6479 vec_add2 (nses, ns, 1);
6480 ns->name = (u8 *)(p->key);
6481 ns->value = (u32) p->value[0];
6485 hash_free (vam->sw_if_index_by_interface_name);
6487 vec_foreach (ns, nses) vec_free (ns->name);
6491 vec_foreach (sub, vam->sw_if_subif_table)
6493 vec_free (sub->interface_name);
6495 vec_free (vam->sw_if_subif_table);
6497 /* recreate the interface name hash table */
6498 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6501 * Ask for all interface names. Otherwise, the epic catalog of
6502 * name filters becomes ridiculously long, and vat ends up needing
6503 * to be taught about new interface types.
6505 M (SW_INTERFACE_DUMP, mp);
6508 /* Use a control ping for synchronization */
6509 MPING (CONTROL_PING, mp_ping);
6517 api_sw_interface_set_flags (vat_main_t * vam)
6519 unformat_input_t *i = vam->input;
6520 vl_api_sw_interface_set_flags_t *mp;
6522 u8 sw_if_index_set = 0;
6526 /* Parse args required to build the message */
6527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6529 if (unformat (i, "admin-up"))
6531 else if (unformat (i, "admin-down"))
6534 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6535 sw_if_index_set = 1;
6536 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6537 sw_if_index_set = 1;
6542 if (sw_if_index_set == 0)
6544 errmsg ("missing interface name or sw_if_index");
6548 /* Construct the API message */
6549 M (SW_INTERFACE_SET_FLAGS, mp);
6550 mp->sw_if_index = ntohl (sw_if_index);
6551 mp->admin_up_down = admin_up;
6556 /* Wait for a reply, return the good/bad news... */
6562 api_sw_interface_set_rx_mode (vat_main_t * vam)
6564 unformat_input_t *i = vam->input;
6565 vl_api_sw_interface_set_rx_mode_t *mp;
6567 u8 sw_if_index_set = 0;
6569 u8 queue_id_valid = 0;
6571 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6573 /* Parse args required to build the message */
6574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6576 if (unformat (i, "queue %d", &queue_id))
6578 else if (unformat (i, "polling"))
6579 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6580 else if (unformat (i, "interrupt"))
6581 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6582 else if (unformat (i, "adaptive"))
6583 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6585 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6586 sw_if_index_set = 1;
6587 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6588 sw_if_index_set = 1;
6593 if (sw_if_index_set == 0)
6595 errmsg ("missing interface name or sw_if_index");
6598 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6600 errmsg ("missing rx-mode");
6604 /* Construct the API message */
6605 M (SW_INTERFACE_SET_RX_MODE, mp);
6606 mp->sw_if_index = ntohl (sw_if_index);
6608 mp->queue_id_valid = queue_id_valid;
6609 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6614 /* Wait for a reply, return the good/bad news... */
6620 api_sw_interface_clear_stats (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_sw_interface_clear_stats_t *mp;
6625 u8 sw_if_index_set = 0;
6628 /* Parse args required to build the message */
6629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6631 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6632 sw_if_index_set = 1;
6633 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6634 sw_if_index_set = 1;
6639 /* Construct the API message */
6640 M (SW_INTERFACE_CLEAR_STATS, mp);
6642 if (sw_if_index_set == 1)
6643 mp->sw_if_index = ntohl (sw_if_index);
6645 mp->sw_if_index = ~0;
6650 /* Wait for a reply, return the good/bad news... */
6656 api_sw_interface_add_del_address (vat_main_t * vam)
6658 unformat_input_t *i = vam->input;
6659 vl_api_sw_interface_add_del_address_t *mp;
6661 u8 sw_if_index_set = 0;
6662 u8 is_add = 1, del_all = 0;
6663 u32 address_length = 0;
6664 u8 v4_address_set = 0;
6665 u8 v6_address_set = 0;
6666 ip4_address_t v4address;
6667 ip6_address_t v6address;
6670 /* Parse args required to build the message */
6671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6673 if (unformat (i, "del-all"))
6675 else if (unformat (i, "del"))
6678 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6679 sw_if_index_set = 1;
6680 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6681 sw_if_index_set = 1;
6682 else if (unformat (i, "%U/%d",
6683 unformat_ip4_address, &v4address, &address_length))
6685 else if (unformat (i, "%U/%d",
6686 unformat_ip6_address, &v6address, &address_length))
6692 if (sw_if_index_set == 0)
6694 errmsg ("missing interface name or sw_if_index");
6697 if (v4_address_set && v6_address_set)
6699 errmsg ("both v4 and v6 addresses set");
6702 if (!v4_address_set && !v6_address_set && !del_all)
6704 errmsg ("no addresses set");
6708 /* Construct the API message */
6709 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6711 mp->sw_if_index = ntohl (sw_if_index);
6712 mp->is_add = is_add;
6713 mp->del_all = del_all;
6717 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6721 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6723 mp->address_length = address_length;
6728 /* Wait for a reply, return good/bad news */
6734 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6736 unformat_input_t *i = vam->input;
6737 vl_api_sw_interface_set_mpls_enable_t *mp;
6739 u8 sw_if_index_set = 0;
6743 /* Parse args required to build the message */
6744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6747 sw_if_index_set = 1;
6748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6749 sw_if_index_set = 1;
6750 else if (unformat (i, "disable"))
6752 else if (unformat (i, "dis"))
6758 if (sw_if_index_set == 0)
6760 errmsg ("missing interface name or sw_if_index");
6764 /* Construct the API message */
6765 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6767 mp->sw_if_index = ntohl (sw_if_index);
6768 mp->enable = enable;
6773 /* Wait for a reply... */
6779 api_sw_interface_set_table (vat_main_t * vam)
6781 unformat_input_t *i = vam->input;
6782 vl_api_sw_interface_set_table_t *mp;
6783 u32 sw_if_index, vrf_id = 0;
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, "vrf %d", &vrf_id))
6797 else if (unformat (i, "ipv6"))
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_TABLE, mp);
6812 mp->sw_if_index = ntohl (sw_if_index);
6813 mp->is_ipv6 = is_ipv6;
6814 mp->vrf_id = ntohl (vrf_id);
6819 /* Wait for a reply... */
6824 static void vl_api_sw_interface_get_table_reply_t_handler
6825 (vl_api_sw_interface_get_table_reply_t * mp)
6827 vat_main_t *vam = &vat_main;
6829 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6831 vam->retval = ntohl (mp->retval);
6832 vam->result_ready = 1;
6836 static void vl_api_sw_interface_get_table_reply_t_handler_json
6837 (vl_api_sw_interface_get_table_reply_t * mp)
6839 vat_main_t *vam = &vat_main;
6840 vat_json_node_t node;
6842 vat_json_init_object (&node);
6843 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6844 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6846 vat_json_print (vam->ofp, &node);
6847 vat_json_free (&node);
6849 vam->retval = ntohl (mp->retval);
6850 vam->result_ready = 1;
6854 api_sw_interface_get_table (vat_main_t * vam)
6856 unformat_input_t *i = vam->input;
6857 vl_api_sw_interface_get_table_t *mp;
6859 u8 sw_if_index_set = 0;
6863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6865 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6868 sw_if_index_set = 1;
6869 else if (unformat (i, "ipv6"))
6875 if (sw_if_index_set == 0)
6877 errmsg ("missing interface name or sw_if_index");
6881 M (SW_INTERFACE_GET_TABLE, mp);
6882 mp->sw_if_index = htonl (sw_if_index);
6883 mp->is_ipv6 = is_ipv6;
6891 api_sw_interface_set_vpath (vat_main_t * vam)
6893 unformat_input_t *i = vam->input;
6894 vl_api_sw_interface_set_vpath_t *mp;
6895 u32 sw_if_index = 0;
6896 u8 sw_if_index_set = 0;
6900 /* Parse args required to build the message */
6901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6903 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6904 sw_if_index_set = 1;
6905 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6906 sw_if_index_set = 1;
6907 else if (unformat (i, "enable"))
6909 else if (unformat (i, "disable"))
6915 if (sw_if_index_set == 0)
6917 errmsg ("missing interface name or sw_if_index");
6921 /* Construct the API message */
6922 M (SW_INTERFACE_SET_VPATH, mp);
6924 mp->sw_if_index = ntohl (sw_if_index);
6925 mp->enable = is_enable;
6930 /* Wait for a reply... */
6936 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6938 unformat_input_t *i = vam->input;
6939 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6940 u32 sw_if_index = 0;
6941 u8 sw_if_index_set = 0;
6946 /* Parse args required to build the message */
6947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6950 sw_if_index_set = 1;
6951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6952 sw_if_index_set = 1;
6953 else if (unformat (i, "enable"))
6955 else if (unformat (i, "disable"))
6957 else if (unformat (i, "ip4"))
6959 else if (unformat (i, "ip6"))
6965 if (sw_if_index_set == 0)
6967 errmsg ("missing interface name or sw_if_index");
6971 /* Construct the API message */
6972 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6974 mp->sw_if_index = ntohl (sw_if_index);
6975 mp->enable = is_enable;
6976 mp->is_ipv6 = is_ipv6;
6981 /* Wait for a reply... */
6987 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6989 unformat_input_t *i = vam->input;
6990 vl_api_sw_interface_set_geneve_bypass_t *mp;
6991 u32 sw_if_index = 0;
6992 u8 sw_if_index_set = 0;
6997 /* Parse args required to build the message */
6998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7001 sw_if_index_set = 1;
7002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7003 sw_if_index_set = 1;
7004 else if (unformat (i, "enable"))
7006 else if (unformat (i, "disable"))
7008 else if (unformat (i, "ip4"))
7010 else if (unformat (i, "ip6"))
7016 if (sw_if_index_set == 0)
7018 errmsg ("missing interface name or sw_if_index");
7022 /* Construct the API message */
7023 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7025 mp->sw_if_index = ntohl (sw_if_index);
7026 mp->enable = is_enable;
7027 mp->is_ipv6 = is_ipv6;
7032 /* Wait for a reply... */
7038 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7040 unformat_input_t *i = vam->input;
7041 vl_api_sw_interface_set_l2_xconnect_t *mp;
7043 u8 rx_sw_if_index_set = 0;
7045 u8 tx_sw_if_index_set = 0;
7049 /* Parse args required to build the message */
7050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7052 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7053 rx_sw_if_index_set = 1;
7054 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7055 tx_sw_if_index_set = 1;
7056 else if (unformat (i, "rx"))
7058 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7060 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7062 rx_sw_if_index_set = 1;
7067 else if (unformat (i, "tx"))
7069 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7071 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7073 tx_sw_if_index_set = 1;
7078 else if (unformat (i, "enable"))
7080 else if (unformat (i, "disable"))
7086 if (rx_sw_if_index_set == 0)
7088 errmsg ("missing rx interface name or rx_sw_if_index");
7092 if (enable && (tx_sw_if_index_set == 0))
7094 errmsg ("missing tx interface name or tx_sw_if_index");
7098 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7100 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7101 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7102 mp->enable = enable;
7110 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7112 unformat_input_t *i = vam->input;
7113 vl_api_sw_interface_set_l2_bridge_t *mp;
7115 u8 rx_sw_if_index_set = 0;
7123 /* Parse args required to build the message */
7124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7126 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7127 rx_sw_if_index_set = 1;
7128 else if (unformat (i, "bd_id %d", &bd_id))
7132 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7133 rx_sw_if_index_set = 1;
7134 else if (unformat (i, "shg %d", &shg))
7136 else if (unformat (i, "bvi"))
7138 else if (unformat (i, "enable"))
7140 else if (unformat (i, "disable"))
7146 if (rx_sw_if_index_set == 0)
7148 errmsg ("missing rx interface name or sw_if_index");
7152 if (enable && (bd_id_set == 0))
7154 errmsg ("missing bridge domain");
7158 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7160 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7161 mp->bd_id = ntohl (bd_id);
7164 mp->enable = enable;
7172 api_bridge_domain_dump (vat_main_t * vam)
7174 unformat_input_t *i = vam->input;
7175 vl_api_bridge_domain_dump_t *mp;
7176 vl_api_control_ping_t *mp_ping;
7180 /* Parse args required to build the message */
7181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7183 if (unformat (i, "bd_id %d", &bd_id))
7189 M (BRIDGE_DOMAIN_DUMP, mp);
7190 mp->bd_id = ntohl (bd_id);
7193 /* Use a control ping for synchronization */
7194 MPING (CONTROL_PING, mp_ping);
7202 api_bridge_domain_add_del (vat_main_t * vam)
7204 unformat_input_t *i = vam->input;
7205 vl_api_bridge_domain_add_del_t *mp;
7208 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7213 /* Parse args required to build the message */
7214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7216 if (unformat (i, "bd_id %d", &bd_id))
7218 else if (unformat (i, "flood %d", &flood))
7220 else if (unformat (i, "uu-flood %d", &uu_flood))
7222 else if (unformat (i, "forward %d", &forward))
7224 else if (unformat (i, "learn %d", &learn))
7226 else if (unformat (i, "arp-term %d", &arp_term))
7228 else if (unformat (i, "mac-age %d", &mac_age))
7230 else if (unformat (i, "bd-tag %s", &bd_tag))
7232 else if (unformat (i, "del"))
7235 flood = uu_flood = forward = learn = 0;
7243 errmsg ("missing bridge domain");
7250 errmsg ("mac age must be less than 256 ");
7255 if ((bd_tag) && (vec_len (bd_tag) > 63))
7257 errmsg ("bd-tag cannot be longer than 63");
7262 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7264 mp->bd_id = ntohl (bd_id);
7266 mp->uu_flood = uu_flood;
7267 mp->forward = forward;
7269 mp->arp_term = arp_term;
7270 mp->is_add = is_add;
7271 mp->mac_age = (u8) mac_age;
7274 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7275 mp->bd_tag[vec_len (bd_tag)] = 0;
7286 api_l2fib_flush_bd (vat_main_t * vam)
7288 unformat_input_t *i = vam->input;
7289 vl_api_l2fib_flush_bd_t *mp;
7293 /* Parse args required to build the message */
7294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7296 if (unformat (i, "bd_id %d", &bd_id));
7303 errmsg ("missing bridge domain");
7307 M (L2FIB_FLUSH_BD, mp);
7309 mp->bd_id = htonl (bd_id);
7317 api_l2fib_flush_int (vat_main_t * vam)
7319 unformat_input_t *i = vam->input;
7320 vl_api_l2fib_flush_int_t *mp;
7321 u32 sw_if_index = ~0;
7324 /* Parse args required to build the message */
7325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 if (unformat (i, "sw_if_index %d", &sw_if_index));
7329 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7334 if (sw_if_index == ~0)
7336 errmsg ("missing interface name or sw_if_index");
7340 M (L2FIB_FLUSH_INT, mp);
7342 mp->sw_if_index = ntohl (sw_if_index);
7350 api_l2fib_add_del (vat_main_t * vam)
7352 unformat_input_t *i = vam->input;
7353 vl_api_l2fib_add_del_t *mp;
7359 u32 sw_if_index = 0;
7360 u8 sw_if_index_set = 0;
7369 /* Parse args required to build the message */
7370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7372 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7374 else if (unformat (i, "bd_id %d", &bd_id))
7376 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7377 sw_if_index_set = 1;
7378 else if (unformat (i, "sw_if"))
7380 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7383 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7384 sw_if_index_set = 1;
7389 else if (unformat (i, "static"))
7391 else if (unformat (i, "filter"))
7396 else if (unformat (i, "bvi"))
7401 else if (unformat (i, "del"))
7403 else if (unformat (i, "count %d", &count))
7411 errmsg ("missing mac address");
7417 errmsg ("missing bridge domain");
7421 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7423 errmsg ("missing interface name or sw_if_index");
7429 /* Turn on async mode */
7430 vam->async_mode = 1;
7431 vam->async_errors = 0;
7432 before = vat_time_now (vam);
7435 for (j = 0; j < count; j++)
7437 M (L2FIB_ADD_DEL, mp);
7439 clib_memcpy (mp->mac, mac, 6);
7440 mp->bd_id = ntohl (bd_id);
7441 mp->is_add = is_add;
7442 mp->sw_if_index = ntohl (sw_if_index);
7446 mp->static_mac = static_mac;
7447 mp->filter_mac = filter_mac;
7448 mp->bvi_mac = bvi_mac;
7450 increment_mac_address (mac);
7457 vl_api_control_ping_t *mp_ping;
7460 /* Shut off async mode */
7461 vam->async_mode = 0;
7463 MPING (CONTROL_PING, mp_ping);
7466 timeout = vat_time_now (vam) + 1.0;
7467 while (vat_time_now (vam) < timeout)
7468 if (vam->result_ready == 1)
7473 if (vam->retval == -99)
7476 if (vam->async_errors > 0)
7478 errmsg ("%d asynchronous errors", vam->async_errors);
7481 vam->async_errors = 0;
7482 after = vat_time_now (vam);
7484 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7485 count, after - before, count / (after - before));
7491 /* Wait for a reply... */
7495 /* Return the good/bad news */
7496 return (vam->retval);
7500 api_bridge_domain_set_mac_age (vat_main_t * vam)
7502 unformat_input_t *i = vam->input;
7503 vl_api_bridge_domain_set_mac_age_t *mp;
7508 /* Parse args required to build the message */
7509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7511 if (unformat (i, "bd_id %d", &bd_id));
7512 else if (unformat (i, "mac-age %d", &mac_age));
7519 errmsg ("missing bridge domain");
7525 errmsg ("mac age must be less than 256 ");
7529 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7531 mp->bd_id = htonl (bd_id);
7532 mp->mac_age = (u8) mac_age;
7540 api_l2_flags (vat_main_t * vam)
7542 unformat_input_t *i = vam->input;
7543 vl_api_l2_flags_t *mp;
7546 u8 sw_if_index_set = 0;
7550 /* Parse args required to build the message */
7551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7553 if (unformat (i, "sw_if_index %d", &sw_if_index))
7554 sw_if_index_set = 1;
7555 else if (unformat (i, "sw_if"))
7557 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7560 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7561 sw_if_index_set = 1;
7566 else if (unformat (i, "learn"))
7568 else if (unformat (i, "forward"))
7570 else if (unformat (i, "flood"))
7572 else if (unformat (i, "uu-flood"))
7573 flags |= L2_UU_FLOOD;
7574 else if (unformat (i, "arp-term"))
7575 flags |= L2_ARP_TERM;
7576 else if (unformat (i, "off"))
7578 else if (unformat (i, "disable"))
7584 if (sw_if_index_set == 0)
7586 errmsg ("missing interface name or sw_if_index");
7592 mp->sw_if_index = ntohl (sw_if_index);
7593 mp->feature_bitmap = ntohl (flags);
7594 mp->is_set = is_set;
7602 api_bridge_flags (vat_main_t * vam)
7604 unformat_input_t *i = vam->input;
7605 vl_api_bridge_flags_t *mp;
7612 /* Parse args required to build the message */
7613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7615 if (unformat (i, "bd_id %d", &bd_id))
7617 else if (unformat (i, "learn"))
7619 else if (unformat (i, "forward"))
7621 else if (unformat (i, "flood"))
7623 else if (unformat (i, "uu-flood"))
7624 flags |= L2_UU_FLOOD;
7625 else if (unformat (i, "arp-term"))
7626 flags |= L2_ARP_TERM;
7627 else if (unformat (i, "off"))
7629 else if (unformat (i, "disable"))
7637 errmsg ("missing bridge domain");
7641 M (BRIDGE_FLAGS, mp);
7643 mp->bd_id = ntohl (bd_id);
7644 mp->feature_bitmap = ntohl (flags);
7645 mp->is_set = is_set;
7653 api_bd_ip_mac_add_del (vat_main_t * vam)
7655 unformat_input_t *i = vam->input;
7656 vl_api_bd_ip_mac_add_del_t *mp;
7663 ip4_address_t v4addr;
7664 ip6_address_t v6addr;
7669 /* Parse args required to build the message */
7670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7672 if (unformat (i, "bd_id %d", &bd_id))
7676 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7680 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7685 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7689 else if (unformat (i, "del"))
7697 errmsg ("missing bridge domain");
7700 else if (ip_set == 0)
7702 errmsg ("missing IP address");
7705 else if (mac_set == 0)
7707 errmsg ("missing MAC address");
7711 M (BD_IP_MAC_ADD_DEL, mp);
7713 mp->bd_id = ntohl (bd_id);
7714 mp->is_ipv6 = is_ipv6;
7715 mp->is_add = is_add;
7717 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7719 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7720 clib_memcpy (mp->mac_address, macaddr, 6);
7727 api_tap_connect (vat_main_t * vam)
7729 unformat_input_t *i = vam->input;
7730 vl_api_tap_connect_t *mp;
7736 ip4_address_t ip4_address;
7738 int ip4_address_set = 0;
7739 ip6_address_t ip6_address;
7741 int ip6_address_set = 0;
7744 memset (mac_address, 0, sizeof (mac_address));
7746 /* Parse args required to build the message */
7747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7749 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7753 else if (unformat (i, "random-mac"))
7755 else if (unformat (i, "tapname %s", &tap_name))
7757 else if (unformat (i, "tag %s", &tag))
7759 else if (unformat (i, "address %U/%d",
7760 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7761 ip4_address_set = 1;
7762 else if (unformat (i, "address %U/%d",
7763 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7764 ip6_address_set = 1;
7771 errmsg ("missing tap name");
7774 if (vec_len (tap_name) > 63)
7776 errmsg ("tap name too long");
7779 vec_add1 (tap_name, 0);
7781 if (vec_len (tag) > 63)
7783 errmsg ("tag too long");
7787 /* Construct the API message */
7788 M (TAP_CONNECT, mp);
7790 mp->use_random_mac = random_mac;
7791 clib_memcpy (mp->mac_address, mac_address, 6);
7792 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7794 clib_memcpy (mp->tag, tag, vec_len (tag));
7796 if (ip4_address_set)
7798 mp->ip4_address_set = 1;
7799 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7800 mp->ip4_mask_width = ip4_mask_width;
7802 if (ip6_address_set)
7804 mp->ip6_address_set = 1;
7805 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7806 mp->ip6_mask_width = ip6_mask_width;
7809 vec_free (tap_name);
7815 /* Wait for a reply... */
7821 api_tap_modify (vat_main_t * vam)
7823 unformat_input_t *i = vam->input;
7824 vl_api_tap_modify_t *mp;
7829 u32 sw_if_index = ~0;
7830 u8 sw_if_index_set = 0;
7833 memset (mac_address, 0, sizeof (mac_address));
7835 /* Parse args required to build the message */
7836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7838 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7839 sw_if_index_set = 1;
7840 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7841 sw_if_index_set = 1;
7842 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7846 else if (unformat (i, "random-mac"))
7848 else if (unformat (i, "tapname %s", &tap_name))
7854 if (sw_if_index_set == 0)
7856 errmsg ("missing vpp interface name");
7861 errmsg ("missing tap name");
7864 if (vec_len (tap_name) > 63)
7866 errmsg ("tap name too long");
7868 vec_add1 (tap_name, 0);
7870 /* Construct the API message */
7873 mp->use_random_mac = random_mac;
7874 mp->sw_if_index = ntohl (sw_if_index);
7875 clib_memcpy (mp->mac_address, mac_address, 6);
7876 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7877 vec_free (tap_name);
7882 /* Wait for a reply... */
7888 api_tap_delete (vat_main_t * vam)
7890 unformat_input_t *i = vam->input;
7891 vl_api_tap_delete_t *mp;
7892 u32 sw_if_index = ~0;
7893 u8 sw_if_index_set = 0;
7896 /* Parse args required to build the message */
7897 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7899 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7900 sw_if_index_set = 1;
7901 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7902 sw_if_index_set = 1;
7907 if (sw_if_index_set == 0)
7909 errmsg ("missing vpp interface name");
7913 /* Construct the API message */
7916 mp->sw_if_index = ntohl (sw_if_index);
7921 /* Wait for a reply... */
7927 api_tap_create_v2 (vat_main_t * vam)
7929 unformat_input_t *i = vam->input;
7930 vl_api_tap_create_v2_t *mp;
7934 u8 *host_if_name = 0;
7936 u8 host_mac_addr[6];
7937 u8 host_mac_addr_set = 0;
7938 u8 *host_bridge = 0;
7939 ip4_address_t host_ip4_addr;
7940 ip4_address_t host_ip4_gw;
7941 u8 host_ip4_gw_set = 0;
7942 u32 host_ip4_prefix_len = 0;
7943 ip6_address_t host_ip6_addr;
7944 ip6_address_t host_ip6_gw;
7945 u8 host_ip6_gw_set = 0;
7946 u32 host_ip6_prefix_len = 0;
7948 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7950 memset (mac_address, 0, sizeof (mac_address));
7952 /* Parse args required to build the message */
7953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7955 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7959 else if (unformat (i, "id %u", &id))
7961 else if (unformat (i, "host-if-name %s", &host_if_name))
7963 else if (unformat (i, "host-ns %s", &host_ns))
7965 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7967 host_mac_addr_set = 1;
7968 else if (unformat (i, "host-bridge %s", &host_bridge))
7970 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7971 &host_ip4_addr, &host_ip4_prefix_len))
7973 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7974 &host_ip6_addr, &host_ip6_prefix_len))
7976 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7978 host_ip4_gw_set = 1;
7979 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7981 host_ip6_gw_set = 1;
7982 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7984 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7990 if (vec_len (host_if_name) > 63)
7992 errmsg ("tap name too long. ");
7995 if (vec_len (host_ns) > 63)
7997 errmsg ("host name space too long. ");
8000 if (vec_len (host_bridge) > 63)
8002 errmsg ("host bridge name too long. ");
8005 if (host_ip4_prefix_len > 32)
8007 errmsg ("host ip4 prefix length not valid. ");
8010 if (host_ip6_prefix_len > 128)
8012 errmsg ("host ip6 prefix length not valid. ");
8015 if (!is_pow2 (rx_ring_sz))
8017 errmsg ("rx ring size must be power of 2. ");
8020 if (rx_ring_sz > 32768)
8022 errmsg ("rx ring size must be 32768 or lower. ");
8025 if (!is_pow2 (tx_ring_sz))
8027 errmsg ("tx ring size must be power of 2. ");
8030 if (tx_ring_sz > 32768)
8032 errmsg ("tx ring size must be 32768 or lower. ");
8036 /* Construct the API message */
8037 M (TAP_CREATE_V2, mp);
8039 mp->use_random_mac = random_mac;
8041 mp->id = ntohl (id);
8042 mp->host_namespace_set = host_ns != 0;
8043 mp->host_bridge_set = host_bridge != 0;
8044 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8045 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8046 mp->rx_ring_sz = ntohs (rx_ring_sz);
8047 mp->tx_ring_sz = ntohs (tx_ring_sz);
8049 if (random_mac == 0)
8050 clib_memcpy (mp->mac_address, mac_address, 6);
8051 if (host_mac_addr_set)
8052 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8054 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8056 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8058 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8059 if (host_ip4_prefix_len)
8060 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8061 if (host_ip4_prefix_len)
8062 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8063 if (host_ip4_gw_set)
8064 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8065 if (host_ip6_gw_set)
8066 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8069 vec_free (host_if_name);
8070 vec_free (host_bridge);
8075 /* Wait for a reply... */
8081 api_tap_delete_v2 (vat_main_t * vam)
8083 unformat_input_t *i = vam->input;
8084 vl_api_tap_delete_v2_t *mp;
8085 u32 sw_if_index = ~0;
8086 u8 sw_if_index_set = 0;
8089 /* Parse args required to build the message */
8090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8093 sw_if_index_set = 1;
8094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8095 sw_if_index_set = 1;
8100 if (sw_if_index_set == 0)
8102 errmsg ("missing vpp interface name. ");
8106 /* Construct the API message */
8107 M (TAP_DELETE_V2, mp);
8109 mp->sw_if_index = ntohl (sw_if_index);
8114 /* Wait for a reply... */
8120 api_bond_create (vat_main_t * vam)
8122 unformat_input_t *i = vam->input;
8123 vl_api_bond_create_t *mp;
8131 memset (mac_address, 0, sizeof (mac_address));
8134 /* Parse args required to build the message */
8135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8137 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8139 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8140 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8142 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8149 if (mode_is_set == 0)
8151 errmsg ("Missing bond mode. ");
8155 /* Construct the API message */
8156 M (BOND_CREATE, mp);
8158 mp->use_custom_mac = custom_mac;
8164 clib_memcpy (mp->mac_address, mac_address, 6);
8169 /* Wait for a reply... */
8175 api_bond_delete (vat_main_t * vam)
8177 unformat_input_t *i = vam->input;
8178 vl_api_bond_delete_t *mp;
8179 u32 sw_if_index = ~0;
8180 u8 sw_if_index_set = 0;
8183 /* Parse args required to build the message */
8184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8187 sw_if_index_set = 1;
8188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8189 sw_if_index_set = 1;
8194 if (sw_if_index_set == 0)
8196 errmsg ("missing vpp interface name. ");
8200 /* Construct the API message */
8201 M (BOND_DELETE, mp);
8203 mp->sw_if_index = ntohl (sw_if_index);
8208 /* Wait for a reply... */
8214 api_bond_enslave (vat_main_t * vam)
8216 unformat_input_t *i = vam->input;
8217 vl_api_bond_enslave_t *mp;
8218 u32 bond_sw_if_index;
8222 u32 bond_sw_if_index_is_set = 0;
8224 u8 sw_if_index_is_set = 0;
8226 /* Parse args required to build the message */
8227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8229 if (unformat (i, "sw_if_index %d", &sw_if_index))
8230 sw_if_index_is_set = 1;
8231 else if (unformat (i, "bond %u", &bond_sw_if_index))
8232 bond_sw_if_index_is_set = 1;
8233 else if (unformat (i, "passive %d", &is_passive))
8235 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8241 if (bond_sw_if_index_is_set == 0)
8243 errmsg ("Missing bond sw_if_index. ");
8246 if (sw_if_index_is_set == 0)
8248 errmsg ("Missing slave sw_if_index. ");
8252 /* Construct the API message */
8253 M (BOND_ENSLAVE, mp);
8255 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8256 mp->sw_if_index = ntohl (sw_if_index);
8257 mp->is_long_timeout = is_long_timeout;
8258 mp->is_passive = is_passive;
8263 /* Wait for a reply... */
8269 api_bond_detach_slave (vat_main_t * vam)
8271 unformat_input_t *i = vam->input;
8272 vl_api_bond_detach_slave_t *mp;
8273 u32 sw_if_index = ~0;
8274 u8 sw_if_index_set = 0;
8277 /* Parse args required to build the message */
8278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8280 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8281 sw_if_index_set = 1;
8282 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8283 sw_if_index_set = 1;
8288 if (sw_if_index_set == 0)
8290 errmsg ("missing vpp interface name. ");
8294 /* Construct the API message */
8295 M (BOND_DETACH_SLAVE, mp);
8297 mp->sw_if_index = ntohl (sw_if_index);
8302 /* Wait for a reply... */
8308 api_ip_table_add_del (vat_main_t * vam)
8310 unformat_input_t *i = vam->input;
8311 vl_api_ip_table_add_del_t *mp;
8317 /* Parse args required to build the message */
8318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8320 if (unformat (i, "ipv6"))
8322 else if (unformat (i, "del"))
8324 else if (unformat (i, "add"))
8326 else if (unformat (i, "table %d", &table_id))
8330 clib_warning ("parse error '%U'", format_unformat_error, i);
8337 errmsg ("missing table-ID");
8341 /* Construct the API message */
8342 M (IP_TABLE_ADD_DEL, mp);
8344 mp->table_id = ntohl (table_id);
8345 mp->is_ipv6 = is_ipv6;
8346 mp->is_add = is_add;
8351 /* Wait for a reply... */
8358 api_ip_add_del_route (vat_main_t * vam)
8360 unformat_input_t *i = vam->input;
8361 vl_api_ip_add_del_route_t *mp;
8362 u32 sw_if_index = ~0, vrf_id = 0;
8364 u8 is_local = 0, is_drop = 0;
8365 u8 is_unreach = 0, is_prohibit = 0;
8367 u32 next_hop_weight = 1;
8368 u8 is_multipath = 0;
8370 u8 address_length_set = 0;
8371 u32 next_hop_table_id = 0;
8372 u32 resolve_attempts = 0;
8373 u32 dst_address_length = 0;
8374 u8 next_hop_set = 0;
8375 ip4_address_t v4_dst_address, v4_next_hop_address;
8376 ip6_address_t v6_dst_address, v6_next_hop_address;
8380 u32 random_add_del = 0;
8381 u32 *random_vector = 0;
8383 u32 random_seed = 0xdeaddabe;
8384 u32 classify_table_index = ~0;
8386 u8 resolve_host = 0, resolve_attached = 0;
8387 mpls_label_t *next_hop_out_label_stack = NULL;
8388 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8389 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8391 /* Parse args required to build the message */
8392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8394 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8396 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8398 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8403 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8408 else if (unformat (i, "/%d", &dst_address_length))
8410 address_length_set = 1;
8413 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8414 &v4_next_hop_address))
8418 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8419 &v6_next_hop_address))
8423 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8425 else if (unformat (i, "weight %d", &next_hop_weight))
8427 else if (unformat (i, "drop"))
8431 else if (unformat (i, "null-send-unreach"))
8435 else if (unformat (i, "null-send-prohibit"))
8439 else if (unformat (i, "local"))
8443 else if (unformat (i, "classify %d", &classify_table_index))
8447 else if (unformat (i, "del"))
8449 else if (unformat (i, "add"))
8451 else if (unformat (i, "resolve-via-host"))
8453 else if (unformat (i, "resolve-via-attached"))
8454 resolve_attached = 1;
8455 else if (unformat (i, "multipath"))
8457 else if (unformat (i, "vrf %d", &vrf_id))
8459 else if (unformat (i, "count %d", &count))
8461 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8463 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8465 else if (unformat (i, "out-label %d", &next_hop_out_label))
8466 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8467 else if (unformat (i, "via-label %d", &next_hop_via_label))
8469 else if (unformat (i, "random"))
8471 else if (unformat (i, "seed %d", &random_seed))
8475 clib_warning ("parse error '%U'", format_unformat_error, i);
8480 if (!next_hop_set && !is_drop && !is_local &&
8481 !is_classify && !is_unreach && !is_prohibit &&
8482 MPLS_LABEL_INVALID == next_hop_via_label)
8485 ("next hop / local / drop / unreach / prohibit / classify not set");
8489 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8491 errmsg ("next hop and next-hop via label set");
8494 if (address_set == 0)
8496 errmsg ("missing addresses");
8500 if (address_length_set == 0)
8502 errmsg ("missing address length");
8506 /* Generate a pile of unique, random routes */
8509 u32 this_random_address;
8510 random_hash = hash_create (count, sizeof (uword));
8512 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8513 for (j = 0; j <= count; j++)
8517 this_random_address = random_u32 (&random_seed);
8518 this_random_address =
8519 clib_host_to_net_u32 (this_random_address);
8521 while (hash_get (random_hash, this_random_address));
8522 vec_add1 (random_vector, this_random_address);
8523 hash_set (random_hash, this_random_address, 1);
8525 hash_free (random_hash);
8526 v4_dst_address.as_u32 = random_vector[0];
8531 /* Turn on async mode */
8532 vam->async_mode = 1;
8533 vam->async_errors = 0;
8534 before = vat_time_now (vam);
8537 for (j = 0; j < count; j++)
8539 /* Construct the API message */
8540 M2 (IP_ADD_DEL_ROUTE, mp,
8541 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8543 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8544 mp->table_id = ntohl (vrf_id);
8546 mp->is_add = is_add;
8547 mp->is_drop = is_drop;
8548 mp->is_unreach = is_unreach;
8549 mp->is_prohibit = is_prohibit;
8550 mp->is_ipv6 = is_ipv6;
8551 mp->is_local = is_local;
8552 mp->is_classify = is_classify;
8553 mp->is_multipath = is_multipath;
8554 mp->is_resolve_host = resolve_host;
8555 mp->is_resolve_attached = resolve_attached;
8556 mp->next_hop_weight = next_hop_weight;
8557 mp->dst_address_length = dst_address_length;
8558 mp->next_hop_table_id = ntohl (next_hop_table_id);
8559 mp->classify_table_index = ntohl (classify_table_index);
8560 mp->next_hop_via_label = ntohl (next_hop_via_label);
8561 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8562 if (0 != mp->next_hop_n_out_labels)
8564 memcpy (mp->next_hop_out_label_stack,
8565 next_hop_out_label_stack,
8566 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8567 vec_free (next_hop_out_label_stack);
8572 clib_memcpy (mp->dst_address, &v6_dst_address,
8573 sizeof (v6_dst_address));
8575 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8576 sizeof (v6_next_hop_address));
8577 increment_v6_address (&v6_dst_address);
8581 clib_memcpy (mp->dst_address, &v4_dst_address,
8582 sizeof (v4_dst_address));
8584 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8585 sizeof (v4_next_hop_address));
8587 v4_dst_address.as_u32 = random_vector[j + 1];
8589 increment_v4_address (&v4_dst_address);
8593 /* If we receive SIGTERM, stop now... */
8598 /* When testing multiple add/del ops, use a control-ping to sync */
8601 vl_api_control_ping_t *mp_ping;
8605 /* Shut off async mode */
8606 vam->async_mode = 0;
8608 MPING (CONTROL_PING, mp_ping);
8611 timeout = vat_time_now (vam) + 1.0;
8612 while (vat_time_now (vam) < timeout)
8613 if (vam->result_ready == 1)
8618 if (vam->retval == -99)
8621 if (vam->async_errors > 0)
8623 errmsg ("%d asynchronous errors", vam->async_errors);
8626 vam->async_errors = 0;
8627 after = vat_time_now (vam);
8629 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8633 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8634 count, after - before, count / (after - before));
8640 /* Wait for a reply... */
8645 /* Return the good/bad news */
8646 return (vam->retval);
8650 api_ip_mroute_add_del (vat_main_t * vam)
8652 unformat_input_t *i = vam->input;
8653 vl_api_ip_mroute_add_del_t *mp;
8654 u32 sw_if_index = ~0, vrf_id = 0;
8659 u32 grp_address_length = 0;
8660 ip4_address_t v4_grp_address, v4_src_address;
8661 ip6_address_t v6_grp_address, v6_src_address;
8662 mfib_itf_flags_t iflags = 0;
8663 mfib_entry_flags_t eflags = 0;
8666 /* Parse args required to build the message */
8667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8669 if (unformat (i, "sw_if_index %d", &sw_if_index))
8671 else if (unformat (i, "%U %U",
8672 unformat_ip4_address, &v4_src_address,
8673 unformat_ip4_address, &v4_grp_address))
8675 grp_address_length = 64;
8679 else if (unformat (i, "%U %U",
8680 unformat_ip6_address, &v6_src_address,
8681 unformat_ip6_address, &v6_grp_address))
8683 grp_address_length = 256;
8687 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8689 memset (&v4_src_address, 0, sizeof (v4_src_address));
8690 grp_address_length = 32;
8694 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8696 memset (&v6_src_address, 0, sizeof (v6_src_address));
8697 grp_address_length = 128;
8701 else if (unformat (i, "/%d", &grp_address_length))
8703 else if (unformat (i, "local"))
8707 else if (unformat (i, "del"))
8709 else if (unformat (i, "add"))
8711 else if (unformat (i, "vrf %d", &vrf_id))
8713 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8715 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8719 clib_warning ("parse error '%U'", format_unformat_error, i);
8724 if (address_set == 0)
8726 errmsg ("missing addresses\n");
8730 /* Construct the API message */
8731 M (IP_MROUTE_ADD_DEL, mp);
8733 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8734 mp->table_id = ntohl (vrf_id);
8736 mp->is_add = is_add;
8737 mp->is_ipv6 = is_ipv6;
8738 mp->is_local = is_local;
8739 mp->itf_flags = ntohl (iflags);
8740 mp->entry_flags = ntohl (eflags);
8741 mp->grp_address_length = grp_address_length;
8742 mp->grp_address_length = ntohs (mp->grp_address_length);
8746 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8747 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8751 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8752 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8758 /* Wait for a reply... */
8764 api_mpls_table_add_del (vat_main_t * vam)
8766 unformat_input_t *i = vam->input;
8767 vl_api_mpls_table_add_del_t *mp;
8772 /* Parse args required to build the message */
8773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8775 if (unformat (i, "table %d", &table_id))
8777 else if (unformat (i, "del"))
8779 else if (unformat (i, "add"))
8783 clib_warning ("parse error '%U'", format_unformat_error, i);
8790 errmsg ("missing table-ID");
8794 /* Construct the API message */
8795 M (MPLS_TABLE_ADD_DEL, mp);
8797 mp->mt_table_id = ntohl (table_id);
8798 mp->mt_is_add = is_add;
8803 /* Wait for a reply... */
8810 api_mpls_route_add_del (vat_main_t * vam)
8812 unformat_input_t *i = vam->input;
8813 vl_api_mpls_route_add_del_t *mp;
8814 u32 sw_if_index = ~0, table_id = 0;
8816 u32 next_hop_weight = 1;
8817 u8 is_multipath = 0;
8818 u32 next_hop_table_id = 0;
8819 u8 next_hop_set = 0;
8820 ip4_address_t v4_next_hop_address = {
8823 ip6_address_t v6_next_hop_address = { {0} };
8827 u32 classify_table_index = ~0;
8829 u8 resolve_host = 0, resolve_attached = 0;
8830 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8831 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8832 mpls_label_t *next_hop_out_label_stack = NULL;
8833 mpls_label_t local_label = MPLS_LABEL_INVALID;
8835 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8837 /* Parse args required to build the message */
8838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8842 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8844 else if (unformat (i, "%d", &local_label))
8846 else if (unformat (i, "eos"))
8848 else if (unformat (i, "non-eos"))
8850 else if (unformat (i, "via %U", unformat_ip4_address,
8851 &v4_next_hop_address))
8854 next_hop_proto = DPO_PROTO_IP4;
8856 else if (unformat (i, "via %U", unformat_ip6_address,
8857 &v6_next_hop_address))
8860 next_hop_proto = DPO_PROTO_IP6;
8862 else if (unformat (i, "weight %d", &next_hop_weight))
8864 else if (unformat (i, "classify %d", &classify_table_index))
8868 else if (unformat (i, "del"))
8870 else if (unformat (i, "add"))
8872 else if (unformat (i, "resolve-via-host"))
8874 else if (unformat (i, "resolve-via-attached"))
8875 resolve_attached = 1;
8876 else if (unformat (i, "multipath"))
8878 else if (unformat (i, "count %d", &count))
8880 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8883 next_hop_proto = DPO_PROTO_IP4;
8885 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8888 next_hop_proto = DPO_PROTO_IP6;
8890 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8892 else if (unformat (i, "via-label %d", &next_hop_via_label))
8894 else if (unformat (i, "out-label %d", &next_hop_out_label))
8895 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8898 clib_warning ("parse error '%U'", format_unformat_error, i);
8903 if (!next_hop_set && !is_classify)
8905 errmsg ("next hop / classify not set");
8909 if (MPLS_LABEL_INVALID == local_label)
8911 errmsg ("missing label");
8917 /* Turn on async mode */
8918 vam->async_mode = 1;
8919 vam->async_errors = 0;
8920 before = vat_time_now (vam);
8923 for (j = 0; j < count; j++)
8925 /* Construct the API message */
8926 M2 (MPLS_ROUTE_ADD_DEL, mp,
8927 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8929 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8930 mp->mr_table_id = ntohl (table_id);
8932 mp->mr_is_add = is_add;
8933 mp->mr_next_hop_proto = next_hop_proto;
8934 mp->mr_is_classify = is_classify;
8935 mp->mr_is_multipath = is_multipath;
8936 mp->mr_is_resolve_host = resolve_host;
8937 mp->mr_is_resolve_attached = resolve_attached;
8938 mp->mr_next_hop_weight = next_hop_weight;
8939 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8940 mp->mr_classify_table_index = ntohl (classify_table_index);
8941 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8942 mp->mr_label = ntohl (local_label);
8943 mp->mr_eos = is_eos;
8945 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8946 if (0 != mp->mr_next_hop_n_out_labels)
8948 memcpy (mp->mr_next_hop_out_label_stack,
8949 next_hop_out_label_stack,
8950 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8951 vec_free (next_hop_out_label_stack);
8956 if (DPO_PROTO_IP4 == next_hop_proto)
8958 clib_memcpy (mp->mr_next_hop,
8959 &v4_next_hop_address,
8960 sizeof (v4_next_hop_address));
8962 else if (DPO_PROTO_IP6 == next_hop_proto)
8965 clib_memcpy (mp->mr_next_hop,
8966 &v6_next_hop_address,
8967 sizeof (v6_next_hop_address));
8974 /* If we receive SIGTERM, stop now... */
8979 /* When testing multiple add/del ops, use a control-ping to sync */
8982 vl_api_control_ping_t *mp_ping;
8986 /* Shut off async mode */
8987 vam->async_mode = 0;
8989 MPING (CONTROL_PING, mp_ping);
8992 timeout = vat_time_now (vam) + 1.0;
8993 while (vat_time_now (vam) < timeout)
8994 if (vam->result_ready == 1)
8999 if (vam->retval == -99)
9002 if (vam->async_errors > 0)
9004 errmsg ("%d asynchronous errors", vam->async_errors);
9007 vam->async_errors = 0;
9008 after = vat_time_now (vam);
9010 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9014 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9015 count, after - before, count / (after - before));
9021 /* Wait for a reply... */
9026 /* Return the good/bad news */
9027 return (vam->retval);
9031 api_mpls_ip_bind_unbind (vat_main_t * vam)
9033 unformat_input_t *i = vam->input;
9034 vl_api_mpls_ip_bind_unbind_t *mp;
9035 u32 ip_table_id = 0;
9038 ip4_address_t v4_address;
9039 ip6_address_t v6_address;
9042 mpls_label_t local_label = MPLS_LABEL_INVALID;
9045 /* Parse args required to build the message */
9046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9048 if (unformat (i, "%U/%d", unformat_ip4_address,
9049 &v4_address, &address_length))
9054 else if (unformat (i, "%U/%d", unformat_ip6_address,
9055 &v6_address, &address_length))
9060 else if (unformat (i, "%d", &local_label))
9062 else if (unformat (i, "table-id %d", &ip_table_id))
9064 else if (unformat (i, "unbind"))
9066 else if (unformat (i, "bind"))
9070 clib_warning ("parse error '%U'", format_unformat_error, i);
9077 errmsg ("IP addres not set");
9081 if (MPLS_LABEL_INVALID == local_label)
9083 errmsg ("missing label");
9087 /* Construct the API message */
9088 M (MPLS_IP_BIND_UNBIND, mp);
9090 mp->mb_is_bind = is_bind;
9091 mp->mb_is_ip4 = is_ip4;
9092 mp->mb_ip_table_id = ntohl (ip_table_id);
9093 mp->mb_mpls_table_id = 0;
9094 mp->mb_label = ntohl (local_label);
9095 mp->mb_address_length = address_length;
9098 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9100 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9105 /* Wait for a reply... */
9111 api_bier_table_add_del (vat_main_t * vam)
9113 unformat_input_t *i = vam->input;
9114 vl_api_bier_table_add_del_t *mp;
9116 u32 set = 0, sub_domain = 0, hdr_len = 3;
9117 mpls_label_t local_label = MPLS_LABEL_INVALID;
9120 /* Parse args required to build the message */
9121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9123 if (unformat (i, "sub-domain %d", &sub_domain))
9125 else if (unformat (i, "set %d", &set))
9127 else if (unformat (i, "label %d", &local_label))
9129 else if (unformat (i, "hdr-len %d", &hdr_len))
9131 else if (unformat (i, "add"))
9133 else if (unformat (i, "del"))
9137 clib_warning ("parse error '%U'", format_unformat_error, i);
9142 if (MPLS_LABEL_INVALID == local_label)
9144 errmsg ("missing label\n");
9148 /* Construct the API message */
9149 M (BIER_TABLE_ADD_DEL, mp);
9151 mp->bt_is_add = is_add;
9152 mp->bt_label = ntohl (local_label);
9153 mp->bt_tbl_id.bt_set = set;
9154 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9155 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9160 /* Wait for a reply... */
9167 api_bier_route_add_del (vat_main_t * vam)
9169 unformat_input_t *i = vam->input;
9170 vl_api_bier_route_add_del_t *mp;
9172 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9173 ip4_address_t v4_next_hop_address;
9174 ip6_address_t v6_next_hop_address;
9175 u8 next_hop_set = 0;
9176 u8 next_hop_proto_is_ip4 = 1;
9177 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9180 /* Parse args required to build the message */
9181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9183 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9185 next_hop_proto_is_ip4 = 1;
9188 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9190 next_hop_proto_is_ip4 = 0;
9193 if (unformat (i, "sub-domain %d", &sub_domain))
9195 else if (unformat (i, "set %d", &set))
9197 else if (unformat (i, "hdr-len %d", &hdr_len))
9199 else if (unformat (i, "bp %d", &bp))
9201 else if (unformat (i, "add"))
9203 else if (unformat (i, "del"))
9205 else if (unformat (i, "out-label %d", &next_hop_out_label))
9209 clib_warning ("parse error '%U'", format_unformat_error, i);
9214 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9216 errmsg ("next hop / label set\n");
9221 errmsg ("bit=position not set\n");
9225 /* Construct the API message */
9226 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9228 mp->br_is_add = is_add;
9229 mp->br_tbl_id.bt_set = set;
9230 mp->br_tbl_id.bt_sub_domain = sub_domain;
9231 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9232 mp->br_bp = ntohs (bp);
9234 mp->br_paths[0].n_labels = 1;
9235 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9236 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9238 if (next_hop_proto_is_ip4)
9240 clib_memcpy (mp->br_paths[0].next_hop,
9241 &v4_next_hop_address, sizeof (v4_next_hop_address));
9245 clib_memcpy (mp->br_paths[0].next_hop,
9246 &v6_next_hop_address, sizeof (v6_next_hop_address));
9252 /* Wait for a reply... */
9259 api_proxy_arp_add_del (vat_main_t * vam)
9261 unformat_input_t *i = vam->input;
9262 vl_api_proxy_arp_add_del_t *mp;
9265 ip4_address_t lo, hi;
9269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9271 if (unformat (i, "vrf %d", &vrf_id))
9273 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9274 unformat_ip4_address, &hi))
9276 else if (unformat (i, "del"))
9280 clib_warning ("parse error '%U'", format_unformat_error, i);
9287 errmsg ("address range not set");
9291 M (PROXY_ARP_ADD_DEL, mp);
9293 mp->proxy.vrf_id = ntohl (vrf_id);
9294 mp->is_add = is_add;
9295 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9296 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9304 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9306 unformat_input_t *i = vam->input;
9307 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9310 u8 sw_if_index_set = 0;
9313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9316 sw_if_index_set = 1;
9317 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9318 sw_if_index_set = 1;
9319 else if (unformat (i, "enable"))
9321 else if (unformat (i, "disable"))
9325 clib_warning ("parse error '%U'", format_unformat_error, i);
9330 if (sw_if_index_set == 0)
9332 errmsg ("missing interface name or sw_if_index");
9336 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9338 mp->sw_if_index = ntohl (sw_if_index);
9339 mp->enable_disable = enable;
9347 api_mpls_tunnel_add_del (vat_main_t * vam)
9349 unformat_input_t *i = vam->input;
9350 vl_api_mpls_tunnel_add_del_t *mp;
9354 u32 sw_if_index = ~0;
9355 u32 next_hop_sw_if_index = ~0;
9356 u32 next_hop_proto_is_ip4 = 1;
9358 u32 next_hop_table_id = 0;
9359 ip4_address_t v4_next_hop_address = {
9362 ip6_address_t v6_next_hop_address = { {0} };
9363 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9368 if (unformat (i, "add"))
9370 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9372 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9374 else if (unformat (i, "via %U",
9375 unformat_ip4_address, &v4_next_hop_address))
9377 next_hop_proto_is_ip4 = 1;
9379 else if (unformat (i, "via %U",
9380 unformat_ip6_address, &v6_next_hop_address))
9382 next_hop_proto_is_ip4 = 0;
9384 else if (unformat (i, "l2-only"))
9386 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9388 else if (unformat (i, "out-label %d", &next_hop_out_label))
9389 vec_add1 (labels, ntohl (next_hop_out_label));
9392 clib_warning ("parse error '%U'", format_unformat_error, i);
9397 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9399 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9400 mp->mt_sw_if_index = ntohl (sw_if_index);
9401 mp->mt_is_add = is_add;
9402 mp->mt_l2_only = l2_only;
9403 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9404 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9406 mp->mt_next_hop_n_out_labels = vec_len (labels);
9408 if (0 != mp->mt_next_hop_n_out_labels)
9410 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9411 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9415 if (next_hop_proto_is_ip4)
9417 clib_memcpy (mp->mt_next_hop,
9418 &v4_next_hop_address, sizeof (v4_next_hop_address));
9422 clib_memcpy (mp->mt_next_hop,
9423 &v6_next_hop_address, sizeof (v6_next_hop_address));
9432 api_sw_interface_set_unnumbered (vat_main_t * vam)
9434 unformat_input_t *i = vam->input;
9435 vl_api_sw_interface_set_unnumbered_t *mp;
9437 u32 unnum_sw_index = ~0;
9439 u8 sw_if_index_set = 0;
9442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9444 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9445 sw_if_index_set = 1;
9446 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9447 sw_if_index_set = 1;
9448 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9450 else if (unformat (i, "del"))
9454 clib_warning ("parse error '%U'", format_unformat_error, i);
9459 if (sw_if_index_set == 0)
9461 errmsg ("missing interface name or sw_if_index");
9465 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9467 mp->sw_if_index = ntohl (sw_if_index);
9468 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9469 mp->is_add = is_add;
9477 api_ip_neighbor_add_del (vat_main_t * vam)
9479 unformat_input_t *i = vam->input;
9480 vl_api_ip_neighbor_add_del_t *mp;
9482 u8 sw_if_index_set = 0;
9485 u8 is_no_fib_entry = 0;
9488 u8 v4_address_set = 0;
9489 u8 v6_address_set = 0;
9490 ip4_address_t v4address;
9491 ip6_address_t v6address;
9494 memset (mac_address, 0, sizeof (mac_address));
9496 /* Parse args required to build the message */
9497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9499 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9503 else if (unformat (i, "del"))
9506 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9507 sw_if_index_set = 1;
9508 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9509 sw_if_index_set = 1;
9510 else if (unformat (i, "is_static"))
9512 else if (unformat (i, "no-fib-entry"))
9513 is_no_fib_entry = 1;
9514 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9516 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9520 clib_warning ("parse error '%U'", format_unformat_error, i);
9525 if (sw_if_index_set == 0)
9527 errmsg ("missing interface name or sw_if_index");
9530 if (v4_address_set && v6_address_set)
9532 errmsg ("both v4 and v6 addresses set");
9535 if (!v4_address_set && !v6_address_set)
9537 errmsg ("no address set");
9541 /* Construct the API message */
9542 M (IP_NEIGHBOR_ADD_DEL, mp);
9544 mp->sw_if_index = ntohl (sw_if_index);
9545 mp->is_add = is_add;
9546 mp->is_static = is_static;
9547 mp->is_no_adj_fib = is_no_fib_entry;
9549 clib_memcpy (mp->mac_address, mac_address, 6);
9553 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9557 /* mp->is_ipv6 = 0; via memset in M macro above */
9558 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9564 /* Wait for a reply, return good/bad news */
9570 api_create_vlan_subif (vat_main_t * vam)
9572 unformat_input_t *i = vam->input;
9573 vl_api_create_vlan_subif_t *mp;
9575 u8 sw_if_index_set = 0;
9580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9582 if (unformat (i, "sw_if_index %d", &sw_if_index))
9583 sw_if_index_set = 1;
9585 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9586 sw_if_index_set = 1;
9587 else if (unformat (i, "vlan %d", &vlan_id))
9591 clib_warning ("parse error '%U'", format_unformat_error, i);
9596 if (sw_if_index_set == 0)
9598 errmsg ("missing interface name or sw_if_index");
9602 if (vlan_id_set == 0)
9604 errmsg ("missing vlan_id");
9607 M (CREATE_VLAN_SUBIF, mp);
9609 mp->sw_if_index = ntohl (sw_if_index);
9610 mp->vlan_id = ntohl (vlan_id);
9617 #define foreach_create_subif_bit \
9624 _(outer_vlan_id_any) \
9625 _(inner_vlan_id_any)
9628 api_create_subif (vat_main_t * vam)
9630 unformat_input_t *i = vam->input;
9631 vl_api_create_subif_t *mp;
9633 u8 sw_if_index_set = 0;
9640 u32 exact_match = 0;
9641 u32 default_sub = 0;
9642 u32 outer_vlan_id_any = 0;
9643 u32 inner_vlan_id_any = 0;
9645 u16 outer_vlan_id = 0;
9646 u16 inner_vlan_id = 0;
9649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9651 if (unformat (i, "sw_if_index %d", &sw_if_index))
9652 sw_if_index_set = 1;
9654 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9655 sw_if_index_set = 1;
9656 else if (unformat (i, "sub_id %d", &sub_id))
9658 else if (unformat (i, "outer_vlan_id %d", &tmp))
9659 outer_vlan_id = tmp;
9660 else if (unformat (i, "inner_vlan_id %d", &tmp))
9661 inner_vlan_id = tmp;
9663 #define _(a) else if (unformat (i, #a)) a = 1 ;
9664 foreach_create_subif_bit
9668 clib_warning ("parse error '%U'", format_unformat_error, i);
9673 if (sw_if_index_set == 0)
9675 errmsg ("missing interface name or sw_if_index");
9679 if (sub_id_set == 0)
9681 errmsg ("missing sub_id");
9684 M (CREATE_SUBIF, mp);
9686 mp->sw_if_index = ntohl (sw_if_index);
9687 mp->sub_id = ntohl (sub_id);
9689 #define _(a) mp->a = a;
9690 foreach_create_subif_bit;
9693 mp->outer_vlan_id = ntohs (outer_vlan_id);
9694 mp->inner_vlan_id = ntohs (inner_vlan_id);
9702 api_oam_add_del (vat_main_t * vam)
9704 unformat_input_t *i = vam->input;
9705 vl_api_oam_add_del_t *mp;
9708 ip4_address_t src, dst;
9713 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9715 if (unformat (i, "vrf %d", &vrf_id))
9717 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9719 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9721 else if (unformat (i, "del"))
9725 clib_warning ("parse error '%U'", format_unformat_error, i);
9732 errmsg ("missing src addr");
9738 errmsg ("missing dst addr");
9742 M (OAM_ADD_DEL, mp);
9744 mp->vrf_id = ntohl (vrf_id);
9745 mp->is_add = is_add;
9746 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9747 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9755 api_reset_fib (vat_main_t * vam)
9757 unformat_input_t *i = vam->input;
9758 vl_api_reset_fib_t *mp;
9764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9766 if (unformat (i, "vrf %d", &vrf_id))
9768 else if (unformat (i, "ipv6"))
9772 clib_warning ("parse error '%U'", format_unformat_error, i);
9777 if (vrf_id_set == 0)
9779 errmsg ("missing vrf id");
9785 mp->vrf_id = ntohl (vrf_id);
9786 mp->is_ipv6 = is_ipv6;
9794 api_dhcp_proxy_config (vat_main_t * vam)
9796 unformat_input_t *i = vam->input;
9797 vl_api_dhcp_proxy_config_t *mp;
9799 u32 server_vrf_id = 0;
9801 u8 v4_address_set = 0;
9802 u8 v6_address_set = 0;
9803 ip4_address_t v4address;
9804 ip6_address_t v6address;
9805 u8 v4_src_address_set = 0;
9806 u8 v6_src_address_set = 0;
9807 ip4_address_t v4srcaddress;
9808 ip6_address_t v6srcaddress;
9811 /* Parse args required to build the message */
9812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9814 if (unformat (i, "del"))
9816 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9818 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9820 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9822 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9824 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9825 v4_src_address_set = 1;
9826 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9827 v6_src_address_set = 1;
9832 if (v4_address_set && v6_address_set)
9834 errmsg ("both v4 and v6 server addresses set");
9837 if (!v4_address_set && !v6_address_set)
9839 errmsg ("no server addresses set");
9843 if (v4_src_address_set && v6_src_address_set)
9845 errmsg ("both v4 and v6 src addresses set");
9848 if (!v4_src_address_set && !v6_src_address_set)
9850 errmsg ("no src addresses set");
9854 if (!(v4_src_address_set && v4_address_set) &&
9855 !(v6_src_address_set && v6_address_set))
9857 errmsg ("no matching server and src addresses set");
9861 /* Construct the API message */
9862 M (DHCP_PROXY_CONFIG, mp);
9864 mp->is_add = is_add;
9865 mp->rx_vrf_id = ntohl (rx_vrf_id);
9866 mp->server_vrf_id = ntohl (server_vrf_id);
9870 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9871 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9875 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9876 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9882 /* Wait for a reply, return good/bad news */
9887 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9888 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9891 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9893 vat_main_t *vam = &vat_main;
9894 u32 i, count = mp->count;
9895 vl_api_dhcp_server_t *s;
9899 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9900 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9901 ntohl (mp->rx_vrf_id),
9902 format_ip6_address, mp->dhcp_src_address,
9903 mp->vss_type, mp->vss_vpn_ascii_id,
9904 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9907 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9908 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9909 ntohl (mp->rx_vrf_id),
9910 format_ip4_address, mp->dhcp_src_address,
9911 mp->vss_type, mp->vss_vpn_ascii_id,
9912 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9914 for (i = 0; i < count; i++)
9916 s = &mp->servers[i];
9920 " Server Table-ID %d, Server Address %U",
9921 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9924 " Server Table-ID %d, Server Address %U",
9925 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9929 static void vl_api_dhcp_proxy_details_t_handler_json
9930 (vl_api_dhcp_proxy_details_t * mp)
9932 vat_main_t *vam = &vat_main;
9933 vat_json_node_t *node = NULL;
9934 u32 i, count = mp->count;
9936 struct in6_addr ip6;
9937 vl_api_dhcp_server_t *s;
9939 if (VAT_JSON_ARRAY != vam->json_tree.type)
9941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9942 vat_json_init_array (&vam->json_tree);
9944 node = vat_json_array_add (&vam->json_tree);
9946 vat_json_init_object (node);
9947 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9948 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9949 sizeof (mp->vss_type));
9950 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9951 mp->vss_vpn_ascii_id);
9952 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9953 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9957 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9958 vat_json_object_add_ip6 (node, "src_address", ip6);
9962 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9963 vat_json_object_add_ip4 (node, "src_address", ip4);
9966 for (i = 0; i < count; i++)
9968 s = &mp->servers[i];
9970 vat_json_object_add_uint (node, "server-table-id",
9971 ntohl (s->server_vrf_id));
9975 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9976 vat_json_object_add_ip4 (node, "src_address", ip4);
9980 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9981 vat_json_object_add_ip6 (node, "server_address", ip6);
9987 api_dhcp_proxy_dump (vat_main_t * vam)
9989 unformat_input_t *i = vam->input;
9990 vl_api_control_ping_t *mp_ping;
9991 vl_api_dhcp_proxy_dump_t *mp;
9995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9997 if (unformat (i, "ipv6"))
10001 clib_warning ("parse error '%U'", format_unformat_error, i);
10006 M (DHCP_PROXY_DUMP, mp);
10008 mp->is_ip6 = is_ipv6;
10011 /* Use a control ping for synchronization */
10012 MPING (CONTROL_PING, mp_ping);
10020 api_dhcp_proxy_set_vss (vat_main_t * vam)
10022 unformat_input_t *i = vam->input;
10023 vl_api_dhcp_proxy_set_vss_t *mp;
10027 u8 vss_type = VSS_TYPE_DEFAULT;
10028 u8 *vpn_ascii_id = 0;
10033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10035 if (unformat (i, "tbl_id %d", &tbl_id))
10037 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10038 vss_type = VSS_TYPE_ASCII;
10039 else if (unformat (i, "fib_id %d", &fib_id))
10040 vss_type = VSS_TYPE_VPN_ID;
10041 else if (unformat (i, "oui %d", &oui))
10042 vss_type = VSS_TYPE_VPN_ID;
10043 else if (unformat (i, "ipv6"))
10045 else if (unformat (i, "del"))
10053 errmsg ("missing tbl_id ");
10054 vec_free (vpn_ascii_id);
10058 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10060 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10061 vec_free (vpn_ascii_id);
10065 M (DHCP_PROXY_SET_VSS, mp);
10066 mp->tbl_id = ntohl (tbl_id);
10067 mp->vss_type = vss_type;
10070 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10071 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10073 mp->vpn_index = ntohl (fib_id);
10074 mp->oui = ntohl (oui);
10075 mp->is_ipv6 = is_ipv6;
10076 mp->is_add = is_add;
10081 vec_free (vpn_ascii_id);
10086 api_dhcp_client_config (vat_main_t * vam)
10088 unformat_input_t *i = vam->input;
10089 vl_api_dhcp_client_config_t *mp;
10091 u8 sw_if_index_set = 0;
10094 u8 disable_event = 0;
10097 /* Parse args required to build the message */
10098 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10100 if (unformat (i, "del"))
10103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10104 sw_if_index_set = 1;
10105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10106 sw_if_index_set = 1;
10107 else if (unformat (i, "hostname %s", &hostname))
10109 else if (unformat (i, "disable_event"))
10115 if (sw_if_index_set == 0)
10117 errmsg ("missing interface name or sw_if_index");
10121 if (vec_len (hostname) > 63)
10123 errmsg ("hostname too long");
10125 vec_add1 (hostname, 0);
10127 /* Construct the API message */
10128 M (DHCP_CLIENT_CONFIG, mp);
10130 mp->is_add = is_add;
10131 mp->client.sw_if_index = htonl (sw_if_index);
10132 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10133 vec_free (hostname);
10134 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10135 mp->client.pid = htonl (getpid ());
10140 /* Wait for a reply, return good/bad news */
10146 api_set_ip_flow_hash (vat_main_t * vam)
10148 unformat_input_t *i = vam->input;
10149 vl_api_set_ip_flow_hash_t *mp;
10161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10163 if (unformat (i, "vrf %d", &vrf_id))
10165 else if (unformat (i, "ipv6"))
10167 else if (unformat (i, "src"))
10169 else if (unformat (i, "dst"))
10171 else if (unformat (i, "sport"))
10173 else if (unformat (i, "dport"))
10175 else if (unformat (i, "proto"))
10177 else if (unformat (i, "reverse"))
10182 clib_warning ("parse error '%U'", format_unformat_error, i);
10187 if (vrf_id_set == 0)
10189 errmsg ("missing vrf id");
10193 M (SET_IP_FLOW_HASH, mp);
10199 mp->reverse = reverse;
10200 mp->vrf_id = ntohl (vrf_id);
10201 mp->is_ipv6 = is_ipv6;
10209 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10211 unformat_input_t *i = vam->input;
10212 vl_api_sw_interface_ip6_enable_disable_t *mp;
10214 u8 sw_if_index_set = 0;
10218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10221 sw_if_index_set = 1;
10222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10223 sw_if_index_set = 1;
10224 else if (unformat (i, "enable"))
10226 else if (unformat (i, "disable"))
10230 clib_warning ("parse error '%U'", format_unformat_error, i);
10235 if (sw_if_index_set == 0)
10237 errmsg ("missing interface name or sw_if_index");
10241 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10243 mp->sw_if_index = ntohl (sw_if_index);
10244 mp->enable = enable;
10252 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10254 unformat_input_t *i = vam->input;
10255 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10257 u8 sw_if_index_set = 0;
10258 u8 v6_address_set = 0;
10259 ip6_address_t v6address;
10262 /* Parse args required to build the message */
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, "%U", unformat_ip6_address, &v6address))
10270 v6_address_set = 1;
10275 if (sw_if_index_set == 0)
10277 errmsg ("missing interface name or sw_if_index");
10280 if (!v6_address_set)
10282 errmsg ("no address set");
10286 /* Construct the API message */
10287 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10289 mp->sw_if_index = ntohl (sw_if_index);
10290 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10295 /* Wait for a reply, return good/bad news */
10301 api_ip6nd_proxy_add_del (vat_main_t * vam)
10303 unformat_input_t *i = vam->input;
10304 vl_api_ip6nd_proxy_add_del_t *mp;
10305 u32 sw_if_index = ~0;
10306 u8 v6_address_set = 0;
10307 ip6_address_t v6address;
10311 /* Parse args required to build the message */
10312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10314 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10318 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10319 v6_address_set = 1;
10320 if (unformat (i, "del"))
10324 clib_warning ("parse error '%U'", format_unformat_error, i);
10329 if (sw_if_index == ~0)
10331 errmsg ("missing interface name or sw_if_index");
10334 if (!v6_address_set)
10336 errmsg ("no address set");
10340 /* Construct the API message */
10341 M (IP6ND_PROXY_ADD_DEL, mp);
10343 mp->is_del = is_del;
10344 mp->sw_if_index = ntohl (sw_if_index);
10345 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10350 /* Wait for a reply, return good/bad news */
10356 api_ip6nd_proxy_dump (vat_main_t * vam)
10358 vl_api_ip6nd_proxy_dump_t *mp;
10359 vl_api_control_ping_t *mp_ping;
10362 M (IP6ND_PROXY_DUMP, mp);
10366 /* Use a control ping for synchronization */
10367 MPING (CONTROL_PING, mp_ping);
10374 static void vl_api_ip6nd_proxy_details_t_handler
10375 (vl_api_ip6nd_proxy_details_t * mp)
10377 vat_main_t *vam = &vat_main;
10379 print (vam->ofp, "host %U sw_if_index %d",
10380 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10383 static void vl_api_ip6nd_proxy_details_t_handler_json
10384 (vl_api_ip6nd_proxy_details_t * mp)
10386 vat_main_t *vam = &vat_main;
10387 struct in6_addr ip6;
10388 vat_json_node_t *node = NULL;
10390 if (VAT_JSON_ARRAY != vam->json_tree.type)
10392 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10393 vat_json_init_array (&vam->json_tree);
10395 node = vat_json_array_add (&vam->json_tree);
10397 vat_json_init_object (node);
10398 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10400 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10401 vat_json_object_add_ip6 (node, "host", ip6);
10405 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10407 unformat_input_t *i = vam->input;
10408 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10410 u8 sw_if_index_set = 0;
10411 u32 address_length = 0;
10412 u8 v6_address_set = 0;
10413 ip6_address_t v6address;
10414 u8 use_default = 0;
10415 u8 no_advertise = 0;
10417 u8 no_autoconfig = 0;
10420 u32 val_lifetime = 0;
10421 u32 pref_lifetime = 0;
10424 /* Parse args required to build the message */
10425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10427 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10428 sw_if_index_set = 1;
10429 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10430 sw_if_index_set = 1;
10431 else if (unformat (i, "%U/%d",
10432 unformat_ip6_address, &v6address, &address_length))
10433 v6_address_set = 1;
10434 else if (unformat (i, "val_life %d", &val_lifetime))
10436 else if (unformat (i, "pref_life %d", &pref_lifetime))
10438 else if (unformat (i, "def"))
10440 else if (unformat (i, "noadv"))
10442 else if (unformat (i, "offl"))
10444 else if (unformat (i, "noauto"))
10446 else if (unformat (i, "nolink"))
10448 else if (unformat (i, "isno"))
10452 clib_warning ("parse error '%U'", format_unformat_error, i);
10457 if (sw_if_index_set == 0)
10459 errmsg ("missing interface name or sw_if_index");
10462 if (!v6_address_set)
10464 errmsg ("no address set");
10468 /* Construct the API message */
10469 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10471 mp->sw_if_index = ntohl (sw_if_index);
10472 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10473 mp->address_length = address_length;
10474 mp->use_default = use_default;
10475 mp->no_advertise = no_advertise;
10476 mp->off_link = off_link;
10477 mp->no_autoconfig = no_autoconfig;
10478 mp->no_onlink = no_onlink;
10480 mp->val_lifetime = ntohl (val_lifetime);
10481 mp->pref_lifetime = ntohl (pref_lifetime);
10486 /* Wait for a reply, return good/bad news */
10492 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10494 unformat_input_t *i = vam->input;
10495 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10497 u8 sw_if_index_set = 0;
10502 u8 send_unicast = 0;
10505 u8 default_router = 0;
10506 u32 max_interval = 0;
10507 u32 min_interval = 0;
10509 u32 initial_count = 0;
10510 u32 initial_interval = 0;
10514 /* Parse args required to build the message */
10515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10517 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10518 sw_if_index_set = 1;
10519 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10520 sw_if_index_set = 1;
10521 else if (unformat (i, "maxint %d", &max_interval))
10523 else if (unformat (i, "minint %d", &min_interval))
10525 else if (unformat (i, "life %d", &lifetime))
10527 else if (unformat (i, "count %d", &initial_count))
10529 else if (unformat (i, "interval %d", &initial_interval))
10531 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10533 else if (unformat (i, "managed"))
10535 else if (unformat (i, "other"))
10537 else if (unformat (i, "ll"))
10539 else if (unformat (i, "send"))
10541 else if (unformat (i, "cease"))
10543 else if (unformat (i, "isno"))
10545 else if (unformat (i, "def"))
10546 default_router = 1;
10549 clib_warning ("parse error '%U'", format_unformat_error, i);
10554 if (sw_if_index_set == 0)
10556 errmsg ("missing interface name or sw_if_index");
10560 /* Construct the API message */
10561 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10563 mp->sw_if_index = ntohl (sw_if_index);
10564 mp->max_interval = ntohl (max_interval);
10565 mp->min_interval = ntohl (min_interval);
10566 mp->lifetime = ntohl (lifetime);
10567 mp->initial_count = ntohl (initial_count);
10568 mp->initial_interval = ntohl (initial_interval);
10569 mp->suppress = suppress;
10570 mp->managed = managed;
10572 mp->ll_option = ll_option;
10573 mp->send_unicast = send_unicast;
10576 mp->default_router = default_router;
10581 /* Wait for a reply, return good/bad news */
10587 api_set_arp_neighbor_limit (vat_main_t * vam)
10589 unformat_input_t *i = vam->input;
10590 vl_api_set_arp_neighbor_limit_t *mp;
10596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10598 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10600 else if (unformat (i, "ipv6"))
10604 clib_warning ("parse error '%U'", format_unformat_error, i);
10609 if (limit_set == 0)
10611 errmsg ("missing limit value");
10615 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10617 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10618 mp->is_ipv6 = is_ipv6;
10626 api_l2_patch_add_del (vat_main_t * vam)
10628 unformat_input_t *i = vam->input;
10629 vl_api_l2_patch_add_del_t *mp;
10630 u32 rx_sw_if_index;
10631 u8 rx_sw_if_index_set = 0;
10632 u32 tx_sw_if_index;
10633 u8 tx_sw_if_index_set = 0;
10637 /* Parse args required to build the message */
10638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10640 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10641 rx_sw_if_index_set = 1;
10642 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10643 tx_sw_if_index_set = 1;
10644 else if (unformat (i, "rx"))
10646 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10648 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10650 rx_sw_if_index_set = 1;
10655 else if (unformat (i, "tx"))
10657 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10659 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10661 tx_sw_if_index_set = 1;
10666 else if (unformat (i, "del"))
10672 if (rx_sw_if_index_set == 0)
10674 errmsg ("missing rx interface name or rx_sw_if_index");
10678 if (tx_sw_if_index_set == 0)
10680 errmsg ("missing tx interface name or tx_sw_if_index");
10684 M (L2_PATCH_ADD_DEL, mp);
10686 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10687 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10688 mp->is_add = is_add;
10696 u8 localsid_addr[16];
10705 api_sr_localsid_add_del (vat_main_t * vam)
10707 unformat_input_t *i = vam->input;
10708 vl_api_sr_localsid_add_del_t *mp;
10711 ip6_address_t localsid;
10715 u32 fib_table = ~(u32) 0;
10716 ip6_address_t next_hop;
10718 bool nexthop_set = 0;
10722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10724 if (unformat (i, "del"))
10726 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10727 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10729 else if (unformat (i, "behavior %u", &behavior));
10730 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10731 else if (unformat (i, "fib-table %u", &fib_table));
10732 else if (unformat (i, "end.psp %u", &behavior));
10737 M (SR_LOCALSID_ADD_DEL, mp);
10739 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10741 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10742 mp->behavior = behavior;
10743 mp->sw_if_index = ntohl (sw_if_index);
10744 mp->fib_table = ntohl (fib_table);
10745 mp->end_psp = end_psp;
10746 mp->is_del = is_del;
10754 api_ioam_enable (vat_main_t * vam)
10756 unformat_input_t *input = vam->input;
10757 vl_api_ioam_enable_t *mp;
10759 int has_trace_option = 0;
10760 int has_pot_option = 0;
10761 int has_seqno_option = 0;
10762 int has_analyse_option = 0;
10765 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10767 if (unformat (input, "trace"))
10768 has_trace_option = 1;
10769 else if (unformat (input, "pot"))
10770 has_pot_option = 1;
10771 else if (unformat (input, "seqno"))
10772 has_seqno_option = 1;
10773 else if (unformat (input, "analyse"))
10774 has_analyse_option = 1;
10778 M (IOAM_ENABLE, mp);
10779 mp->id = htons (id);
10780 mp->seqno = has_seqno_option;
10781 mp->analyse = has_analyse_option;
10782 mp->pot_enable = has_pot_option;
10783 mp->trace_enable = has_trace_option;
10792 api_ioam_disable (vat_main_t * vam)
10794 vl_api_ioam_disable_t *mp;
10797 M (IOAM_DISABLE, mp);
10803 #define foreach_tcp_proto_field \
10807 #define foreach_udp_proto_field \
10811 #define foreach_ip4_proto_field \
10823 u16 src_port, dst_port;
10826 #if VPP_API_TEST_BUILTIN == 0
10828 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10830 u8 **maskp = va_arg (*args, u8 **);
10832 u8 found_something = 0;
10835 #define _(a) u8 a=0;
10836 foreach_tcp_proto_field;
10839 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10842 #define _(a) else if (unformat (input, #a)) a=1;
10843 foreach_tcp_proto_field
10849 #define _(a) found_something += a;
10850 foreach_tcp_proto_field;
10853 if (found_something == 0)
10856 vec_validate (mask, sizeof (*tcp) - 1);
10858 tcp = (tcp_header_t *) mask;
10860 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10861 foreach_tcp_proto_field;
10869 unformat_udp_mask (unformat_input_t * input, va_list * args)
10871 u8 **maskp = va_arg (*args, u8 **);
10873 u8 found_something = 0;
10876 #define _(a) u8 a=0;
10877 foreach_udp_proto_field;
10880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10883 #define _(a) else if (unformat (input, #a)) a=1;
10884 foreach_udp_proto_field
10890 #define _(a) found_something += a;
10891 foreach_udp_proto_field;
10894 if (found_something == 0)
10897 vec_validate (mask, sizeof (*udp) - 1);
10899 udp = (udp_header_t *) mask;
10901 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10902 foreach_udp_proto_field;
10910 unformat_l4_mask (unformat_input_t * input, va_list * args)
10912 u8 **maskp = va_arg (*args, u8 **);
10913 u16 src_port = 0, dst_port = 0;
10914 tcpudp_header_t *tcpudp;
10916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10918 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10920 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10922 else if (unformat (input, "src_port"))
10924 else if (unformat (input, "dst_port"))
10930 if (!src_port && !dst_port)
10934 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10936 tcpudp = (tcpudp_header_t *) mask;
10937 tcpudp->src_port = src_port;
10938 tcpudp->dst_port = dst_port;
10946 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10948 u8 **maskp = va_arg (*args, u8 **);
10950 u8 found_something = 0;
10953 #define _(a) u8 a=0;
10954 foreach_ip4_proto_field;
10960 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10962 if (unformat (input, "version"))
10964 else if (unformat (input, "hdr_length"))
10966 else if (unformat (input, "src"))
10968 else if (unformat (input, "dst"))
10970 else if (unformat (input, "proto"))
10973 #define _(a) else if (unformat (input, #a)) a=1;
10974 foreach_ip4_proto_field
10980 #define _(a) found_something += a;
10981 foreach_ip4_proto_field;
10984 if (found_something == 0)
10987 vec_validate (mask, sizeof (*ip) - 1);
10989 ip = (ip4_header_t *) mask;
10991 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10992 foreach_ip4_proto_field;
10995 ip->ip_version_and_header_length = 0;
10998 ip->ip_version_and_header_length |= 0xF0;
11001 ip->ip_version_and_header_length |= 0x0F;
11007 #define foreach_ip6_proto_field \
11010 _(payload_length) \
11015 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11017 u8 **maskp = va_arg (*args, u8 **);
11019 u8 found_something = 0;
11021 u32 ip_version_traffic_class_and_flow_label;
11023 #define _(a) u8 a=0;
11024 foreach_ip6_proto_field;
11027 u8 traffic_class = 0;
11030 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11032 if (unformat (input, "version"))
11034 else if (unformat (input, "traffic-class"))
11036 else if (unformat (input, "flow-label"))
11038 else if (unformat (input, "src"))
11040 else if (unformat (input, "dst"))
11042 else if (unformat (input, "proto"))
11045 #define _(a) else if (unformat (input, #a)) a=1;
11046 foreach_ip6_proto_field
11052 #define _(a) found_something += a;
11053 foreach_ip6_proto_field;
11056 if (found_something == 0)
11059 vec_validate (mask, sizeof (*ip) - 1);
11061 ip = (ip6_header_t *) mask;
11063 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11064 foreach_ip6_proto_field;
11067 ip_version_traffic_class_and_flow_label = 0;
11070 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11073 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11076 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11078 ip->ip_version_traffic_class_and_flow_label =
11079 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11086 unformat_l3_mask (unformat_input_t * input, va_list * args)
11088 u8 **maskp = va_arg (*args, u8 **);
11090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11092 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11094 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11103 unformat_l2_mask (unformat_input_t * input, va_list * args)
11105 u8 **maskp = va_arg (*args, u8 **);
11112 u8 ignore_tag1 = 0;
11113 u8 ignore_tag2 = 0;
11120 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11122 if (unformat (input, "src"))
11124 else if (unformat (input, "dst"))
11126 else if (unformat (input, "proto"))
11128 else if (unformat (input, "tag1"))
11130 else if (unformat (input, "tag2"))
11132 else if (unformat (input, "ignore-tag1"))
11134 else if (unformat (input, "ignore-tag2"))
11136 else if (unformat (input, "cos1"))
11138 else if (unformat (input, "cos2"))
11140 else if (unformat (input, "dot1q"))
11142 else if (unformat (input, "dot1ad"))
11147 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11148 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11151 if (tag1 || ignore_tag1 || cos1 || dot1q)
11153 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11156 vec_validate (mask, len - 1);
11159 memset (mask, 0xff, 6);
11162 memset (mask + 6, 0xff, 6);
11164 if (tag2 || dot1ad)
11166 /* inner vlan tag */
11175 mask[21] = mask[20] = 0xff;
11196 mask[16] = mask[17] = 0xff;
11206 mask[12] = mask[13] = 0xff;
11213 unformat_classify_mask (unformat_input_t * input, va_list * args)
11215 u8 **maskp = va_arg (*args, u8 **);
11216 u32 *skipp = va_arg (*args, u32 *);
11217 u32 *matchp = va_arg (*args, u32 *);
11225 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11227 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11229 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11231 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11233 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11247 if (mask || l2 || l3 || l4)
11249 if (l2 || l3 || l4)
11251 /* "With a free Ethernet header in every package" */
11253 vec_validate (l2, 13);
11257 vec_append (mask, l3);
11262 vec_append (mask, l4);
11267 /* Scan forward looking for the first significant mask octet */
11268 for (i = 0; i < vec_len (mask); i++)
11272 /* compute (skip, match) params */
11273 *skipp = i / sizeof (u32x4);
11274 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11276 /* Pad mask to an even multiple of the vector size */
11277 while (vec_len (mask) % sizeof (u32x4))
11278 vec_add1 (mask, 0);
11280 match = vec_len (mask) / sizeof (u32x4);
11282 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11284 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11285 if (*tmp || *(tmp + 1))
11290 clib_warning ("BUG: match 0");
11292 _vec_len (mask) = match * sizeof (u32x4);
11302 #endif /* VPP_API_TEST_BUILTIN */
11304 #define foreach_l2_next \
11306 _(ethernet, ETHERNET_INPUT) \
11307 _(ip4, IP4_INPUT) \
11311 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11313 u32 *miss_next_indexp = va_arg (*args, u32 *);
11314 u32 next_index = 0;
11318 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11322 if (unformat (input, "%d", &tmp))
11331 *miss_next_indexp = next_index;
11335 #define foreach_ip_next \
11338 _(rewrite, REWRITE)
11341 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11343 u32 *miss_next_indexp = va_arg (*args, u32 *);
11344 u32 next_index = 0;
11348 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11352 if (unformat (input, "%d", &tmp))
11361 *miss_next_indexp = next_index;
11365 #define foreach_acl_next \
11369 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11371 u32 *miss_next_indexp = va_arg (*args, u32 *);
11372 u32 next_index = 0;
11376 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11380 if (unformat (input, "permit"))
11385 else if (unformat (input, "%d", &tmp))
11394 *miss_next_indexp = next_index;
11399 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11401 u32 *r = va_arg (*args, u32 *);
11403 if (unformat (input, "conform-color"))
11404 *r = POLICE_CONFORM;
11405 else if (unformat (input, "exceed-color"))
11406 *r = POLICE_EXCEED;
11414 api_classify_add_del_table (vat_main_t * vam)
11416 unformat_input_t *i = vam->input;
11417 vl_api_classify_add_del_table_t *mp;
11424 u32 table_index = ~0;
11425 u32 next_table_index = ~0;
11426 u32 miss_next_index = ~0;
11427 u32 memory_size = 32 << 20;
11429 u32 current_data_flag = 0;
11430 int current_data_offset = 0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "del"))
11437 else if (unformat (i, "del-chain"))
11442 else if (unformat (i, "buckets %d", &nbuckets))
11444 else if (unformat (i, "memory_size %d", &memory_size))
11446 else if (unformat (i, "skip %d", &skip))
11448 else if (unformat (i, "match %d", &match))
11450 else if (unformat (i, "table %d", &table_index))
11452 else if (unformat (i, "mask %U", unformat_classify_mask,
11453 &mask, &skip, &match))
11455 else if (unformat (i, "next-table %d", &next_table_index))
11457 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11460 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11463 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11466 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11468 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11474 if (is_add && mask == 0)
11476 errmsg ("Mask required");
11480 if (is_add && skip == ~0)
11482 errmsg ("skip count required");
11486 if (is_add && match == ~0)
11488 errmsg ("match count required");
11492 if (!is_add && table_index == ~0)
11494 errmsg ("table index required for delete");
11498 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11500 mp->is_add = is_add;
11501 mp->del_chain = del_chain;
11502 mp->table_index = ntohl (table_index);
11503 mp->nbuckets = ntohl (nbuckets);
11504 mp->memory_size = ntohl (memory_size);
11505 mp->skip_n_vectors = ntohl (skip);
11506 mp->match_n_vectors = ntohl (match);
11507 mp->next_table_index = ntohl (next_table_index);
11508 mp->miss_next_index = ntohl (miss_next_index);
11509 mp->current_data_flag = ntohl (current_data_flag);
11510 mp->current_data_offset = ntohl (current_data_offset);
11511 clib_memcpy (mp->mask, mask, vec_len (mask));
11520 #if VPP_API_TEST_BUILTIN == 0
11522 unformat_l4_match (unformat_input_t * input, va_list * args)
11524 u8 **matchp = va_arg (*args, u8 **);
11526 u8 *proto_header = 0;
11532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11534 if (unformat (input, "src_port %d", &src_port))
11536 else if (unformat (input, "dst_port %d", &dst_port))
11542 h.src_port = clib_host_to_net_u16 (src_port);
11543 h.dst_port = clib_host_to_net_u16 (dst_port);
11544 vec_validate (proto_header, sizeof (h) - 1);
11545 memcpy (proto_header, &h, sizeof (h));
11547 *matchp = proto_header;
11553 unformat_ip4_match (unformat_input_t * input, va_list * args)
11555 u8 **matchp = va_arg (*args, u8 **);
11560 int hdr_length = 0;
11561 u32 hdr_length_val;
11562 int src = 0, dst = 0;
11563 ip4_address_t src_val, dst_val;
11570 int fragment_id = 0;
11571 u32 fragment_id_val;
11577 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11579 if (unformat (input, "version %d", &version_val))
11581 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11583 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11585 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11587 else if (unformat (input, "proto %d", &proto_val))
11589 else if (unformat (input, "tos %d", &tos_val))
11591 else if (unformat (input, "length %d", &length_val))
11593 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11595 else if (unformat (input, "ttl %d", &ttl_val))
11597 else if (unformat (input, "checksum %d", &checksum_val))
11603 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11604 + ttl + checksum == 0)
11608 * Aligned because we use the real comparison functions
11610 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11612 ip = (ip4_header_t *) match;
11614 /* These are realistically matched in practice */
11616 ip->src_address.as_u32 = src_val.as_u32;
11619 ip->dst_address.as_u32 = dst_val.as_u32;
11622 ip->protocol = proto_val;
11625 /* These are not, but they're included for completeness */
11627 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11630 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11636 ip->length = clib_host_to_net_u16 (length_val);
11642 ip->checksum = clib_host_to_net_u16 (checksum_val);
11649 unformat_ip6_match (unformat_input_t * input, va_list * args)
11651 u8 **matchp = va_arg (*args, u8 **);
11656 u8 traffic_class = 0;
11657 u32 traffic_class_val = 0;
11660 int src = 0, dst = 0;
11661 ip6_address_t src_val, dst_val;
11664 int payload_length = 0;
11665 u32 payload_length_val;
11668 u32 ip_version_traffic_class_and_flow_label;
11670 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11672 if (unformat (input, "version %d", &version_val))
11674 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11676 else if (unformat (input, "flow_label %d", &flow_label_val))
11678 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11680 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11682 else if (unformat (input, "proto %d", &proto_val))
11684 else if (unformat (input, "payload_length %d", &payload_length_val))
11685 payload_length = 1;
11686 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11692 if (version + traffic_class + flow_label + src + dst + proto +
11693 payload_length + hop_limit == 0)
11697 * Aligned because we use the real comparison functions
11699 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11701 ip = (ip6_header_t *) match;
11704 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11707 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11710 ip->protocol = proto_val;
11712 ip_version_traffic_class_and_flow_label = 0;
11715 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11718 ip_version_traffic_class_and_flow_label |=
11719 (traffic_class_val & 0xFF) << 20;
11722 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11724 ip->ip_version_traffic_class_and_flow_label =
11725 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11727 if (payload_length)
11728 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11731 ip->hop_limit = hop_limit_val;
11738 unformat_l3_match (unformat_input_t * input, va_list * args)
11740 u8 **matchp = va_arg (*args, u8 **);
11742 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11744 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11746 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11755 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11757 u8 *tagp = va_arg (*args, u8 *);
11760 if (unformat (input, "%d", &tag))
11762 tagp[0] = (tag >> 8) & 0x0F;
11763 tagp[1] = tag & 0xFF;
11771 unformat_l2_match (unformat_input_t * input, va_list * args)
11773 u8 **matchp = va_arg (*args, u8 **);
11786 u8 ignore_tag1 = 0;
11787 u8 ignore_tag2 = 0;
11793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11795 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11798 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11800 else if (unformat (input, "proto %U",
11801 unformat_ethernet_type_host_byte_order, &proto_val))
11803 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11805 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11807 else if (unformat (input, "ignore-tag1"))
11809 else if (unformat (input, "ignore-tag2"))
11811 else if (unformat (input, "cos1 %d", &cos1_val))
11813 else if (unformat (input, "cos2 %d", &cos2_val))
11818 if ((src + dst + proto + tag1 + tag2 +
11819 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11822 if (tag1 || ignore_tag1 || cos1)
11824 if (tag2 || ignore_tag2 || cos2)
11827 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11830 clib_memcpy (match, dst_val, 6);
11833 clib_memcpy (match + 6, src_val, 6);
11837 /* inner vlan tag */
11838 match[19] = tag2_val[1];
11839 match[18] = tag2_val[0];
11841 match[18] |= (cos2_val & 0x7) << 5;
11844 match[21] = proto_val & 0xff;
11845 match[20] = proto_val >> 8;
11849 match[15] = tag1_val[1];
11850 match[14] = tag1_val[0];
11853 match[14] |= (cos1_val & 0x7) << 5;
11859 match[15] = tag1_val[1];
11860 match[14] = tag1_val[0];
11863 match[17] = proto_val & 0xff;
11864 match[16] = proto_val >> 8;
11867 match[14] |= (cos1_val & 0x7) << 5;
11873 match[18] |= (cos2_val & 0x7) << 5;
11875 match[14] |= (cos1_val & 0x7) << 5;
11878 match[13] = proto_val & 0xff;
11879 match[12] = proto_val >> 8;
11887 unformat_qos_source (unformat_input_t * input, va_list * args)
11889 int *qs = va_arg (*args, int *);
11891 if (unformat (input, "ip"))
11892 *qs = QOS_SOURCE_IP;
11893 else if (unformat (input, "mpls"))
11894 *qs = QOS_SOURCE_MPLS;
11895 else if (unformat (input, "ext"))
11896 *qs = QOS_SOURCE_EXT;
11897 else if (unformat (input, "vlan"))
11898 *qs = QOS_SOURCE_VLAN;
11907 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11909 u8 **matchp = va_arg (*args, u8 **);
11910 u32 skip_n_vectors = va_arg (*args, u32);
11911 u32 match_n_vectors = va_arg (*args, u32);
11918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11920 if (unformat (input, "hex %U", unformat_hex_string, &match))
11922 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11924 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11926 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11940 if (match || l2 || l3 || l4)
11942 if (l2 || l3 || l4)
11944 /* "Win a free Ethernet header in every packet" */
11946 vec_validate_aligned (l2, 13, sizeof (u32x4));
11950 vec_append_aligned (match, l3, sizeof (u32x4));
11955 vec_append_aligned (match, l4, sizeof (u32x4));
11960 /* Make sure the vector is big enough even if key is all 0's */
11961 vec_validate_aligned
11962 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11965 /* Set size, include skipped vectors */
11966 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11977 api_classify_add_del_session (vat_main_t * vam)
11979 unformat_input_t *i = vam->input;
11980 vl_api_classify_add_del_session_t *mp;
11982 u32 table_index = ~0;
11983 u32 hit_next_index = ~0;
11984 u32 opaque_index = ~0;
11987 u32 skip_n_vectors = 0;
11988 u32 match_n_vectors = 0;
11994 * Warning: you have to supply skip_n and match_n
11995 * because the API client cant simply look at the classify
11999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12001 if (unformat (i, "del"))
12003 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12006 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12009 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12012 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12014 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12016 else if (unformat (i, "opaque-index %d", &opaque_index))
12018 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12020 else if (unformat (i, "match_n %d", &match_n_vectors))
12022 else if (unformat (i, "match %U", api_unformat_classify_match,
12023 &match, skip_n_vectors, match_n_vectors))
12025 else if (unformat (i, "advance %d", &advance))
12027 else if (unformat (i, "table-index %d", &table_index))
12029 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12031 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12033 else if (unformat (i, "action %d", &action))
12035 else if (unformat (i, "metadata %d", &metadata))
12041 if (table_index == ~0)
12043 errmsg ("Table index required");
12047 if (is_add && match == 0)
12049 errmsg ("Match value required");
12053 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12055 mp->is_add = is_add;
12056 mp->table_index = ntohl (table_index);
12057 mp->hit_next_index = ntohl (hit_next_index);
12058 mp->opaque_index = ntohl (opaque_index);
12059 mp->advance = ntohl (advance);
12060 mp->action = action;
12061 mp->metadata = ntohl (metadata);
12062 clib_memcpy (mp->match, match, vec_len (match));
12071 api_classify_set_interface_ip_table (vat_main_t * vam)
12073 unformat_input_t *i = vam->input;
12074 vl_api_classify_set_interface_ip_table_t *mp;
12076 int sw_if_index_set;
12077 u32 table_index = ~0;
12081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12084 sw_if_index_set = 1;
12085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12086 sw_if_index_set = 1;
12087 else if (unformat (i, "table %d", &table_index))
12091 clib_warning ("parse error '%U'", format_unformat_error, i);
12096 if (sw_if_index_set == 0)
12098 errmsg ("missing interface name or sw_if_index");
12103 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12105 mp->sw_if_index = ntohl (sw_if_index);
12106 mp->table_index = ntohl (table_index);
12107 mp->is_ipv6 = is_ipv6;
12115 api_classify_set_interface_l2_tables (vat_main_t * vam)
12117 unformat_input_t *i = vam->input;
12118 vl_api_classify_set_interface_l2_tables_t *mp;
12120 int sw_if_index_set;
12121 u32 ip4_table_index = ~0;
12122 u32 ip6_table_index = ~0;
12123 u32 other_table_index = ~0;
12127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12130 sw_if_index_set = 1;
12131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12132 sw_if_index_set = 1;
12133 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12135 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12137 else if (unformat (i, "other-table %d", &other_table_index))
12139 else if (unformat (i, "is-input %d", &is_input))
12143 clib_warning ("parse error '%U'", format_unformat_error, i);
12148 if (sw_if_index_set == 0)
12150 errmsg ("missing interface name or sw_if_index");
12155 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12157 mp->sw_if_index = ntohl (sw_if_index);
12158 mp->ip4_table_index = ntohl (ip4_table_index);
12159 mp->ip6_table_index = ntohl (ip6_table_index);
12160 mp->other_table_index = ntohl (other_table_index);
12161 mp->is_input = (u8) is_input;
12169 api_set_ipfix_exporter (vat_main_t * vam)
12171 unformat_input_t *i = vam->input;
12172 vl_api_set_ipfix_exporter_t *mp;
12173 ip4_address_t collector_address;
12174 u8 collector_address_set = 0;
12175 u32 collector_port = ~0;
12176 ip4_address_t src_address;
12177 u8 src_address_set = 0;
12180 u32 template_interval = ~0;
12181 u8 udp_checksum = 0;
12184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12186 if (unformat (i, "collector_address %U", unformat_ip4_address,
12187 &collector_address))
12188 collector_address_set = 1;
12189 else if (unformat (i, "collector_port %d", &collector_port))
12191 else if (unformat (i, "src_address %U", unformat_ip4_address,
12193 src_address_set = 1;
12194 else if (unformat (i, "vrf_id %d", &vrf_id))
12196 else if (unformat (i, "path_mtu %d", &path_mtu))
12198 else if (unformat (i, "template_interval %d", &template_interval))
12200 else if (unformat (i, "udp_checksum"))
12206 if (collector_address_set == 0)
12208 errmsg ("collector_address required");
12212 if (src_address_set == 0)
12214 errmsg ("src_address required");
12218 M (SET_IPFIX_EXPORTER, mp);
12220 memcpy (mp->collector_address, collector_address.data,
12221 sizeof (collector_address.data));
12222 mp->collector_port = htons ((u16) collector_port);
12223 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12224 mp->vrf_id = htonl (vrf_id);
12225 mp->path_mtu = htonl (path_mtu);
12226 mp->template_interval = htonl (template_interval);
12227 mp->udp_checksum = udp_checksum;
12235 api_set_ipfix_classify_stream (vat_main_t * vam)
12237 unformat_input_t *i = vam->input;
12238 vl_api_set_ipfix_classify_stream_t *mp;
12240 u32 src_port = UDP_DST_PORT_ipfix;
12243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12245 if (unformat (i, "domain %d", &domain_id))
12247 else if (unformat (i, "src_port %d", &src_port))
12251 errmsg ("unknown input `%U'", format_unformat_error, i);
12256 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12258 mp->domain_id = htonl (domain_id);
12259 mp->src_port = htons ((u16) src_port);
12267 api_ipfix_classify_table_add_del (vat_main_t * vam)
12269 unformat_input_t *i = vam->input;
12270 vl_api_ipfix_classify_table_add_del_t *mp;
12272 u32 classify_table_index = ~0;
12274 u8 transport_protocol = 255;
12277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12279 if (unformat (i, "add"))
12281 else if (unformat (i, "del"))
12283 else if (unformat (i, "table %d", &classify_table_index))
12285 else if (unformat (i, "ip4"))
12287 else if (unformat (i, "ip6"))
12289 else if (unformat (i, "tcp"))
12290 transport_protocol = 6;
12291 else if (unformat (i, "udp"))
12292 transport_protocol = 17;
12295 errmsg ("unknown input `%U'", format_unformat_error, i);
12302 errmsg ("expecting: add|del");
12305 if (classify_table_index == ~0)
12307 errmsg ("classifier table not specified");
12310 if (ip_version == 0)
12312 errmsg ("IP version not specified");
12316 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12318 mp->is_add = is_add;
12319 mp->table_id = htonl (classify_table_index);
12320 mp->ip_version = ip_version;
12321 mp->transport_protocol = transport_protocol;
12329 api_get_node_index (vat_main_t * vam)
12331 unformat_input_t *i = vam->input;
12332 vl_api_get_node_index_t *mp;
12336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12338 if (unformat (i, "node %s", &name))
12345 errmsg ("node name required");
12348 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12350 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12354 M (GET_NODE_INDEX, mp);
12355 clib_memcpy (mp->node_name, name, vec_len (name));
12364 api_get_next_index (vat_main_t * vam)
12366 unformat_input_t *i = vam->input;
12367 vl_api_get_next_index_t *mp;
12368 u8 *node_name = 0, *next_node_name = 0;
12371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12373 if (unformat (i, "node-name %s", &node_name))
12375 else if (unformat (i, "next-node-name %s", &next_node_name))
12379 if (node_name == 0)
12381 errmsg ("node name required");
12384 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12386 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12390 if (next_node_name == 0)
12392 errmsg ("next node name required");
12395 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12397 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12401 M (GET_NEXT_INDEX, mp);
12402 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12403 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12404 vec_free (node_name);
12405 vec_free (next_node_name);
12413 api_add_node_next (vat_main_t * vam)
12415 unformat_input_t *i = vam->input;
12416 vl_api_add_node_next_t *mp;
12421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12423 if (unformat (i, "node %s", &name))
12425 else if (unformat (i, "next %s", &next))
12432 errmsg ("node name required");
12435 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12437 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12442 errmsg ("next node required");
12445 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12447 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12451 M (ADD_NODE_NEXT, mp);
12452 clib_memcpy (mp->node_name, name, vec_len (name));
12453 clib_memcpy (mp->next_name, next, vec_len (next));
12463 api_l2tpv3_create_tunnel (vat_main_t * vam)
12465 unformat_input_t *i = vam->input;
12466 ip6_address_t client_address, our_address;
12467 int client_address_set = 0;
12468 int our_address_set = 0;
12469 u32 local_session_id = 0;
12470 u32 remote_session_id = 0;
12471 u64 local_cookie = 0;
12472 u64 remote_cookie = 0;
12473 u8 l2_sublayer_present = 0;
12474 vl_api_l2tpv3_create_tunnel_t *mp;
12477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12479 if (unformat (i, "client_address %U", unformat_ip6_address,
12481 client_address_set = 1;
12482 else if (unformat (i, "our_address %U", unformat_ip6_address,
12484 our_address_set = 1;
12485 else if (unformat (i, "local_session_id %d", &local_session_id))
12487 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12489 else if (unformat (i, "local_cookie %lld", &local_cookie))
12491 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12493 else if (unformat (i, "l2-sublayer-present"))
12494 l2_sublayer_present = 1;
12499 if (client_address_set == 0)
12501 errmsg ("client_address required");
12505 if (our_address_set == 0)
12507 errmsg ("our_address required");
12511 M (L2TPV3_CREATE_TUNNEL, mp);
12513 clib_memcpy (mp->client_address, client_address.as_u8,
12514 sizeof (mp->client_address));
12516 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12518 mp->local_session_id = ntohl (local_session_id);
12519 mp->remote_session_id = ntohl (remote_session_id);
12520 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12521 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12522 mp->l2_sublayer_present = l2_sublayer_present;
12531 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12533 unformat_input_t *i = vam->input;
12535 u8 sw_if_index_set = 0;
12536 u64 new_local_cookie = 0;
12537 u64 new_remote_cookie = 0;
12538 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12544 sw_if_index_set = 1;
12545 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12546 sw_if_index_set = 1;
12547 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12549 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12555 if (sw_if_index_set == 0)
12557 errmsg ("missing interface name or sw_if_index");
12561 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12563 mp->sw_if_index = ntohl (sw_if_index);
12564 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12565 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12573 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12575 unformat_input_t *i = vam->input;
12576 vl_api_l2tpv3_interface_enable_disable_t *mp;
12578 u8 sw_if_index_set = 0;
12579 u8 enable_disable = 1;
12582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12584 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12585 sw_if_index_set = 1;
12586 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12587 sw_if_index_set = 1;
12588 else if (unformat (i, "enable"))
12589 enable_disable = 1;
12590 else if (unformat (i, "disable"))
12591 enable_disable = 0;
12596 if (sw_if_index_set == 0)
12598 errmsg ("missing interface name or sw_if_index");
12602 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12604 mp->sw_if_index = ntohl (sw_if_index);
12605 mp->enable_disable = enable_disable;
12613 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12615 unformat_input_t *i = vam->input;
12616 vl_api_l2tpv3_set_lookup_key_t *mp;
12620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12622 if (unformat (i, "lookup_v6_src"))
12623 key = L2T_LOOKUP_SRC_ADDRESS;
12624 else if (unformat (i, "lookup_v6_dst"))
12625 key = L2T_LOOKUP_DST_ADDRESS;
12626 else if (unformat (i, "lookup_session_id"))
12627 key = L2T_LOOKUP_SESSION_ID;
12632 if (key == (u8) ~ 0)
12634 errmsg ("l2tp session lookup key unset");
12638 M (L2TPV3_SET_LOOKUP_KEY, mp);
12647 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12648 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12650 vat_main_t *vam = &vat_main;
12652 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12653 format_ip6_address, mp->our_address,
12654 format_ip6_address, mp->client_address,
12655 clib_net_to_host_u32 (mp->sw_if_index));
12658 " local cookies %016llx %016llx remote cookie %016llx",
12659 clib_net_to_host_u64 (mp->local_cookie[0]),
12660 clib_net_to_host_u64 (mp->local_cookie[1]),
12661 clib_net_to_host_u64 (mp->remote_cookie));
12663 print (vam->ofp, " local session-id %d remote session-id %d",
12664 clib_net_to_host_u32 (mp->local_session_id),
12665 clib_net_to_host_u32 (mp->remote_session_id));
12667 print (vam->ofp, " l2 specific sublayer %s\n",
12668 mp->l2_sublayer_present ? "preset" : "absent");
12672 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12673 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12675 vat_main_t *vam = &vat_main;
12676 vat_json_node_t *node = NULL;
12677 struct in6_addr addr;
12679 if (VAT_JSON_ARRAY != vam->json_tree.type)
12681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12682 vat_json_init_array (&vam->json_tree);
12684 node = vat_json_array_add (&vam->json_tree);
12686 vat_json_init_object (node);
12688 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12689 vat_json_object_add_ip6 (node, "our_address", addr);
12690 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12691 vat_json_object_add_ip6 (node, "client_address", addr);
12693 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12694 vat_json_init_array (lc);
12695 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12696 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12697 vat_json_object_add_uint (node, "remote_cookie",
12698 clib_net_to_host_u64 (mp->remote_cookie));
12700 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12701 vat_json_object_add_uint (node, "local_session_id",
12702 clib_net_to_host_u32 (mp->local_session_id));
12703 vat_json_object_add_uint (node, "remote_session_id",
12704 clib_net_to_host_u32 (mp->remote_session_id));
12705 vat_json_object_add_string_copy (node, "l2_sublayer",
12706 mp->l2_sublayer_present ? (u8 *) "present"
12707 : (u8 *) "absent");
12711 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12713 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12714 vl_api_control_ping_t *mp_ping;
12717 /* Get list of l2tpv3-tunnel interfaces */
12718 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12721 /* Use a control ping for synchronization */
12722 MPING (CONTROL_PING, mp_ping);
12730 static void vl_api_sw_interface_tap_details_t_handler
12731 (vl_api_sw_interface_tap_details_t * mp)
12733 vat_main_t *vam = &vat_main;
12735 print (vam->ofp, "%-16s %d",
12736 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12739 static void vl_api_sw_interface_tap_details_t_handler_json
12740 (vl_api_sw_interface_tap_details_t * mp)
12742 vat_main_t *vam = &vat_main;
12743 vat_json_node_t *node = NULL;
12745 if (VAT_JSON_ARRAY != vam->json_tree.type)
12747 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12748 vat_json_init_array (&vam->json_tree);
12750 node = vat_json_array_add (&vam->json_tree);
12752 vat_json_init_object (node);
12753 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12754 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12758 api_sw_interface_tap_dump (vat_main_t * vam)
12760 vl_api_sw_interface_tap_dump_t *mp;
12761 vl_api_control_ping_t *mp_ping;
12764 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12765 /* Get list of tap interfaces */
12766 M (SW_INTERFACE_TAP_DUMP, mp);
12769 /* Use a control ping for synchronization */
12770 MPING (CONTROL_PING, mp_ping);
12777 static void vl_api_sw_interface_tap_v2_details_t_handler
12778 (vl_api_sw_interface_tap_v2_details_t * mp)
12780 vat_main_t *vam = &vat_main;
12782 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12783 mp->host_ip4_prefix_len);
12784 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12785 mp->host_ip6_prefix_len);
12788 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12789 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12790 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12791 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12792 mp->host_bridge, ip4, ip6);
12798 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12799 (vl_api_sw_interface_tap_v2_details_t * mp)
12801 vat_main_t *vam = &vat_main;
12802 vat_json_node_t *node = NULL;
12804 if (VAT_JSON_ARRAY != vam->json_tree.type)
12806 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12807 vat_json_init_array (&vam->json_tree);
12809 node = vat_json_array_add (&vam->json_tree);
12811 vat_json_init_object (node);
12812 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12813 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12814 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12815 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12816 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12817 vat_json_object_add_string_copy (node, "host_mac_addr",
12818 format (0, "%U", format_ethernet_address,
12819 &mp->host_mac_addr));
12820 vat_json_object_add_string_copy (node, "host_namespace",
12821 mp->host_namespace);
12822 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12823 vat_json_object_add_string_copy (node, "host_ip4_addr",
12824 format (0, "%U/%d", format_ip4_address,
12826 mp->host_ip4_prefix_len));
12827 vat_json_object_add_string_copy (node, "host_ip6_addr",
12828 format (0, "%U/%d", format_ip6_address,
12830 mp->host_ip6_prefix_len));
12835 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12837 vl_api_sw_interface_tap_v2_dump_t *mp;
12838 vl_api_control_ping_t *mp_ping;
12842 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12843 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12844 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12847 /* Get list of tap interfaces */
12848 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12851 /* Use a control ping for synchronization */
12852 MPING (CONTROL_PING, mp_ping);
12859 static uword unformat_vxlan_decap_next
12860 (unformat_input_t * input, va_list * args)
12862 u32 *result = va_arg (*args, u32 *);
12865 if (unformat (input, "l2"))
12866 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12867 else if (unformat (input, "%d", &tmp))
12875 api_vxlan_add_del_tunnel (vat_main_t * vam)
12877 unformat_input_t *line_input = vam->input;
12878 vl_api_vxlan_add_del_tunnel_t *mp;
12879 ip46_address_t src, dst;
12881 u8 ipv4_set = 0, ipv6_set = 0;
12886 u32 mcast_sw_if_index = ~0;
12887 u32 encap_vrf_id = 0;
12888 u32 decap_next_index = ~0;
12892 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12893 memset (&src, 0, sizeof src);
12894 memset (&dst, 0, sizeof dst);
12896 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12898 if (unformat (line_input, "del"))
12900 else if (unformat (line_input, "instance %d", &instance))
12903 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12909 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12915 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12921 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12926 else if (unformat (line_input, "group %U %U",
12927 unformat_ip4_address, &dst.ip4,
12928 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12930 grp_set = dst_set = 1;
12933 else if (unformat (line_input, "group %U",
12934 unformat_ip4_address, &dst.ip4))
12936 grp_set = dst_set = 1;
12939 else if (unformat (line_input, "group %U %U",
12940 unformat_ip6_address, &dst.ip6,
12941 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12943 grp_set = dst_set = 1;
12946 else if (unformat (line_input, "group %U",
12947 unformat_ip6_address, &dst.ip6))
12949 grp_set = dst_set = 1;
12953 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12955 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12957 else if (unformat (line_input, "decap-next %U",
12958 unformat_vxlan_decap_next, &decap_next_index))
12960 else if (unformat (line_input, "vni %d", &vni))
12964 errmsg ("parse error '%U'", format_unformat_error, line_input);
12971 errmsg ("tunnel src address not specified");
12976 errmsg ("tunnel dst address not specified");
12980 if (grp_set && !ip46_address_is_multicast (&dst))
12982 errmsg ("tunnel group address not multicast");
12985 if (grp_set && mcast_sw_if_index == ~0)
12987 errmsg ("tunnel nonexistent multicast device");
12990 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12992 errmsg ("tunnel dst address must be unicast");
12997 if (ipv4_set && ipv6_set)
12999 errmsg ("both IPv4 and IPv6 addresses specified");
13003 if ((vni == 0) || (vni >> 24))
13005 errmsg ("vni not specified or out of range");
13009 M (VXLAN_ADD_DEL_TUNNEL, mp);
13013 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13014 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13018 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13019 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13022 mp->instance = htonl (instance);
13023 mp->encap_vrf_id = ntohl (encap_vrf_id);
13024 mp->decap_next_index = ntohl (decap_next_index);
13025 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13026 mp->vni = ntohl (vni);
13027 mp->is_add = is_add;
13028 mp->is_ipv6 = ipv6_set;
13035 static void vl_api_vxlan_tunnel_details_t_handler
13036 (vl_api_vxlan_tunnel_details_t * mp)
13038 vat_main_t *vam = &vat_main;
13039 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13040 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13042 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13043 ntohl (mp->sw_if_index),
13044 ntohl (mp->instance),
13045 format_ip46_address, &src, IP46_TYPE_ANY,
13046 format_ip46_address, &dst, IP46_TYPE_ANY,
13047 ntohl (mp->encap_vrf_id),
13048 ntohl (mp->decap_next_index), ntohl (mp->vni),
13049 ntohl (mp->mcast_sw_if_index));
13052 static void vl_api_vxlan_tunnel_details_t_handler_json
13053 (vl_api_vxlan_tunnel_details_t * mp)
13055 vat_main_t *vam = &vat_main;
13056 vat_json_node_t *node = NULL;
13058 if (VAT_JSON_ARRAY != vam->json_tree.type)
13060 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13061 vat_json_init_array (&vam->json_tree);
13063 node = vat_json_array_add (&vam->json_tree);
13065 vat_json_init_object (node);
13066 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13068 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13072 struct in6_addr ip6;
13074 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13075 vat_json_object_add_ip6 (node, "src_address", ip6);
13076 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13077 vat_json_object_add_ip6 (node, "dst_address", ip6);
13081 struct in_addr ip4;
13083 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13084 vat_json_object_add_ip4 (node, "src_address", ip4);
13085 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13086 vat_json_object_add_ip4 (node, "dst_address", ip4);
13088 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13089 vat_json_object_add_uint (node, "decap_next_index",
13090 ntohl (mp->decap_next_index));
13091 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13092 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13093 vat_json_object_add_uint (node, "mcast_sw_if_index",
13094 ntohl (mp->mcast_sw_if_index));
13098 api_vxlan_tunnel_dump (vat_main_t * vam)
13100 unformat_input_t *i = vam->input;
13101 vl_api_vxlan_tunnel_dump_t *mp;
13102 vl_api_control_ping_t *mp_ping;
13104 u8 sw_if_index_set = 0;
13107 /* Parse args required to build the message */
13108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13110 if (unformat (i, "sw_if_index %d", &sw_if_index))
13111 sw_if_index_set = 1;
13116 if (sw_if_index_set == 0)
13121 if (!vam->json_output)
13123 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13124 "sw_if_index", "instance", "src_address", "dst_address",
13125 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13128 /* Get list of vxlan-tunnel interfaces */
13129 M (VXLAN_TUNNEL_DUMP, mp);
13131 mp->sw_if_index = htonl (sw_if_index);
13135 /* Use a control ping for synchronization */
13136 MPING (CONTROL_PING, mp_ping);
13143 static uword unformat_geneve_decap_next
13144 (unformat_input_t * input, va_list * args)
13146 u32 *result = va_arg (*args, u32 *);
13149 if (unformat (input, "l2"))
13150 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13151 else if (unformat (input, "%d", &tmp))
13159 api_geneve_add_del_tunnel (vat_main_t * vam)
13161 unformat_input_t *line_input = vam->input;
13162 vl_api_geneve_add_del_tunnel_t *mp;
13163 ip46_address_t src, dst;
13165 u8 ipv4_set = 0, ipv6_set = 0;
13169 u32 mcast_sw_if_index = ~0;
13170 u32 encap_vrf_id = 0;
13171 u32 decap_next_index = ~0;
13175 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13176 memset (&src, 0, sizeof src);
13177 memset (&dst, 0, sizeof dst);
13179 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13181 if (unformat (line_input, "del"))
13184 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13190 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13196 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13202 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13207 else if (unformat (line_input, "group %U %U",
13208 unformat_ip4_address, &dst.ip4,
13209 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13211 grp_set = dst_set = 1;
13214 else if (unformat (line_input, "group %U",
13215 unformat_ip4_address, &dst.ip4))
13217 grp_set = dst_set = 1;
13220 else if (unformat (line_input, "group %U %U",
13221 unformat_ip6_address, &dst.ip6,
13222 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13224 grp_set = dst_set = 1;
13227 else if (unformat (line_input, "group %U",
13228 unformat_ip6_address, &dst.ip6))
13230 grp_set = dst_set = 1;
13234 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13236 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13238 else if (unformat (line_input, "decap-next %U",
13239 unformat_geneve_decap_next, &decap_next_index))
13241 else if (unformat (line_input, "vni %d", &vni))
13245 errmsg ("parse error '%U'", format_unformat_error, line_input);
13252 errmsg ("tunnel src address not specified");
13257 errmsg ("tunnel dst address not specified");
13261 if (grp_set && !ip46_address_is_multicast (&dst))
13263 errmsg ("tunnel group address not multicast");
13266 if (grp_set && mcast_sw_if_index == ~0)
13268 errmsg ("tunnel nonexistent multicast device");
13271 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13273 errmsg ("tunnel dst address must be unicast");
13278 if (ipv4_set && ipv6_set)
13280 errmsg ("both IPv4 and IPv6 addresses specified");
13284 if ((vni == 0) || (vni >> 24))
13286 errmsg ("vni not specified or out of range");
13290 M (GENEVE_ADD_DEL_TUNNEL, mp);
13294 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13295 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13299 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13300 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13302 mp->encap_vrf_id = ntohl (encap_vrf_id);
13303 mp->decap_next_index = ntohl (decap_next_index);
13304 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13305 mp->vni = ntohl (vni);
13306 mp->is_add = is_add;
13307 mp->is_ipv6 = ipv6_set;
13314 static void vl_api_geneve_tunnel_details_t_handler
13315 (vl_api_geneve_tunnel_details_t * mp)
13317 vat_main_t *vam = &vat_main;
13318 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13319 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13321 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13322 ntohl (mp->sw_if_index),
13323 format_ip46_address, &src, IP46_TYPE_ANY,
13324 format_ip46_address, &dst, IP46_TYPE_ANY,
13325 ntohl (mp->encap_vrf_id),
13326 ntohl (mp->decap_next_index), ntohl (mp->vni),
13327 ntohl (mp->mcast_sw_if_index));
13330 static void vl_api_geneve_tunnel_details_t_handler_json
13331 (vl_api_geneve_tunnel_details_t * mp)
13333 vat_main_t *vam = &vat_main;
13334 vat_json_node_t *node = NULL;
13336 if (VAT_JSON_ARRAY != vam->json_tree.type)
13338 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13339 vat_json_init_array (&vam->json_tree);
13341 node = vat_json_array_add (&vam->json_tree);
13343 vat_json_init_object (node);
13344 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13347 struct in6_addr ip6;
13349 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13350 vat_json_object_add_ip6 (node, "src_address", ip6);
13351 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13352 vat_json_object_add_ip6 (node, "dst_address", ip6);
13356 struct in_addr ip4;
13358 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13359 vat_json_object_add_ip4 (node, "src_address", ip4);
13360 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13361 vat_json_object_add_ip4 (node, "dst_address", ip4);
13363 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13364 vat_json_object_add_uint (node, "decap_next_index",
13365 ntohl (mp->decap_next_index));
13366 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13367 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13368 vat_json_object_add_uint (node, "mcast_sw_if_index",
13369 ntohl (mp->mcast_sw_if_index));
13373 api_geneve_tunnel_dump (vat_main_t * vam)
13375 unformat_input_t *i = vam->input;
13376 vl_api_geneve_tunnel_dump_t *mp;
13377 vl_api_control_ping_t *mp_ping;
13379 u8 sw_if_index_set = 0;
13382 /* Parse args required to build the message */
13383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13385 if (unformat (i, "sw_if_index %d", &sw_if_index))
13386 sw_if_index_set = 1;
13391 if (sw_if_index_set == 0)
13396 if (!vam->json_output)
13398 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13399 "sw_if_index", "local_address", "remote_address",
13400 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13403 /* Get list of geneve-tunnel interfaces */
13404 M (GENEVE_TUNNEL_DUMP, mp);
13406 mp->sw_if_index = htonl (sw_if_index);
13410 /* Use a control ping for synchronization */
13411 M (CONTROL_PING, mp_ping);
13419 api_gre_add_del_tunnel (vat_main_t * vam)
13421 unformat_input_t *line_input = vam->input;
13422 vl_api_gre_add_del_tunnel_t *mp;
13423 ip4_address_t src4, dst4;
13424 ip6_address_t src6, dst6;
13428 u8 t_type = GRE_TUNNEL_TYPE_L3;
13431 u32 outer_fib_id = 0;
13432 u32 session_id = 0;
13436 memset (&src4, 0, sizeof src4);
13437 memset (&dst4, 0, sizeof dst4);
13438 memset (&src6, 0, sizeof src6);
13439 memset (&dst6, 0, sizeof dst6);
13441 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13443 if (unformat (line_input, "del"))
13445 else if (unformat (line_input, "instance %d", &instance))
13447 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13452 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13457 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13462 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13467 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13469 else if (unformat (line_input, "teb"))
13470 t_type = GRE_TUNNEL_TYPE_TEB;
13471 else if (unformat (line_input, "erspan %d", &session_id))
13472 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13475 errmsg ("parse error '%U'", format_unformat_error, line_input);
13482 errmsg ("tunnel src address not specified");
13487 errmsg ("tunnel dst address not specified");
13490 if (ipv4_set && ipv6_set)
13492 errmsg ("both IPv4 and IPv6 addresses specified");
13497 M (GRE_ADD_DEL_TUNNEL, mp);
13501 clib_memcpy (&mp->src_address, &src4, 4);
13502 clib_memcpy (&mp->dst_address, &dst4, 4);
13506 clib_memcpy (&mp->src_address, &src6, 16);
13507 clib_memcpy (&mp->dst_address, &dst6, 16);
13509 mp->instance = htonl (instance);
13510 mp->outer_fib_id = htonl (outer_fib_id);
13511 mp->is_add = is_add;
13512 mp->session_id = htons ((u16) session_id);
13513 mp->tunnel_type = t_type;
13514 mp->is_ipv6 = ipv6_set;
13521 static void vl_api_gre_tunnel_details_t_handler
13522 (vl_api_gre_tunnel_details_t * mp)
13524 vat_main_t *vam = &vat_main;
13525 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13526 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13528 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13529 ntohl (mp->sw_if_index),
13530 ntohl (mp->instance),
13531 format_ip46_address, &src, IP46_TYPE_ANY,
13532 format_ip46_address, &dst, IP46_TYPE_ANY,
13533 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13536 static void vl_api_gre_tunnel_details_t_handler_json
13537 (vl_api_gre_tunnel_details_t * mp)
13539 vat_main_t *vam = &vat_main;
13540 vat_json_node_t *node = NULL;
13541 struct in_addr ip4;
13542 struct in6_addr ip6;
13544 if (VAT_JSON_ARRAY != vam->json_tree.type)
13546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13547 vat_json_init_array (&vam->json_tree);
13549 node = vat_json_array_add (&vam->json_tree);
13551 vat_json_init_object (node);
13552 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13553 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13556 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13557 vat_json_object_add_ip4 (node, "src_address", ip4);
13558 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13559 vat_json_object_add_ip4 (node, "dst_address", ip4);
13563 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13564 vat_json_object_add_ip6 (node, "src_address", ip6);
13565 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13566 vat_json_object_add_ip6 (node, "dst_address", ip6);
13568 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13569 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13570 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13571 vat_json_object_add_uint (node, "session_id", mp->session_id);
13575 api_gre_tunnel_dump (vat_main_t * vam)
13577 unformat_input_t *i = vam->input;
13578 vl_api_gre_tunnel_dump_t *mp;
13579 vl_api_control_ping_t *mp_ping;
13581 u8 sw_if_index_set = 0;
13584 /* Parse args required to build the message */
13585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13587 if (unformat (i, "sw_if_index %d", &sw_if_index))
13588 sw_if_index_set = 1;
13593 if (sw_if_index_set == 0)
13598 if (!vam->json_output)
13600 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13601 "sw_if_index", "instance", "src_address", "dst_address",
13602 "tunnel_type", "outer_fib_id", "session_id");
13605 /* Get list of gre-tunnel interfaces */
13606 M (GRE_TUNNEL_DUMP, mp);
13608 mp->sw_if_index = htonl (sw_if_index);
13612 /* Use a control ping for synchronization */
13613 MPING (CONTROL_PING, mp_ping);
13621 api_l2_fib_clear_table (vat_main_t * vam)
13623 // unformat_input_t * i = vam->input;
13624 vl_api_l2_fib_clear_table_t *mp;
13627 M (L2_FIB_CLEAR_TABLE, mp);
13635 api_l2_interface_efp_filter (vat_main_t * vam)
13637 unformat_input_t *i = vam->input;
13638 vl_api_l2_interface_efp_filter_t *mp;
13641 u8 sw_if_index_set = 0;
13644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13647 sw_if_index_set = 1;
13648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13649 sw_if_index_set = 1;
13650 else if (unformat (i, "enable"))
13652 else if (unformat (i, "disable"))
13656 clib_warning ("parse error '%U'", format_unformat_error, i);
13661 if (sw_if_index_set == 0)
13663 errmsg ("missing sw_if_index");
13667 M (L2_INTERFACE_EFP_FILTER, mp);
13669 mp->sw_if_index = ntohl (sw_if_index);
13670 mp->enable_disable = enable;
13677 #define foreach_vtr_op \
13678 _("disable", L2_VTR_DISABLED) \
13679 _("push-1", L2_VTR_PUSH_1) \
13680 _("push-2", L2_VTR_PUSH_2) \
13681 _("pop-1", L2_VTR_POP_1) \
13682 _("pop-2", L2_VTR_POP_2) \
13683 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13684 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13685 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13686 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13689 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13691 unformat_input_t *i = vam->input;
13692 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13694 u8 sw_if_index_set = 0;
13697 u32 push_dot1q = 1;
13702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13704 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13705 sw_if_index_set = 1;
13706 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13707 sw_if_index_set = 1;
13708 else if (unformat (i, "vtr_op %d", &vtr_op))
13710 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13713 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13715 else if (unformat (i, "tag1 %d", &tag1))
13717 else if (unformat (i, "tag2 %d", &tag2))
13721 clib_warning ("parse error '%U'", format_unformat_error, i);
13726 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13728 errmsg ("missing vtr operation or sw_if_index");
13732 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13733 mp->sw_if_index = ntohl (sw_if_index);
13734 mp->vtr_op = ntohl (vtr_op);
13735 mp->push_dot1q = ntohl (push_dot1q);
13736 mp->tag1 = ntohl (tag1);
13737 mp->tag2 = ntohl (tag2);
13745 api_create_vhost_user_if (vat_main_t * vam)
13747 unformat_input_t *i = vam->input;
13748 vl_api_create_vhost_user_if_t *mp;
13751 u8 file_name_set = 0;
13752 u32 custom_dev_instance = ~0;
13754 u8 use_custom_mac = 0;
13758 /* Shut up coverity */
13759 memset (hwaddr, 0, sizeof (hwaddr));
13761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13763 if (unformat (i, "socket %s", &file_name))
13767 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13769 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13770 use_custom_mac = 1;
13771 else if (unformat (i, "server"))
13773 else if (unformat (i, "tag %s", &tag))
13779 if (file_name_set == 0)
13781 errmsg ("missing socket file name");
13785 if (vec_len (file_name) > 255)
13787 errmsg ("socket file name too long");
13790 vec_add1 (file_name, 0);
13792 M (CREATE_VHOST_USER_IF, mp);
13794 mp->is_server = is_server;
13795 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13796 vec_free (file_name);
13797 if (custom_dev_instance != ~0)
13800 mp->custom_dev_instance = ntohl (custom_dev_instance);
13802 mp->use_custom_mac = use_custom_mac;
13803 clib_memcpy (mp->mac_address, hwaddr, 6);
13805 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13814 api_modify_vhost_user_if (vat_main_t * vam)
13816 unformat_input_t *i = vam->input;
13817 vl_api_modify_vhost_user_if_t *mp;
13820 u8 file_name_set = 0;
13821 u32 custom_dev_instance = ~0;
13822 u8 sw_if_index_set = 0;
13823 u32 sw_if_index = (u32) ~ 0;
13826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13828 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13829 sw_if_index_set = 1;
13830 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13831 sw_if_index_set = 1;
13832 else if (unformat (i, "socket %s", &file_name))
13836 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13838 else if (unformat (i, "server"))
13844 if (sw_if_index_set == 0)
13846 errmsg ("missing sw_if_index or interface name");
13850 if (file_name_set == 0)
13852 errmsg ("missing socket file name");
13856 if (vec_len (file_name) > 255)
13858 errmsg ("socket file name too long");
13861 vec_add1 (file_name, 0);
13863 M (MODIFY_VHOST_USER_IF, mp);
13865 mp->sw_if_index = ntohl (sw_if_index);
13866 mp->is_server = is_server;
13867 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13868 vec_free (file_name);
13869 if (custom_dev_instance != ~0)
13872 mp->custom_dev_instance = ntohl (custom_dev_instance);
13881 api_delete_vhost_user_if (vat_main_t * vam)
13883 unformat_input_t *i = vam->input;
13884 vl_api_delete_vhost_user_if_t *mp;
13885 u32 sw_if_index = ~0;
13886 u8 sw_if_index_set = 0;
13889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13892 sw_if_index_set = 1;
13893 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13894 sw_if_index_set = 1;
13899 if (sw_if_index_set == 0)
13901 errmsg ("missing sw_if_index or interface name");
13906 M (DELETE_VHOST_USER_IF, mp);
13908 mp->sw_if_index = ntohl (sw_if_index);
13915 static void vl_api_sw_interface_vhost_user_details_t_handler
13916 (vl_api_sw_interface_vhost_user_details_t * mp)
13918 vat_main_t *vam = &vat_main;
13920 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13921 (char *) mp->interface_name,
13922 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13923 clib_net_to_host_u64 (mp->features), mp->is_server,
13924 ntohl (mp->num_regions), (char *) mp->sock_filename);
13925 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13928 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13929 (vl_api_sw_interface_vhost_user_details_t * mp)
13931 vat_main_t *vam = &vat_main;
13932 vat_json_node_t *node = NULL;
13934 if (VAT_JSON_ARRAY != vam->json_tree.type)
13936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13937 vat_json_init_array (&vam->json_tree);
13939 node = vat_json_array_add (&vam->json_tree);
13941 vat_json_init_object (node);
13942 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13943 vat_json_object_add_string_copy (node, "interface_name",
13944 mp->interface_name);
13945 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13946 ntohl (mp->virtio_net_hdr_sz));
13947 vat_json_object_add_uint (node, "features",
13948 clib_net_to_host_u64 (mp->features));
13949 vat_json_object_add_uint (node, "is_server", mp->is_server);
13950 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13951 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13952 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13956 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13958 vl_api_sw_interface_vhost_user_dump_t *mp;
13959 vl_api_control_ping_t *mp_ping;
13962 "Interface name idx hdr_sz features server regions filename");
13964 /* Get list of vhost-user interfaces */
13965 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13968 /* Use a control ping for synchronization */
13969 MPING (CONTROL_PING, mp_ping);
13977 api_show_version (vat_main_t * vam)
13979 vl_api_show_version_t *mp;
13982 M (SHOW_VERSION, mp);
13991 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13993 unformat_input_t *line_input = vam->input;
13994 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13995 ip4_address_t local4, remote4;
13996 ip6_address_t local6, remote6;
13998 u8 ipv4_set = 0, ipv6_set = 0;
14002 u32 mcast_sw_if_index = ~0;
14003 u32 encap_vrf_id = 0;
14004 u32 decap_vrf_id = 0;
14010 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14011 memset (&local4, 0, sizeof local4);
14012 memset (&remote4, 0, sizeof remote4);
14013 memset (&local6, 0, sizeof local6);
14014 memset (&remote6, 0, sizeof remote6);
14016 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14018 if (unformat (line_input, "del"))
14020 else if (unformat (line_input, "local %U",
14021 unformat_ip4_address, &local4))
14026 else if (unformat (line_input, "remote %U",
14027 unformat_ip4_address, &remote4))
14032 else if (unformat (line_input, "local %U",
14033 unformat_ip6_address, &local6))
14038 else if (unformat (line_input, "remote %U",
14039 unformat_ip6_address, &remote6))
14044 else if (unformat (line_input, "group %U %U",
14045 unformat_ip4_address, &remote4,
14046 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14048 grp_set = remote_set = 1;
14051 else if (unformat (line_input, "group %U",
14052 unformat_ip4_address, &remote4))
14054 grp_set = remote_set = 1;
14057 else if (unformat (line_input, "group %U %U",
14058 unformat_ip6_address, &remote6,
14059 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14061 grp_set = remote_set = 1;
14064 else if (unformat (line_input, "group %U",
14065 unformat_ip6_address, &remote6))
14067 grp_set = remote_set = 1;
14071 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14073 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14075 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14077 else if (unformat (line_input, "vni %d", &vni))
14079 else if (unformat (line_input, "next-ip4"))
14081 else if (unformat (line_input, "next-ip6"))
14083 else if (unformat (line_input, "next-ethernet"))
14085 else if (unformat (line_input, "next-nsh"))
14089 errmsg ("parse error '%U'", format_unformat_error, line_input);
14094 if (local_set == 0)
14096 errmsg ("tunnel local address not specified");
14099 if (remote_set == 0)
14101 errmsg ("tunnel remote address not specified");
14104 if (grp_set && mcast_sw_if_index == ~0)
14106 errmsg ("tunnel nonexistent multicast device");
14109 if (ipv4_set && ipv6_set)
14111 errmsg ("both IPv4 and IPv6 addresses specified");
14117 errmsg ("vni not specified");
14121 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14126 clib_memcpy (&mp->local, &local6, sizeof (local6));
14127 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14131 clib_memcpy (&mp->local, &local4, sizeof (local4));
14132 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14135 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14136 mp->encap_vrf_id = ntohl (encap_vrf_id);
14137 mp->decap_vrf_id = ntohl (decap_vrf_id);
14138 mp->protocol = protocol;
14139 mp->vni = ntohl (vni);
14140 mp->is_add = is_add;
14141 mp->is_ipv6 = ipv6_set;
14148 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14149 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14151 vat_main_t *vam = &vat_main;
14152 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14153 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14155 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14156 ntohl (mp->sw_if_index),
14157 format_ip46_address, &local, IP46_TYPE_ANY,
14158 format_ip46_address, &remote, IP46_TYPE_ANY,
14159 ntohl (mp->vni), mp->protocol,
14160 ntohl (mp->mcast_sw_if_index),
14161 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14165 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14166 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14168 vat_main_t *vam = &vat_main;
14169 vat_json_node_t *node = NULL;
14170 struct in_addr ip4;
14171 struct in6_addr ip6;
14173 if (VAT_JSON_ARRAY != vam->json_tree.type)
14175 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14176 vat_json_init_array (&vam->json_tree);
14178 node = vat_json_array_add (&vam->json_tree);
14180 vat_json_init_object (node);
14181 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14184 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14185 vat_json_object_add_ip6 (node, "local", ip6);
14186 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14187 vat_json_object_add_ip6 (node, "remote", ip6);
14191 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14192 vat_json_object_add_ip4 (node, "local", ip4);
14193 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14194 vat_json_object_add_ip4 (node, "remote", ip4);
14196 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14197 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14198 vat_json_object_add_uint (node, "mcast_sw_if_index",
14199 ntohl (mp->mcast_sw_if_index));
14200 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14201 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14202 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14206 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14208 unformat_input_t *i = vam->input;
14209 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14210 vl_api_control_ping_t *mp_ping;
14212 u8 sw_if_index_set = 0;
14215 /* Parse args required to build the message */
14216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14218 if (unformat (i, "sw_if_index %d", &sw_if_index))
14219 sw_if_index_set = 1;
14224 if (sw_if_index_set == 0)
14229 if (!vam->json_output)
14231 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14232 "sw_if_index", "local", "remote", "vni",
14233 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14236 /* Get list of vxlan-tunnel interfaces */
14237 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14239 mp->sw_if_index = htonl (sw_if_index);
14243 /* Use a control ping for synchronization */
14244 MPING (CONTROL_PING, mp_ping);
14251 static void vl_api_l2_fib_table_details_t_handler
14252 (vl_api_l2_fib_table_details_t * mp)
14254 vat_main_t *vam = &vat_main;
14256 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14258 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14259 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14263 static void vl_api_l2_fib_table_details_t_handler_json
14264 (vl_api_l2_fib_table_details_t * mp)
14266 vat_main_t *vam = &vat_main;
14267 vat_json_node_t *node = NULL;
14269 if (VAT_JSON_ARRAY != vam->json_tree.type)
14271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14272 vat_json_init_array (&vam->json_tree);
14274 node = vat_json_array_add (&vam->json_tree);
14276 vat_json_init_object (node);
14277 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14278 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14279 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14280 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14281 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14282 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14286 api_l2_fib_table_dump (vat_main_t * vam)
14288 unformat_input_t *i = vam->input;
14289 vl_api_l2_fib_table_dump_t *mp;
14290 vl_api_control_ping_t *mp_ping;
14295 /* Parse args required to build the message */
14296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14298 if (unformat (i, "bd_id %d", &bd_id))
14304 if (bd_id_set == 0)
14306 errmsg ("missing bridge domain");
14310 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14312 /* Get list of l2 fib entries */
14313 M (L2_FIB_TABLE_DUMP, mp);
14315 mp->bd_id = ntohl (bd_id);
14318 /* Use a control ping for synchronization */
14319 MPING (CONTROL_PING, mp_ping);
14328 api_interface_name_renumber (vat_main_t * vam)
14330 unformat_input_t *line_input = vam->input;
14331 vl_api_interface_name_renumber_t *mp;
14332 u32 sw_if_index = ~0;
14333 u32 new_show_dev_instance = ~0;
14336 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14338 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14341 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14343 else if (unformat (line_input, "new_show_dev_instance %d",
14344 &new_show_dev_instance))
14350 if (sw_if_index == ~0)
14352 errmsg ("missing interface name or sw_if_index");
14356 if (new_show_dev_instance == ~0)
14358 errmsg ("missing new_show_dev_instance");
14362 M (INTERFACE_NAME_RENUMBER, mp);
14364 mp->sw_if_index = ntohl (sw_if_index);
14365 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14373 api_ip_probe_neighbor (vat_main_t * vam)
14375 unformat_input_t *i = vam->input;
14376 vl_api_ip_probe_neighbor_t *mp;
14384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14386 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14388 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14390 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14392 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14403 errmsg ("missing interface");
14409 errmsg ("missing addresses");
14413 M (IP_PROBE_NEIGHBOR, mp);
14415 mp->sw_if_index = ntohl (sw_if_index);
14416 mp->is_ipv6 = is_ipv6;
14417 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14425 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14427 unformat_input_t *i = vam->input;
14428 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14429 u8 mode = IP_SCAN_V46_NEIGHBORS;
14430 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14435 if (unformat (i, "ip4"))
14436 mode = IP_SCAN_V4_NEIGHBORS;
14437 else if (unformat (i, "ip6"))
14438 mode = IP_SCAN_V6_NEIGHBORS;
14439 if (unformat (i, "both"))
14440 mode = IP_SCAN_V46_NEIGHBORS;
14441 else if (unformat (i, "disable"))
14442 mode = IP_SCAN_DISABLED;
14443 else if (unformat (i, "interval %d", &interval))
14445 else if (unformat (i, "max-time %d", &time))
14447 else if (unformat (i, "max-update %d", &update))
14449 else if (unformat (i, "delay %d", &delay))
14451 else if (unformat (i, "stale %d", &stale))
14457 if (interval > 255)
14459 errmsg ("interval cannot exceed 255 minutes.");
14464 errmsg ("max-time cannot exceed 255 usec.");
14469 errmsg ("max-update cannot exceed 255.");
14474 errmsg ("delay cannot exceed 255 msec.");
14479 errmsg ("stale cannot exceed 255 minutes.");
14483 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14485 mp->scan_interval = interval;
14486 mp->max_proc_time = time;
14487 mp->max_update = update;
14488 mp->scan_int_delay = delay;
14489 mp->stale_threshold = stale;
14497 api_want_ip4_arp_events (vat_main_t * vam)
14499 unformat_input_t *line_input = vam->input;
14500 vl_api_want_ip4_arp_events_t *mp;
14501 ip4_address_t address;
14502 int address_set = 0;
14503 u32 enable_disable = 1;
14506 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14508 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14510 else if (unformat (line_input, "del"))
14511 enable_disable = 0;
14516 if (address_set == 0)
14518 errmsg ("missing addresses");
14522 M (WANT_IP4_ARP_EVENTS, mp);
14523 mp->enable_disable = enable_disable;
14524 mp->pid = htonl (getpid ());
14525 mp->address = address.as_u32;
14533 api_want_ip6_nd_events (vat_main_t * vam)
14535 unformat_input_t *line_input = vam->input;
14536 vl_api_want_ip6_nd_events_t *mp;
14537 ip6_address_t address;
14538 int address_set = 0;
14539 u32 enable_disable = 1;
14542 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14544 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14546 else if (unformat (line_input, "del"))
14547 enable_disable = 0;
14552 if (address_set == 0)
14554 errmsg ("missing addresses");
14558 M (WANT_IP6_ND_EVENTS, mp);
14559 mp->enable_disable = enable_disable;
14560 mp->pid = htonl (getpid ());
14561 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14569 api_want_l2_macs_events (vat_main_t * vam)
14571 unformat_input_t *line_input = vam->input;
14572 vl_api_want_l2_macs_events_t *mp;
14573 u8 enable_disable = 1;
14574 u32 scan_delay = 0;
14575 u32 max_macs_in_event = 0;
14576 u32 learn_limit = 0;
14579 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14581 if (unformat (line_input, "learn-limit %d", &learn_limit))
14583 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14585 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14587 else if (unformat (line_input, "disable"))
14588 enable_disable = 0;
14593 M (WANT_L2_MACS_EVENTS, mp);
14594 mp->enable_disable = enable_disable;
14595 mp->pid = htonl (getpid ());
14596 mp->learn_limit = htonl (learn_limit);
14597 mp->scan_delay = (u8) scan_delay;
14598 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14605 api_input_acl_set_interface (vat_main_t * vam)
14607 unformat_input_t *i = vam->input;
14608 vl_api_input_acl_set_interface_t *mp;
14610 int sw_if_index_set;
14611 u32 ip4_table_index = ~0;
14612 u32 ip6_table_index = ~0;
14613 u32 l2_table_index = ~0;
14617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14619 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14620 sw_if_index_set = 1;
14621 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14622 sw_if_index_set = 1;
14623 else if (unformat (i, "del"))
14625 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14627 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14629 else if (unformat (i, "l2-table %d", &l2_table_index))
14633 clib_warning ("parse error '%U'", format_unformat_error, i);
14638 if (sw_if_index_set == 0)
14640 errmsg ("missing interface name or sw_if_index");
14644 M (INPUT_ACL_SET_INTERFACE, mp);
14646 mp->sw_if_index = ntohl (sw_if_index);
14647 mp->ip4_table_index = ntohl (ip4_table_index);
14648 mp->ip6_table_index = ntohl (ip6_table_index);
14649 mp->l2_table_index = ntohl (l2_table_index);
14650 mp->is_add = is_add;
14658 api_output_acl_set_interface (vat_main_t * vam)
14660 unformat_input_t *i = vam->input;
14661 vl_api_output_acl_set_interface_t *mp;
14663 int sw_if_index_set;
14664 u32 ip4_table_index = ~0;
14665 u32 ip6_table_index = ~0;
14666 u32 l2_table_index = ~0;
14670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14672 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14673 sw_if_index_set = 1;
14674 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14675 sw_if_index_set = 1;
14676 else if (unformat (i, "del"))
14678 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14680 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14682 else if (unformat (i, "l2-table %d", &l2_table_index))
14686 clib_warning ("parse error '%U'", format_unformat_error, i);
14691 if (sw_if_index_set == 0)
14693 errmsg ("missing interface name or sw_if_index");
14697 M (OUTPUT_ACL_SET_INTERFACE, mp);
14699 mp->sw_if_index = ntohl (sw_if_index);
14700 mp->ip4_table_index = ntohl (ip4_table_index);
14701 mp->ip6_table_index = ntohl (ip6_table_index);
14702 mp->l2_table_index = ntohl (l2_table_index);
14703 mp->is_add = is_add;
14711 api_ip_address_dump (vat_main_t * vam)
14713 unformat_input_t *i = vam->input;
14714 vl_api_ip_address_dump_t *mp;
14715 vl_api_control_ping_t *mp_ping;
14716 u32 sw_if_index = ~0;
14717 u8 sw_if_index_set = 0;
14722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14724 if (unformat (i, "sw_if_index %d", &sw_if_index))
14725 sw_if_index_set = 1;
14727 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14728 sw_if_index_set = 1;
14729 else if (unformat (i, "ipv4"))
14731 else if (unformat (i, "ipv6"))
14737 if (ipv4_set && ipv6_set)
14739 errmsg ("ipv4 and ipv6 flags cannot be both set");
14743 if ((!ipv4_set) && (!ipv6_set))
14745 errmsg ("no ipv4 nor ipv6 flag set");
14749 if (sw_if_index_set == 0)
14751 errmsg ("missing interface name or sw_if_index");
14755 vam->current_sw_if_index = sw_if_index;
14756 vam->is_ipv6 = ipv6_set;
14758 M (IP_ADDRESS_DUMP, mp);
14759 mp->sw_if_index = ntohl (sw_if_index);
14760 mp->is_ipv6 = ipv6_set;
14763 /* Use a control ping for synchronization */
14764 MPING (CONTROL_PING, mp_ping);
14772 api_ip_dump (vat_main_t * vam)
14774 vl_api_ip_dump_t *mp;
14775 vl_api_control_ping_t *mp_ping;
14776 unformat_input_t *in = vam->input;
14783 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14785 if (unformat (in, "ipv4"))
14787 else if (unformat (in, "ipv6"))
14793 if (ipv4_set && ipv6_set)
14795 errmsg ("ipv4 and ipv6 flags cannot be both set");
14799 if ((!ipv4_set) && (!ipv6_set))
14801 errmsg ("no ipv4 nor ipv6 flag set");
14805 is_ipv6 = ipv6_set;
14806 vam->is_ipv6 = is_ipv6;
14808 /* free old data */
14809 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14811 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14813 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14816 mp->is_ipv6 = ipv6_set;
14819 /* Use a control ping for synchronization */
14820 MPING (CONTROL_PING, mp_ping);
14828 api_ipsec_spd_add_del (vat_main_t * vam)
14830 unformat_input_t *i = vam->input;
14831 vl_api_ipsec_spd_add_del_t *mp;
14836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14838 if (unformat (i, "spd_id %d", &spd_id))
14840 else if (unformat (i, "del"))
14844 clib_warning ("parse error '%U'", format_unformat_error, i);
14850 errmsg ("spd_id must be set");
14854 M (IPSEC_SPD_ADD_DEL, mp);
14856 mp->spd_id = ntohl (spd_id);
14857 mp->is_add = is_add;
14865 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14867 unformat_input_t *i = vam->input;
14868 vl_api_ipsec_interface_add_del_spd_t *mp;
14870 u8 sw_if_index_set = 0;
14871 u32 spd_id = (u32) ~ 0;
14875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14877 if (unformat (i, "del"))
14879 else if (unformat (i, "spd_id %d", &spd_id))
14882 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14883 sw_if_index_set = 1;
14884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14885 sw_if_index_set = 1;
14888 clib_warning ("parse error '%U'", format_unformat_error, i);
14894 if (spd_id == (u32) ~ 0)
14896 errmsg ("spd_id must be set");
14900 if (sw_if_index_set == 0)
14902 errmsg ("missing interface name or sw_if_index");
14906 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14908 mp->spd_id = ntohl (spd_id);
14909 mp->sw_if_index = ntohl (sw_if_index);
14910 mp->is_add = is_add;
14918 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14920 unformat_input_t *i = vam->input;
14921 vl_api_ipsec_spd_add_del_entry_t *mp;
14922 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14923 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14925 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14926 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14927 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14928 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14931 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14932 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14933 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14934 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14935 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14936 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14940 if (unformat (i, "del"))
14942 if (unformat (i, "outbound"))
14944 if (unformat (i, "inbound"))
14946 else if (unformat (i, "spd_id %d", &spd_id))
14948 else if (unformat (i, "sa_id %d", &sa_id))
14950 else if (unformat (i, "priority %d", &priority))
14952 else if (unformat (i, "protocol %d", &protocol))
14954 else if (unformat (i, "lport_start %d", &lport_start))
14956 else if (unformat (i, "lport_stop %d", &lport_stop))
14958 else if (unformat (i, "rport_start %d", &rport_start))
14960 else if (unformat (i, "rport_stop %d", &rport_stop))
14964 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14970 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14977 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14983 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14990 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14996 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15003 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15009 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15015 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15017 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15019 clib_warning ("unsupported action: 'resolve'");
15025 clib_warning ("parse error '%U'", format_unformat_error, i);
15031 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15033 mp->spd_id = ntohl (spd_id);
15034 mp->priority = ntohl (priority);
15035 mp->is_outbound = is_outbound;
15037 mp->is_ipv6 = is_ipv6;
15038 if (is_ipv6 || is_ip_any)
15040 clib_memcpy (mp->remote_address_start, &raddr6_start,
15041 sizeof (ip6_address_t));
15042 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15043 sizeof (ip6_address_t));
15044 clib_memcpy (mp->local_address_start, &laddr6_start,
15045 sizeof (ip6_address_t));
15046 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15047 sizeof (ip6_address_t));
15051 clib_memcpy (mp->remote_address_start, &raddr4_start,
15052 sizeof (ip4_address_t));
15053 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15054 sizeof (ip4_address_t));
15055 clib_memcpy (mp->local_address_start, &laddr4_start,
15056 sizeof (ip4_address_t));
15057 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15058 sizeof (ip4_address_t));
15060 mp->protocol = (u8) protocol;
15061 mp->local_port_start = ntohs ((u16) lport_start);
15062 mp->local_port_stop = ntohs ((u16) lport_stop);
15063 mp->remote_port_start = ntohs ((u16) rport_start);
15064 mp->remote_port_stop = ntohs ((u16) rport_stop);
15065 mp->policy = (u8) policy;
15066 mp->sa_id = ntohl (sa_id);
15067 mp->is_add = is_add;
15068 mp->is_ip_any = is_ip_any;
15075 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15077 unformat_input_t *i = vam->input;
15078 vl_api_ipsec_sad_add_del_entry_t *mp;
15079 u32 sad_id = 0, spi = 0;
15080 u8 *ck = 0, *ik = 0;
15083 u8 protocol = IPSEC_PROTOCOL_AH;
15084 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15085 u32 crypto_alg = 0, integ_alg = 0;
15086 ip4_address_t tun_src4;
15087 ip4_address_t tun_dst4;
15088 ip6_address_t tun_src6;
15089 ip6_address_t tun_dst6;
15092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15094 if (unformat (i, "del"))
15096 else if (unformat (i, "sad_id %d", &sad_id))
15098 else if (unformat (i, "spi %d", &spi))
15100 else if (unformat (i, "esp"))
15101 protocol = IPSEC_PROTOCOL_ESP;
15102 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15105 is_tunnel_ipv6 = 0;
15107 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15110 is_tunnel_ipv6 = 0;
15112 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15115 is_tunnel_ipv6 = 1;
15117 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15120 is_tunnel_ipv6 = 1;
15124 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15126 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15127 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15129 clib_warning ("unsupported crypto-alg: '%U'",
15130 format_ipsec_crypto_alg, crypto_alg);
15134 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15138 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15140 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15141 integ_alg >= IPSEC_INTEG_N_ALG)
15143 clib_warning ("unsupported integ-alg: '%U'",
15144 format_ipsec_integ_alg, integ_alg);
15148 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15152 clib_warning ("parse error '%U'", format_unformat_error, i);
15158 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15160 mp->sad_id = ntohl (sad_id);
15161 mp->is_add = is_add;
15162 mp->protocol = protocol;
15163 mp->spi = ntohl (spi);
15164 mp->is_tunnel = is_tunnel;
15165 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15166 mp->crypto_algorithm = crypto_alg;
15167 mp->integrity_algorithm = integ_alg;
15168 mp->crypto_key_length = vec_len (ck);
15169 mp->integrity_key_length = vec_len (ik);
15171 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15172 mp->crypto_key_length = sizeof (mp->crypto_key);
15174 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15175 mp->integrity_key_length = sizeof (mp->integrity_key);
15178 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15180 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15184 if (is_tunnel_ipv6)
15186 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15187 sizeof (ip6_address_t));
15188 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15189 sizeof (ip6_address_t));
15193 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15194 sizeof (ip4_address_t));
15195 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15196 sizeof (ip4_address_t));
15206 api_ipsec_sa_set_key (vat_main_t * vam)
15208 unformat_input_t *i = vam->input;
15209 vl_api_ipsec_sa_set_key_t *mp;
15211 u8 *ck = 0, *ik = 0;
15214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15216 if (unformat (i, "sa_id %d", &sa_id))
15218 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15220 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15224 clib_warning ("parse error '%U'", format_unformat_error, i);
15229 M (IPSEC_SA_SET_KEY, mp);
15231 mp->sa_id = ntohl (sa_id);
15232 mp->crypto_key_length = vec_len (ck);
15233 mp->integrity_key_length = vec_len (ik);
15235 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15236 mp->crypto_key_length = sizeof (mp->crypto_key);
15238 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15239 mp->integrity_key_length = sizeof (mp->integrity_key);
15242 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15244 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15252 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15254 unformat_input_t *i = vam->input;
15255 vl_api_ipsec_tunnel_if_add_del_t *mp;
15256 u32 local_spi = 0, remote_spi = 0;
15257 u32 crypto_alg = 0, integ_alg = 0;
15258 u8 *lck = NULL, *rck = NULL;
15259 u8 *lik = NULL, *rik = NULL;
15260 ip4_address_t local_ip = { {0} };
15261 ip4_address_t remote_ip = { {0} };
15264 u8 anti_replay = 0;
15269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15271 if (unformat (i, "del"))
15273 else if (unformat (i, "esn"))
15275 else if (unformat (i, "anti_replay"))
15277 else if (unformat (i, "local_spi %d", &local_spi))
15279 else if (unformat (i, "remote_spi %d", &remote_spi))
15281 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15283 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15285 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15288 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15290 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15292 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15296 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15298 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15299 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15301 errmsg ("unsupported crypto-alg: '%U'\n",
15302 format_ipsec_crypto_alg, crypto_alg);
15308 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15310 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15311 integ_alg >= IPSEC_INTEG_N_ALG)
15313 errmsg ("unsupported integ-alg: '%U'\n",
15314 format_ipsec_integ_alg, integ_alg);
15318 else if (unformat (i, "instance %u", &instance))
15322 errmsg ("parse error '%U'\n", format_unformat_error, i);
15327 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15329 mp->is_add = is_add;
15331 mp->anti_replay = anti_replay;
15333 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15334 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15336 mp->local_spi = htonl (local_spi);
15337 mp->remote_spi = htonl (remote_spi);
15338 mp->crypto_alg = (u8) crypto_alg;
15340 mp->local_crypto_key_len = 0;
15343 mp->local_crypto_key_len = vec_len (lck);
15344 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15345 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15346 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15349 mp->remote_crypto_key_len = 0;
15352 mp->remote_crypto_key_len = vec_len (rck);
15353 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15354 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15355 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15358 mp->integ_alg = (u8) integ_alg;
15360 mp->local_integ_key_len = 0;
15363 mp->local_integ_key_len = vec_len (lik);
15364 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15365 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15366 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15369 mp->remote_integ_key_len = 0;
15372 mp->remote_integ_key_len = vec_len (rik);
15373 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15374 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15375 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15380 mp->renumber = renumber;
15381 mp->show_instance = ntohl (instance);
15390 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15392 vat_main_t *vam = &vat_main;
15394 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15395 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15396 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15397 "tunnel_src_addr %U tunnel_dst_addr %U "
15398 "salt %u seq_outbound %lu last_seq_inbound %lu "
15399 "replay_window %lu total_data_size %lu\n",
15400 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15402 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15403 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15404 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15405 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15406 mp->tunnel_src_addr,
15407 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15408 mp->tunnel_dst_addr,
15410 clib_net_to_host_u64 (mp->seq_outbound),
15411 clib_net_to_host_u64 (mp->last_seq_inbound),
15412 clib_net_to_host_u64 (mp->replay_window),
15413 clib_net_to_host_u64 (mp->total_data_size));
15416 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15417 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15419 static void vl_api_ipsec_sa_details_t_handler_json
15420 (vl_api_ipsec_sa_details_t * mp)
15422 vat_main_t *vam = &vat_main;
15423 vat_json_node_t *node = NULL;
15424 struct in_addr src_ip4, dst_ip4;
15425 struct in6_addr src_ip6, dst_ip6;
15427 if (VAT_JSON_ARRAY != vam->json_tree.type)
15429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15430 vat_json_init_array (&vam->json_tree);
15432 node = vat_json_array_add (&vam->json_tree);
15434 vat_json_init_object (node);
15435 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15436 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15437 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15438 vat_json_object_add_uint (node, "proto", mp->protocol);
15439 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15440 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15441 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15442 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15443 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15444 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15445 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15446 mp->crypto_key_len);
15447 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15448 mp->integ_key_len);
15449 if (mp->is_tunnel_ip6)
15451 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15452 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15453 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15454 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15458 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15459 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15460 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15461 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15463 vat_json_object_add_uint (node, "replay_window",
15464 clib_net_to_host_u64 (mp->replay_window));
15465 vat_json_object_add_uint (node, "total_data_size",
15466 clib_net_to_host_u64 (mp->total_data_size));
15471 api_ipsec_sa_dump (vat_main_t * vam)
15473 unformat_input_t *i = vam->input;
15474 vl_api_ipsec_sa_dump_t *mp;
15475 vl_api_control_ping_t *mp_ping;
15479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15481 if (unformat (i, "sa_id %d", &sa_id))
15485 clib_warning ("parse error '%U'", format_unformat_error, i);
15490 M (IPSEC_SA_DUMP, mp);
15492 mp->sa_id = ntohl (sa_id);
15496 /* Use a control ping for synchronization */
15497 M (CONTROL_PING, mp_ping);
15505 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15507 unformat_input_t *i = vam->input;
15508 vl_api_ipsec_tunnel_if_set_key_t *mp;
15509 u32 sw_if_index = ~0;
15510 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15517 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15520 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15521 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15523 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15524 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15525 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15526 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15528 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15529 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15530 else if (unformat (i, "%U", unformat_hex_string, &key))
15534 clib_warning ("parse error '%U'", format_unformat_error, i);
15539 if (sw_if_index == ~0)
15541 errmsg ("interface must be specified");
15545 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15547 errmsg ("key type must be specified");
15553 errmsg ("algorithm must be specified");
15557 if (vec_len (key) == 0)
15559 errmsg ("key must be specified");
15563 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15565 mp->sw_if_index = htonl (sw_if_index);
15567 mp->key_type = key_type;
15568 mp->key_len = vec_len (key);
15569 clib_memcpy (mp->key, key, vec_len (key));
15578 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15580 unformat_input_t *i = vam->input;
15581 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15582 u32 sw_if_index = ~0;
15584 u8 is_outbound = (u8) ~ 0;
15587 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15589 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15591 else if (unformat (i, "sa_id %d", &sa_id))
15593 else if (unformat (i, "outbound"))
15595 else if (unformat (i, "inbound"))
15599 clib_warning ("parse error '%U'", format_unformat_error, i);
15604 if (sw_if_index == ~0)
15606 errmsg ("interface must be specified");
15612 errmsg ("SA ID must be specified");
15616 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15618 mp->sw_if_index = htonl (sw_if_index);
15619 mp->sa_id = htonl (sa_id);
15620 mp->is_outbound = is_outbound;
15629 api_ikev2_profile_add_del (vat_main_t * vam)
15631 unformat_input_t *i = vam->input;
15632 vl_api_ikev2_profile_add_del_t *mp;
15637 const char *valid_chars = "a-zA-Z0-9_";
15639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15641 if (unformat (i, "del"))
15643 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15644 vec_add1 (name, 0);
15647 errmsg ("parse error '%U'", format_unformat_error, i);
15652 if (!vec_len (name))
15654 errmsg ("profile name must be specified");
15658 if (vec_len (name) > 64)
15660 errmsg ("profile name too long");
15664 M (IKEV2_PROFILE_ADD_DEL, mp);
15666 clib_memcpy (mp->name, name, vec_len (name));
15667 mp->is_add = is_add;
15676 api_ikev2_profile_set_auth (vat_main_t * vam)
15678 unformat_input_t *i = vam->input;
15679 vl_api_ikev2_profile_set_auth_t *mp;
15682 u32 auth_method = 0;
15686 const char *valid_chars = "a-zA-Z0-9_";
15688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15690 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15691 vec_add1 (name, 0);
15692 else if (unformat (i, "auth_method %U",
15693 unformat_ikev2_auth_method, &auth_method))
15695 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15697 else if (unformat (i, "auth_data %v", &data))
15701 errmsg ("parse error '%U'", format_unformat_error, i);
15706 if (!vec_len (name))
15708 errmsg ("profile name must be specified");
15712 if (vec_len (name) > 64)
15714 errmsg ("profile name too long");
15718 if (!vec_len (data))
15720 errmsg ("auth_data must be specified");
15726 errmsg ("auth_method must be specified");
15730 M (IKEV2_PROFILE_SET_AUTH, mp);
15732 mp->is_hex = is_hex;
15733 mp->auth_method = (u8) auth_method;
15734 mp->data_len = vec_len (data);
15735 clib_memcpy (mp->name, name, vec_len (name));
15736 clib_memcpy (mp->data, data, vec_len (data));
15746 api_ikev2_profile_set_id (vat_main_t * vam)
15748 unformat_input_t *i = vam->input;
15749 vl_api_ikev2_profile_set_id_t *mp;
15757 const char *valid_chars = "a-zA-Z0-9_";
15759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15761 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15762 vec_add1 (name, 0);
15763 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15765 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15767 data = vec_new (u8, 4);
15768 clib_memcpy (data, ip4.as_u8, 4);
15770 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15772 else if (unformat (i, "id_data %v", &data))
15774 else if (unformat (i, "local"))
15776 else if (unformat (i, "remote"))
15780 errmsg ("parse error '%U'", format_unformat_error, i);
15785 if (!vec_len (name))
15787 errmsg ("profile name must be specified");
15791 if (vec_len (name) > 64)
15793 errmsg ("profile name too long");
15797 if (!vec_len (data))
15799 errmsg ("id_data must be specified");
15805 errmsg ("id_type must be specified");
15809 M (IKEV2_PROFILE_SET_ID, mp);
15811 mp->is_local = is_local;
15812 mp->id_type = (u8) id_type;
15813 mp->data_len = vec_len (data);
15814 clib_memcpy (mp->name, name, vec_len (name));
15815 clib_memcpy (mp->data, data, vec_len (data));
15825 api_ikev2_profile_set_ts (vat_main_t * vam)
15827 unformat_input_t *i = vam->input;
15828 vl_api_ikev2_profile_set_ts_t *mp;
15831 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15832 ip4_address_t start_addr, end_addr;
15834 const char *valid_chars = "a-zA-Z0-9_";
15837 start_addr.as_u32 = 0;
15838 end_addr.as_u32 = (u32) ~ 0;
15840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15842 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15843 vec_add1 (name, 0);
15844 else if (unformat (i, "protocol %d", &proto))
15846 else if (unformat (i, "start_port %d", &start_port))
15848 else if (unformat (i, "end_port %d", &end_port))
15851 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15853 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15855 else if (unformat (i, "local"))
15857 else if (unformat (i, "remote"))
15861 errmsg ("parse error '%U'", format_unformat_error, i);
15866 if (!vec_len (name))
15868 errmsg ("profile name must be specified");
15872 if (vec_len (name) > 64)
15874 errmsg ("profile name too long");
15878 M (IKEV2_PROFILE_SET_TS, mp);
15880 mp->is_local = is_local;
15881 mp->proto = (u8) proto;
15882 mp->start_port = (u16) start_port;
15883 mp->end_port = (u16) end_port;
15884 mp->start_addr = start_addr.as_u32;
15885 mp->end_addr = end_addr.as_u32;
15886 clib_memcpy (mp->name, name, vec_len (name));
15895 api_ikev2_set_local_key (vat_main_t * vam)
15897 unformat_input_t *i = vam->input;
15898 vl_api_ikev2_set_local_key_t *mp;
15902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15904 if (unformat (i, "file %v", &file))
15905 vec_add1 (file, 0);
15908 errmsg ("parse error '%U'", format_unformat_error, i);
15913 if (!vec_len (file))
15915 errmsg ("RSA key file must be specified");
15919 if (vec_len (file) > 256)
15921 errmsg ("file name too long");
15925 M (IKEV2_SET_LOCAL_KEY, mp);
15927 clib_memcpy (mp->key_file, file, vec_len (file));
15936 api_ikev2_set_responder (vat_main_t * vam)
15938 unformat_input_t *i = vam->input;
15939 vl_api_ikev2_set_responder_t *mp;
15942 u32 sw_if_index = ~0;
15943 ip4_address_t address;
15945 const char *valid_chars = "a-zA-Z0-9_";
15947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15950 (i, "%U interface %d address %U", unformat_token, valid_chars,
15951 &name, &sw_if_index, unformat_ip4_address, &address))
15952 vec_add1 (name, 0);
15955 errmsg ("parse error '%U'", format_unformat_error, i);
15960 if (!vec_len (name))
15962 errmsg ("profile name must be specified");
15966 if (vec_len (name) > 64)
15968 errmsg ("profile name too long");
15972 M (IKEV2_SET_RESPONDER, mp);
15974 clib_memcpy (mp->name, name, vec_len (name));
15977 mp->sw_if_index = sw_if_index;
15978 clib_memcpy (mp->address, &address, sizeof (address));
15986 api_ikev2_set_ike_transforms (vat_main_t * vam)
15988 unformat_input_t *i = vam->input;
15989 vl_api_ikev2_set_ike_transforms_t *mp;
15992 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15994 const char *valid_chars = "a-zA-Z0-9_";
15996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15998 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15999 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16000 vec_add1 (name, 0);
16003 errmsg ("parse error '%U'", format_unformat_error, i);
16008 if (!vec_len (name))
16010 errmsg ("profile name must be specified");
16014 if (vec_len (name) > 64)
16016 errmsg ("profile name too long");
16020 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16022 clib_memcpy (mp->name, name, vec_len (name));
16024 mp->crypto_alg = crypto_alg;
16025 mp->crypto_key_size = crypto_key_size;
16026 mp->integ_alg = integ_alg;
16027 mp->dh_group = dh_group;
16036 api_ikev2_set_esp_transforms (vat_main_t * vam)
16038 unformat_input_t *i = vam->input;
16039 vl_api_ikev2_set_esp_transforms_t *mp;
16042 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16044 const char *valid_chars = "a-zA-Z0-9_";
16046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16048 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16049 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16050 vec_add1 (name, 0);
16053 errmsg ("parse error '%U'", format_unformat_error, i);
16058 if (!vec_len (name))
16060 errmsg ("profile name must be specified");
16064 if (vec_len (name) > 64)
16066 errmsg ("profile name too long");
16070 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16072 clib_memcpy (mp->name, name, vec_len (name));
16074 mp->crypto_alg = crypto_alg;
16075 mp->crypto_key_size = crypto_key_size;
16076 mp->integ_alg = integ_alg;
16077 mp->dh_group = dh_group;
16085 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16087 unformat_input_t *i = vam->input;
16088 vl_api_ikev2_set_sa_lifetime_t *mp;
16091 u64 lifetime, lifetime_maxdata;
16092 u32 lifetime_jitter, handover;
16094 const char *valid_chars = "a-zA-Z0-9_";
16096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16098 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16099 &lifetime, &lifetime_jitter, &handover,
16100 &lifetime_maxdata))
16101 vec_add1 (name, 0);
16104 errmsg ("parse error '%U'", format_unformat_error, i);
16109 if (!vec_len (name))
16111 errmsg ("profile name must be specified");
16115 if (vec_len (name) > 64)
16117 errmsg ("profile name too long");
16121 M (IKEV2_SET_SA_LIFETIME, mp);
16123 clib_memcpy (mp->name, name, vec_len (name));
16125 mp->lifetime = lifetime;
16126 mp->lifetime_jitter = lifetime_jitter;
16127 mp->handover = handover;
16128 mp->lifetime_maxdata = lifetime_maxdata;
16136 api_ikev2_initiate_sa_init (vat_main_t * vam)
16138 unformat_input_t *i = vam->input;
16139 vl_api_ikev2_initiate_sa_init_t *mp;
16143 const char *valid_chars = "a-zA-Z0-9_";
16145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16147 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16148 vec_add1 (name, 0);
16151 errmsg ("parse error '%U'", format_unformat_error, i);
16156 if (!vec_len (name))
16158 errmsg ("profile name must be specified");
16162 if (vec_len (name) > 64)
16164 errmsg ("profile name too long");
16168 M (IKEV2_INITIATE_SA_INIT, mp);
16170 clib_memcpy (mp->name, name, vec_len (name));
16179 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16181 unformat_input_t *i = vam->input;
16182 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16189 if (unformat (i, "%lx", &ispi))
16193 errmsg ("parse error '%U'", format_unformat_error, i);
16198 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16208 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16210 unformat_input_t *i = vam->input;
16211 vl_api_ikev2_initiate_del_child_sa_t *mp;
16216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16218 if (unformat (i, "%x", &ispi))
16222 errmsg ("parse error '%U'", format_unformat_error, i);
16227 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16237 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16239 unformat_input_t *i = vam->input;
16240 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16247 if (unformat (i, "%x", &ispi))
16251 errmsg ("parse error '%U'", format_unformat_error, i);
16256 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16269 api_map_add_domain (vat_main_t * vam)
16271 unformat_input_t *i = vam->input;
16272 vl_api_map_add_domain_t *mp;
16274 ip4_address_t ip4_prefix;
16275 ip6_address_t ip6_prefix;
16276 ip6_address_t ip6_src;
16277 u32 num_m_args = 0;
16278 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16279 0, psid_length = 0;
16280 u8 is_translation = 0;
16282 u32 ip6_src_len = 128;
16285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16287 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16288 &ip4_prefix, &ip4_prefix_len))
16290 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16291 &ip6_prefix, &ip6_prefix_len))
16295 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16298 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16300 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16302 else if (unformat (i, "psid-offset %d", &psid_offset))
16304 else if (unformat (i, "psid-len %d", &psid_length))
16306 else if (unformat (i, "mtu %d", &mtu))
16308 else if (unformat (i, "map-t"))
16309 is_translation = 1;
16312 clib_warning ("parse error '%U'", format_unformat_error, i);
16317 if (num_m_args < 3)
16319 errmsg ("mandatory argument(s) missing");
16323 /* Construct the API message */
16324 M (MAP_ADD_DOMAIN, mp);
16326 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16327 mp->ip4_prefix_len = ip4_prefix_len;
16329 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16330 mp->ip6_prefix_len = ip6_prefix_len;
16332 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16333 mp->ip6_src_prefix_len = ip6_src_len;
16335 mp->ea_bits_len = ea_bits_len;
16336 mp->psid_offset = psid_offset;
16337 mp->psid_length = psid_length;
16338 mp->is_translation = is_translation;
16339 mp->mtu = htons (mtu);
16344 /* Wait for a reply, return good/bad news */
16350 api_map_del_domain (vat_main_t * vam)
16352 unformat_input_t *i = vam->input;
16353 vl_api_map_del_domain_t *mp;
16355 u32 num_m_args = 0;
16359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16361 if (unformat (i, "index %d", &index))
16365 clib_warning ("parse error '%U'", format_unformat_error, i);
16370 if (num_m_args != 1)
16372 errmsg ("mandatory argument(s) missing");
16376 /* Construct the API message */
16377 M (MAP_DEL_DOMAIN, mp);
16379 mp->index = ntohl (index);
16384 /* Wait for a reply, return good/bad news */
16390 api_map_add_del_rule (vat_main_t * vam)
16392 unformat_input_t *i = vam->input;
16393 vl_api_map_add_del_rule_t *mp;
16395 ip6_address_t ip6_dst;
16396 u32 num_m_args = 0, index, psid = 0;
16399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16401 if (unformat (i, "index %d", &index))
16403 else if (unformat (i, "psid %d", &psid))
16405 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16407 else if (unformat (i, "del"))
16413 clib_warning ("parse error '%U'", format_unformat_error, i);
16418 /* Construct the API message */
16419 M (MAP_ADD_DEL_RULE, mp);
16421 mp->index = ntohl (index);
16422 mp->is_add = is_add;
16423 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16424 mp->psid = ntohs (psid);
16429 /* Wait for a reply, return good/bad news */
16435 api_map_domain_dump (vat_main_t * vam)
16437 vl_api_map_domain_dump_t *mp;
16438 vl_api_control_ping_t *mp_ping;
16441 /* Construct the API message */
16442 M (MAP_DOMAIN_DUMP, mp);
16447 /* Use a control ping for synchronization */
16448 MPING (CONTROL_PING, mp_ping);
16456 api_map_rule_dump (vat_main_t * vam)
16458 unformat_input_t *i = vam->input;
16459 vl_api_map_rule_dump_t *mp;
16460 vl_api_control_ping_t *mp_ping;
16461 u32 domain_index = ~0;
16464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16466 if (unformat (i, "index %u", &domain_index))
16472 if (domain_index == ~0)
16474 clib_warning ("parse error: domain index expected");
16478 /* Construct the API message */
16479 M (MAP_RULE_DUMP, mp);
16481 mp->domain_index = htonl (domain_index);
16486 /* Use a control ping for synchronization */
16487 MPING (CONTROL_PING, mp_ping);
16494 static void vl_api_map_add_domain_reply_t_handler
16495 (vl_api_map_add_domain_reply_t * mp)
16497 vat_main_t *vam = &vat_main;
16498 i32 retval = ntohl (mp->retval);
16500 if (vam->async_mode)
16502 vam->async_errors += (retval < 0);
16506 vam->retval = retval;
16507 vam->result_ready = 1;
16511 static void vl_api_map_add_domain_reply_t_handler_json
16512 (vl_api_map_add_domain_reply_t * mp)
16514 vat_main_t *vam = &vat_main;
16515 vat_json_node_t node;
16517 vat_json_init_object (&node);
16518 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16519 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16521 vat_json_print (vam->ofp, &node);
16522 vat_json_free (&node);
16524 vam->retval = ntohl (mp->retval);
16525 vam->result_ready = 1;
16529 api_get_first_msg_id (vat_main_t * vam)
16531 vl_api_get_first_msg_id_t *mp;
16532 unformat_input_t *i = vam->input;
16537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16539 if (unformat (i, "client %s", &name))
16547 errmsg ("missing client name");
16550 vec_add1 (name, 0);
16552 if (vec_len (name) > 63)
16554 errmsg ("client name too long");
16558 M (GET_FIRST_MSG_ID, mp);
16559 clib_memcpy (mp->name, name, vec_len (name));
16566 api_cop_interface_enable_disable (vat_main_t * vam)
16568 unformat_input_t *line_input = vam->input;
16569 vl_api_cop_interface_enable_disable_t *mp;
16570 u32 sw_if_index = ~0;
16571 u8 enable_disable = 1;
16574 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16576 if (unformat (line_input, "disable"))
16577 enable_disable = 0;
16578 if (unformat (line_input, "enable"))
16579 enable_disable = 1;
16580 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16581 vam, &sw_if_index))
16583 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16589 if (sw_if_index == ~0)
16591 errmsg ("missing interface name or sw_if_index");
16595 /* Construct the API message */
16596 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16597 mp->sw_if_index = ntohl (sw_if_index);
16598 mp->enable_disable = enable_disable;
16602 /* Wait for the reply */
16608 api_cop_whitelist_enable_disable (vat_main_t * vam)
16610 unformat_input_t *line_input = vam->input;
16611 vl_api_cop_whitelist_enable_disable_t *mp;
16612 u32 sw_if_index = ~0;
16613 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16619 if (unformat (line_input, "ip4"))
16621 else if (unformat (line_input, "ip6"))
16623 else if (unformat (line_input, "default"))
16625 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16626 vam, &sw_if_index))
16628 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16630 else if (unformat (line_input, "fib-id %d", &fib_id))
16636 if (sw_if_index == ~0)
16638 errmsg ("missing interface name or sw_if_index");
16642 /* Construct the API message */
16643 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16644 mp->sw_if_index = ntohl (sw_if_index);
16645 mp->fib_id = ntohl (fib_id);
16648 mp->default_cop = default_cop;
16652 /* Wait for the reply */
16658 api_get_node_graph (vat_main_t * vam)
16660 vl_api_get_node_graph_t *mp;
16663 M (GET_NODE_GRAPH, mp);
16667 /* Wait for the reply */
16673 /** Used for parsing LISP eids */
16674 typedef CLIB_PACKED(struct{
16675 u8 addr[16]; /**< eid address */
16676 u32 len; /**< prefix length if IP */
16677 u8 type; /**< type of eid */
16682 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16684 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16686 memset (a, 0, sizeof (a[0]));
16688 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16690 a->type = 0; /* ipv4 type */
16692 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16694 a->type = 1; /* ipv6 type */
16696 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16698 a->type = 2; /* mac type */
16700 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16702 a->type = 3; /* NSH type */
16703 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16704 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16711 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16720 lisp_eid_size_vat (u8 type)
16737 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16739 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16743 api_one_add_del_locator_set (vat_main_t * vam)
16745 unformat_input_t *input = vam->input;
16746 vl_api_one_add_del_locator_set_t *mp;
16748 u8 *locator_set_name = NULL;
16749 u8 locator_set_name_set = 0;
16750 vl_api_local_locator_t locator, *locators = 0;
16751 u32 sw_if_index, priority, weight;
16755 /* Parse args required to build the message */
16756 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16758 if (unformat (input, "del"))
16762 else if (unformat (input, "locator-set %s", &locator_set_name))
16764 locator_set_name_set = 1;
16766 else if (unformat (input, "sw_if_index %u p %u w %u",
16767 &sw_if_index, &priority, &weight))
16769 locator.sw_if_index = htonl (sw_if_index);
16770 locator.priority = priority;
16771 locator.weight = weight;
16772 vec_add1 (locators, locator);
16776 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16777 &sw_if_index, &priority, &weight))
16779 locator.sw_if_index = htonl (sw_if_index);
16780 locator.priority = priority;
16781 locator.weight = weight;
16782 vec_add1 (locators, locator);
16788 if (locator_set_name_set == 0)
16790 errmsg ("missing locator-set name");
16791 vec_free (locators);
16795 if (vec_len (locator_set_name) > 64)
16797 errmsg ("locator-set name too long");
16798 vec_free (locator_set_name);
16799 vec_free (locators);
16802 vec_add1 (locator_set_name, 0);
16804 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16806 /* Construct the API message */
16807 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16809 mp->is_add = is_add;
16810 clib_memcpy (mp->locator_set_name, locator_set_name,
16811 vec_len (locator_set_name));
16812 vec_free (locator_set_name);
16814 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16816 clib_memcpy (mp->locators, locators, data_len);
16817 vec_free (locators);
16822 /* Wait for a reply... */
16827 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16830 api_one_add_del_locator (vat_main_t * vam)
16832 unformat_input_t *input = vam->input;
16833 vl_api_one_add_del_locator_t *mp;
16834 u32 tmp_if_index = ~0;
16835 u32 sw_if_index = ~0;
16836 u8 sw_if_index_set = 0;
16837 u8 sw_if_index_if_name_set = 0;
16839 u8 priority_set = 0;
16843 u8 *locator_set_name = NULL;
16844 u8 locator_set_name_set = 0;
16847 /* Parse args required to build the message */
16848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16850 if (unformat (input, "del"))
16854 else if (unformat (input, "locator-set %s", &locator_set_name))
16856 locator_set_name_set = 1;
16858 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16861 sw_if_index_if_name_set = 1;
16862 sw_if_index = tmp_if_index;
16864 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16866 sw_if_index_set = 1;
16867 sw_if_index = tmp_if_index;
16869 else if (unformat (input, "p %d", &priority))
16873 else if (unformat (input, "w %d", &weight))
16881 if (locator_set_name_set == 0)
16883 errmsg ("missing locator-set name");
16887 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16889 errmsg ("missing sw_if_index");
16890 vec_free (locator_set_name);
16894 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16896 errmsg ("cannot use both params interface name and sw_if_index");
16897 vec_free (locator_set_name);
16901 if (priority_set == 0)
16903 errmsg ("missing locator-set priority");
16904 vec_free (locator_set_name);
16908 if (weight_set == 0)
16910 errmsg ("missing locator-set weight");
16911 vec_free (locator_set_name);
16915 if (vec_len (locator_set_name) > 64)
16917 errmsg ("locator-set name too long");
16918 vec_free (locator_set_name);
16921 vec_add1 (locator_set_name, 0);
16923 /* Construct the API message */
16924 M (ONE_ADD_DEL_LOCATOR, mp);
16926 mp->is_add = is_add;
16927 mp->sw_if_index = ntohl (sw_if_index);
16928 mp->priority = priority;
16929 mp->weight = weight;
16930 clib_memcpy (mp->locator_set_name, locator_set_name,
16931 vec_len (locator_set_name));
16932 vec_free (locator_set_name);
16937 /* Wait for a reply... */
16942 #define api_lisp_add_del_locator api_one_add_del_locator
16945 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16947 u32 *key_id = va_arg (*args, u32 *);
16950 if (unformat (input, "%s", &s))
16952 if (!strcmp ((char *) s, "sha1"))
16953 key_id[0] = HMAC_SHA_1_96;
16954 else if (!strcmp ((char *) s, "sha256"))
16955 key_id[0] = HMAC_SHA_256_128;
16958 clib_warning ("invalid key_id: '%s'", s);
16959 key_id[0] = HMAC_NO_KEY;
16970 api_one_add_del_local_eid (vat_main_t * vam)
16972 unformat_input_t *input = vam->input;
16973 vl_api_one_add_del_local_eid_t *mp;
16976 lisp_eid_vat_t _eid, *eid = &_eid;
16977 u8 *locator_set_name = 0;
16978 u8 locator_set_name_set = 0;
16984 /* Parse args required to build the message */
16985 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16987 if (unformat (input, "del"))
16991 else if (unformat (input, "vni %d", &vni))
16995 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16999 else if (unformat (input, "locator-set %s", &locator_set_name))
17001 locator_set_name_set = 1;
17003 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17005 else if (unformat (input, "secret-key %_%v%_", &key))
17011 if (locator_set_name_set == 0)
17013 errmsg ("missing locator-set name");
17019 errmsg ("EID address not set!");
17020 vec_free (locator_set_name);
17024 if (key && (0 == key_id))
17026 errmsg ("invalid key_id!");
17030 if (vec_len (key) > 64)
17032 errmsg ("key too long");
17037 if (vec_len (locator_set_name) > 64)
17039 errmsg ("locator-set name too long");
17040 vec_free (locator_set_name);
17043 vec_add1 (locator_set_name, 0);
17045 /* Construct the API message */
17046 M (ONE_ADD_DEL_LOCAL_EID, mp);
17048 mp->is_add = is_add;
17049 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17050 mp->eid_type = eid->type;
17051 mp->prefix_len = eid->len;
17052 mp->vni = clib_host_to_net_u32 (vni);
17053 mp->key_id = clib_host_to_net_u16 (key_id);
17054 clib_memcpy (mp->locator_set_name, locator_set_name,
17055 vec_len (locator_set_name));
17056 clib_memcpy (mp->key, key, vec_len (key));
17058 vec_free (locator_set_name);
17064 /* Wait for a reply... */
17069 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17072 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17074 u32 dp_table = 0, vni = 0;;
17075 unformat_input_t *input = vam->input;
17076 vl_api_gpe_add_del_fwd_entry_t *mp;
17078 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17079 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17080 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17081 u32 action = ~0, w;
17082 ip4_address_t rmt_rloc4, lcl_rloc4;
17083 ip6_address_t rmt_rloc6, lcl_rloc6;
17084 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17087 memset (&rloc, 0, sizeof (rloc));
17089 /* Parse args required to build the message */
17090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17092 if (unformat (input, "del"))
17094 else if (unformat (input, "add"))
17096 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17100 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17104 else if (unformat (input, "vrf %d", &dp_table))
17106 else if (unformat (input, "bd %d", &dp_table))
17108 else if (unformat (input, "vni %d", &vni))
17110 else if (unformat (input, "w %d", &w))
17114 errmsg ("No RLOC configured for setting priority/weight!");
17117 curr_rloc->weight = w;
17119 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17120 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17124 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17126 vec_add1 (lcl_locs, rloc);
17128 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17129 vec_add1 (rmt_locs, rloc);
17130 /* weight saved in rmt loc */
17131 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17133 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17134 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17137 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17139 vec_add1 (lcl_locs, rloc);
17141 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17142 vec_add1 (rmt_locs, rloc);
17143 /* weight saved in rmt loc */
17144 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17146 else if (unformat (input, "action %d", &action))
17152 clib_warning ("parse error '%U'", format_unformat_error, input);
17159 errmsg ("remote eid addresses not set");
17163 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17165 errmsg ("eid types don't match");
17169 if (0 == rmt_locs && (u32) ~ 0 == action)
17171 errmsg ("action not set for negative mapping");
17175 /* Construct the API message */
17176 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17177 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17179 mp->is_add = is_add;
17180 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17181 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17182 mp->eid_type = rmt_eid->type;
17183 mp->dp_table = clib_host_to_net_u32 (dp_table);
17184 mp->vni = clib_host_to_net_u32 (vni);
17185 mp->rmt_len = rmt_eid->len;
17186 mp->lcl_len = lcl_eid->len;
17187 mp->action = action;
17189 if (0 != rmt_locs && 0 != lcl_locs)
17191 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17192 clib_memcpy (mp->locs, lcl_locs,
17193 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17195 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17196 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17197 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17199 vec_free (lcl_locs);
17200 vec_free (rmt_locs);
17205 /* Wait for a reply... */
17211 api_one_add_del_map_server (vat_main_t * vam)
17213 unformat_input_t *input = vam->input;
17214 vl_api_one_add_del_map_server_t *mp;
17218 ip4_address_t ipv4;
17219 ip6_address_t ipv6;
17222 /* Parse args required to build the message */
17223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17225 if (unformat (input, "del"))
17229 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17233 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17241 if (ipv4_set && ipv6_set)
17243 errmsg ("both eid v4 and v6 addresses set");
17247 if (!ipv4_set && !ipv6_set)
17249 errmsg ("eid addresses not set");
17253 /* Construct the API message */
17254 M (ONE_ADD_DEL_MAP_SERVER, mp);
17256 mp->is_add = is_add;
17260 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17265 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17271 /* Wait for a reply... */
17276 #define api_lisp_add_del_map_server api_one_add_del_map_server
17279 api_one_add_del_map_resolver (vat_main_t * vam)
17281 unformat_input_t *input = vam->input;
17282 vl_api_one_add_del_map_resolver_t *mp;
17286 ip4_address_t ipv4;
17287 ip6_address_t ipv6;
17290 /* Parse args required to build the message */
17291 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17293 if (unformat (input, "del"))
17297 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17301 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17309 if (ipv4_set && ipv6_set)
17311 errmsg ("both eid v4 and v6 addresses set");
17315 if (!ipv4_set && !ipv6_set)
17317 errmsg ("eid addresses not set");
17321 /* Construct the API message */
17322 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17324 mp->is_add = is_add;
17328 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17333 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17339 /* Wait for a reply... */
17344 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17347 api_lisp_gpe_enable_disable (vat_main_t * vam)
17349 unformat_input_t *input = vam->input;
17350 vl_api_gpe_enable_disable_t *mp;
17355 /* Parse args required to build the message */
17356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17358 if (unformat (input, "enable"))
17363 else if (unformat (input, "disable"))
17374 errmsg ("Value not set");
17378 /* Construct the API message */
17379 M (GPE_ENABLE_DISABLE, mp);
17386 /* Wait for a reply... */
17392 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17394 unformat_input_t *input = vam->input;
17395 vl_api_one_rloc_probe_enable_disable_t *mp;
17400 /* Parse args required to build the message */
17401 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17403 if (unformat (input, "enable"))
17408 else if (unformat (input, "disable"))
17416 errmsg ("Value not set");
17420 /* Construct the API message */
17421 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17423 mp->is_enabled = is_en;
17428 /* Wait for a reply... */
17433 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17436 api_one_map_register_enable_disable (vat_main_t * vam)
17438 unformat_input_t *input = vam->input;
17439 vl_api_one_map_register_enable_disable_t *mp;
17444 /* Parse args required to build the message */
17445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17447 if (unformat (input, "enable"))
17452 else if (unformat (input, "disable"))
17460 errmsg ("Value not set");
17464 /* Construct the API message */
17465 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17467 mp->is_enabled = is_en;
17472 /* Wait for a reply... */
17477 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17480 api_one_enable_disable (vat_main_t * vam)
17482 unformat_input_t *input = vam->input;
17483 vl_api_one_enable_disable_t *mp;
17488 /* Parse args required to build the message */
17489 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17491 if (unformat (input, "enable"))
17496 else if (unformat (input, "disable"))
17506 errmsg ("Value not set");
17510 /* Construct the API message */
17511 M (ONE_ENABLE_DISABLE, mp);
17518 /* Wait for a reply... */
17523 #define api_lisp_enable_disable api_one_enable_disable
17526 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17528 unformat_input_t *input = vam->input;
17529 vl_api_one_enable_disable_xtr_mode_t *mp;
17534 /* Parse args required to build the message */
17535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17537 if (unformat (input, "enable"))
17542 else if (unformat (input, "disable"))
17552 errmsg ("Value not set");
17556 /* Construct the API message */
17557 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17564 /* Wait for a reply... */
17570 api_one_show_xtr_mode (vat_main_t * vam)
17572 vl_api_one_show_xtr_mode_t *mp;
17575 /* Construct the API message */
17576 M (ONE_SHOW_XTR_MODE, mp);
17581 /* Wait for a reply... */
17587 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17589 unformat_input_t *input = vam->input;
17590 vl_api_one_enable_disable_pitr_mode_t *mp;
17595 /* Parse args required to build the message */
17596 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17598 if (unformat (input, "enable"))
17603 else if (unformat (input, "disable"))
17613 errmsg ("Value not set");
17617 /* Construct the API message */
17618 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17625 /* Wait for a reply... */
17631 api_one_show_pitr_mode (vat_main_t * vam)
17633 vl_api_one_show_pitr_mode_t *mp;
17636 /* Construct the API message */
17637 M (ONE_SHOW_PITR_MODE, mp);
17642 /* Wait for a reply... */
17648 api_one_enable_disable_petr_mode (vat_main_t * vam)
17650 unformat_input_t *input = vam->input;
17651 vl_api_one_enable_disable_petr_mode_t *mp;
17656 /* Parse args required to build the message */
17657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17659 if (unformat (input, "enable"))
17664 else if (unformat (input, "disable"))
17674 errmsg ("Value not set");
17678 /* Construct the API message */
17679 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17686 /* Wait for a reply... */
17692 api_one_show_petr_mode (vat_main_t * vam)
17694 vl_api_one_show_petr_mode_t *mp;
17697 /* Construct the API message */
17698 M (ONE_SHOW_PETR_MODE, mp);
17703 /* Wait for a reply... */
17709 api_show_one_map_register_state (vat_main_t * vam)
17711 vl_api_show_one_map_register_state_t *mp;
17714 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17719 /* wait for reply */
17724 #define api_show_lisp_map_register_state api_show_one_map_register_state
17727 api_show_one_rloc_probe_state (vat_main_t * vam)
17729 vl_api_show_one_rloc_probe_state_t *mp;
17732 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17737 /* wait for reply */
17742 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17745 api_one_add_del_ndp_entry (vat_main_t * vam)
17747 vl_api_one_add_del_ndp_entry_t *mp;
17748 unformat_input_t *input = vam->input;
17753 u8 mac[6] = { 0, };
17754 u8 ip6[16] = { 0, };
17758 /* Parse args required to build the message */
17759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17761 if (unformat (input, "del"))
17763 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17765 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17767 else if (unformat (input, "bd %d", &bd))
17771 errmsg ("parse error '%U'", format_unformat_error, input);
17776 if (!bd_set || !ip_set || (!mac_set && is_add))
17778 errmsg ("Missing BD, IP or MAC!");
17782 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17783 mp->is_add = is_add;
17784 clib_memcpy (mp->mac, mac, 6);
17785 mp->bd = clib_host_to_net_u32 (bd);
17786 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17791 /* wait for reply */
17797 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17799 vl_api_one_add_del_l2_arp_entry_t *mp;
17800 unformat_input_t *input = vam->input;
17805 u8 mac[6] = { 0, };
17806 u32 ip4 = 0, bd = ~0;
17809 /* Parse args required to build the message */
17810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17812 if (unformat (input, "del"))
17814 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17816 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17818 else if (unformat (input, "bd %d", &bd))
17822 errmsg ("parse error '%U'", format_unformat_error, input);
17827 if (!bd_set || !ip_set || (!mac_set && is_add))
17829 errmsg ("Missing BD, IP or MAC!");
17833 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17834 mp->is_add = is_add;
17835 clib_memcpy (mp->mac, mac, 6);
17836 mp->bd = clib_host_to_net_u32 (bd);
17842 /* wait for reply */
17848 api_one_ndp_bd_get (vat_main_t * vam)
17850 vl_api_one_ndp_bd_get_t *mp;
17853 M (ONE_NDP_BD_GET, mp);
17858 /* wait for reply */
17864 api_one_ndp_entries_get (vat_main_t * vam)
17866 vl_api_one_ndp_entries_get_t *mp;
17867 unformat_input_t *input = vam->input;
17872 /* Parse args required to build the message */
17873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17875 if (unformat (input, "bd %d", &bd))
17879 errmsg ("parse error '%U'", format_unformat_error, input);
17886 errmsg ("Expected bridge domain!");
17890 M (ONE_NDP_ENTRIES_GET, mp);
17891 mp->bd = clib_host_to_net_u32 (bd);
17896 /* wait for reply */
17902 api_one_l2_arp_bd_get (vat_main_t * vam)
17904 vl_api_one_l2_arp_bd_get_t *mp;
17907 M (ONE_L2_ARP_BD_GET, mp);
17912 /* wait for reply */
17918 api_one_l2_arp_entries_get (vat_main_t * vam)
17920 vl_api_one_l2_arp_entries_get_t *mp;
17921 unformat_input_t *input = vam->input;
17926 /* Parse args required to build the message */
17927 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17929 if (unformat (input, "bd %d", &bd))
17933 errmsg ("parse error '%U'", format_unformat_error, input);
17940 errmsg ("Expected bridge domain!");
17944 M (ONE_L2_ARP_ENTRIES_GET, mp);
17945 mp->bd = clib_host_to_net_u32 (bd);
17950 /* wait for reply */
17956 api_one_stats_enable_disable (vat_main_t * vam)
17958 vl_api_one_stats_enable_disable_t *mp;
17959 unformat_input_t *input = vam->input;
17964 /* Parse args required to build the message */
17965 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17967 if (unformat (input, "enable"))
17972 else if (unformat (input, "disable"))
17982 errmsg ("Value not set");
17986 M (ONE_STATS_ENABLE_DISABLE, mp);
17992 /* wait for reply */
17998 api_show_one_stats_enable_disable (vat_main_t * vam)
18000 vl_api_show_one_stats_enable_disable_t *mp;
18003 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18008 /* wait for reply */
18014 api_show_one_map_request_mode (vat_main_t * vam)
18016 vl_api_show_one_map_request_mode_t *mp;
18019 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18024 /* wait for reply */
18029 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18032 api_one_map_request_mode (vat_main_t * vam)
18034 unformat_input_t *input = vam->input;
18035 vl_api_one_map_request_mode_t *mp;
18039 /* Parse args required to build the message */
18040 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18042 if (unformat (input, "dst-only"))
18044 else if (unformat (input, "src-dst"))
18048 errmsg ("parse error '%U'", format_unformat_error, input);
18053 M (ONE_MAP_REQUEST_MODE, mp);
18060 /* wait for reply */
18065 #define api_lisp_map_request_mode api_one_map_request_mode
18068 * Enable/disable ONE proxy ITR.
18070 * @param vam vpp API test context
18071 * @return return code
18074 api_one_pitr_set_locator_set (vat_main_t * vam)
18076 u8 ls_name_set = 0;
18077 unformat_input_t *input = vam->input;
18078 vl_api_one_pitr_set_locator_set_t *mp;
18083 /* Parse args required to build the message */
18084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18086 if (unformat (input, "del"))
18088 else if (unformat (input, "locator-set %s", &ls_name))
18092 errmsg ("parse error '%U'", format_unformat_error, input);
18099 errmsg ("locator-set name not set!");
18103 M (ONE_PITR_SET_LOCATOR_SET, mp);
18105 mp->is_add = is_add;
18106 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18107 vec_free (ls_name);
18112 /* wait for reply */
18117 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18120 api_one_nsh_set_locator_set (vat_main_t * vam)
18122 u8 ls_name_set = 0;
18123 unformat_input_t *input = vam->input;
18124 vl_api_one_nsh_set_locator_set_t *mp;
18129 /* Parse args required to build the message */
18130 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18132 if (unformat (input, "del"))
18134 else if (unformat (input, "ls %s", &ls_name))
18138 errmsg ("parse error '%U'", format_unformat_error, input);
18143 if (!ls_name_set && is_add)
18145 errmsg ("locator-set name not set!");
18149 M (ONE_NSH_SET_LOCATOR_SET, mp);
18151 mp->is_add = is_add;
18152 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18153 vec_free (ls_name);
18158 /* wait for reply */
18164 api_show_one_pitr (vat_main_t * vam)
18166 vl_api_show_one_pitr_t *mp;
18169 if (!vam->json_output)
18171 print (vam->ofp, "%=20s", "lisp status:");
18174 M (SHOW_ONE_PITR, mp);
18178 /* Wait for a reply... */
18183 #define api_show_lisp_pitr api_show_one_pitr
18186 api_one_use_petr (vat_main_t * vam)
18188 unformat_input_t *input = vam->input;
18189 vl_api_one_use_petr_t *mp;
18194 memset (&ip, 0, sizeof (ip));
18196 /* Parse args required to build the message */
18197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18199 if (unformat (input, "disable"))
18202 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18205 ip_addr_version (&ip) = IP4;
18208 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18211 ip_addr_version (&ip) = IP6;
18215 errmsg ("parse error '%U'", format_unformat_error, input);
18220 M (ONE_USE_PETR, mp);
18222 mp->is_add = is_add;
18225 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18227 clib_memcpy (mp->address, &ip, 4);
18229 clib_memcpy (mp->address, &ip, 16);
18235 /* wait for reply */
18240 #define api_lisp_use_petr api_one_use_petr
18243 api_show_one_nsh_mapping (vat_main_t * vam)
18245 vl_api_show_one_use_petr_t *mp;
18248 if (!vam->json_output)
18250 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18253 M (SHOW_ONE_NSH_MAPPING, mp);
18257 /* Wait for a reply... */
18263 api_show_one_use_petr (vat_main_t * vam)
18265 vl_api_show_one_use_petr_t *mp;
18268 if (!vam->json_output)
18270 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18273 M (SHOW_ONE_USE_PETR, mp);
18277 /* Wait for a reply... */
18282 #define api_show_lisp_use_petr api_show_one_use_petr
18285 * Add/delete mapping between vni and vrf
18288 api_one_eid_table_add_del_map (vat_main_t * vam)
18290 unformat_input_t *input = vam->input;
18291 vl_api_one_eid_table_add_del_map_t *mp;
18292 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18293 u32 vni, vrf, bd_index;
18296 /* Parse args required to build the message */
18297 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18299 if (unformat (input, "del"))
18301 else if (unformat (input, "vrf %d", &vrf))
18303 else if (unformat (input, "bd_index %d", &bd_index))
18305 else if (unformat (input, "vni %d", &vni))
18311 if (!vni_set || (!vrf_set && !bd_index_set))
18313 errmsg ("missing arguments!");
18317 if (vrf_set && bd_index_set)
18319 errmsg ("error: both vrf and bd entered!");
18323 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18325 mp->is_add = is_add;
18326 mp->vni = htonl (vni);
18327 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18328 mp->is_l2 = bd_index_set;
18333 /* wait for reply */
18338 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18341 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18343 u32 *action = va_arg (*args, u32 *);
18346 if (unformat (input, "%s", &s))
18348 if (!strcmp ((char *) s, "no-action"))
18350 else if (!strcmp ((char *) s, "natively-forward"))
18352 else if (!strcmp ((char *) s, "send-map-request"))
18354 else if (!strcmp ((char *) s, "drop"))
18358 clib_warning ("invalid action: '%s'", s);
18370 * Add/del remote mapping to/from ONE control plane
18372 * @param vam vpp API test context
18373 * @return return code
18376 api_one_add_del_remote_mapping (vat_main_t * vam)
18378 unformat_input_t *input = vam->input;
18379 vl_api_one_add_del_remote_mapping_t *mp;
18381 lisp_eid_vat_t _eid, *eid = &_eid;
18382 lisp_eid_vat_t _seid, *seid = &_seid;
18383 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18384 u32 action = ~0, p, w, data_len;
18385 ip4_address_t rloc4;
18386 ip6_address_t rloc6;
18387 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18390 memset (&rloc, 0, sizeof (rloc));
18392 /* Parse args required to build the message */
18393 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18395 if (unformat (input, "del-all"))
18399 else if (unformat (input, "del"))
18403 else if (unformat (input, "add"))
18407 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18411 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18415 else if (unformat (input, "vni %d", &vni))
18419 else if (unformat (input, "p %d w %d", &p, &w))
18423 errmsg ("No RLOC configured for setting priority/weight!");
18426 curr_rloc->priority = p;
18427 curr_rloc->weight = w;
18429 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18432 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18433 vec_add1 (rlocs, rloc);
18434 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18436 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18439 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18440 vec_add1 (rlocs, rloc);
18441 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18443 else if (unformat (input, "action %U",
18444 unformat_negative_mapping_action, &action))
18450 clib_warning ("parse error '%U'", format_unformat_error, input);
18457 errmsg ("missing params!");
18461 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18463 errmsg ("no action set for negative map-reply!");
18467 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18469 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18470 mp->is_add = is_add;
18471 mp->vni = htonl (vni);
18472 mp->action = (u8) action;
18473 mp->is_src_dst = seid_set;
18474 mp->eid_len = eid->len;
18475 mp->seid_len = seid->len;
18476 mp->del_all = del_all;
18477 mp->eid_type = eid->type;
18478 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18479 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18481 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18482 clib_memcpy (mp->rlocs, rlocs, data_len);
18488 /* Wait for a reply... */
18493 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18496 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18497 * forwarding entries in data-plane accordingly.
18499 * @param vam vpp API test context
18500 * @return return code
18503 api_one_add_del_adjacency (vat_main_t * vam)
18505 unformat_input_t *input = vam->input;
18506 vl_api_one_add_del_adjacency_t *mp;
18508 ip4_address_t leid4, reid4;
18509 ip6_address_t leid6, reid6;
18510 u8 reid_mac[6] = { 0 };
18511 u8 leid_mac[6] = { 0 };
18512 u8 reid_type, leid_type;
18513 u32 leid_len = 0, reid_len = 0, len;
18517 leid_type = reid_type = (u8) ~ 0;
18519 /* Parse args required to build the message */
18520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18522 if (unformat (input, "del"))
18526 else if (unformat (input, "add"))
18530 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18533 reid_type = 0; /* ipv4 */
18536 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18539 reid_type = 1; /* ipv6 */
18542 else if (unformat (input, "reid %U", unformat_ethernet_address,
18545 reid_type = 2; /* mac */
18547 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18550 leid_type = 0; /* ipv4 */
18553 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18556 leid_type = 1; /* ipv6 */
18559 else if (unformat (input, "leid %U", unformat_ethernet_address,
18562 leid_type = 2; /* mac */
18564 else if (unformat (input, "vni %d", &vni))
18570 errmsg ("parse error '%U'", format_unformat_error, input);
18575 if ((u8) ~ 0 == reid_type)
18577 errmsg ("missing params!");
18581 if (leid_type != reid_type)
18583 errmsg ("remote and local EIDs are of different types!");
18587 M (ONE_ADD_DEL_ADJACENCY, mp);
18588 mp->is_add = is_add;
18589 mp->vni = htonl (vni);
18590 mp->leid_len = leid_len;
18591 mp->reid_len = reid_len;
18592 mp->eid_type = reid_type;
18594 switch (mp->eid_type)
18597 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18598 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18601 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18602 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18605 clib_memcpy (mp->leid, leid_mac, 6);
18606 clib_memcpy (mp->reid, reid_mac, 6);
18609 errmsg ("unknown EID type %d!", mp->eid_type);
18616 /* Wait for a reply... */
18621 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18624 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18626 u32 *mode = va_arg (*args, u32 *);
18628 if (unformat (input, "lisp"))
18630 else if (unformat (input, "vxlan"))
18639 api_gpe_get_encap_mode (vat_main_t * vam)
18641 vl_api_gpe_get_encap_mode_t *mp;
18644 /* Construct the API message */
18645 M (GPE_GET_ENCAP_MODE, mp);
18650 /* Wait for a reply... */
18656 api_gpe_set_encap_mode (vat_main_t * vam)
18658 unformat_input_t *input = vam->input;
18659 vl_api_gpe_set_encap_mode_t *mp;
18663 /* Parse args required to build the message */
18664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18666 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18672 /* Construct the API message */
18673 M (GPE_SET_ENCAP_MODE, mp);
18680 /* Wait for a reply... */
18686 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18688 unformat_input_t *input = vam->input;
18689 vl_api_gpe_add_del_iface_t *mp;
18690 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18691 u32 dp_table = 0, vni = 0;
18694 /* Parse args required to build the message */
18695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18697 if (unformat (input, "up"))
18702 else if (unformat (input, "down"))
18707 else if (unformat (input, "table_id %d", &dp_table))
18711 else if (unformat (input, "bd_id %d", &dp_table))
18716 else if (unformat (input, "vni %d", &vni))
18724 if (action_set == 0)
18726 errmsg ("Action not set");
18729 if (dp_table_set == 0 || vni_set == 0)
18731 errmsg ("vni and dp_table must be set");
18735 /* Construct the API message */
18736 M (GPE_ADD_DEL_IFACE, mp);
18738 mp->is_add = is_add;
18739 mp->dp_table = clib_host_to_net_u32 (dp_table);
18741 mp->vni = clib_host_to_net_u32 (vni);
18746 /* Wait for a reply... */
18752 api_one_map_register_fallback_threshold (vat_main_t * vam)
18754 unformat_input_t *input = vam->input;
18755 vl_api_one_map_register_fallback_threshold_t *mp;
18760 /* Parse args required to build the message */
18761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18763 if (unformat (input, "%u", &value))
18767 clib_warning ("parse error '%U'", format_unformat_error, input);
18774 errmsg ("fallback threshold value is missing!");
18778 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18779 mp->value = clib_host_to_net_u32 (value);
18784 /* Wait for a reply... */
18790 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18792 vl_api_show_one_map_register_fallback_threshold_t *mp;
18795 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18800 /* Wait for a reply... */
18806 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18808 u32 *proto = va_arg (*args, u32 *);
18810 if (unformat (input, "udp"))
18812 else if (unformat (input, "api"))
18821 api_one_set_transport_protocol (vat_main_t * vam)
18823 unformat_input_t *input = vam->input;
18824 vl_api_one_set_transport_protocol_t *mp;
18829 /* Parse args required to build the message */
18830 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18832 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18836 clib_warning ("parse error '%U'", format_unformat_error, input);
18843 errmsg ("Transport protocol missing!");
18847 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18848 mp->protocol = (u8) protocol;
18853 /* Wait for a reply... */
18859 api_one_get_transport_protocol (vat_main_t * vam)
18861 vl_api_one_get_transport_protocol_t *mp;
18864 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18869 /* Wait for a reply... */
18875 api_one_map_register_set_ttl (vat_main_t * vam)
18877 unformat_input_t *input = vam->input;
18878 vl_api_one_map_register_set_ttl_t *mp;
18883 /* Parse args required to build the message */
18884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18886 if (unformat (input, "%u", &ttl))
18890 clib_warning ("parse error '%U'", format_unformat_error, input);
18897 errmsg ("TTL value missing!");
18901 M (ONE_MAP_REGISTER_SET_TTL, mp);
18902 mp->ttl = clib_host_to_net_u32 (ttl);
18907 /* Wait for a reply... */
18913 api_show_one_map_register_ttl (vat_main_t * vam)
18915 vl_api_show_one_map_register_ttl_t *mp;
18918 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18923 /* Wait for a reply... */
18929 * Add/del map request itr rlocs from ONE control plane and updates
18931 * @param vam vpp API test context
18932 * @return return code
18935 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18937 unformat_input_t *input = vam->input;
18938 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18939 u8 *locator_set_name = 0;
18940 u8 locator_set_name_set = 0;
18944 /* Parse args required to build the message */
18945 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18947 if (unformat (input, "del"))
18951 else if (unformat (input, "%_%v%_", &locator_set_name))
18953 locator_set_name_set = 1;
18957 clib_warning ("parse error '%U'", format_unformat_error, input);
18962 if (is_add && !locator_set_name_set)
18964 errmsg ("itr-rloc is not set!");
18968 if (is_add && vec_len (locator_set_name) > 64)
18970 errmsg ("itr-rloc locator-set name too long");
18971 vec_free (locator_set_name);
18975 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18976 mp->is_add = is_add;
18979 clib_memcpy (mp->locator_set_name, locator_set_name,
18980 vec_len (locator_set_name));
18984 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18986 vec_free (locator_set_name);
18991 /* Wait for a reply... */
18996 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18999 api_one_locator_dump (vat_main_t * vam)
19001 unformat_input_t *input = vam->input;
19002 vl_api_one_locator_dump_t *mp;
19003 vl_api_control_ping_t *mp_ping;
19004 u8 is_index_set = 0, is_name_set = 0;
19009 /* Parse args required to build the message */
19010 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19012 if (unformat (input, "ls_name %_%v%_", &ls_name))
19016 else if (unformat (input, "ls_index %d", &ls_index))
19022 errmsg ("parse error '%U'", format_unformat_error, input);
19027 if (!is_index_set && !is_name_set)
19029 errmsg ("error: expected one of index or name!");
19033 if (is_index_set && is_name_set)
19035 errmsg ("error: only one param expected!");
19039 if (vec_len (ls_name) > 62)
19041 errmsg ("error: locator set name too long!");
19045 if (!vam->json_output)
19047 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19050 M (ONE_LOCATOR_DUMP, mp);
19051 mp->is_index_set = is_index_set;
19054 mp->ls_index = clib_host_to_net_u32 (ls_index);
19057 vec_add1 (ls_name, 0);
19058 strncpy ((char *) mp->ls_name, (char *) ls_name,
19059 sizeof (mp->ls_name) - 1);
19065 /* Use a control ping for synchronization */
19066 MPING (CONTROL_PING, mp_ping);
19069 /* Wait for a reply... */
19074 #define api_lisp_locator_dump api_one_locator_dump
19077 api_one_locator_set_dump (vat_main_t * vam)
19079 vl_api_one_locator_set_dump_t *mp;
19080 vl_api_control_ping_t *mp_ping;
19081 unformat_input_t *input = vam->input;
19085 /* Parse args required to build the message */
19086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19088 if (unformat (input, "local"))
19092 else if (unformat (input, "remote"))
19098 errmsg ("parse error '%U'", format_unformat_error, input);
19103 if (!vam->json_output)
19105 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19108 M (ONE_LOCATOR_SET_DUMP, mp);
19110 mp->filter = filter;
19115 /* Use a control ping for synchronization */
19116 MPING (CONTROL_PING, mp_ping);
19119 /* Wait for a reply... */
19124 #define api_lisp_locator_set_dump api_one_locator_set_dump
19127 api_one_eid_table_map_dump (vat_main_t * vam)
19131 unformat_input_t *input = vam->input;
19132 vl_api_one_eid_table_map_dump_t *mp;
19133 vl_api_control_ping_t *mp_ping;
19136 /* Parse args required to build the message */
19137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19139 if (unformat (input, "l2"))
19144 else if (unformat (input, "l3"))
19151 errmsg ("parse error '%U'", format_unformat_error, input);
19158 errmsg ("expected one of 'l2' or 'l3' parameter!");
19162 if (!vam->json_output)
19164 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19167 M (ONE_EID_TABLE_MAP_DUMP, mp);
19173 /* Use a control ping for synchronization */
19174 MPING (CONTROL_PING, mp_ping);
19177 /* Wait for a reply... */
19182 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19185 api_one_eid_table_vni_dump (vat_main_t * vam)
19187 vl_api_one_eid_table_vni_dump_t *mp;
19188 vl_api_control_ping_t *mp_ping;
19191 if (!vam->json_output)
19193 print (vam->ofp, "VNI");
19196 M (ONE_EID_TABLE_VNI_DUMP, mp);
19201 /* Use a control ping for synchronization */
19202 MPING (CONTROL_PING, mp_ping);
19205 /* Wait for a reply... */
19210 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19213 api_one_eid_table_dump (vat_main_t * vam)
19215 unformat_input_t *i = vam->input;
19216 vl_api_one_eid_table_dump_t *mp;
19217 vl_api_control_ping_t *mp_ping;
19218 struct in_addr ip4;
19219 struct in6_addr ip6;
19221 u8 eid_type = ~0, eid_set = 0;
19222 u32 prefix_length = ~0, t, vni = 0;
19225 lisp_nsh_api_t nsh;
19227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19229 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19235 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19241 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19246 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19251 else if (unformat (i, "vni %d", &t))
19255 else if (unformat (i, "local"))
19259 else if (unformat (i, "remote"))
19265 errmsg ("parse error '%U'", format_unformat_error, i);
19270 if (!vam->json_output)
19272 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19273 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19276 M (ONE_EID_TABLE_DUMP, mp);
19278 mp->filter = filter;
19282 mp->vni = htonl (vni);
19283 mp->eid_type = eid_type;
19287 mp->prefix_length = prefix_length;
19288 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19291 mp->prefix_length = prefix_length;
19292 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19295 clib_memcpy (mp->eid, mac, sizeof (mac));
19298 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19301 errmsg ("unknown EID type %d!", eid_type);
19309 /* Use a control ping for synchronization */
19310 MPING (CONTROL_PING, mp_ping);
19313 /* Wait for a reply... */
19318 #define api_lisp_eid_table_dump api_one_eid_table_dump
19321 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19323 unformat_input_t *i = vam->input;
19324 vl_api_gpe_fwd_entries_get_t *mp;
19329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19331 if (unformat (i, "vni %d", &vni))
19337 errmsg ("parse error '%U'", format_unformat_error, i);
19344 errmsg ("vni not set!");
19348 if (!vam->json_output)
19350 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19354 M (GPE_FWD_ENTRIES_GET, mp);
19355 mp->vni = clib_host_to_net_u32 (vni);
19360 /* Wait for a reply... */
19365 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19366 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19367 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19368 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19369 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19370 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19371 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19372 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19375 api_one_adjacencies_get (vat_main_t * vam)
19377 unformat_input_t *i = vam->input;
19378 vl_api_one_adjacencies_get_t *mp;
19383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19385 if (unformat (i, "vni %d", &vni))
19391 errmsg ("parse error '%U'", format_unformat_error, i);
19398 errmsg ("vni not set!");
19402 if (!vam->json_output)
19404 print (vam->ofp, "%s %40s", "leid", "reid");
19407 M (ONE_ADJACENCIES_GET, mp);
19408 mp->vni = clib_host_to_net_u32 (vni);
19413 /* Wait for a reply... */
19418 #define api_lisp_adjacencies_get api_one_adjacencies_get
19421 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19423 unformat_input_t *i = vam->input;
19424 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19426 u8 ip_family_set = 0, is_ip4 = 1;
19428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19430 if (unformat (i, "ip4"))
19435 else if (unformat (i, "ip6"))
19442 errmsg ("parse error '%U'", format_unformat_error, i);
19447 if (!ip_family_set)
19449 errmsg ("ip family not set!");
19453 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19454 mp->is_ip4 = is_ip4;
19459 /* Wait for a reply... */
19465 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19467 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19470 if (!vam->json_output)
19472 print (vam->ofp, "VNIs");
19475 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19480 /* Wait for a reply... */
19486 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19488 unformat_input_t *i = vam->input;
19489 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19491 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19492 struct in_addr ip4;
19493 struct in6_addr ip6;
19494 u32 table_id = 0, nh_sw_if_index = ~0;
19496 memset (&ip4, 0, sizeof (ip4));
19497 memset (&ip6, 0, sizeof (ip6));
19499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19501 if (unformat (i, "del"))
19503 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19504 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19509 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19510 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19515 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19519 nh_sw_if_index = ~0;
19521 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19525 nh_sw_if_index = ~0;
19527 else if (unformat (i, "table %d", &table_id))
19531 errmsg ("parse error '%U'", format_unformat_error, i);
19538 errmsg ("nh addr not set!");
19542 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19543 mp->is_add = is_add;
19544 mp->table_id = clib_host_to_net_u32 (table_id);
19545 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19546 mp->is_ip4 = is_ip4;
19548 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19550 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19555 /* Wait for a reply... */
19561 api_one_map_server_dump (vat_main_t * vam)
19563 vl_api_one_map_server_dump_t *mp;
19564 vl_api_control_ping_t *mp_ping;
19567 if (!vam->json_output)
19569 print (vam->ofp, "%=20s", "Map server");
19572 M (ONE_MAP_SERVER_DUMP, mp);
19576 /* Use a control ping for synchronization */
19577 MPING (CONTROL_PING, mp_ping);
19580 /* Wait for a reply... */
19585 #define api_lisp_map_server_dump api_one_map_server_dump
19588 api_one_map_resolver_dump (vat_main_t * vam)
19590 vl_api_one_map_resolver_dump_t *mp;
19591 vl_api_control_ping_t *mp_ping;
19594 if (!vam->json_output)
19596 print (vam->ofp, "%=20s", "Map resolver");
19599 M (ONE_MAP_RESOLVER_DUMP, mp);
19603 /* Use a control ping for synchronization */
19604 MPING (CONTROL_PING, mp_ping);
19607 /* Wait for a reply... */
19612 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19615 api_one_stats_flush (vat_main_t * vam)
19617 vl_api_one_stats_flush_t *mp;
19620 M (ONE_STATS_FLUSH, mp);
19627 api_one_stats_dump (vat_main_t * vam)
19629 vl_api_one_stats_dump_t *mp;
19630 vl_api_control_ping_t *mp_ping;
19633 M (ONE_STATS_DUMP, mp);
19637 /* Use a control ping for synchronization */
19638 MPING (CONTROL_PING, mp_ping);
19641 /* Wait for a reply... */
19647 api_show_one_status (vat_main_t * vam)
19649 vl_api_show_one_status_t *mp;
19652 if (!vam->json_output)
19654 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19657 M (SHOW_ONE_STATUS, mp);
19660 /* Wait for a reply... */
19665 #define api_show_lisp_status api_show_one_status
19668 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19670 vl_api_gpe_fwd_entry_path_dump_t *mp;
19671 vl_api_control_ping_t *mp_ping;
19672 unformat_input_t *i = vam->input;
19673 u32 fwd_entry_index = ~0;
19676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19678 if (unformat (i, "index %d", &fwd_entry_index))
19684 if (~0 == fwd_entry_index)
19686 errmsg ("no index specified!");
19690 if (!vam->json_output)
19692 print (vam->ofp, "first line");
19695 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19699 /* Use a control ping for synchronization */
19700 MPING (CONTROL_PING, mp_ping);
19703 /* Wait for a reply... */
19709 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19711 vl_api_one_get_map_request_itr_rlocs_t *mp;
19714 if (!vam->json_output)
19716 print (vam->ofp, "%=20s", "itr-rlocs:");
19719 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19722 /* Wait for a reply... */
19727 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19730 api_af_packet_create (vat_main_t * vam)
19732 unformat_input_t *i = vam->input;
19733 vl_api_af_packet_create_t *mp;
19734 u8 *host_if_name = 0;
19736 u8 random_hw_addr = 1;
19739 memset (hw_addr, 0, sizeof (hw_addr));
19741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19743 if (unformat (i, "name %s", &host_if_name))
19744 vec_add1 (host_if_name, 0);
19745 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19746 random_hw_addr = 0;
19751 if (!vec_len (host_if_name))
19753 errmsg ("host-interface name must be specified");
19757 if (vec_len (host_if_name) > 64)
19759 errmsg ("host-interface name too long");
19763 M (AF_PACKET_CREATE, mp);
19765 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19766 clib_memcpy (mp->hw_addr, hw_addr, 6);
19767 mp->use_random_hw_addr = random_hw_addr;
19768 vec_free (host_if_name);
19776 fprintf (vam->ofp ? vam->ofp : stderr,
19777 " new sw_if_index = %d\n", vam->sw_if_index);
19784 api_af_packet_delete (vat_main_t * vam)
19786 unformat_input_t *i = vam->input;
19787 vl_api_af_packet_delete_t *mp;
19788 u8 *host_if_name = 0;
19791 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19793 if (unformat (i, "name %s", &host_if_name))
19794 vec_add1 (host_if_name, 0);
19799 if (!vec_len (host_if_name))
19801 errmsg ("host-interface name must be specified");
19805 if (vec_len (host_if_name) > 64)
19807 errmsg ("host-interface name too long");
19811 M (AF_PACKET_DELETE, mp);
19813 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19814 vec_free (host_if_name);
19821 static void vl_api_af_packet_details_t_handler
19822 (vl_api_af_packet_details_t * mp)
19824 vat_main_t *vam = &vat_main;
19826 print (vam->ofp, "%-16s %d",
19827 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19830 static void vl_api_af_packet_details_t_handler_json
19831 (vl_api_af_packet_details_t * mp)
19833 vat_main_t *vam = &vat_main;
19834 vat_json_node_t *node = NULL;
19836 if (VAT_JSON_ARRAY != vam->json_tree.type)
19838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19839 vat_json_init_array (&vam->json_tree);
19841 node = vat_json_array_add (&vam->json_tree);
19843 vat_json_init_object (node);
19844 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19845 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19849 api_af_packet_dump (vat_main_t * vam)
19851 vl_api_af_packet_dump_t *mp;
19852 vl_api_control_ping_t *mp_ping;
19855 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19856 /* Get list of tap interfaces */
19857 M (AF_PACKET_DUMP, mp);
19860 /* Use a control ping for synchronization */
19861 MPING (CONTROL_PING, mp_ping);
19869 api_policer_add_del (vat_main_t * vam)
19871 unformat_input_t *i = vam->input;
19872 vl_api_policer_add_del_t *mp;
19882 u8 color_aware = 0;
19883 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19886 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19887 conform_action.dscp = 0;
19888 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19889 exceed_action.dscp = 0;
19890 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19891 violate_action.dscp = 0;
19893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19895 if (unformat (i, "del"))
19897 else if (unformat (i, "name %s", &name))
19898 vec_add1 (name, 0);
19899 else if (unformat (i, "cir %u", &cir))
19901 else if (unformat (i, "eir %u", &eir))
19903 else if (unformat (i, "cb %u", &cb))
19905 else if (unformat (i, "eb %u", &eb))
19907 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19910 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19913 else if (unformat (i, "type %U", unformat_policer_type, &type))
19915 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19918 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19921 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19924 else if (unformat (i, "color-aware"))
19930 if (!vec_len (name))
19932 errmsg ("policer name must be specified");
19936 if (vec_len (name) > 64)
19938 errmsg ("policer name too long");
19942 M (POLICER_ADD_DEL, mp);
19944 clib_memcpy (mp->name, name, vec_len (name));
19946 mp->is_add = is_add;
19947 mp->cir = ntohl (cir);
19948 mp->eir = ntohl (eir);
19949 mp->cb = clib_net_to_host_u64 (cb);
19950 mp->eb = clib_net_to_host_u64 (eb);
19951 mp->rate_type = rate_type;
19952 mp->round_type = round_type;
19954 mp->conform_action_type = conform_action.action_type;
19955 mp->conform_dscp = conform_action.dscp;
19956 mp->exceed_action_type = exceed_action.action_type;
19957 mp->exceed_dscp = exceed_action.dscp;
19958 mp->violate_action_type = violate_action.action_type;
19959 mp->violate_dscp = violate_action.dscp;
19960 mp->color_aware = color_aware;
19968 api_policer_dump (vat_main_t * vam)
19970 unformat_input_t *i = vam->input;
19971 vl_api_policer_dump_t *mp;
19972 vl_api_control_ping_t *mp_ping;
19973 u8 *match_name = 0;
19974 u8 match_name_valid = 0;
19977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19979 if (unformat (i, "name %s", &match_name))
19981 vec_add1 (match_name, 0);
19982 match_name_valid = 1;
19988 M (POLICER_DUMP, mp);
19989 mp->match_name_valid = match_name_valid;
19990 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19991 vec_free (match_name);
19995 /* Use a control ping for synchronization */
19996 MPING (CONTROL_PING, mp_ping);
19999 /* Wait for a reply... */
20005 api_policer_classify_set_interface (vat_main_t * vam)
20007 unformat_input_t *i = vam->input;
20008 vl_api_policer_classify_set_interface_t *mp;
20010 int sw_if_index_set;
20011 u32 ip4_table_index = ~0;
20012 u32 ip6_table_index = ~0;
20013 u32 l2_table_index = ~0;
20017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20020 sw_if_index_set = 1;
20021 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20022 sw_if_index_set = 1;
20023 else if (unformat (i, "del"))
20025 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20027 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20029 else if (unformat (i, "l2-table %d", &l2_table_index))
20033 clib_warning ("parse error '%U'", format_unformat_error, i);
20038 if (sw_if_index_set == 0)
20040 errmsg ("missing interface name or sw_if_index");
20044 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20046 mp->sw_if_index = ntohl (sw_if_index);
20047 mp->ip4_table_index = ntohl (ip4_table_index);
20048 mp->ip6_table_index = ntohl (ip6_table_index);
20049 mp->l2_table_index = ntohl (l2_table_index);
20050 mp->is_add = is_add;
20058 api_policer_classify_dump (vat_main_t * vam)
20060 unformat_input_t *i = vam->input;
20061 vl_api_policer_classify_dump_t *mp;
20062 vl_api_control_ping_t *mp_ping;
20063 u8 type = POLICER_CLASSIFY_N_TABLES;
20066 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20070 errmsg ("classify table type must be specified");
20074 if (!vam->json_output)
20076 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20079 M (POLICER_CLASSIFY_DUMP, mp);
20084 /* Use a control ping for synchronization */
20085 MPING (CONTROL_PING, mp_ping);
20088 /* Wait for a reply... */
20094 api_netmap_create (vat_main_t * vam)
20096 unformat_input_t *i = vam->input;
20097 vl_api_netmap_create_t *mp;
20100 u8 random_hw_addr = 1;
20105 memset (hw_addr, 0, sizeof (hw_addr));
20107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20109 if (unformat (i, "name %s", &if_name))
20110 vec_add1 (if_name, 0);
20111 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20112 random_hw_addr = 0;
20113 else if (unformat (i, "pipe"))
20115 else if (unformat (i, "master"))
20117 else if (unformat (i, "slave"))
20123 if (!vec_len (if_name))
20125 errmsg ("interface name must be specified");
20129 if (vec_len (if_name) > 64)
20131 errmsg ("interface name too long");
20135 M (NETMAP_CREATE, mp);
20137 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20138 clib_memcpy (mp->hw_addr, hw_addr, 6);
20139 mp->use_random_hw_addr = random_hw_addr;
20140 mp->is_pipe = is_pipe;
20141 mp->is_master = is_master;
20142 vec_free (if_name);
20150 api_netmap_delete (vat_main_t * vam)
20152 unformat_input_t *i = vam->input;
20153 vl_api_netmap_delete_t *mp;
20157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20159 if (unformat (i, "name %s", &if_name))
20160 vec_add1 (if_name, 0);
20165 if (!vec_len (if_name))
20167 errmsg ("interface name must be specified");
20171 if (vec_len (if_name) > 64)
20173 errmsg ("interface name too long");
20177 M (NETMAP_DELETE, mp);
20179 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20180 vec_free (if_name);
20188 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20190 if (fp->afi == IP46_TYPE_IP6)
20192 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20193 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20194 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20195 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20196 format_ip6_address, fp->next_hop);
20197 else if (fp->afi == IP46_TYPE_IP4)
20199 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20200 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20201 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20202 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20203 format_ip4_address, fp->next_hop);
20207 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20208 vl_api_fib_path_t * fp)
20210 struct in_addr ip4;
20211 struct in6_addr ip6;
20213 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20214 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20215 vat_json_object_add_uint (node, "is_local", fp->is_local);
20216 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20217 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20218 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20219 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20220 if (fp->afi == IP46_TYPE_IP4)
20222 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20223 vat_json_object_add_ip4 (node, "next_hop", ip4);
20225 else if (fp->afi == IP46_TYPE_IP6)
20227 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20228 vat_json_object_add_ip6 (node, "next_hop", ip6);
20233 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20235 vat_main_t *vam = &vat_main;
20236 int count = ntohl (mp->mt_count);
20237 vl_api_fib_path_t *fp;
20240 print (vam->ofp, "[%d]: sw_if_index %d via:",
20241 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20243 for (i = 0; i < count; i++)
20245 vl_api_mpls_fib_path_print (vam, fp);
20249 print (vam->ofp, "");
20252 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20253 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20256 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20258 vat_main_t *vam = &vat_main;
20259 vat_json_node_t *node = NULL;
20260 int count = ntohl (mp->mt_count);
20261 vl_api_fib_path_t *fp;
20264 if (VAT_JSON_ARRAY != vam->json_tree.type)
20266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20267 vat_json_init_array (&vam->json_tree);
20269 node = vat_json_array_add (&vam->json_tree);
20271 vat_json_init_object (node);
20272 vat_json_object_add_uint (node, "tunnel_index",
20273 ntohl (mp->mt_tunnel_index));
20274 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20276 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20279 for (i = 0; i < count; i++)
20281 vl_api_mpls_fib_path_json_print (node, fp);
20287 api_mpls_tunnel_dump (vat_main_t * vam)
20289 vl_api_mpls_tunnel_dump_t *mp;
20290 vl_api_control_ping_t *mp_ping;
20294 /* Parse args required to build the message */
20295 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20297 if (!unformat (vam->input, "tunnel_index %d", &index))
20304 print (vam->ofp, " tunnel_index %d", index);
20306 M (MPLS_TUNNEL_DUMP, mp);
20307 mp->tunnel_index = htonl (index);
20310 /* Use a control ping for synchronization */
20311 MPING (CONTROL_PING, mp_ping);
20318 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20319 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20323 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20325 vat_main_t *vam = &vat_main;
20326 int count = ntohl (mp->count);
20327 vl_api_fib_path_t *fp;
20331 "table-id %d, label %u, ess_bit %u",
20332 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20334 for (i = 0; i < count; i++)
20336 vl_api_mpls_fib_path_print (vam, fp);
20341 static void vl_api_mpls_fib_details_t_handler_json
20342 (vl_api_mpls_fib_details_t * mp)
20344 vat_main_t *vam = &vat_main;
20345 int count = ntohl (mp->count);
20346 vat_json_node_t *node = NULL;
20347 vl_api_fib_path_t *fp;
20350 if (VAT_JSON_ARRAY != vam->json_tree.type)
20352 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20353 vat_json_init_array (&vam->json_tree);
20355 node = vat_json_array_add (&vam->json_tree);
20357 vat_json_init_object (node);
20358 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20359 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20360 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20361 vat_json_object_add_uint (node, "path_count", count);
20363 for (i = 0; i < count; i++)
20365 vl_api_mpls_fib_path_json_print (node, fp);
20371 api_mpls_fib_dump (vat_main_t * vam)
20373 vl_api_mpls_fib_dump_t *mp;
20374 vl_api_control_ping_t *mp_ping;
20377 M (MPLS_FIB_DUMP, mp);
20380 /* Use a control ping for synchronization */
20381 MPING (CONTROL_PING, mp_ping);
20388 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20389 #define vl_api_ip_fib_details_t_print vl_noop_handler
20392 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20394 vat_main_t *vam = &vat_main;
20395 int count = ntohl (mp->count);
20396 vl_api_fib_path_t *fp;
20400 "table-id %d, prefix %U/%d",
20401 ntohl (mp->table_id), format_ip4_address, mp->address,
20402 mp->address_length);
20404 for (i = 0; i < count; i++)
20406 if (fp->afi == IP46_TYPE_IP6)
20408 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20409 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20410 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20411 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20412 format_ip6_address, fp->next_hop);
20413 else if (fp->afi == IP46_TYPE_IP4)
20415 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20416 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20417 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20418 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20419 format_ip4_address, fp->next_hop);
20424 static void vl_api_ip_fib_details_t_handler_json
20425 (vl_api_ip_fib_details_t * mp)
20427 vat_main_t *vam = &vat_main;
20428 int count = ntohl (mp->count);
20429 vat_json_node_t *node = NULL;
20430 struct in_addr ip4;
20431 struct in6_addr ip6;
20432 vl_api_fib_path_t *fp;
20435 if (VAT_JSON_ARRAY != vam->json_tree.type)
20437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20438 vat_json_init_array (&vam->json_tree);
20440 node = vat_json_array_add (&vam->json_tree);
20442 vat_json_init_object (node);
20443 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20444 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20445 vat_json_object_add_ip4 (node, "prefix", ip4);
20446 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20447 vat_json_object_add_uint (node, "path_count", count);
20449 for (i = 0; i < count; i++)
20451 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20452 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20453 vat_json_object_add_uint (node, "is_local", fp->is_local);
20454 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20455 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20456 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20457 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20458 if (fp->afi == IP46_TYPE_IP4)
20460 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20461 vat_json_object_add_ip4 (node, "next_hop", ip4);
20463 else if (fp->afi == IP46_TYPE_IP6)
20465 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20466 vat_json_object_add_ip6 (node, "next_hop", ip6);
20472 api_ip_fib_dump (vat_main_t * vam)
20474 vl_api_ip_fib_dump_t *mp;
20475 vl_api_control_ping_t *mp_ping;
20478 M (IP_FIB_DUMP, mp);
20481 /* Use a control ping for synchronization */
20482 MPING (CONTROL_PING, mp_ping);
20490 api_ip_mfib_dump (vat_main_t * vam)
20492 vl_api_ip_mfib_dump_t *mp;
20493 vl_api_control_ping_t *mp_ping;
20496 M (IP_MFIB_DUMP, mp);
20499 /* Use a control ping for synchronization */
20500 MPING (CONTROL_PING, mp_ping);
20507 static void vl_api_ip_neighbor_details_t_handler
20508 (vl_api_ip_neighbor_details_t * mp)
20510 vat_main_t *vam = &vat_main;
20512 print (vam->ofp, "%c %U %U",
20513 (mp->is_static) ? 'S' : 'D',
20514 format_ethernet_address, &mp->mac_address,
20515 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20519 static void vl_api_ip_neighbor_details_t_handler_json
20520 (vl_api_ip_neighbor_details_t * mp)
20523 vat_main_t *vam = &vat_main;
20524 vat_json_node_t *node;
20525 struct in_addr ip4;
20526 struct in6_addr ip6;
20528 if (VAT_JSON_ARRAY != vam->json_tree.type)
20530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20531 vat_json_init_array (&vam->json_tree);
20533 node = vat_json_array_add (&vam->json_tree);
20535 vat_json_init_object (node);
20536 vat_json_object_add_string_copy (node, "flag",
20537 (mp->is_static) ? (u8 *) "static" : (u8 *)
20540 vat_json_object_add_string_copy (node, "link_layer",
20541 format (0, "%U", format_ethernet_address,
20542 &mp->mac_address));
20546 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20547 vat_json_object_add_ip6 (node, "ip_address", ip6);
20551 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20552 vat_json_object_add_ip4 (node, "ip_address", ip4);
20557 api_ip_neighbor_dump (vat_main_t * vam)
20559 unformat_input_t *i = vam->input;
20560 vl_api_ip_neighbor_dump_t *mp;
20561 vl_api_control_ping_t *mp_ping;
20563 u32 sw_if_index = ~0;
20566 /* Parse args required to build the message */
20567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20573 else if (unformat (i, "ip6"))
20579 if (sw_if_index == ~0)
20581 errmsg ("missing interface name or sw_if_index");
20585 M (IP_NEIGHBOR_DUMP, mp);
20586 mp->is_ipv6 = (u8) is_ipv6;
20587 mp->sw_if_index = ntohl (sw_if_index);
20590 /* Use a control ping for synchronization */
20591 MPING (CONTROL_PING, mp_ping);
20598 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20599 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20602 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20604 vat_main_t *vam = &vat_main;
20605 int count = ntohl (mp->count);
20606 vl_api_fib_path_t *fp;
20610 "table-id %d, prefix %U/%d",
20611 ntohl (mp->table_id), format_ip6_address, mp->address,
20612 mp->address_length);
20614 for (i = 0; i < count; i++)
20616 if (fp->afi == IP46_TYPE_IP6)
20618 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20619 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20620 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20621 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20622 format_ip6_address, fp->next_hop);
20623 else if (fp->afi == IP46_TYPE_IP4)
20625 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20626 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20627 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20628 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20629 format_ip4_address, fp->next_hop);
20634 static void vl_api_ip6_fib_details_t_handler_json
20635 (vl_api_ip6_fib_details_t * mp)
20637 vat_main_t *vam = &vat_main;
20638 int count = ntohl (mp->count);
20639 vat_json_node_t *node = NULL;
20640 struct in_addr ip4;
20641 struct in6_addr ip6;
20642 vl_api_fib_path_t *fp;
20645 if (VAT_JSON_ARRAY != vam->json_tree.type)
20647 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20648 vat_json_init_array (&vam->json_tree);
20650 node = vat_json_array_add (&vam->json_tree);
20652 vat_json_init_object (node);
20653 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20654 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20655 vat_json_object_add_ip6 (node, "prefix", ip6);
20656 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20657 vat_json_object_add_uint (node, "path_count", count);
20659 for (i = 0; i < count; i++)
20661 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20662 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20663 vat_json_object_add_uint (node, "is_local", fp->is_local);
20664 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20665 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20666 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20667 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20668 if (fp->afi == IP46_TYPE_IP4)
20670 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20671 vat_json_object_add_ip4 (node, "next_hop", ip4);
20673 else if (fp->afi == IP46_TYPE_IP6)
20675 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20676 vat_json_object_add_ip6 (node, "next_hop", ip6);
20682 api_ip6_fib_dump (vat_main_t * vam)
20684 vl_api_ip6_fib_dump_t *mp;
20685 vl_api_control_ping_t *mp_ping;
20688 M (IP6_FIB_DUMP, mp);
20691 /* Use a control ping for synchronization */
20692 MPING (CONTROL_PING, mp_ping);
20700 api_ip6_mfib_dump (vat_main_t * vam)
20702 vl_api_ip6_mfib_dump_t *mp;
20703 vl_api_control_ping_t *mp_ping;
20706 M (IP6_MFIB_DUMP, mp);
20709 /* Use a control ping for synchronization */
20710 MPING (CONTROL_PING, mp_ping);
20718 api_classify_table_ids (vat_main_t * vam)
20720 vl_api_classify_table_ids_t *mp;
20723 /* Construct the API message */
20724 M (CLASSIFY_TABLE_IDS, mp);
20733 api_classify_table_by_interface (vat_main_t * vam)
20735 unformat_input_t *input = vam->input;
20736 vl_api_classify_table_by_interface_t *mp;
20738 u32 sw_if_index = ~0;
20740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20742 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20744 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20749 if (sw_if_index == ~0)
20751 errmsg ("missing interface name or sw_if_index");
20755 /* Construct the API message */
20756 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20758 mp->sw_if_index = ntohl (sw_if_index);
20766 api_classify_table_info (vat_main_t * vam)
20768 unformat_input_t *input = vam->input;
20769 vl_api_classify_table_info_t *mp;
20773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20775 if (unformat (input, "table_id %d", &table_id))
20780 if (table_id == ~0)
20782 errmsg ("missing table id");
20786 /* Construct the API message */
20787 M (CLASSIFY_TABLE_INFO, mp);
20789 mp->table_id = ntohl (table_id);
20797 api_classify_session_dump (vat_main_t * vam)
20799 unformat_input_t *input = vam->input;
20800 vl_api_classify_session_dump_t *mp;
20801 vl_api_control_ping_t *mp_ping;
20805 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20807 if (unformat (input, "table_id %d", &table_id))
20812 if (table_id == ~0)
20814 errmsg ("missing table id");
20818 /* Construct the API message */
20819 M (CLASSIFY_SESSION_DUMP, mp);
20821 mp->table_id = ntohl (table_id);
20824 /* Use a control ping for synchronization */
20825 MPING (CONTROL_PING, mp_ping);
20833 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20835 vat_main_t *vam = &vat_main;
20837 print (vam->ofp, "collector_address %U, collector_port %d, "
20838 "src_address %U, vrf_id %d, path_mtu %u, "
20839 "template_interval %u, udp_checksum %d",
20840 format_ip4_address, mp->collector_address,
20841 ntohs (mp->collector_port),
20842 format_ip4_address, mp->src_address,
20843 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20844 ntohl (mp->template_interval), mp->udp_checksum);
20847 vam->result_ready = 1;
20851 vl_api_ipfix_exporter_details_t_handler_json
20852 (vl_api_ipfix_exporter_details_t * mp)
20854 vat_main_t *vam = &vat_main;
20855 vat_json_node_t node;
20856 struct in_addr collector_address;
20857 struct in_addr src_address;
20859 vat_json_init_object (&node);
20860 clib_memcpy (&collector_address, &mp->collector_address,
20861 sizeof (collector_address));
20862 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20863 vat_json_object_add_uint (&node, "collector_port",
20864 ntohs (mp->collector_port));
20865 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20866 vat_json_object_add_ip4 (&node, "src_address", src_address);
20867 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20868 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20869 vat_json_object_add_uint (&node, "template_interval",
20870 ntohl (mp->template_interval));
20871 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20873 vat_json_print (vam->ofp, &node);
20874 vat_json_free (&node);
20876 vam->result_ready = 1;
20880 api_ipfix_exporter_dump (vat_main_t * vam)
20882 vl_api_ipfix_exporter_dump_t *mp;
20885 /* Construct the API message */
20886 M (IPFIX_EXPORTER_DUMP, mp);
20895 api_ipfix_classify_stream_dump (vat_main_t * vam)
20897 vl_api_ipfix_classify_stream_dump_t *mp;
20900 /* Construct the API message */
20901 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20912 vl_api_ipfix_classify_stream_details_t_handler
20913 (vl_api_ipfix_classify_stream_details_t * mp)
20915 vat_main_t *vam = &vat_main;
20916 print (vam->ofp, "domain_id %d, src_port %d",
20917 ntohl (mp->domain_id), ntohs (mp->src_port));
20919 vam->result_ready = 1;
20923 vl_api_ipfix_classify_stream_details_t_handler_json
20924 (vl_api_ipfix_classify_stream_details_t * mp)
20926 vat_main_t *vam = &vat_main;
20927 vat_json_node_t node;
20929 vat_json_init_object (&node);
20930 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20931 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20933 vat_json_print (vam->ofp, &node);
20934 vat_json_free (&node);
20936 vam->result_ready = 1;
20940 api_ipfix_classify_table_dump (vat_main_t * vam)
20942 vl_api_ipfix_classify_table_dump_t *mp;
20943 vl_api_control_ping_t *mp_ping;
20946 if (!vam->json_output)
20948 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20949 "transport_protocol");
20952 /* Construct the API message */
20953 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20958 /* Use a control ping for synchronization */
20959 MPING (CONTROL_PING, mp_ping);
20967 vl_api_ipfix_classify_table_details_t_handler
20968 (vl_api_ipfix_classify_table_details_t * mp)
20970 vat_main_t *vam = &vat_main;
20971 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20972 mp->transport_protocol);
20976 vl_api_ipfix_classify_table_details_t_handler_json
20977 (vl_api_ipfix_classify_table_details_t * mp)
20979 vat_json_node_t *node = NULL;
20980 vat_main_t *vam = &vat_main;
20982 if (VAT_JSON_ARRAY != vam->json_tree.type)
20984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20985 vat_json_init_array (&vam->json_tree);
20988 node = vat_json_array_add (&vam->json_tree);
20989 vat_json_init_object (node);
20991 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20992 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20993 vat_json_object_add_uint (node, "transport_protocol",
20994 mp->transport_protocol);
20998 api_sw_interface_span_enable_disable (vat_main_t * vam)
21000 unformat_input_t *i = vam->input;
21001 vl_api_sw_interface_span_enable_disable_t *mp;
21002 u32 src_sw_if_index = ~0;
21003 u32 dst_sw_if_index = ~0;
21008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21011 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21013 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21017 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21019 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21021 else if (unformat (i, "disable"))
21023 else if (unformat (i, "rx"))
21025 else if (unformat (i, "tx"))
21027 else if (unformat (i, "both"))
21029 else if (unformat (i, "l2"))
21035 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21037 mp->sw_if_index_from = htonl (src_sw_if_index);
21038 mp->sw_if_index_to = htonl (dst_sw_if_index);
21048 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21051 vat_main_t *vam = &vat_main;
21052 u8 *sw_if_from_name = 0;
21053 u8 *sw_if_to_name = 0;
21054 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21055 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21056 char *states[] = { "none", "rx", "tx", "both" };
21060 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21062 if ((u32) p->value[0] == sw_if_index_from)
21064 sw_if_from_name = (u8 *)(p->key);
21068 if ((u32) p->value[0] == sw_if_index_to)
21070 sw_if_to_name = (u8 *)(p->key);
21071 if (sw_if_from_name)
21076 print (vam->ofp, "%20s => %20s (%s) %s",
21077 sw_if_from_name, sw_if_to_name, states[mp->state],
21078 mp->is_l2 ? "l2" : "device");
21082 vl_api_sw_interface_span_details_t_handler_json
21083 (vl_api_sw_interface_span_details_t * mp)
21085 vat_main_t *vam = &vat_main;
21086 vat_json_node_t *node = NULL;
21087 u8 *sw_if_from_name = 0;
21088 u8 *sw_if_to_name = 0;
21089 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21090 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21094 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21096 if ((u32) p->value[0] == sw_if_index_from)
21098 sw_if_from_name = (u8 *)(p->key);
21102 if ((u32) p->value[0] == sw_if_index_to)
21104 sw_if_to_name = (u8 *)(p->key);
21105 if (sw_if_from_name)
21111 if (VAT_JSON_ARRAY != vam->json_tree.type)
21113 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21114 vat_json_init_array (&vam->json_tree);
21116 node = vat_json_array_add (&vam->json_tree);
21118 vat_json_init_object (node);
21119 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21120 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21121 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21122 if (0 != sw_if_to_name)
21124 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21126 vat_json_object_add_uint (node, "state", mp->state);
21127 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21131 api_sw_interface_span_dump (vat_main_t * vam)
21133 unformat_input_t *input = vam->input;
21134 vl_api_sw_interface_span_dump_t *mp;
21135 vl_api_control_ping_t *mp_ping;
21139 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21141 if (unformat (input, "l2"))
21147 M (SW_INTERFACE_SPAN_DUMP, mp);
21151 /* Use a control ping for synchronization */
21152 MPING (CONTROL_PING, mp_ping);
21160 api_pg_create_interface (vat_main_t * vam)
21162 unformat_input_t *input = vam->input;
21163 vl_api_pg_create_interface_t *mp;
21167 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21169 if (unformat (input, "if_id %d", &if_id))
21176 errmsg ("missing pg interface index");
21180 /* Construct the API message */
21181 M (PG_CREATE_INTERFACE, mp);
21183 mp->interface_id = ntohl (if_id);
21191 api_pg_capture (vat_main_t * vam)
21193 unformat_input_t *input = vam->input;
21194 vl_api_pg_capture_t *mp;
21199 u8 pcap_file_set = 0;
21202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21204 if (unformat (input, "if_id %d", &if_id))
21206 else if (unformat (input, "pcap %s", &pcap_file))
21208 else if (unformat (input, "count %d", &count))
21210 else if (unformat (input, "disable"))
21217 errmsg ("missing pg interface index");
21220 if (pcap_file_set > 0)
21222 if (vec_len (pcap_file) > 255)
21224 errmsg ("pcap file name is too long");
21229 u32 name_len = vec_len (pcap_file);
21230 /* Construct the API message */
21231 M (PG_CAPTURE, mp);
21233 mp->interface_id = ntohl (if_id);
21234 mp->is_enabled = enable;
21235 mp->count = ntohl (count);
21236 mp->pcap_name_length = ntohl (name_len);
21237 if (pcap_file_set != 0)
21239 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21241 vec_free (pcap_file);
21249 api_pg_enable_disable (vat_main_t * vam)
21251 unformat_input_t *input = vam->input;
21252 vl_api_pg_enable_disable_t *mp;
21255 u8 stream_name_set = 0;
21256 u8 *stream_name = 0;
21258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21260 if (unformat (input, "stream %s", &stream_name))
21261 stream_name_set = 1;
21262 else if (unformat (input, "disable"))
21268 if (stream_name_set > 0)
21270 if (vec_len (stream_name) > 255)
21272 errmsg ("stream name too long");
21277 u32 name_len = vec_len (stream_name);
21278 /* Construct the API message */
21279 M (PG_ENABLE_DISABLE, mp);
21281 mp->is_enabled = enable;
21282 if (stream_name_set != 0)
21284 mp->stream_name_length = ntohl (name_len);
21285 clib_memcpy (mp->stream_name, stream_name, name_len);
21287 vec_free (stream_name);
21295 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21297 unformat_input_t *input = vam->input;
21298 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21300 u16 *low_ports = 0;
21301 u16 *high_ports = 0;
21304 ip4_address_t ip4_addr;
21305 ip6_address_t ip6_addr;
21314 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21316 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21322 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21327 else if (unformat (input, "vrf %d", &vrf_id))
21329 else if (unformat (input, "del"))
21331 else if (unformat (input, "port %d", &tmp))
21333 if (tmp == 0 || tmp > 65535)
21335 errmsg ("port %d out of range", tmp);
21339 this_hi = this_low + 1;
21340 vec_add1 (low_ports, this_low);
21341 vec_add1 (high_ports, this_hi);
21343 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21345 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21347 errmsg ("incorrect range parameters");
21351 /* Note: in debug CLI +1 is added to high before
21352 passing to real fn that does "the work"
21353 (ip_source_and_port_range_check_add_del).
21354 This fn is a wrapper around the binary API fn a
21355 control plane will call, which expects this increment
21356 to have occurred. Hence letting the binary API control
21357 plane fn do the increment for consistency between VAT
21358 and other control planes.
21361 vec_add1 (low_ports, this_low);
21362 vec_add1 (high_ports, this_hi);
21368 if (prefix_set == 0)
21370 errmsg ("<address>/<mask> not specified");
21376 errmsg ("VRF ID required, not specified");
21383 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21387 if (vec_len (low_ports) == 0)
21389 errmsg ("At least one port or port range required");
21393 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21395 mp->is_add = is_add;
21400 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21405 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21408 mp->mask_length = length;
21409 mp->number_of_ranges = vec_len (low_ports);
21411 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21412 vec_free (low_ports);
21414 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21415 vec_free (high_ports);
21417 mp->vrf_id = ntohl (vrf_id);
21425 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21427 unformat_input_t *input = vam->input;
21428 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21429 u32 sw_if_index = ~0;
21431 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21432 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21436 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21438 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21440 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21442 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21444 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21446 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21448 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21450 else if (unformat (input, "del"))
21456 if (sw_if_index == ~0)
21458 errmsg ("Interface required but not specified");
21464 errmsg ("VRF ID required but not specified");
21468 if (tcp_out_vrf_id == 0
21469 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21472 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21476 /* Construct the API message */
21477 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21479 mp->sw_if_index = ntohl (sw_if_index);
21480 mp->is_add = is_add;
21481 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21482 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21483 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21484 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21489 /* Wait for a reply... */
21495 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21497 unformat_input_t *i = vam->input;
21498 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21499 u32 local_sa_id = 0;
21500 u32 remote_sa_id = 0;
21501 ip4_address_t src_address;
21502 ip4_address_t dst_address;
21506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21508 if (unformat (i, "local_sa %d", &local_sa_id))
21510 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21512 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21514 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21516 else if (unformat (i, "del"))
21520 clib_warning ("parse error '%U'", format_unformat_error, i);
21525 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21527 mp->local_sa_id = ntohl (local_sa_id);
21528 mp->remote_sa_id = ntohl (remote_sa_id);
21529 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21530 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21531 mp->is_add = is_add;
21539 api_punt (vat_main_t * vam)
21541 unformat_input_t *i = vam->input;
21549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21551 if (unformat (i, "ip %d", &ipv))
21553 else if (unformat (i, "protocol %d", &protocol))
21555 else if (unformat (i, "port %d", &port))
21557 else if (unformat (i, "del"))
21561 clib_warning ("parse error '%U'", format_unformat_error, i);
21568 mp->is_add = (u8) is_add;
21569 mp->ipv = (u8) ipv;
21570 mp->l4_protocol = (u8) protocol;
21571 mp->l4_port = htons ((u16) port);
21578 static void vl_api_ipsec_gre_tunnel_details_t_handler
21579 (vl_api_ipsec_gre_tunnel_details_t * mp)
21581 vat_main_t *vam = &vat_main;
21583 print (vam->ofp, "%11d%15U%15U%14d%14d",
21584 ntohl (mp->sw_if_index),
21585 format_ip4_address, &mp->src_address,
21586 format_ip4_address, &mp->dst_address,
21587 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21590 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21591 (vl_api_ipsec_gre_tunnel_details_t * mp)
21593 vat_main_t *vam = &vat_main;
21594 vat_json_node_t *node = NULL;
21595 struct in_addr ip4;
21597 if (VAT_JSON_ARRAY != vam->json_tree.type)
21599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21600 vat_json_init_array (&vam->json_tree);
21602 node = vat_json_array_add (&vam->json_tree);
21604 vat_json_init_object (node);
21605 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21606 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21607 vat_json_object_add_ip4 (node, "src_address", ip4);
21608 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21609 vat_json_object_add_ip4 (node, "dst_address", ip4);
21610 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21611 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21615 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21617 unformat_input_t *i = vam->input;
21618 vl_api_ipsec_gre_tunnel_dump_t *mp;
21619 vl_api_control_ping_t *mp_ping;
21621 u8 sw_if_index_set = 0;
21624 /* Parse args required to build the message */
21625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21627 if (unformat (i, "sw_if_index %d", &sw_if_index))
21628 sw_if_index_set = 1;
21633 if (sw_if_index_set == 0)
21638 if (!vam->json_output)
21640 print (vam->ofp, "%11s%15s%15s%14s%14s",
21641 "sw_if_index", "src_address", "dst_address",
21642 "local_sa_id", "remote_sa_id");
21645 /* Get list of gre-tunnel interfaces */
21646 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21648 mp->sw_if_index = htonl (sw_if_index);
21652 /* Use a control ping for synchronization */
21653 MPING (CONTROL_PING, mp_ping);
21661 api_delete_subif (vat_main_t * vam)
21663 unformat_input_t *i = vam->input;
21664 vl_api_delete_subif_t *mp;
21665 u32 sw_if_index = ~0;
21668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21672 if (unformat (i, "sw_if_index %d", &sw_if_index))
21678 if (sw_if_index == ~0)
21680 errmsg ("missing sw_if_index");
21684 /* Construct the API message */
21685 M (DELETE_SUBIF, mp);
21686 mp->sw_if_index = ntohl (sw_if_index);
21693 #define foreach_pbb_vtr_op \
21694 _("disable", L2_VTR_DISABLED) \
21695 _("pop", L2_VTR_POP_2) \
21696 _("push", L2_VTR_PUSH_2)
21699 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21701 unformat_input_t *i = vam->input;
21702 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21703 u32 sw_if_index = ~0, vtr_op = ~0;
21704 u16 outer_tag = ~0;
21705 u8 dmac[6], smac[6];
21706 u8 dmac_set = 0, smac_set = 0;
21712 /* Shut up coverity */
21713 memset (dmac, 0, sizeof (dmac));
21714 memset (smac, 0, sizeof (smac));
21716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21722 else if (unformat (i, "vtr_op %d", &vtr_op))
21724 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21727 else if (unformat (i, "translate_pbb_stag"))
21729 if (unformat (i, "%d", &tmp))
21731 vtr_op = L2_VTR_TRANSLATE_2_1;
21737 ("translate_pbb_stag operation requires outer tag definition");
21741 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21743 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21745 else if (unformat (i, "sid %d", &sid))
21747 else if (unformat (i, "vlanid %d", &tmp))
21751 clib_warning ("parse error '%U'", format_unformat_error, i);
21756 if ((sw_if_index == ~0) || (vtr_op == ~0))
21758 errmsg ("missing sw_if_index or vtr operation");
21761 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21762 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21765 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21769 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21770 mp->sw_if_index = ntohl (sw_if_index);
21771 mp->vtr_op = ntohl (vtr_op);
21772 mp->outer_tag = ntohs (outer_tag);
21773 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21774 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21775 mp->b_vlanid = ntohs (vlanid);
21776 mp->i_sid = ntohl (sid);
21784 api_flow_classify_set_interface (vat_main_t * vam)
21786 unformat_input_t *i = vam->input;
21787 vl_api_flow_classify_set_interface_t *mp;
21789 int sw_if_index_set;
21790 u32 ip4_table_index = ~0;
21791 u32 ip6_table_index = ~0;
21795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21797 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21798 sw_if_index_set = 1;
21799 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21800 sw_if_index_set = 1;
21801 else if (unformat (i, "del"))
21803 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21805 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21809 clib_warning ("parse error '%U'", format_unformat_error, i);
21814 if (sw_if_index_set == 0)
21816 errmsg ("missing interface name or sw_if_index");
21820 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21822 mp->sw_if_index = ntohl (sw_if_index);
21823 mp->ip4_table_index = ntohl (ip4_table_index);
21824 mp->ip6_table_index = ntohl (ip6_table_index);
21825 mp->is_add = is_add;
21833 api_flow_classify_dump (vat_main_t * vam)
21835 unformat_input_t *i = vam->input;
21836 vl_api_flow_classify_dump_t *mp;
21837 vl_api_control_ping_t *mp_ping;
21838 u8 type = FLOW_CLASSIFY_N_TABLES;
21841 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21845 errmsg ("classify table type must be specified");
21849 if (!vam->json_output)
21851 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21854 M (FLOW_CLASSIFY_DUMP, mp);
21859 /* Use a control ping for synchronization */
21860 MPING (CONTROL_PING, mp_ping);
21863 /* Wait for a reply... */
21869 api_feature_enable_disable (vat_main_t * vam)
21871 unformat_input_t *i = vam->input;
21872 vl_api_feature_enable_disable_t *mp;
21874 u8 *feature_name = 0;
21875 u32 sw_if_index = ~0;
21879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21881 if (unformat (i, "arc_name %s", &arc_name))
21883 else if (unformat (i, "feature_name %s", &feature_name))
21886 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21888 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21890 else if (unformat (i, "disable"))
21898 errmsg ("missing arc name");
21901 if (vec_len (arc_name) > 63)
21903 errmsg ("arc name too long");
21906 if (feature_name == 0)
21908 errmsg ("missing feature name");
21911 if (vec_len (feature_name) > 63)
21913 errmsg ("feature name too long");
21916 if (sw_if_index == ~0)
21918 errmsg ("missing interface name or sw_if_index");
21922 /* Construct the API message */
21923 M (FEATURE_ENABLE_DISABLE, mp);
21924 mp->sw_if_index = ntohl (sw_if_index);
21925 mp->enable = enable;
21926 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21927 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21928 vec_free (arc_name);
21929 vec_free (feature_name);
21937 api_sw_interface_tag_add_del (vat_main_t * vam)
21939 unformat_input_t *i = vam->input;
21940 vl_api_sw_interface_tag_add_del_t *mp;
21941 u32 sw_if_index = ~0;
21946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21948 if (unformat (i, "tag %s", &tag))
21950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21954 else if (unformat (i, "del"))
21960 if (sw_if_index == ~0)
21962 errmsg ("missing interface name or sw_if_index");
21966 if (enable && (tag == 0))
21968 errmsg ("no tag specified");
21972 /* Construct the API message */
21973 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21974 mp->sw_if_index = ntohl (sw_if_index);
21975 mp->is_add = enable;
21977 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21985 static void vl_api_l2_xconnect_details_t_handler
21986 (vl_api_l2_xconnect_details_t * mp)
21988 vat_main_t *vam = &vat_main;
21990 print (vam->ofp, "%15d%15d",
21991 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21994 static void vl_api_l2_xconnect_details_t_handler_json
21995 (vl_api_l2_xconnect_details_t * mp)
21997 vat_main_t *vam = &vat_main;
21998 vat_json_node_t *node = NULL;
22000 if (VAT_JSON_ARRAY != vam->json_tree.type)
22002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22003 vat_json_init_array (&vam->json_tree);
22005 node = vat_json_array_add (&vam->json_tree);
22007 vat_json_init_object (node);
22008 vat_json_object_add_uint (node, "rx_sw_if_index",
22009 ntohl (mp->rx_sw_if_index));
22010 vat_json_object_add_uint (node, "tx_sw_if_index",
22011 ntohl (mp->tx_sw_if_index));
22015 api_l2_xconnect_dump (vat_main_t * vam)
22017 vl_api_l2_xconnect_dump_t *mp;
22018 vl_api_control_ping_t *mp_ping;
22021 if (!vam->json_output)
22023 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22026 M (L2_XCONNECT_DUMP, mp);
22030 /* Use a control ping for synchronization */
22031 MPING (CONTROL_PING, mp_ping);
22039 api_hw_interface_set_mtu (vat_main_t * vam)
22041 unformat_input_t *i = vam->input;
22042 vl_api_hw_interface_set_mtu_t *mp;
22043 u32 sw_if_index = ~0;
22047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22049 if (unformat (i, "mtu %d", &mtu))
22051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22059 if (sw_if_index == ~0)
22061 errmsg ("missing interface name or sw_if_index");
22067 errmsg ("no mtu specified");
22071 /* Construct the API message */
22072 M (HW_INTERFACE_SET_MTU, mp);
22073 mp->sw_if_index = ntohl (sw_if_index);
22074 mp->mtu = ntohs ((u16) mtu);
22082 api_p2p_ethernet_add (vat_main_t * vam)
22084 unformat_input_t *i = vam->input;
22085 vl_api_p2p_ethernet_add_t *mp;
22086 u32 parent_if_index = ~0;
22092 memset (remote_mac, 0, sizeof (remote_mac));
22093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22097 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22101 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22103 else if (unformat (i, "sub_id %d", &sub_id))
22107 clib_warning ("parse error '%U'", format_unformat_error, i);
22112 if (parent_if_index == ~0)
22114 errmsg ("missing interface name or sw_if_index");
22119 errmsg ("missing remote mac address");
22124 errmsg ("missing sub-interface id");
22128 M (P2P_ETHERNET_ADD, mp);
22129 mp->parent_if_index = ntohl (parent_if_index);
22130 mp->subif_id = ntohl (sub_id);
22131 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22139 api_p2p_ethernet_del (vat_main_t * vam)
22141 unformat_input_t *i = vam->input;
22142 vl_api_p2p_ethernet_del_t *mp;
22143 u32 parent_if_index = ~0;
22148 memset (remote_mac, 0, sizeof (remote_mac));
22149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22151 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22153 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22157 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22161 clib_warning ("parse error '%U'", format_unformat_error, i);
22166 if (parent_if_index == ~0)
22168 errmsg ("missing interface name or sw_if_index");
22173 errmsg ("missing remote mac address");
22177 M (P2P_ETHERNET_DEL, mp);
22178 mp->parent_if_index = ntohl (parent_if_index);
22179 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22187 api_lldp_config (vat_main_t * vam)
22189 unformat_input_t *i = vam->input;
22190 vl_api_lldp_config_t *mp;
22192 int tx_interval = 0;
22193 u8 *sys_name = NULL;
22196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22198 if (unformat (i, "system-name %s", &sys_name))
22200 else if (unformat (i, "tx-hold %d", &tx_hold))
22202 else if (unformat (i, "tx-interval %d", &tx_interval))
22206 clib_warning ("parse error '%U'", format_unformat_error, i);
22211 vec_add1 (sys_name, 0);
22213 M (LLDP_CONFIG, mp);
22214 mp->tx_hold = htonl (tx_hold);
22215 mp->tx_interval = htonl (tx_interval);
22216 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22217 vec_free (sys_name);
22225 api_sw_interface_set_lldp (vat_main_t * vam)
22227 unformat_input_t *i = vam->input;
22228 vl_api_sw_interface_set_lldp_t *mp;
22229 u32 sw_if_index = ~0;
22231 u8 *port_desc = NULL, *mgmt_oid = NULL;
22232 ip4_address_t ip4_addr;
22233 ip6_address_t ip6_addr;
22236 memset (&ip4_addr, 0, sizeof (ip4_addr));
22237 memset (&ip6_addr, 0, sizeof (ip6_addr));
22239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22241 if (unformat (i, "disable"))
22244 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22246 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22248 else if (unformat (i, "port-desc %s", &port_desc))
22250 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22252 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22254 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22260 if (sw_if_index == ~0)
22262 errmsg ("missing interface name or sw_if_index");
22266 /* Construct the API message */
22267 vec_add1 (port_desc, 0);
22268 vec_add1 (mgmt_oid, 0);
22269 M (SW_INTERFACE_SET_LLDP, mp);
22270 mp->sw_if_index = ntohl (sw_if_index);
22271 mp->enable = enable;
22272 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22273 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22274 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22275 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22276 vec_free (port_desc);
22277 vec_free (mgmt_oid);
22285 api_tcp_configure_src_addresses (vat_main_t * vam)
22287 vl_api_tcp_configure_src_addresses_t *mp;
22288 unformat_input_t *i = vam->input;
22289 ip4_address_t v4first, v4last;
22290 ip6_address_t v6first, v6last;
22295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22297 if (unformat (i, "%U - %U",
22298 unformat_ip4_address, &v4first,
22299 unformat_ip4_address, &v4last))
22303 errmsg ("one range per message (range already set)");
22308 else if (unformat (i, "%U - %U",
22309 unformat_ip6_address, &v6first,
22310 unformat_ip6_address, &v6last))
22314 errmsg ("one range per message (range already set)");
22319 else if (unformat (i, "vrf %d", &vrf_id))
22325 if (range_set == 0)
22327 errmsg ("address range not set");
22331 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22332 mp->vrf_id = ntohl (vrf_id);
22334 if (range_set == 2)
22337 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22338 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22343 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22344 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22351 static void vl_api_app_namespace_add_del_reply_t_handler
22352 (vl_api_app_namespace_add_del_reply_t * mp)
22354 vat_main_t *vam = &vat_main;
22355 i32 retval = ntohl (mp->retval);
22356 if (vam->async_mode)
22358 vam->async_errors += (retval < 0);
22362 vam->retval = retval;
22364 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22365 vam->result_ready = 1;
22369 static void vl_api_app_namespace_add_del_reply_t_handler_json
22370 (vl_api_app_namespace_add_del_reply_t * mp)
22372 vat_main_t *vam = &vat_main;
22373 vat_json_node_t node;
22375 vat_json_init_object (&node);
22376 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22377 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22379 vat_json_print (vam->ofp, &node);
22380 vat_json_free (&node);
22382 vam->retval = ntohl (mp->retval);
22383 vam->result_ready = 1;
22387 api_app_namespace_add_del (vat_main_t * vam)
22389 vl_api_app_namespace_add_del_t *mp;
22390 unformat_input_t *i = vam->input;
22391 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22392 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22398 if (unformat (i, "id %_%v%_", &ns_id))
22400 else if (unformat (i, "secret %lu", &secret))
22402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22403 sw_if_index_set = 1;
22404 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22406 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22411 if (!ns_id || !secret_set || !sw_if_index_set)
22413 errmsg ("namespace id, secret and sw_if_index must be set");
22416 if (vec_len (ns_id) > 64)
22418 errmsg ("namespace id too long");
22421 M (APP_NAMESPACE_ADD_DEL, mp);
22423 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22424 mp->namespace_id_len = vec_len (ns_id);
22425 mp->secret = clib_host_to_net_u64 (secret);
22426 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22427 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22428 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22435 static void vl_api_map_stats_segment_reply_t_handler
22436 (vl_api_map_stats_segment_reply_t * mp)
22438 #if VPP_API_TEST_BUILTIN == 0
22439 vat_main_t *vam = &vat_main;
22440 ssvm_private_t *ssvmp = &vam->stat_segment;
22441 ssvm_shared_header_t *shared_header;
22442 socket_client_main_t *scm = vam->socket_client_main;
22443 int rv = ntohl (mp->retval);
22445 clib_error_t *error;
22451 vam->result_ready = 1;
22456 * Check the socket for the magic fd
22458 error = vl_sock_api_recv_fd_msg (scm->socket_fd, &my_fd, 5);
22461 clib_error_report (error);
22463 vam->result_ready = 1;
22467 memset (ssvmp, 0, sizeof (*ssvmp));
22470 /* Note: this closes memfd.fd */
22471 retval = ssvm_slave_init_memfd (ssvmp);
22474 clib_warning ("WARNING: segment map returned %d", retval);
22476 vam->result_ready = 1;
22480 errmsg ("stat segment mapped OK...");
22482 ASSERT (ssvmp && ssvmp->sh);
22484 /* Pick up the segment lock from the shared memory header */
22485 shared_header = ssvmp->sh;
22486 vam->stat_segment_lockp = (clib_spinlock_t *) (shared_header->opaque[0]);
22488 vam->result_ready = 1;
22492 static void vl_api_map_stats_segment_reply_t_handler_json
22493 (vl_api_map_stats_segment_reply_t * mp)
22495 #if VPP_API_TEST_BUILTIN == 0
22496 vat_main_t *vam = &vat_main;
22497 clib_warning ("not implemented");
22499 vam->result_ready = 1;
22504 api_map_stats_segment (vat_main_t * vam)
22506 #if VPP_API_TEST_BUILTIN == 0
22507 vl_api_map_stats_segment_t *mp;
22510 M (MAP_STATS_SEGMENT, mp);
22516 errmsg ("api unavailable");
22522 api_sock_init_shm (vat_main_t * vam)
22524 #if VPP_API_TEST_BUILTIN == 0
22525 unformat_input_t *i = vam->input;
22526 vl_api_shm_elem_config_t *config = 0;
22527 u64 size = 64 << 20;
22530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22532 if (unformat (i, "size %U", unformat_memory_size, &size))
22539 * Canned custom ring allocator config.
22540 * Should probably parse all of this
22542 vec_validate (config, 6);
22543 config[0].type = VL_API_VLIB_RING;
22544 config[0].size = 256;
22545 config[0].count = 32;
22547 config[1].type = VL_API_VLIB_RING;
22548 config[1].size = 1024;
22549 config[1].count = 16;
22551 config[2].type = VL_API_VLIB_RING;
22552 config[2].size = 4096;
22553 config[2].count = 2;
22555 config[3].type = VL_API_CLIENT_RING;
22556 config[3].size = 256;
22557 config[3].count = 32;
22559 config[4].type = VL_API_CLIENT_RING;
22560 config[4].size = 1024;
22561 config[4].count = 16;
22563 config[5].type = VL_API_CLIENT_RING;
22564 config[5].size = 4096;
22565 config[5].count = 2;
22567 config[6].type = VL_API_QUEUE;
22568 config[6].count = 128;
22569 config[6].size = sizeof (uword);
22571 rv = vl_socket_client_init_shm (config);
22573 vam->client_index_invalid = 1;
22581 api_dns_enable_disable (vat_main_t * vam)
22583 unformat_input_t *line_input = vam->input;
22584 vl_api_dns_enable_disable_t *mp;
22585 u8 enable_disable = 1;
22588 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22590 if (unformat (line_input, "disable"))
22591 enable_disable = 0;
22592 if (unformat (line_input, "enable"))
22593 enable_disable = 1;
22598 /* Construct the API message */
22599 M (DNS_ENABLE_DISABLE, mp);
22600 mp->enable = enable_disable;
22604 /* Wait for the reply */
22610 api_dns_resolve_name (vat_main_t * vam)
22612 unformat_input_t *line_input = vam->input;
22613 vl_api_dns_resolve_name_t *mp;
22617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22619 if (unformat (line_input, "%s", &name))
22625 if (vec_len (name) > 127)
22627 errmsg ("name too long");
22631 /* Construct the API message */
22632 M (DNS_RESOLVE_NAME, mp);
22633 memcpy (mp->name, name, vec_len (name));
22638 /* Wait for the reply */
22644 api_dns_resolve_ip (vat_main_t * vam)
22646 unformat_input_t *line_input = vam->input;
22647 vl_api_dns_resolve_ip_t *mp;
22649 ip4_address_t addr4;
22650 ip6_address_t addr6;
22653 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22655 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22657 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22665 errmsg ("missing address");
22669 /* Construct the API message */
22670 M (DNS_RESOLVE_IP, mp);
22671 mp->is_ip6 = is_ip6;
22673 memcpy (mp->address, &addr6, sizeof (addr6));
22675 memcpy (mp->address, &addr4, sizeof (addr4));
22679 /* Wait for the reply */
22685 api_dns_name_server_add_del (vat_main_t * vam)
22687 unformat_input_t *i = vam->input;
22688 vl_api_dns_name_server_add_del_t *mp;
22690 ip6_address_t ip6_server;
22691 ip4_address_t ip4_server;
22696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22698 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22700 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22702 else if (unformat (i, "del"))
22706 clib_warning ("parse error '%U'", format_unformat_error, i);
22711 if (ip4_set && ip6_set)
22713 errmsg ("Only one server address allowed per message");
22716 if ((ip4_set + ip6_set) == 0)
22718 errmsg ("Server address required");
22722 /* Construct the API message */
22723 M (DNS_NAME_SERVER_ADD_DEL, mp);
22727 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22732 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22736 mp->is_add = is_add;
22741 /* Wait for a reply, return good/bad news */
22747 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22749 vat_main_t *vam = &vat_main;
22754 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22755 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22756 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22757 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22758 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22759 clib_net_to_host_u32 (mp->action_index), mp->tag);
22764 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22765 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22766 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22767 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22768 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22769 clib_net_to_host_u32 (mp->action_index), mp->tag);
22774 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22777 vat_main_t *vam = &vat_main;
22778 vat_json_node_t *node = NULL;
22779 struct in6_addr ip6;
22780 struct in_addr ip4;
22782 if (VAT_JSON_ARRAY != vam->json_tree.type)
22784 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22785 vat_json_init_array (&vam->json_tree);
22787 node = vat_json_array_add (&vam->json_tree);
22788 vat_json_init_object (node);
22790 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22791 vat_json_object_add_uint (node, "appns_index",
22792 clib_net_to_host_u32 (mp->appns_index));
22793 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22794 vat_json_object_add_uint (node, "scope", mp->scope);
22795 vat_json_object_add_uint (node, "action_index",
22796 clib_net_to_host_u32 (mp->action_index));
22797 vat_json_object_add_uint (node, "lcl_port",
22798 clib_net_to_host_u16 (mp->lcl_port));
22799 vat_json_object_add_uint (node, "rmt_port",
22800 clib_net_to_host_u16 (mp->rmt_port));
22801 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22802 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22803 vat_json_object_add_string_copy (node, "tag", mp->tag);
22806 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22807 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22808 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22809 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22813 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22814 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22815 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22816 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22821 api_session_rule_add_del (vat_main_t * vam)
22823 vl_api_session_rule_add_del_t *mp;
22824 unformat_input_t *i = vam->input;
22825 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22826 u32 appns_index = 0, scope = 0;
22827 ip4_address_t lcl_ip4, rmt_ip4;
22828 ip6_address_t lcl_ip6, rmt_ip6;
22829 u8 is_ip4 = 1, conn_set = 0;
22830 u8 is_add = 1, *tag = 0;
22833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22835 if (unformat (i, "del"))
22837 else if (unformat (i, "add"))
22839 else if (unformat (i, "proto tcp"))
22841 else if (unformat (i, "proto udp"))
22843 else if (unformat (i, "appns %d", &appns_index))
22845 else if (unformat (i, "scope %d", &scope))
22847 else if (unformat (i, "tag %_%v%_", &tag))
22851 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22852 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22860 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22861 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22867 else if (unformat (i, "action %d", &action))
22872 if (proto == ~0 || !conn_set || action == ~0)
22874 errmsg ("transport proto, connection and action must be set");
22880 errmsg ("scope should be 0-3");
22884 M (SESSION_RULE_ADD_DEL, mp);
22886 mp->is_ip4 = is_ip4;
22887 mp->transport_proto = proto;
22888 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22889 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22890 mp->lcl_plen = lcl_plen;
22891 mp->rmt_plen = rmt_plen;
22892 mp->action_index = clib_host_to_net_u32 (action);
22893 mp->appns_index = clib_host_to_net_u32 (appns_index);
22895 mp->is_add = is_add;
22898 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22899 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22903 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22904 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22908 clib_memcpy (mp->tag, tag, vec_len (tag));
22918 api_session_rules_dump (vat_main_t * vam)
22920 vl_api_session_rules_dump_t *mp;
22921 vl_api_control_ping_t *mp_ping;
22924 if (!vam->json_output)
22926 print (vam->ofp, "%=20s", "Session Rules");
22929 M (SESSION_RULES_DUMP, mp);
22933 /* Use a control ping for synchronization */
22934 MPING (CONTROL_PING, mp_ping);
22937 /* Wait for a reply... */
22943 api_ip_container_proxy_add_del (vat_main_t * vam)
22945 vl_api_ip_container_proxy_add_del_t *mp;
22946 unformat_input_t *i = vam->input;
22947 u32 plen = ~0, sw_if_index = ~0;
22954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22956 if (unformat (i, "del"))
22958 else if (unformat (i, "add"))
22960 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22965 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22970 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22975 if (sw_if_index == ~0 || plen == ~0)
22977 errmsg ("address and sw_if_index must be set");
22981 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22983 mp->is_ip4 = is_ip4;
22984 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22986 mp->is_add = is_add;
22988 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22990 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22998 api_qos_record_enable_disable (vat_main_t * vam)
23000 unformat_input_t *i = vam->input;
23001 vl_api_qos_record_enable_disable_t *mp;
23002 u32 sw_if_index, qs = 0xff;
23003 u8 sw_if_index_set = 0;
23007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
23009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
23010 sw_if_index_set = 1;
23011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
23012 sw_if_index_set = 1;
23013 else if (unformat (i, "%U", unformat_qos_source, &qs))
23015 else if (unformat (i, "disable"))
23019 clib_warning ("parse error '%U'", format_unformat_error, i);
23024 if (sw_if_index_set == 0)
23026 errmsg ("missing interface name or sw_if_index");
23031 errmsg ("input location must be specified");
23035 M (QOS_RECORD_ENABLE_DISABLE, mp);
23037 mp->sw_if_index = ntohl (sw_if_index);
23038 mp->input_source = qs;
23039 mp->enable = enable;
23048 q_or_quit (vat_main_t * vam)
23050 #if VPP_API_TEST_BUILTIN == 0
23051 longjmp (vam->jump_buf, 1);
23053 return 0; /* not so much */
23057 q (vat_main_t * vam)
23059 return q_or_quit (vam);
23063 quit (vat_main_t * vam)
23065 return q_or_quit (vam);
23069 comment (vat_main_t * vam)
23075 statseg (vat_main_t * vam)
23077 ssvm_private_t *ssvmp = &vam->stat_segment;
23078 ssvm_shared_header_t *shared_header = ssvmp->sh;
23079 vlib_counter_t **counters;
23080 u64 thread0_index1_packets;
23081 u64 thread0_index1_bytes;
23082 f64 vector_rate, input_rate;
23085 uword *counter_vector_by_name;
23086 if (vam->stat_segment_lockp == 0)
23088 errmsg ("Stat segment not mapped...");
23092 /* look up "/if/rx for sw_if_index 1 as a test */
23094 clib_spinlock_lock (vam->stat_segment_lockp);
23096 counter_vector_by_name = (uword *) shared_header->opaque[1];
23098 p = hash_get_mem (counter_vector_by_name, "/if/rx");
23101 clib_spinlock_unlock (vam->stat_segment_lockp);
23102 errmsg ("/if/tx not found?");
23106 /* Fish per-thread vector of combined counters from shared memory */
23107 counters = (vlib_counter_t **) p[0];
23109 if (vec_len (counters[0]) < 2)
23111 clib_spinlock_unlock (vam->stat_segment_lockp);
23112 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
23116 /* Read thread 0 sw_if_index 1 counter */
23117 thread0_index1_packets = counters[0][1].packets;
23118 thread0_index1_bytes = counters[0][1].bytes;
23120 p = hash_get_mem (counter_vector_by_name, "vector_rate");
23123 clib_spinlock_unlock (vam->stat_segment_lockp);
23124 errmsg ("vector_rate not found?");
23128 vector_rate = *(f64 *) (p[0]);
23129 p = hash_get_mem (counter_vector_by_name, "input_rate");
23132 clib_spinlock_unlock (vam->stat_segment_lockp);
23133 errmsg ("input_rate not found?");
23136 input_rate = *(f64 *) (p[0]);
23138 clib_spinlock_unlock (vam->stat_segment_lockp);
23140 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
23141 vector_rate, input_rate);
23142 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
23143 thread0_index1_packets, thread0_index1_bytes);
23149 cmd_cmp (void *a1, void *a2)
23154 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
23158 help (vat_main_t * vam)
23163 unformat_input_t *i = vam->input;
23166 if (unformat (i, "%s", &name))
23170 vec_add1 (name, 0);
23172 hs = hash_get_mem (vam->help_by_name, name);
23174 print (vam->ofp, "usage: %s %s", name, hs[0]);
23176 print (vam->ofp, "No such msg / command '%s'", name);
23181 print (vam->ofp, "Help is available for the following:");
23184 hash_foreach_pair (p, vam->function_by_name,
23186 vec_add1 (cmds, (u8 *)(p->key));
23190 vec_sort_with_function (cmds, cmd_cmp);
23192 for (j = 0; j < vec_len (cmds); j++)
23193 print (vam->ofp, "%s", cmds[j]);
23200 set (vat_main_t * vam)
23202 u8 *name = 0, *value = 0;
23203 unformat_input_t *i = vam->input;
23205 if (unformat (i, "%s", &name))
23207 /* The input buffer is a vector, not a string. */
23208 value = vec_dup (i->buffer);
23209 vec_delete (value, i->index, 0);
23210 /* Almost certainly has a trailing newline */
23211 if (value[vec_len (value) - 1] == '\n')
23212 value[vec_len (value) - 1] = 0;
23213 /* Make sure it's a proper string, one way or the other */
23214 vec_add1 (value, 0);
23215 (void) clib_macro_set_value (&vam->macro_main,
23216 (char *) name, (char *) value);
23219 errmsg ("usage: set <name> <value>");
23227 unset (vat_main_t * vam)
23231 if (unformat (vam->input, "%s", &name))
23232 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23233 errmsg ("unset: %s wasn't set", name);
23246 macro_sort_cmp (void *a1, void *a2)
23248 macro_sort_t *s1 = a1;
23249 macro_sort_t *s2 = a2;
23251 return strcmp ((char *) (s1->name), (char *) (s2->name));
23255 dump_macro_table (vat_main_t * vam)
23257 macro_sort_t *sort_me = 0, *sm;
23262 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23264 vec_add2 (sort_me, sm, 1);
23265 sm->name = (u8 *)(p->key);
23266 sm->value = (u8 *) (p->value[0]);
23270 vec_sort_with_function (sort_me, macro_sort_cmp);
23272 if (vec_len (sort_me))
23273 print (vam->ofp, "%-15s%s", "Name", "Value");
23275 print (vam->ofp, "The macro table is empty...");
23277 for (i = 0; i < vec_len (sort_me); i++)
23278 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23283 dump_node_table (vat_main_t * vam)
23286 vlib_node_t *node, *next_node;
23288 if (vec_len (vam->graph_nodes) == 0)
23290 print (vam->ofp, "Node table empty, issue get_node_graph...");
23294 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23296 node = vam->graph_nodes[i];
23297 print (vam->ofp, "[%d] %s", i, node->name);
23298 for (j = 0; j < vec_len (node->next_nodes); j++)
23300 if (node->next_nodes[j] != ~0)
23302 next_node = vam->graph_nodes[node->next_nodes[j]];
23303 print (vam->ofp, " [%d] %s", j, next_node->name);
23311 value_sort_cmp (void *a1, void *a2)
23313 name_sort_t *n1 = a1;
23314 name_sort_t *n2 = a2;
23316 if (n1->value < n2->value)
23318 if (n1->value > n2->value)
23325 dump_msg_api_table (vat_main_t * vam)
23327 api_main_t *am = &api_main;
23328 name_sort_t *nses = 0, *ns;
23333 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23335 vec_add2 (nses, ns, 1);
23336 ns->name = (u8 *)(hp->key);
23337 ns->value = (u32) hp->value[0];
23341 vec_sort_with_function (nses, value_sort_cmp);
23343 for (i = 0; i < vec_len (nses); i++)
23344 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23350 get_msg_id (vat_main_t * vam)
23355 if (unformat (vam->input, "%s", &name_and_crc))
23357 message_index = vl_msg_api_get_msg_index (name_and_crc);
23358 if (message_index == ~0)
23360 print (vam->ofp, " '%s' not found", name_and_crc);
23363 print (vam->ofp, " '%s' has message index %d",
23364 name_and_crc, message_index);
23367 errmsg ("name_and_crc required...");
23372 search_node_table (vat_main_t * vam)
23374 unformat_input_t *line_input = vam->input;
23377 vlib_node_t *node, *next_node;
23380 if (vam->graph_node_index_by_name == 0)
23382 print (vam->ofp, "Node table empty, issue get_node_graph...");
23386 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23388 if (unformat (line_input, "%s", &node_to_find))
23390 vec_add1 (node_to_find, 0);
23391 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23394 print (vam->ofp, "%s not found...", node_to_find);
23397 node = vam->graph_nodes[p[0]];
23398 print (vam->ofp, "[%d] %s", p[0], node->name);
23399 for (j = 0; j < vec_len (node->next_nodes); j++)
23401 if (node->next_nodes[j] != ~0)
23403 next_node = vam->graph_nodes[node->next_nodes[j]];
23404 print (vam->ofp, " [%d] %s", j, next_node->name);
23411 clib_warning ("parse error '%U'", format_unformat_error,
23417 vec_free (node_to_find);
23426 script (vat_main_t * vam)
23428 #if (VPP_API_TEST_BUILTIN==0)
23430 char *save_current_file;
23431 unformat_input_t save_input;
23432 jmp_buf save_jump_buf;
23433 u32 save_line_number;
23435 FILE *new_fp, *save_ifp;
23437 if (unformat (vam->input, "%s", &s))
23439 new_fp = fopen ((char *) s, "r");
23442 errmsg ("Couldn't open script file %s", s);
23449 errmsg ("Missing script name");
23453 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23454 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23455 save_ifp = vam->ifp;
23456 save_line_number = vam->input_line_number;
23457 save_current_file = (char *) vam->current_file;
23459 vam->input_line_number = 0;
23461 vam->current_file = s;
23464 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23465 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23466 vam->ifp = save_ifp;
23467 vam->input_line_number = save_line_number;
23468 vam->current_file = (u8 *) save_current_file;
23473 clib_warning ("use the exec command...");
23479 echo (vat_main_t * vam)
23481 print (vam->ofp, "%v", vam->input->buffer);
23485 /* List of API message constructors, CLI names map to api_xxx */
23486 #define foreach_vpe_api_msg \
23487 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23488 _(sw_interface_dump,"") \
23489 _(sw_interface_set_flags, \
23490 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23491 _(sw_interface_add_del_address, \
23492 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23493 _(sw_interface_set_rx_mode, \
23494 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23495 _(sw_interface_set_table, \
23496 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23497 _(sw_interface_set_mpls_enable, \
23498 "<intfc> | sw_if_index [disable | dis]") \
23499 _(sw_interface_set_vpath, \
23500 "<intfc> | sw_if_index <id> enable | disable") \
23501 _(sw_interface_set_vxlan_bypass, \
23502 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23503 _(sw_interface_set_geneve_bypass, \
23504 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23505 _(sw_interface_set_l2_xconnect, \
23506 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23507 "enable | disable") \
23508 _(sw_interface_set_l2_bridge, \
23509 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23510 "[shg <split-horizon-group>] [bvi]\n" \
23511 "enable | disable") \
23512 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23513 _(bridge_domain_add_del, \
23514 "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") \
23515 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23517 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23518 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23519 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23521 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23523 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23525 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23527 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23529 "<vpp-if-name> | sw_if_index <id>") \
23530 _(sw_interface_tap_dump, "") \
23532 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23534 "<vpp-if-name> | sw_if_index <id>") \
23535 _(sw_interface_tap_v2_dump, "") \
23537 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23538 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23540 "<vpp-if-name> | sw_if_index <id>") \
23542 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23543 _(bond_detach_slave, \
23544 "sw_if_index <n>") \
23545 _(sw_interface_bond_dump, "") \
23546 _(sw_interface_slave_dump, \
23547 "<vpp-if-name> | sw_if_index <id>") \
23548 _(ip_table_add_del, \
23549 "table-id <n> [ipv6]\n") \
23550 _(ip_add_del_route, \
23551 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23552 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23553 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23554 "[multipath] [count <n>]") \
23555 _(ip_mroute_add_del, \
23556 "<src> <grp>/<mask> [table-id <n>]\n" \
23557 "[<intfc> | sw_if_index <id>] [local] [del]") \
23558 _(mpls_table_add_del, \
23559 "table-id <n>\n") \
23560 _(mpls_route_add_del, \
23561 "<label> <eos> via <addr> [table-id <n>]\n" \
23562 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23563 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23564 "[multipath] [count <n>]") \
23565 _(mpls_ip_bind_unbind, \
23566 "<label> <addr/len>") \
23567 _(mpls_tunnel_add_del, \
23568 " via <addr> [table-id <n>]\n" \
23569 "sw_if_index <id>] [l2] [del]") \
23570 _(bier_table_add_del, \
23571 "<label> <sub-domain> <set> <bsl> [del]") \
23572 _(bier_route_add_del, \
23573 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23574 "[<intfc> | sw_if_index <id>]" \
23575 "[weight <n>] [del] [multipath]") \
23576 _(proxy_arp_add_del, \
23577 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23578 _(proxy_arp_intfc_enable_disable, \
23579 "<intfc> | sw_if_index <id> enable | disable") \
23580 _(sw_interface_set_unnumbered, \
23581 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23582 _(ip_neighbor_add_del, \
23583 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23584 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23585 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23586 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23587 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23588 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23589 "[outer_vlan_id_any][inner_vlan_id_any]") \
23590 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23591 _(reset_fib, "vrf <n> [ipv6]") \
23592 _(dhcp_proxy_config, \
23593 "svr <v46-address> src <v46-address>\n" \
23594 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23595 _(dhcp_proxy_set_vss, \
23596 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23597 _(dhcp_proxy_dump, "ip6") \
23598 _(dhcp_client_config, \
23599 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23600 _(set_ip_flow_hash, \
23601 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23602 _(sw_interface_ip6_enable_disable, \
23603 "<intfc> | sw_if_index <id> enable | disable") \
23604 _(sw_interface_ip6_set_link_local_address, \
23605 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23606 _(ip6nd_proxy_add_del, \
23607 "<intfc> | sw_if_index <id> <ip6-address>") \
23608 _(ip6nd_proxy_dump, "") \
23609 _(sw_interface_ip6nd_ra_prefix, \
23610 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23611 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23612 "[nolink] [isno]") \
23613 _(sw_interface_ip6nd_ra_config, \
23614 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23615 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23616 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23617 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23618 _(l2_patch_add_del, \
23619 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23620 "enable | disable") \
23621 _(sr_localsid_add_del, \
23622 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23623 "fib-table <num> (end.psp) sw_if_index <num>") \
23624 _(classify_add_del_table, \
23625 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23626 " [del] [del-chain] mask <mask-value>\n" \
23627 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23628 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23629 _(classify_add_del_session, \
23630 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23631 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23632 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23633 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23634 _(classify_set_interface_ip_table, \
23635 "<intfc> | sw_if_index <nn> table <nn>") \
23636 _(classify_set_interface_l2_tables, \
23637 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23638 " [other-table <nn>]") \
23639 _(get_node_index, "node <node-name") \
23640 _(add_node_next, "node <node-name> next <next-node-name>") \
23641 _(l2tpv3_create_tunnel, \
23642 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23643 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23644 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23645 _(l2tpv3_set_tunnel_cookies, \
23646 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23647 "[new_remote_cookie <nn>]\n") \
23648 _(l2tpv3_interface_enable_disable, \
23649 "<intfc> | sw_if_index <nn> enable | disable") \
23650 _(l2tpv3_set_lookup_key, \
23651 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23652 _(sw_if_l2tpv3_tunnel_dump, "") \
23653 _(vxlan_add_del_tunnel, \
23654 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23655 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23656 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23657 _(geneve_add_del_tunnel, \
23658 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23659 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23660 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23661 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23662 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23663 _(gre_add_del_tunnel, \
23664 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23665 "[teb | erspan <session-id>] [del]") \
23666 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23667 _(l2_fib_clear_table, "") \
23668 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23669 _(l2_interface_vlan_tag_rewrite, \
23670 "<intfc> | sw_if_index <nn> \n" \
23671 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23672 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23673 _(create_vhost_user_if, \
23674 "socket <filename> [server] [renumber <dev_instance>] " \
23675 "[mac <mac_address>]") \
23676 _(modify_vhost_user_if, \
23677 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23678 "[server] [renumber <dev_instance>]") \
23679 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23680 _(sw_interface_vhost_user_dump, "") \
23681 _(show_version, "") \
23682 _(vxlan_gpe_add_del_tunnel, \
23683 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23684 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23685 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23686 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23687 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23688 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23689 _(interface_name_renumber, \
23690 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23691 _(input_acl_set_interface, \
23692 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23693 " [l2-table <nn>] [del]") \
23694 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23695 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23696 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23697 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23698 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23699 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23700 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23701 _(ip_dump, "ipv4 | ipv6") \
23702 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23703 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23705 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23706 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23707 " integ_alg <alg> integ_key <hex>") \
23708 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23709 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23710 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23711 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23712 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23713 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23714 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23715 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23716 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23717 " [instance <n>]") \
23718 _(ipsec_sa_dump, "[sa_id <n>]") \
23719 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23720 " <alg> <hex>\n") \
23721 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23722 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23723 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23724 "(auth_data 0x<data> | auth_data <data>)") \
23725 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23726 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23727 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23728 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23729 "(local|remote)") \
23730 _(ikev2_set_local_key, "file <absolute_file_path>") \
23731 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23732 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23733 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23734 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23735 _(ikev2_initiate_sa_init, "<profile_name>") \
23736 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23737 _(ikev2_initiate_del_child_sa, "<ispi>") \
23738 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23739 _(delete_loopback,"sw_if_index <nn>") \
23740 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23741 _(map_add_domain, \
23742 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23743 "ip6-src <ip6addr> " \
23744 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23745 _(map_del_domain, "index <n>") \
23746 _(map_add_del_rule, \
23747 "index <n> psid <n> dst <ip6addr> [del]") \
23748 _(map_domain_dump, "") \
23749 _(map_rule_dump, "index <map-domain>") \
23750 _(want_interface_events, "enable|disable") \
23751 _(want_stats,"enable|disable") \
23752 _(get_first_msg_id, "client <name>") \
23753 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23754 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23755 "fib-id <nn> [ip4][ip6][default]") \
23756 _(get_node_graph, " ") \
23757 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23758 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23759 _(ioam_disable, "") \
23760 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23761 " sw_if_index <sw_if_index> p <priority> " \
23762 "w <weight>] [del]") \
23763 _(one_add_del_locator, "locator-set <locator_name> " \
23764 "iface <intf> | sw_if_index <sw_if_index> " \
23765 "p <priority> w <weight> [del]") \
23766 _(one_add_del_local_eid,"vni <vni> eid " \
23767 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23768 "locator-set <locator_name> [del]" \
23769 "[key-id sha1|sha256 secret-key <secret-key>]")\
23770 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23771 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23772 _(one_enable_disable, "enable|disable") \
23773 _(one_map_register_enable_disable, "enable|disable") \
23774 _(one_map_register_fallback_threshold, "<value>") \
23775 _(one_rloc_probe_enable_disable, "enable|disable") \
23776 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23778 "rloc <locator> p <prio> " \
23779 "w <weight> [rloc <loc> ... ] " \
23780 "action <action> [del-all]") \
23781 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23783 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23784 _(one_use_petr, "ip-address> | disable") \
23785 _(one_map_request_mode, "src-dst|dst-only") \
23786 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23787 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23788 _(one_locator_set_dump, "[local | remote]") \
23789 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23790 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23791 "[local] | [remote]") \
23792 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23793 _(one_ndp_bd_get, "") \
23794 _(one_ndp_entries_get, "bd <bridge-domain>") \
23795 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23796 _(one_l2_arp_bd_get, "") \
23797 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23798 _(one_stats_enable_disable, "enable|disalbe") \
23799 _(show_one_stats_enable_disable, "") \
23800 _(one_eid_table_vni_dump, "") \
23801 _(one_eid_table_map_dump, "l2|l3") \
23802 _(one_map_resolver_dump, "") \
23803 _(one_map_server_dump, "") \
23804 _(one_adjacencies_get, "vni <vni>") \
23805 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23806 _(show_one_rloc_probe_state, "") \
23807 _(show_one_map_register_state, "") \
23808 _(show_one_status, "") \
23809 _(one_stats_dump, "") \
23810 _(one_stats_flush, "") \
23811 _(one_get_map_request_itr_rlocs, "") \
23812 _(one_map_register_set_ttl, "<ttl>") \
23813 _(one_set_transport_protocol, "udp|api") \
23814 _(one_get_transport_protocol, "") \
23815 _(one_enable_disable_xtr_mode, "enable|disable") \
23816 _(one_show_xtr_mode, "") \
23817 _(one_enable_disable_pitr_mode, "enable|disable") \
23818 _(one_show_pitr_mode, "") \
23819 _(one_enable_disable_petr_mode, "enable|disable") \
23820 _(one_show_petr_mode, "") \
23821 _(show_one_nsh_mapping, "") \
23822 _(show_one_pitr, "") \
23823 _(show_one_use_petr, "") \
23824 _(show_one_map_request_mode, "") \
23825 _(show_one_map_register_ttl, "") \
23826 _(show_one_map_register_fallback_threshold, "") \
23827 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23828 " sw_if_index <sw_if_index> p <priority> " \
23829 "w <weight>] [del]") \
23830 _(lisp_add_del_locator, "locator-set <locator_name> " \
23831 "iface <intf> | sw_if_index <sw_if_index> " \
23832 "p <priority> w <weight> [del]") \
23833 _(lisp_add_del_local_eid,"vni <vni> eid " \
23834 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23835 "locator-set <locator_name> [del]" \
23836 "[key-id sha1|sha256 secret-key <secret-key>]") \
23837 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23838 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23839 _(lisp_enable_disable, "enable|disable") \
23840 _(lisp_map_register_enable_disable, "enable|disable") \
23841 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23842 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23844 "rloc <locator> p <prio> " \
23845 "w <weight> [rloc <loc> ... ] " \
23846 "action <action> [del-all]") \
23847 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23849 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23850 _(lisp_use_petr, "<ip-address> | disable") \
23851 _(lisp_map_request_mode, "src-dst|dst-only") \
23852 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23853 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23854 _(lisp_locator_set_dump, "[local | remote]") \
23855 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23856 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23857 "[local] | [remote]") \
23858 _(lisp_eid_table_vni_dump, "") \
23859 _(lisp_eid_table_map_dump, "l2|l3") \
23860 _(lisp_map_resolver_dump, "") \
23861 _(lisp_map_server_dump, "") \
23862 _(lisp_adjacencies_get, "vni <vni>") \
23863 _(gpe_fwd_entry_vnis_get, "") \
23864 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23865 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23866 "[table <table-id>]") \
23867 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23868 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23869 _(gpe_set_encap_mode, "lisp|vxlan") \
23870 _(gpe_get_encap_mode, "") \
23871 _(lisp_gpe_add_del_iface, "up|down") \
23872 _(lisp_gpe_enable_disable, "enable|disable") \
23873 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23874 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23875 _(show_lisp_rloc_probe_state, "") \
23876 _(show_lisp_map_register_state, "") \
23877 _(show_lisp_status, "") \
23878 _(lisp_get_map_request_itr_rlocs, "") \
23879 _(show_lisp_pitr, "") \
23880 _(show_lisp_use_petr, "") \
23881 _(show_lisp_map_request_mode, "") \
23882 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23883 _(af_packet_delete, "name <host interface name>") \
23884 _(af_packet_dump, "") \
23885 _(policer_add_del, "name <policer name> <params> [del]") \
23886 _(policer_dump, "[name <policer name>]") \
23887 _(policer_classify_set_interface, \
23888 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23889 " [l2-table <nn>] [del]") \
23890 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23891 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23892 "[master|slave]") \
23893 _(netmap_delete, "name <interface name>") \
23894 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23895 _(mpls_fib_dump, "") \
23896 _(classify_table_ids, "") \
23897 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23898 _(classify_table_info, "table_id <nn>") \
23899 _(classify_session_dump, "table_id <nn>") \
23900 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23901 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23902 "[template_interval <nn>] [udp_checksum]") \
23903 _(ipfix_exporter_dump, "") \
23904 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23905 _(ipfix_classify_stream_dump, "") \
23906 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23907 _(ipfix_classify_table_dump, "") \
23908 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23909 _(sw_interface_span_dump, "[l2]") \
23910 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23911 _(pg_create_interface, "if_id <nn>") \
23912 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23913 _(pg_enable_disable, "[stream <id>] disable") \
23914 _(ip_source_and_port_range_check_add_del, \
23915 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23916 _(ip_source_and_port_range_check_interface_add_del, \
23917 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23918 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23919 _(ipsec_gre_add_del_tunnel, \
23920 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23921 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23922 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23923 _(l2_interface_pbb_tag_rewrite, \
23924 "<intfc> | sw_if_index <nn> \n" \
23925 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23926 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23927 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23928 _(flow_classify_set_interface, \
23929 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23930 _(flow_classify_dump, "type [ip4|ip6]") \
23931 _(ip_fib_dump, "") \
23932 _(ip_mfib_dump, "") \
23933 _(ip6_fib_dump, "") \
23934 _(ip6_mfib_dump, "") \
23935 _(feature_enable_disable, "arc_name <arc_name> " \
23936 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23937 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23939 _(l2_xconnect_dump, "") \
23940 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
23941 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23942 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23943 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23944 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23945 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23946 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23947 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23948 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23949 _(sock_init_shm, "size <nnn>") \
23950 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23951 _(dns_enable_disable, "[enable][disable]") \
23952 _(dns_name_server_add_del, "<ip-address> [del]") \
23953 _(dns_resolve_name, "<hostname>") \
23954 _(dns_resolve_ip, "<ip4|ip6>") \
23955 _(dns_name_server_add_del, "<ip-address> [del]") \
23956 _(dns_resolve_name, "<hostname>") \
23957 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23958 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23959 _(session_rules_dump, "") \
23960 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23961 _(output_acl_set_interface, \
23962 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23963 " [l2-table <nn>] [del]") \
23964 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]") \
23965 _(map_stats_segment, "<no-args>")
23967 /* List of command functions, CLI names map directly to functions */
23968 #define foreach_cli_function \
23969 _(comment, "usage: comment <ignore-rest-of-line>") \
23970 _(dump_interface_table, "usage: dump_interface_table") \
23971 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23972 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23973 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23974 _(dump_stats_table, "usage: dump_stats_table") \
23975 _(dump_macro_table, "usage: dump_macro_table ") \
23976 _(dump_node_table, "usage: dump_node_table") \
23977 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23978 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23979 _(echo, "usage: echo <message>") \
23980 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23981 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23982 _(help, "usage: help") \
23983 _(q, "usage: quit") \
23984 _(quit, "usage: quit") \
23985 _(search_node_table, "usage: search_node_table <name>...") \
23986 _(set, "usage: set <variable-name> <value>") \
23987 _(script, "usage: script <file-name>") \
23988 _(statseg, "usage: statseg"); \
23989 _(unset, "usage: unset <variable-name>")
23992 static void vl_api_##n##_t_handler_uni \
23993 (vl_api_##n##_t * mp) \
23995 vat_main_t * vam = &vat_main; \
23996 if (vam->json_output) { \
23997 vl_api_##n##_t_handler_json(mp); \
23999 vl_api_##n##_t_handler(mp); \
24002 foreach_vpe_api_reply_msg;
24003 #if VPP_API_TEST_BUILTIN == 0
24004 foreach_standalone_reply_msg;
24009 vat_api_hookup (vat_main_t * vam)
24012 vl_msg_api_set_handlers(VL_API_##N, #n, \
24013 vl_api_##n##_t_handler_uni, \
24015 vl_api_##n##_t_endian, \
24016 vl_api_##n##_t_print, \
24017 sizeof(vl_api_##n##_t), 1);
24018 foreach_vpe_api_reply_msg;
24019 #if VPP_API_TEST_BUILTIN == 0
24020 foreach_standalone_reply_msg;
24024 #if (VPP_API_TEST_BUILTIN==0)
24025 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
24027 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
24029 vam->function_by_name = hash_create_string (0, sizeof (uword));
24031 vam->help_by_name = hash_create_string (0, sizeof (uword));
24034 /* API messages we can send */
24035 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
24036 foreach_vpe_api_msg;
24040 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24041 foreach_vpe_api_msg;
24044 /* CLI functions */
24045 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
24046 foreach_cli_function;
24050 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
24051 foreach_cli_function;
24055 #if VPP_API_TEST_BUILTIN
24056 static clib_error_t *
24057 vat_api_hookup_shim (vlib_main_t * vm)
24059 vat_api_hookup (&vat_main);
24063 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
24067 * fd.io coding-style-patch-verification: ON
24070 * eval: (c-set-style "gnu")