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 _(sw_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 _(SW_INTERFACE_SET_MTU_REPLY, sw_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)
5889 #define foreach_standalone_reply_msg \
5890 _(SW_INTERFACE_EVENT, sw_interface_event) \
5891 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5892 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5893 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5894 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5895 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5896 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5904 #define STR_VTR_OP_CASE(op) \
5905 case L2_VTR_ ## op: \
5909 str_vtr_op (u32 vtr_op)
5913 STR_VTR_OP_CASE (DISABLED);
5914 STR_VTR_OP_CASE (PUSH_1);
5915 STR_VTR_OP_CASE (PUSH_2);
5916 STR_VTR_OP_CASE (POP_1);
5917 STR_VTR_OP_CASE (POP_2);
5918 STR_VTR_OP_CASE (TRANSLATE_1_1);
5919 STR_VTR_OP_CASE (TRANSLATE_1_2);
5920 STR_VTR_OP_CASE (TRANSLATE_2_1);
5921 STR_VTR_OP_CASE (TRANSLATE_2_2);
5928 dump_sub_interface_table (vat_main_t * vam)
5930 const sw_interface_subif_t *sub = NULL;
5932 if (vam->json_output)
5935 ("JSON output supported only for VPE API calls and dump_stats_table");
5940 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5941 "Interface", "sw_if_index",
5942 "sub id", "dot1ad", "tags", "outer id",
5943 "inner id", "exact", "default", "outer any", "inner any");
5945 vec_foreach (sub, vam->sw_if_subif_table)
5948 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5949 sub->interface_name,
5951 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5952 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5953 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5954 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5955 if (sub->vtr_op != L2_VTR_DISABLED)
5958 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5959 "tag1: %d tag2: %d ]",
5960 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5961 sub->vtr_tag1, sub->vtr_tag2);
5969 name_sort_cmp (void *a1, void *a2)
5971 name_sort_t *n1 = a1;
5972 name_sort_t *n2 = a2;
5974 return strcmp ((char *) n1->name, (char *) n2->name);
5978 dump_interface_table (vat_main_t * vam)
5981 name_sort_t *nses = 0, *ns;
5983 if (vam->json_output)
5986 ("JSON output supported only for VPE API calls and dump_stats_table");
5991 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5993 vec_add2 (nses, ns, 1);
5994 ns->name = (u8 *)(p->key);
5995 ns->value = (u32) p->value[0];
5999 vec_sort_with_function (nses, name_sort_cmp);
6001 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6002 vec_foreach (ns, nses)
6004 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6011 dump_ip_table (vat_main_t * vam, int is_ipv6)
6013 const ip_details_t *det = NULL;
6014 const ip_address_details_t *address = NULL;
6017 print (vam->ofp, "%-12s", "sw_if_index");
6019 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6026 print (vam->ofp, "%-12d", i);
6027 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6032 vec_foreach (address, det->addr)
6036 is_ipv6 ? format_ip6_address : format_ip4_address,
6037 address->ip, address->prefix_length);
6045 dump_ipv4_table (vat_main_t * vam)
6047 if (vam->json_output)
6050 ("JSON output supported only for VPE API calls and dump_stats_table");
6054 return dump_ip_table (vam, 0);
6058 dump_ipv6_table (vat_main_t * vam)
6060 if (vam->json_output)
6063 ("JSON output supported only for VPE API calls and dump_stats_table");
6067 return dump_ip_table (vam, 1);
6071 counter_type_to_str (u8 counter_type, u8 is_combined)
6075 switch (counter_type)
6077 case VNET_INTERFACE_COUNTER_DROP:
6079 case VNET_INTERFACE_COUNTER_PUNT:
6081 case VNET_INTERFACE_COUNTER_IP4:
6083 case VNET_INTERFACE_COUNTER_IP6:
6085 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6087 case VNET_INTERFACE_COUNTER_RX_MISS:
6089 case VNET_INTERFACE_COUNTER_RX_ERROR:
6091 case VNET_INTERFACE_COUNTER_TX_ERROR:
6094 return "INVALID-COUNTER-TYPE";
6099 switch (counter_type)
6101 case VNET_INTERFACE_COUNTER_RX:
6103 case VNET_INTERFACE_COUNTER_TX:
6106 return "INVALID-COUNTER-TYPE";
6112 dump_stats_table (vat_main_t * vam)
6114 vat_json_node_t node;
6115 vat_json_node_t *msg_array;
6116 vat_json_node_t *msg;
6117 vat_json_node_t *counter_array;
6118 vat_json_node_t *counter;
6119 interface_counter_t c;
6121 ip4_fib_counter_t *c4;
6122 ip6_fib_counter_t *c6;
6123 ip4_nbr_counter_t *n4;
6124 ip6_nbr_counter_t *n6;
6127 if (!vam->json_output)
6129 clib_warning ("dump_stats_table supported only in JSON format");
6133 vat_json_init_object (&node);
6135 /* interface counters */
6136 msg_array = vat_json_object_add (&node, "interface_counters");
6137 vat_json_init_array (msg_array);
6138 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6140 msg = vat_json_array_add (msg_array);
6141 vat_json_init_object (msg);
6142 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6143 (u8 *) counter_type_to_str (i, 0));
6144 vat_json_object_add_int (msg, "is_combined", 0);
6145 counter_array = vat_json_object_add (msg, "data");
6146 vat_json_init_array (counter_array);
6147 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6149 packets = vam->simple_interface_counters[i][j];
6150 vat_json_array_add_uint (counter_array, packets);
6153 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6155 msg = vat_json_array_add (msg_array);
6156 vat_json_init_object (msg);
6157 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6158 (u8 *) counter_type_to_str (i, 1));
6159 vat_json_object_add_int (msg, "is_combined", 1);
6160 counter_array = vat_json_object_add (msg, "data");
6161 vat_json_init_array (counter_array);
6162 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6164 c = vam->combined_interface_counters[i][j];
6165 counter = vat_json_array_add (counter_array);
6166 vat_json_init_object (counter);
6167 vat_json_object_add_uint (counter, "packets", c.packets);
6168 vat_json_object_add_uint (counter, "bytes", c.bytes);
6172 /* ip4 fib counters */
6173 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6174 vat_json_init_array (msg_array);
6175 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6177 msg = vat_json_array_add (msg_array);
6178 vat_json_init_object (msg);
6179 vat_json_object_add_uint (msg, "vrf_id",
6180 vam->ip4_fib_counters_vrf_id_by_index[i]);
6181 counter_array = vat_json_object_add (msg, "c");
6182 vat_json_init_array (counter_array);
6183 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6185 counter = vat_json_array_add (counter_array);
6186 vat_json_init_object (counter);
6187 c4 = &vam->ip4_fib_counters[i][j];
6188 vat_json_object_add_ip4 (counter, "address", c4->address);
6189 vat_json_object_add_uint (counter, "address_length",
6190 c4->address_length);
6191 vat_json_object_add_uint (counter, "packets", c4->packets);
6192 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6196 /* ip6 fib counters */
6197 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6198 vat_json_init_array (msg_array);
6199 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6201 msg = vat_json_array_add (msg_array);
6202 vat_json_init_object (msg);
6203 vat_json_object_add_uint (msg, "vrf_id",
6204 vam->ip6_fib_counters_vrf_id_by_index[i]);
6205 counter_array = vat_json_object_add (msg, "c");
6206 vat_json_init_array (counter_array);
6207 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6209 counter = vat_json_array_add (counter_array);
6210 vat_json_init_object (counter);
6211 c6 = &vam->ip6_fib_counters[i][j];
6212 vat_json_object_add_ip6 (counter, "address", c6->address);
6213 vat_json_object_add_uint (counter, "address_length",
6214 c6->address_length);
6215 vat_json_object_add_uint (counter, "packets", c6->packets);
6216 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6220 /* ip4 nbr counters */
6221 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6222 vat_json_init_array (msg_array);
6223 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6225 msg = vat_json_array_add (msg_array);
6226 vat_json_init_object (msg);
6227 vat_json_object_add_uint (msg, "sw_if_index", i);
6228 counter_array = vat_json_object_add (msg, "c");
6229 vat_json_init_array (counter_array);
6230 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6232 counter = vat_json_array_add (counter_array);
6233 vat_json_init_object (counter);
6234 n4 = &vam->ip4_nbr_counters[i][j];
6235 vat_json_object_add_ip4 (counter, "address", n4->address);
6236 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6237 vat_json_object_add_uint (counter, "packets", n4->packets);
6238 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6242 /* ip6 nbr counters */
6243 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6244 vat_json_init_array (msg_array);
6245 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6247 msg = vat_json_array_add (msg_array);
6248 vat_json_init_object (msg);
6249 vat_json_object_add_uint (msg, "sw_if_index", i);
6250 counter_array = vat_json_object_add (msg, "c");
6251 vat_json_init_array (counter_array);
6252 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6254 counter = vat_json_array_add (counter_array);
6255 vat_json_init_object (counter);
6256 n6 = &vam->ip6_nbr_counters[i][j];
6257 vat_json_object_add_ip6 (counter, "address", n6->address);
6258 vat_json_object_add_uint (counter, "packets", n6->packets);
6259 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6263 vat_json_print (vam->ofp, &node);
6264 vat_json_free (&node);
6270 * Pass CLI buffers directly in the CLI_INBAND API message,
6271 * instead of an additional shared memory area.
6274 exec_inband (vat_main_t * vam)
6276 vl_api_cli_inband_t *mp;
6277 unformat_input_t *i = vam->input;
6280 if (vec_len (i->buffer) == 0)
6283 if (vam->exec_mode == 0 && unformat (i, "mode"))
6288 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6295 * In order for the CLI command to work, it
6296 * must be a vector ending in \n, not a C-string ending
6299 u32 len = vec_len (vam->input->buffer);
6300 M2 (CLI_INBAND, mp, len);
6301 clib_memcpy (mp->cmd, vam->input->buffer, len);
6302 mp->length = htonl (len);
6306 /* json responses may or may not include a useful reply... */
6307 if (vec_len (vam->cmd_reply))
6308 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6313 exec (vat_main_t * vam)
6315 return exec_inband (vam);
6319 api_create_loopback (vat_main_t * vam)
6321 unformat_input_t *i = vam->input;
6322 vl_api_create_loopback_t *mp;
6323 vl_api_create_loopback_instance_t *mp_lbi;
6326 u8 is_specified = 0;
6327 u32 user_instance = 0;
6330 memset (mac_address, 0, sizeof (mac_address));
6332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6334 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6336 if (unformat (i, "instance %d", &user_instance))
6344 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6345 mp_lbi->is_specified = is_specified;
6347 mp_lbi->user_instance = htonl (user_instance);
6349 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6354 /* Construct the API message */
6355 M (CREATE_LOOPBACK, mp);
6357 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6366 api_delete_loopback (vat_main_t * vam)
6368 unformat_input_t *i = vam->input;
6369 vl_api_delete_loopback_t *mp;
6370 u32 sw_if_index = ~0;
6373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6375 if (unformat (i, "sw_if_index %d", &sw_if_index))
6381 if (sw_if_index == ~0)
6383 errmsg ("missing sw_if_index");
6387 /* Construct the API message */
6388 M (DELETE_LOOPBACK, mp);
6389 mp->sw_if_index = ntohl (sw_if_index);
6397 api_want_stats (vat_main_t * vam)
6399 unformat_input_t *i = vam->input;
6400 vl_api_want_stats_t *mp;
6404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6406 if (unformat (i, "enable"))
6408 else if (unformat (i, "disable"))
6416 errmsg ("missing enable|disable");
6421 mp->enable_disable = enable;
6429 api_want_interface_events (vat_main_t * vam)
6431 unformat_input_t *i = vam->input;
6432 vl_api_want_interface_events_t *mp;
6436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6438 if (unformat (i, "enable"))
6440 else if (unformat (i, "disable"))
6448 errmsg ("missing enable|disable");
6452 M (WANT_INTERFACE_EVENTS, mp);
6453 mp->enable_disable = enable;
6455 vam->interface_event_display = enable;
6463 /* Note: non-static, called once to set up the initial intfc table */
6465 api_sw_interface_dump (vat_main_t * vam)
6467 vl_api_sw_interface_dump_t *mp;
6468 vl_api_control_ping_t *mp_ping;
6470 name_sort_t *nses = 0, *ns;
6471 sw_interface_subif_t *sub = NULL;
6474 /* Toss the old name table */
6476 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6478 vec_add2 (nses, ns, 1);
6479 ns->name = (u8 *)(p->key);
6480 ns->value = (u32) p->value[0];
6484 hash_free (vam->sw_if_index_by_interface_name);
6486 vec_foreach (ns, nses) vec_free (ns->name);
6490 vec_foreach (sub, vam->sw_if_subif_table)
6492 vec_free (sub->interface_name);
6494 vec_free (vam->sw_if_subif_table);
6496 /* recreate the interface name hash table */
6497 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6500 * Ask for all interface names. Otherwise, the epic catalog of
6501 * name filters becomes ridiculously long, and vat ends up needing
6502 * to be taught about new interface types.
6504 M (SW_INTERFACE_DUMP, mp);
6507 /* Use a control ping for synchronization */
6508 MPING (CONTROL_PING, mp_ping);
6516 api_sw_interface_set_flags (vat_main_t * vam)
6518 unformat_input_t *i = vam->input;
6519 vl_api_sw_interface_set_flags_t *mp;
6521 u8 sw_if_index_set = 0;
6525 /* Parse args required to build the message */
6526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6528 if (unformat (i, "admin-up"))
6530 else if (unformat (i, "admin-down"))
6533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6534 sw_if_index_set = 1;
6535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6536 sw_if_index_set = 1;
6541 if (sw_if_index_set == 0)
6543 errmsg ("missing interface name or sw_if_index");
6547 /* Construct the API message */
6548 M (SW_INTERFACE_SET_FLAGS, mp);
6549 mp->sw_if_index = ntohl (sw_if_index);
6550 mp->admin_up_down = admin_up;
6555 /* Wait for a reply, return the good/bad news... */
6561 api_sw_interface_set_rx_mode (vat_main_t * vam)
6563 unformat_input_t *i = vam->input;
6564 vl_api_sw_interface_set_rx_mode_t *mp;
6566 u8 sw_if_index_set = 0;
6568 u8 queue_id_valid = 0;
6570 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6572 /* Parse args required to build the message */
6573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "queue %d", &queue_id))
6577 else if (unformat (i, "polling"))
6578 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6579 else if (unformat (i, "interrupt"))
6580 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6581 else if (unformat (i, "adaptive"))
6582 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6584 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6585 sw_if_index_set = 1;
6586 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6587 sw_if_index_set = 1;
6592 if (sw_if_index_set == 0)
6594 errmsg ("missing interface name or sw_if_index");
6597 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6599 errmsg ("missing rx-mode");
6603 /* Construct the API message */
6604 M (SW_INTERFACE_SET_RX_MODE, mp);
6605 mp->sw_if_index = ntohl (sw_if_index);
6607 mp->queue_id_valid = queue_id_valid;
6608 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6613 /* Wait for a reply, return the good/bad news... */
6619 api_sw_interface_clear_stats (vat_main_t * vam)
6621 unformat_input_t *i = vam->input;
6622 vl_api_sw_interface_clear_stats_t *mp;
6624 u8 sw_if_index_set = 0;
6627 /* Parse args required to build the message */
6628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6630 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6631 sw_if_index_set = 1;
6632 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6633 sw_if_index_set = 1;
6638 /* Construct the API message */
6639 M (SW_INTERFACE_CLEAR_STATS, mp);
6641 if (sw_if_index_set == 1)
6642 mp->sw_if_index = ntohl (sw_if_index);
6644 mp->sw_if_index = ~0;
6649 /* Wait for a reply, return the good/bad news... */
6655 api_sw_interface_add_del_address (vat_main_t * vam)
6657 unformat_input_t *i = vam->input;
6658 vl_api_sw_interface_add_del_address_t *mp;
6660 u8 sw_if_index_set = 0;
6661 u8 is_add = 1, del_all = 0;
6662 u32 address_length = 0;
6663 u8 v4_address_set = 0;
6664 u8 v6_address_set = 0;
6665 ip4_address_t v4address;
6666 ip6_address_t v6address;
6669 /* Parse args required to build the message */
6670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6672 if (unformat (i, "del-all"))
6674 else if (unformat (i, "del"))
6677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6678 sw_if_index_set = 1;
6679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6680 sw_if_index_set = 1;
6681 else if (unformat (i, "%U/%d",
6682 unformat_ip4_address, &v4address, &address_length))
6684 else if (unformat (i, "%U/%d",
6685 unformat_ip6_address, &v6address, &address_length))
6691 if (sw_if_index_set == 0)
6693 errmsg ("missing interface name or sw_if_index");
6696 if (v4_address_set && v6_address_set)
6698 errmsg ("both v4 and v6 addresses set");
6701 if (!v4_address_set && !v6_address_set && !del_all)
6703 errmsg ("no addresses set");
6707 /* Construct the API message */
6708 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6710 mp->sw_if_index = ntohl (sw_if_index);
6711 mp->is_add = is_add;
6712 mp->del_all = del_all;
6716 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6720 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6722 mp->address_length = address_length;
6727 /* Wait for a reply, return good/bad news */
6733 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6735 unformat_input_t *i = vam->input;
6736 vl_api_sw_interface_set_mpls_enable_t *mp;
6738 u8 sw_if_index_set = 0;
6742 /* Parse args required to build the message */
6743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6745 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6746 sw_if_index_set = 1;
6747 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6748 sw_if_index_set = 1;
6749 else if (unformat (i, "disable"))
6751 else if (unformat (i, "dis"))
6757 if (sw_if_index_set == 0)
6759 errmsg ("missing interface name or sw_if_index");
6763 /* Construct the API message */
6764 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6766 mp->sw_if_index = ntohl (sw_if_index);
6767 mp->enable = enable;
6772 /* Wait for a reply... */
6778 api_sw_interface_set_table (vat_main_t * vam)
6780 unformat_input_t *i = vam->input;
6781 vl_api_sw_interface_set_table_t *mp;
6782 u32 sw_if_index, vrf_id = 0;
6783 u8 sw_if_index_set = 0;
6787 /* Parse args required to build the message */
6788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6791 sw_if_index_set = 1;
6792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6793 sw_if_index_set = 1;
6794 else if (unformat (i, "vrf %d", &vrf_id))
6796 else if (unformat (i, "ipv6"))
6802 if (sw_if_index_set == 0)
6804 errmsg ("missing interface name or sw_if_index");
6808 /* Construct the API message */
6809 M (SW_INTERFACE_SET_TABLE, mp);
6811 mp->sw_if_index = ntohl (sw_if_index);
6812 mp->is_ipv6 = is_ipv6;
6813 mp->vrf_id = ntohl (vrf_id);
6818 /* Wait for a reply... */
6823 static void vl_api_sw_interface_get_table_reply_t_handler
6824 (vl_api_sw_interface_get_table_reply_t * mp)
6826 vat_main_t *vam = &vat_main;
6828 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6830 vam->retval = ntohl (mp->retval);
6831 vam->result_ready = 1;
6835 static void vl_api_sw_interface_get_table_reply_t_handler_json
6836 (vl_api_sw_interface_get_table_reply_t * mp)
6838 vat_main_t *vam = &vat_main;
6839 vat_json_node_t node;
6841 vat_json_init_object (&node);
6842 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6843 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6845 vat_json_print (vam->ofp, &node);
6846 vat_json_free (&node);
6848 vam->retval = ntohl (mp->retval);
6849 vam->result_ready = 1;
6853 api_sw_interface_get_table (vat_main_t * vam)
6855 unformat_input_t *i = vam->input;
6856 vl_api_sw_interface_get_table_t *mp;
6858 u8 sw_if_index_set = 0;
6862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6864 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6865 sw_if_index_set = 1;
6866 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6867 sw_if_index_set = 1;
6868 else if (unformat (i, "ipv6"))
6874 if (sw_if_index_set == 0)
6876 errmsg ("missing interface name or sw_if_index");
6880 M (SW_INTERFACE_GET_TABLE, mp);
6881 mp->sw_if_index = htonl (sw_if_index);
6882 mp->is_ipv6 = is_ipv6;
6890 api_sw_interface_set_vpath (vat_main_t * vam)
6892 unformat_input_t *i = vam->input;
6893 vl_api_sw_interface_set_vpath_t *mp;
6894 u32 sw_if_index = 0;
6895 u8 sw_if_index_set = 0;
6899 /* Parse args required to build the message */
6900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6902 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6903 sw_if_index_set = 1;
6904 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6905 sw_if_index_set = 1;
6906 else if (unformat (i, "enable"))
6908 else if (unformat (i, "disable"))
6914 if (sw_if_index_set == 0)
6916 errmsg ("missing interface name or sw_if_index");
6920 /* Construct the API message */
6921 M (SW_INTERFACE_SET_VPATH, mp);
6923 mp->sw_if_index = ntohl (sw_if_index);
6924 mp->enable = is_enable;
6929 /* Wait for a reply... */
6935 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6937 unformat_input_t *i = vam->input;
6938 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6939 u32 sw_if_index = 0;
6940 u8 sw_if_index_set = 0;
6945 /* Parse args required to build the message */
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6949 sw_if_index_set = 1;
6950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6951 sw_if_index_set = 1;
6952 else if (unformat (i, "enable"))
6954 else if (unformat (i, "disable"))
6956 else if (unformat (i, "ip4"))
6958 else if (unformat (i, "ip6"))
6964 if (sw_if_index_set == 0)
6966 errmsg ("missing interface name or sw_if_index");
6970 /* Construct the API message */
6971 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6973 mp->sw_if_index = ntohl (sw_if_index);
6974 mp->enable = is_enable;
6975 mp->is_ipv6 = is_ipv6;
6980 /* Wait for a reply... */
6986 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6988 unformat_input_t *i = vam->input;
6989 vl_api_sw_interface_set_geneve_bypass_t *mp;
6990 u32 sw_if_index = 0;
6991 u8 sw_if_index_set = 0;
6996 /* Parse args required to build the message */
6997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7000 sw_if_index_set = 1;
7001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7002 sw_if_index_set = 1;
7003 else if (unformat (i, "enable"))
7005 else if (unformat (i, "disable"))
7007 else if (unformat (i, "ip4"))
7009 else if (unformat (i, "ip6"))
7015 if (sw_if_index_set == 0)
7017 errmsg ("missing interface name or sw_if_index");
7021 /* Construct the API message */
7022 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7024 mp->sw_if_index = ntohl (sw_if_index);
7025 mp->enable = is_enable;
7026 mp->is_ipv6 = is_ipv6;
7031 /* Wait for a reply... */
7037 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7039 unformat_input_t *i = vam->input;
7040 vl_api_sw_interface_set_l2_xconnect_t *mp;
7042 u8 rx_sw_if_index_set = 0;
7044 u8 tx_sw_if_index_set = 0;
7048 /* Parse args required to build the message */
7049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7051 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7052 rx_sw_if_index_set = 1;
7053 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7054 tx_sw_if_index_set = 1;
7055 else if (unformat (i, "rx"))
7057 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7059 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7061 rx_sw_if_index_set = 1;
7066 else if (unformat (i, "tx"))
7068 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7070 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7072 tx_sw_if_index_set = 1;
7077 else if (unformat (i, "enable"))
7079 else if (unformat (i, "disable"))
7085 if (rx_sw_if_index_set == 0)
7087 errmsg ("missing rx interface name or rx_sw_if_index");
7091 if (enable && (tx_sw_if_index_set == 0))
7093 errmsg ("missing tx interface name or tx_sw_if_index");
7097 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7099 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7100 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7101 mp->enable = enable;
7109 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7111 unformat_input_t *i = vam->input;
7112 vl_api_sw_interface_set_l2_bridge_t *mp;
7114 u8 rx_sw_if_index_set = 0;
7122 /* Parse args required to build the message */
7123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7125 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7126 rx_sw_if_index_set = 1;
7127 else if (unformat (i, "bd_id %d", &bd_id))
7131 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7132 rx_sw_if_index_set = 1;
7133 else if (unformat (i, "shg %d", &shg))
7135 else if (unformat (i, "bvi"))
7137 else if (unformat (i, "enable"))
7139 else if (unformat (i, "disable"))
7145 if (rx_sw_if_index_set == 0)
7147 errmsg ("missing rx interface name or sw_if_index");
7151 if (enable && (bd_id_set == 0))
7153 errmsg ("missing bridge domain");
7157 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7159 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7160 mp->bd_id = ntohl (bd_id);
7163 mp->enable = enable;
7171 api_bridge_domain_dump (vat_main_t * vam)
7173 unformat_input_t *i = vam->input;
7174 vl_api_bridge_domain_dump_t *mp;
7175 vl_api_control_ping_t *mp_ping;
7179 /* Parse args required to build the message */
7180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7182 if (unformat (i, "bd_id %d", &bd_id))
7188 M (BRIDGE_DOMAIN_DUMP, mp);
7189 mp->bd_id = ntohl (bd_id);
7192 /* Use a control ping for synchronization */
7193 MPING (CONTROL_PING, mp_ping);
7201 api_bridge_domain_add_del (vat_main_t * vam)
7203 unformat_input_t *i = vam->input;
7204 vl_api_bridge_domain_add_del_t *mp;
7207 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7212 /* Parse args required to build the message */
7213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7215 if (unformat (i, "bd_id %d", &bd_id))
7217 else if (unformat (i, "flood %d", &flood))
7219 else if (unformat (i, "uu-flood %d", &uu_flood))
7221 else if (unformat (i, "forward %d", &forward))
7223 else if (unformat (i, "learn %d", &learn))
7225 else if (unformat (i, "arp-term %d", &arp_term))
7227 else if (unformat (i, "mac-age %d", &mac_age))
7229 else if (unformat (i, "bd-tag %s", &bd_tag))
7231 else if (unformat (i, "del"))
7234 flood = uu_flood = forward = learn = 0;
7242 errmsg ("missing bridge domain");
7249 errmsg ("mac age must be less than 256 ");
7254 if ((bd_tag) && (vec_len (bd_tag) > 63))
7256 errmsg ("bd-tag cannot be longer than 63");
7261 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7263 mp->bd_id = ntohl (bd_id);
7265 mp->uu_flood = uu_flood;
7266 mp->forward = forward;
7268 mp->arp_term = arp_term;
7269 mp->is_add = is_add;
7270 mp->mac_age = (u8) mac_age;
7273 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7274 mp->bd_tag[vec_len (bd_tag)] = 0;
7285 api_l2fib_flush_bd (vat_main_t * vam)
7287 unformat_input_t *i = vam->input;
7288 vl_api_l2fib_flush_bd_t *mp;
7292 /* Parse args required to build the message */
7293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7295 if (unformat (i, "bd_id %d", &bd_id));
7302 errmsg ("missing bridge domain");
7306 M (L2FIB_FLUSH_BD, mp);
7308 mp->bd_id = htonl (bd_id);
7316 api_l2fib_flush_int (vat_main_t * vam)
7318 unformat_input_t *i = vam->input;
7319 vl_api_l2fib_flush_int_t *mp;
7320 u32 sw_if_index = ~0;
7323 /* Parse args required to build the message */
7324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7326 if (unformat (i, "sw_if_index %d", &sw_if_index));
7328 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7333 if (sw_if_index == ~0)
7335 errmsg ("missing interface name or sw_if_index");
7339 M (L2FIB_FLUSH_INT, mp);
7341 mp->sw_if_index = ntohl (sw_if_index);
7349 api_l2fib_add_del (vat_main_t * vam)
7351 unformat_input_t *i = vam->input;
7352 vl_api_l2fib_add_del_t *mp;
7358 u32 sw_if_index = 0;
7359 u8 sw_if_index_set = 0;
7368 /* Parse args required to build the message */
7369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7371 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7373 else if (unformat (i, "bd_id %d", &bd_id))
7375 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7376 sw_if_index_set = 1;
7377 else if (unformat (i, "sw_if"))
7379 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7382 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7383 sw_if_index_set = 1;
7388 else if (unformat (i, "static"))
7390 else if (unformat (i, "filter"))
7395 else if (unformat (i, "bvi"))
7400 else if (unformat (i, "del"))
7402 else if (unformat (i, "count %d", &count))
7410 errmsg ("missing mac address");
7416 errmsg ("missing bridge domain");
7420 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7422 errmsg ("missing interface name or sw_if_index");
7428 /* Turn on async mode */
7429 vam->async_mode = 1;
7430 vam->async_errors = 0;
7431 before = vat_time_now (vam);
7434 for (j = 0; j < count; j++)
7436 M (L2FIB_ADD_DEL, mp);
7438 clib_memcpy (mp->mac, mac, 6);
7439 mp->bd_id = ntohl (bd_id);
7440 mp->is_add = is_add;
7441 mp->sw_if_index = ntohl (sw_if_index);
7445 mp->static_mac = static_mac;
7446 mp->filter_mac = filter_mac;
7447 mp->bvi_mac = bvi_mac;
7449 increment_mac_address (mac);
7456 vl_api_control_ping_t *mp_ping;
7459 /* Shut off async mode */
7460 vam->async_mode = 0;
7462 MPING (CONTROL_PING, mp_ping);
7465 timeout = vat_time_now (vam) + 1.0;
7466 while (vat_time_now (vam) < timeout)
7467 if (vam->result_ready == 1)
7472 if (vam->retval == -99)
7475 if (vam->async_errors > 0)
7477 errmsg ("%d asynchronous errors", vam->async_errors);
7480 vam->async_errors = 0;
7481 after = vat_time_now (vam);
7483 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7484 count, after - before, count / (after - before));
7490 /* Wait for a reply... */
7494 /* Return the good/bad news */
7495 return (vam->retval);
7499 api_bridge_domain_set_mac_age (vat_main_t * vam)
7501 unformat_input_t *i = vam->input;
7502 vl_api_bridge_domain_set_mac_age_t *mp;
7507 /* Parse args required to build the message */
7508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7510 if (unformat (i, "bd_id %d", &bd_id));
7511 else if (unformat (i, "mac-age %d", &mac_age));
7518 errmsg ("missing bridge domain");
7524 errmsg ("mac age must be less than 256 ");
7528 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7530 mp->bd_id = htonl (bd_id);
7531 mp->mac_age = (u8) mac_age;
7539 api_l2_flags (vat_main_t * vam)
7541 unformat_input_t *i = vam->input;
7542 vl_api_l2_flags_t *mp;
7545 u8 sw_if_index_set = 0;
7549 /* Parse args required to build the message */
7550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7552 if (unformat (i, "sw_if_index %d", &sw_if_index))
7553 sw_if_index_set = 1;
7554 else if (unformat (i, "sw_if"))
7556 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7559 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7560 sw_if_index_set = 1;
7565 else if (unformat (i, "learn"))
7567 else if (unformat (i, "forward"))
7569 else if (unformat (i, "flood"))
7571 else if (unformat (i, "uu-flood"))
7572 flags |= L2_UU_FLOOD;
7573 else if (unformat (i, "arp-term"))
7574 flags |= L2_ARP_TERM;
7575 else if (unformat (i, "off"))
7577 else if (unformat (i, "disable"))
7583 if (sw_if_index_set == 0)
7585 errmsg ("missing interface name or sw_if_index");
7591 mp->sw_if_index = ntohl (sw_if_index);
7592 mp->feature_bitmap = ntohl (flags);
7593 mp->is_set = is_set;
7601 api_bridge_flags (vat_main_t * vam)
7603 unformat_input_t *i = vam->input;
7604 vl_api_bridge_flags_t *mp;
7611 /* Parse args required to build the message */
7612 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7614 if (unformat (i, "bd_id %d", &bd_id))
7616 else if (unformat (i, "learn"))
7618 else if (unformat (i, "forward"))
7620 else if (unformat (i, "flood"))
7622 else if (unformat (i, "uu-flood"))
7623 flags |= L2_UU_FLOOD;
7624 else if (unformat (i, "arp-term"))
7625 flags |= L2_ARP_TERM;
7626 else if (unformat (i, "off"))
7628 else if (unformat (i, "disable"))
7636 errmsg ("missing bridge domain");
7640 M (BRIDGE_FLAGS, mp);
7642 mp->bd_id = ntohl (bd_id);
7643 mp->feature_bitmap = ntohl (flags);
7644 mp->is_set = is_set;
7652 api_bd_ip_mac_add_del (vat_main_t * vam)
7654 unformat_input_t *i = vam->input;
7655 vl_api_bd_ip_mac_add_del_t *mp;
7662 ip4_address_t v4addr;
7663 ip6_address_t v6addr;
7668 /* Parse args required to build the message */
7669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7671 if (unformat (i, "bd_id %d", &bd_id))
7675 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7679 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7684 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7688 else if (unformat (i, "del"))
7696 errmsg ("missing bridge domain");
7699 else if (ip_set == 0)
7701 errmsg ("missing IP address");
7704 else if (mac_set == 0)
7706 errmsg ("missing MAC address");
7710 M (BD_IP_MAC_ADD_DEL, mp);
7712 mp->bd_id = ntohl (bd_id);
7713 mp->is_ipv6 = is_ipv6;
7714 mp->is_add = is_add;
7716 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7718 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7719 clib_memcpy (mp->mac_address, macaddr, 6);
7726 api_tap_connect (vat_main_t * vam)
7728 unformat_input_t *i = vam->input;
7729 vl_api_tap_connect_t *mp;
7735 ip4_address_t ip4_address;
7737 int ip4_address_set = 0;
7738 ip6_address_t ip6_address;
7740 int ip6_address_set = 0;
7743 memset (mac_address, 0, sizeof (mac_address));
7745 /* Parse args required to build the message */
7746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7748 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7752 else if (unformat (i, "random-mac"))
7754 else if (unformat (i, "tapname %s", &tap_name))
7756 else if (unformat (i, "tag %s", &tag))
7758 else if (unformat (i, "address %U/%d",
7759 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7760 ip4_address_set = 1;
7761 else if (unformat (i, "address %U/%d",
7762 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7763 ip6_address_set = 1;
7770 errmsg ("missing tap name");
7773 if (vec_len (tap_name) > 63)
7775 errmsg ("tap name too long");
7778 vec_add1 (tap_name, 0);
7780 if (vec_len (tag) > 63)
7782 errmsg ("tag too long");
7786 /* Construct the API message */
7787 M (TAP_CONNECT, mp);
7789 mp->use_random_mac = random_mac;
7790 clib_memcpy (mp->mac_address, mac_address, 6);
7791 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7793 clib_memcpy (mp->tag, tag, vec_len (tag));
7795 if (ip4_address_set)
7797 mp->ip4_address_set = 1;
7798 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7799 mp->ip4_mask_width = ip4_mask_width;
7801 if (ip6_address_set)
7803 mp->ip6_address_set = 1;
7804 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7805 mp->ip6_mask_width = ip6_mask_width;
7808 vec_free (tap_name);
7814 /* Wait for a reply... */
7820 api_tap_modify (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_tap_modify_t *mp;
7828 u32 sw_if_index = ~0;
7829 u8 sw_if_index_set = 0;
7832 memset (mac_address, 0, sizeof (mac_address));
7834 /* Parse args required to build the message */
7835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7838 sw_if_index_set = 1;
7839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7840 sw_if_index_set = 1;
7841 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7845 else if (unformat (i, "random-mac"))
7847 else if (unformat (i, "tapname %s", &tap_name))
7853 if (sw_if_index_set == 0)
7855 errmsg ("missing vpp interface name");
7860 errmsg ("missing tap name");
7863 if (vec_len (tap_name) > 63)
7865 errmsg ("tap name too long");
7867 vec_add1 (tap_name, 0);
7869 /* Construct the API message */
7872 mp->use_random_mac = random_mac;
7873 mp->sw_if_index = ntohl (sw_if_index);
7874 clib_memcpy (mp->mac_address, mac_address, 6);
7875 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7876 vec_free (tap_name);
7881 /* Wait for a reply... */
7887 api_tap_delete (vat_main_t * vam)
7889 unformat_input_t *i = vam->input;
7890 vl_api_tap_delete_t *mp;
7891 u32 sw_if_index = ~0;
7892 u8 sw_if_index_set = 0;
7895 /* Parse args required to build the message */
7896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7899 sw_if_index_set = 1;
7900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7901 sw_if_index_set = 1;
7906 if (sw_if_index_set == 0)
7908 errmsg ("missing vpp interface name");
7912 /* Construct the API message */
7915 mp->sw_if_index = ntohl (sw_if_index);
7920 /* Wait for a reply... */
7926 api_tap_create_v2 (vat_main_t * vam)
7928 unformat_input_t *i = vam->input;
7929 vl_api_tap_create_v2_t *mp;
7933 u8 *host_if_name = 0;
7935 u8 host_mac_addr[6];
7936 u8 host_mac_addr_set = 0;
7937 u8 *host_bridge = 0;
7938 ip4_address_t host_ip4_addr;
7939 ip4_address_t host_ip4_gw;
7940 u8 host_ip4_gw_set = 0;
7941 u32 host_ip4_prefix_len = 0;
7942 ip6_address_t host_ip6_addr;
7943 ip6_address_t host_ip6_gw;
7944 u8 host_ip6_gw_set = 0;
7945 u32 host_ip6_prefix_len = 0;
7947 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7949 memset (mac_address, 0, sizeof (mac_address));
7951 /* Parse args required to build the message */
7952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7954 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7958 else if (unformat (i, "id %u", &id))
7960 else if (unformat (i, "host-if-name %s", &host_if_name))
7962 else if (unformat (i, "host-ns %s", &host_ns))
7964 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7966 host_mac_addr_set = 1;
7967 else if (unformat (i, "host-bridge %s", &host_bridge))
7969 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7970 &host_ip4_addr, &host_ip4_prefix_len))
7972 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7973 &host_ip6_addr, &host_ip6_prefix_len))
7975 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7977 host_ip4_gw_set = 1;
7978 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7980 host_ip6_gw_set = 1;
7981 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7983 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7989 if (vec_len (host_if_name) > 63)
7991 errmsg ("tap name too long. ");
7994 if (vec_len (host_ns) > 63)
7996 errmsg ("host name space too long. ");
7999 if (vec_len (host_bridge) > 63)
8001 errmsg ("host bridge name too long. ");
8004 if (host_ip4_prefix_len > 32)
8006 errmsg ("host ip4 prefix length not valid. ");
8009 if (host_ip6_prefix_len > 128)
8011 errmsg ("host ip6 prefix length not valid. ");
8014 if (!is_pow2 (rx_ring_sz))
8016 errmsg ("rx ring size must be power of 2. ");
8019 if (rx_ring_sz > 32768)
8021 errmsg ("rx ring size must be 32768 or lower. ");
8024 if (!is_pow2 (tx_ring_sz))
8026 errmsg ("tx ring size must be power of 2. ");
8029 if (tx_ring_sz > 32768)
8031 errmsg ("tx ring size must be 32768 or lower. ");
8035 /* Construct the API message */
8036 M (TAP_CREATE_V2, mp);
8038 mp->use_random_mac = random_mac;
8040 mp->id = ntohl (id);
8041 mp->host_namespace_set = host_ns != 0;
8042 mp->host_bridge_set = host_bridge != 0;
8043 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8044 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8045 mp->rx_ring_sz = ntohs (rx_ring_sz);
8046 mp->tx_ring_sz = ntohs (tx_ring_sz);
8048 if (random_mac == 0)
8049 clib_memcpy (mp->mac_address, mac_address, 6);
8050 if (host_mac_addr_set)
8051 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8053 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8055 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8057 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8058 if (host_ip4_prefix_len)
8059 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8060 if (host_ip4_prefix_len)
8061 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8062 if (host_ip4_gw_set)
8063 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8064 if (host_ip6_gw_set)
8065 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8068 vec_free (host_if_name);
8069 vec_free (host_bridge);
8074 /* Wait for a reply... */
8080 api_tap_delete_v2 (vat_main_t * vam)
8082 unformat_input_t *i = vam->input;
8083 vl_api_tap_delete_v2_t *mp;
8084 u32 sw_if_index = ~0;
8085 u8 sw_if_index_set = 0;
8088 /* Parse args required to build the message */
8089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8092 sw_if_index_set = 1;
8093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8094 sw_if_index_set = 1;
8099 if (sw_if_index_set == 0)
8101 errmsg ("missing vpp interface name. ");
8105 /* Construct the API message */
8106 M (TAP_DELETE_V2, mp);
8108 mp->sw_if_index = ntohl (sw_if_index);
8113 /* Wait for a reply... */
8119 api_bond_create (vat_main_t * vam)
8121 unformat_input_t *i = vam->input;
8122 vl_api_bond_create_t *mp;
8130 memset (mac_address, 0, sizeof (mac_address));
8133 /* Parse args required to build the message */
8134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8136 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8138 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8139 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8141 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8148 if (mode_is_set == 0)
8150 errmsg ("Missing bond mode. ");
8154 /* Construct the API message */
8155 M (BOND_CREATE, mp);
8157 mp->use_custom_mac = custom_mac;
8163 clib_memcpy (mp->mac_address, mac_address, 6);
8168 /* Wait for a reply... */
8174 api_bond_delete (vat_main_t * vam)
8176 unformat_input_t *i = vam->input;
8177 vl_api_bond_delete_t *mp;
8178 u32 sw_if_index = ~0;
8179 u8 sw_if_index_set = 0;
8182 /* Parse args required to build the message */
8183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8185 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8186 sw_if_index_set = 1;
8187 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8188 sw_if_index_set = 1;
8193 if (sw_if_index_set == 0)
8195 errmsg ("missing vpp interface name. ");
8199 /* Construct the API message */
8200 M (BOND_DELETE, mp);
8202 mp->sw_if_index = ntohl (sw_if_index);
8207 /* Wait for a reply... */
8213 api_bond_enslave (vat_main_t * vam)
8215 unformat_input_t *i = vam->input;
8216 vl_api_bond_enslave_t *mp;
8217 u32 bond_sw_if_index;
8221 u32 bond_sw_if_index_is_set = 0;
8223 u8 sw_if_index_is_set = 0;
8225 /* Parse args required to build the message */
8226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8228 if (unformat (i, "sw_if_index %d", &sw_if_index))
8229 sw_if_index_is_set = 1;
8230 else if (unformat (i, "bond %u", &bond_sw_if_index))
8231 bond_sw_if_index_is_set = 1;
8232 else if (unformat (i, "passive %d", &is_passive))
8234 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8240 if (bond_sw_if_index_is_set == 0)
8242 errmsg ("Missing bond sw_if_index. ");
8245 if (sw_if_index_is_set == 0)
8247 errmsg ("Missing slave sw_if_index. ");
8251 /* Construct the API message */
8252 M (BOND_ENSLAVE, mp);
8254 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8255 mp->sw_if_index = ntohl (sw_if_index);
8256 mp->is_long_timeout = is_long_timeout;
8257 mp->is_passive = is_passive;
8262 /* Wait for a reply... */
8268 api_bond_detach_slave (vat_main_t * vam)
8270 unformat_input_t *i = vam->input;
8271 vl_api_bond_detach_slave_t *mp;
8272 u32 sw_if_index = ~0;
8273 u8 sw_if_index_set = 0;
8276 /* Parse args required to build the message */
8277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8279 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8280 sw_if_index_set = 1;
8281 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8282 sw_if_index_set = 1;
8287 if (sw_if_index_set == 0)
8289 errmsg ("missing vpp interface name. ");
8293 /* Construct the API message */
8294 M (BOND_DETACH_SLAVE, mp);
8296 mp->sw_if_index = ntohl (sw_if_index);
8301 /* Wait for a reply... */
8307 api_ip_table_add_del (vat_main_t * vam)
8309 unformat_input_t *i = vam->input;
8310 vl_api_ip_table_add_del_t *mp;
8316 /* Parse args required to build the message */
8317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8319 if (unformat (i, "ipv6"))
8321 else if (unformat (i, "del"))
8323 else if (unformat (i, "add"))
8325 else if (unformat (i, "table %d", &table_id))
8329 clib_warning ("parse error '%U'", format_unformat_error, i);
8336 errmsg ("missing table-ID");
8340 /* Construct the API message */
8341 M (IP_TABLE_ADD_DEL, mp);
8343 mp->table_id = ntohl (table_id);
8344 mp->is_ipv6 = is_ipv6;
8345 mp->is_add = is_add;
8350 /* Wait for a reply... */
8357 api_ip_add_del_route (vat_main_t * vam)
8359 unformat_input_t *i = vam->input;
8360 vl_api_ip_add_del_route_t *mp;
8361 u32 sw_if_index = ~0, vrf_id = 0;
8363 u8 is_local = 0, is_drop = 0;
8364 u8 is_unreach = 0, is_prohibit = 0;
8366 u32 next_hop_weight = 1;
8367 u8 is_multipath = 0;
8369 u8 address_length_set = 0;
8370 u32 next_hop_table_id = 0;
8371 u32 resolve_attempts = 0;
8372 u32 dst_address_length = 0;
8373 u8 next_hop_set = 0;
8374 ip4_address_t v4_dst_address, v4_next_hop_address;
8375 ip6_address_t v6_dst_address, v6_next_hop_address;
8379 u32 random_add_del = 0;
8380 u32 *random_vector = 0;
8382 u32 random_seed = 0xdeaddabe;
8383 u32 classify_table_index = ~0;
8385 u8 resolve_host = 0, resolve_attached = 0;
8386 mpls_label_t *next_hop_out_label_stack = NULL;
8387 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8388 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8390 /* Parse args required to build the message */
8391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8397 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8402 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8407 else if (unformat (i, "/%d", &dst_address_length))
8409 address_length_set = 1;
8412 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8413 &v4_next_hop_address))
8417 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8418 &v6_next_hop_address))
8422 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8424 else if (unformat (i, "weight %d", &next_hop_weight))
8426 else if (unformat (i, "drop"))
8430 else if (unformat (i, "null-send-unreach"))
8434 else if (unformat (i, "null-send-prohibit"))
8438 else if (unformat (i, "local"))
8442 else if (unformat (i, "classify %d", &classify_table_index))
8446 else if (unformat (i, "del"))
8448 else if (unformat (i, "add"))
8450 else if (unformat (i, "resolve-via-host"))
8452 else if (unformat (i, "resolve-via-attached"))
8453 resolve_attached = 1;
8454 else if (unformat (i, "multipath"))
8456 else if (unformat (i, "vrf %d", &vrf_id))
8458 else if (unformat (i, "count %d", &count))
8460 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8462 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8464 else if (unformat (i, "out-label %d", &next_hop_out_label))
8465 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8466 else if (unformat (i, "via-label %d", &next_hop_via_label))
8468 else if (unformat (i, "random"))
8470 else if (unformat (i, "seed %d", &random_seed))
8474 clib_warning ("parse error '%U'", format_unformat_error, i);
8479 if (!next_hop_set && !is_drop && !is_local &&
8480 !is_classify && !is_unreach && !is_prohibit &&
8481 MPLS_LABEL_INVALID == next_hop_via_label)
8484 ("next hop / local / drop / unreach / prohibit / classify not set");
8488 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8490 errmsg ("next hop and next-hop via label set");
8493 if (address_set == 0)
8495 errmsg ("missing addresses");
8499 if (address_length_set == 0)
8501 errmsg ("missing address length");
8505 /* Generate a pile of unique, random routes */
8508 u32 this_random_address;
8509 random_hash = hash_create (count, sizeof (uword));
8511 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8512 for (j = 0; j <= count; j++)
8516 this_random_address = random_u32 (&random_seed);
8517 this_random_address =
8518 clib_host_to_net_u32 (this_random_address);
8520 while (hash_get (random_hash, this_random_address));
8521 vec_add1 (random_vector, this_random_address);
8522 hash_set (random_hash, this_random_address, 1);
8524 hash_free (random_hash);
8525 v4_dst_address.as_u32 = random_vector[0];
8530 /* Turn on async mode */
8531 vam->async_mode = 1;
8532 vam->async_errors = 0;
8533 before = vat_time_now (vam);
8536 for (j = 0; j < count; j++)
8538 /* Construct the API message */
8539 M2 (IP_ADD_DEL_ROUTE, mp,
8540 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8542 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8543 mp->table_id = ntohl (vrf_id);
8545 mp->is_add = is_add;
8546 mp->is_drop = is_drop;
8547 mp->is_unreach = is_unreach;
8548 mp->is_prohibit = is_prohibit;
8549 mp->is_ipv6 = is_ipv6;
8550 mp->is_local = is_local;
8551 mp->is_classify = is_classify;
8552 mp->is_multipath = is_multipath;
8553 mp->is_resolve_host = resolve_host;
8554 mp->is_resolve_attached = resolve_attached;
8555 mp->next_hop_weight = next_hop_weight;
8556 mp->dst_address_length = dst_address_length;
8557 mp->next_hop_table_id = ntohl (next_hop_table_id);
8558 mp->classify_table_index = ntohl (classify_table_index);
8559 mp->next_hop_via_label = ntohl (next_hop_via_label);
8560 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8561 if (0 != mp->next_hop_n_out_labels)
8563 memcpy (mp->next_hop_out_label_stack,
8564 next_hop_out_label_stack,
8565 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8566 vec_free (next_hop_out_label_stack);
8571 clib_memcpy (mp->dst_address, &v6_dst_address,
8572 sizeof (v6_dst_address));
8574 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8575 sizeof (v6_next_hop_address));
8576 increment_v6_address (&v6_dst_address);
8580 clib_memcpy (mp->dst_address, &v4_dst_address,
8581 sizeof (v4_dst_address));
8583 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8584 sizeof (v4_next_hop_address));
8586 v4_dst_address.as_u32 = random_vector[j + 1];
8588 increment_v4_address (&v4_dst_address);
8592 /* If we receive SIGTERM, stop now... */
8597 /* When testing multiple add/del ops, use a control-ping to sync */
8600 vl_api_control_ping_t *mp_ping;
8604 /* Shut off async mode */
8605 vam->async_mode = 0;
8607 MPING (CONTROL_PING, mp_ping);
8610 timeout = vat_time_now (vam) + 1.0;
8611 while (vat_time_now (vam) < timeout)
8612 if (vam->result_ready == 1)
8617 if (vam->retval == -99)
8620 if (vam->async_errors > 0)
8622 errmsg ("%d asynchronous errors", vam->async_errors);
8625 vam->async_errors = 0;
8626 after = vat_time_now (vam);
8628 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8632 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8633 count, after - before, count / (after - before));
8639 /* Wait for a reply... */
8644 /* Return the good/bad news */
8645 return (vam->retval);
8649 api_ip_mroute_add_del (vat_main_t * vam)
8651 unformat_input_t *i = vam->input;
8652 vl_api_ip_mroute_add_del_t *mp;
8653 u32 sw_if_index = ~0, vrf_id = 0;
8658 u32 grp_address_length = 0;
8659 ip4_address_t v4_grp_address, v4_src_address;
8660 ip6_address_t v6_grp_address, v6_src_address;
8661 mfib_itf_flags_t iflags = 0;
8662 mfib_entry_flags_t eflags = 0;
8665 /* Parse args required to build the message */
8666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8668 if (unformat (i, "sw_if_index %d", &sw_if_index))
8670 else if (unformat (i, "%U %U",
8671 unformat_ip4_address, &v4_src_address,
8672 unformat_ip4_address, &v4_grp_address))
8674 grp_address_length = 64;
8678 else if (unformat (i, "%U %U",
8679 unformat_ip6_address, &v6_src_address,
8680 unformat_ip6_address, &v6_grp_address))
8682 grp_address_length = 256;
8686 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8688 memset (&v4_src_address, 0, sizeof (v4_src_address));
8689 grp_address_length = 32;
8693 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8695 memset (&v6_src_address, 0, sizeof (v6_src_address));
8696 grp_address_length = 128;
8700 else if (unformat (i, "/%d", &grp_address_length))
8702 else if (unformat (i, "local"))
8706 else if (unformat (i, "del"))
8708 else if (unformat (i, "add"))
8710 else if (unformat (i, "vrf %d", &vrf_id))
8712 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8714 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8718 clib_warning ("parse error '%U'", format_unformat_error, i);
8723 if (address_set == 0)
8725 errmsg ("missing addresses\n");
8729 /* Construct the API message */
8730 M (IP_MROUTE_ADD_DEL, mp);
8732 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8733 mp->table_id = ntohl (vrf_id);
8735 mp->is_add = is_add;
8736 mp->is_ipv6 = is_ipv6;
8737 mp->is_local = is_local;
8738 mp->itf_flags = ntohl (iflags);
8739 mp->entry_flags = ntohl (eflags);
8740 mp->grp_address_length = grp_address_length;
8741 mp->grp_address_length = ntohs (mp->grp_address_length);
8745 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8746 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8750 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8751 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8757 /* Wait for a reply... */
8763 api_mpls_table_add_del (vat_main_t * vam)
8765 unformat_input_t *i = vam->input;
8766 vl_api_mpls_table_add_del_t *mp;
8771 /* Parse args required to build the message */
8772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8774 if (unformat (i, "table %d", &table_id))
8776 else if (unformat (i, "del"))
8778 else if (unformat (i, "add"))
8782 clib_warning ("parse error '%U'", format_unformat_error, i);
8789 errmsg ("missing table-ID");
8793 /* Construct the API message */
8794 M (MPLS_TABLE_ADD_DEL, mp);
8796 mp->mt_table_id = ntohl (table_id);
8797 mp->mt_is_add = is_add;
8802 /* Wait for a reply... */
8809 api_mpls_route_add_del (vat_main_t * vam)
8811 unformat_input_t *i = vam->input;
8812 vl_api_mpls_route_add_del_t *mp;
8813 u32 sw_if_index = ~0, table_id = 0;
8815 u32 next_hop_weight = 1;
8816 u8 is_multipath = 0;
8817 u32 next_hop_table_id = 0;
8818 u8 next_hop_set = 0;
8819 ip4_address_t v4_next_hop_address = {
8822 ip6_address_t v6_next_hop_address = { {0} };
8826 u32 classify_table_index = ~0;
8828 u8 resolve_host = 0, resolve_attached = 0;
8829 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8830 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8831 mpls_label_t *next_hop_out_label_stack = NULL;
8832 mpls_label_t local_label = MPLS_LABEL_INVALID;
8834 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8836 /* Parse args required to build the message */
8837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8839 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8841 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8843 else if (unformat (i, "%d", &local_label))
8845 else if (unformat (i, "eos"))
8847 else if (unformat (i, "non-eos"))
8849 else if (unformat (i, "via %U", unformat_ip4_address,
8850 &v4_next_hop_address))
8853 next_hop_proto = DPO_PROTO_IP4;
8855 else if (unformat (i, "via %U", unformat_ip6_address,
8856 &v6_next_hop_address))
8859 next_hop_proto = DPO_PROTO_IP6;
8861 else if (unformat (i, "weight %d", &next_hop_weight))
8863 else if (unformat (i, "classify %d", &classify_table_index))
8867 else if (unformat (i, "del"))
8869 else if (unformat (i, "add"))
8871 else if (unformat (i, "resolve-via-host"))
8873 else if (unformat (i, "resolve-via-attached"))
8874 resolve_attached = 1;
8875 else if (unformat (i, "multipath"))
8877 else if (unformat (i, "count %d", &count))
8879 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8882 next_hop_proto = DPO_PROTO_IP4;
8884 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8887 next_hop_proto = DPO_PROTO_IP6;
8889 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8891 else if (unformat (i, "via-label %d", &next_hop_via_label))
8893 else if (unformat (i, "out-label %d", &next_hop_out_label))
8894 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8902 if (!next_hop_set && !is_classify)
8904 errmsg ("next hop / classify not set");
8908 if (MPLS_LABEL_INVALID == local_label)
8910 errmsg ("missing label");
8916 /* Turn on async mode */
8917 vam->async_mode = 1;
8918 vam->async_errors = 0;
8919 before = vat_time_now (vam);
8922 for (j = 0; j < count; j++)
8924 /* Construct the API message */
8925 M2 (MPLS_ROUTE_ADD_DEL, mp,
8926 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8928 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8929 mp->mr_table_id = ntohl (table_id);
8931 mp->mr_is_add = is_add;
8932 mp->mr_next_hop_proto = next_hop_proto;
8933 mp->mr_is_classify = is_classify;
8934 mp->mr_is_multipath = is_multipath;
8935 mp->mr_is_resolve_host = resolve_host;
8936 mp->mr_is_resolve_attached = resolve_attached;
8937 mp->mr_next_hop_weight = next_hop_weight;
8938 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8939 mp->mr_classify_table_index = ntohl (classify_table_index);
8940 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8941 mp->mr_label = ntohl (local_label);
8942 mp->mr_eos = is_eos;
8944 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8945 if (0 != mp->mr_next_hop_n_out_labels)
8947 memcpy (mp->mr_next_hop_out_label_stack,
8948 next_hop_out_label_stack,
8949 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8950 vec_free (next_hop_out_label_stack);
8955 if (DPO_PROTO_IP4 == next_hop_proto)
8957 clib_memcpy (mp->mr_next_hop,
8958 &v4_next_hop_address,
8959 sizeof (v4_next_hop_address));
8961 else if (DPO_PROTO_IP6 == next_hop_proto)
8964 clib_memcpy (mp->mr_next_hop,
8965 &v6_next_hop_address,
8966 sizeof (v6_next_hop_address));
8973 /* If we receive SIGTERM, stop now... */
8978 /* When testing multiple add/del ops, use a control-ping to sync */
8981 vl_api_control_ping_t *mp_ping;
8985 /* Shut off async mode */
8986 vam->async_mode = 0;
8988 MPING (CONTROL_PING, mp_ping);
8991 timeout = vat_time_now (vam) + 1.0;
8992 while (vat_time_now (vam) < timeout)
8993 if (vam->result_ready == 1)
8998 if (vam->retval == -99)
9001 if (vam->async_errors > 0)
9003 errmsg ("%d asynchronous errors", vam->async_errors);
9006 vam->async_errors = 0;
9007 after = vat_time_now (vam);
9009 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9013 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9014 count, after - before, count / (after - before));
9020 /* Wait for a reply... */
9025 /* Return the good/bad news */
9026 return (vam->retval);
9030 api_mpls_ip_bind_unbind (vat_main_t * vam)
9032 unformat_input_t *i = vam->input;
9033 vl_api_mpls_ip_bind_unbind_t *mp;
9034 u32 ip_table_id = 0;
9037 ip4_address_t v4_address;
9038 ip6_address_t v6_address;
9041 mpls_label_t local_label = MPLS_LABEL_INVALID;
9044 /* Parse args required to build the message */
9045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9047 if (unformat (i, "%U/%d", unformat_ip4_address,
9048 &v4_address, &address_length))
9053 else if (unformat (i, "%U/%d", unformat_ip6_address,
9054 &v6_address, &address_length))
9059 else if (unformat (i, "%d", &local_label))
9061 else if (unformat (i, "table-id %d", &ip_table_id))
9063 else if (unformat (i, "unbind"))
9065 else if (unformat (i, "bind"))
9069 clib_warning ("parse error '%U'", format_unformat_error, i);
9076 errmsg ("IP addres not set");
9080 if (MPLS_LABEL_INVALID == local_label)
9082 errmsg ("missing label");
9086 /* Construct the API message */
9087 M (MPLS_IP_BIND_UNBIND, mp);
9089 mp->mb_is_bind = is_bind;
9090 mp->mb_is_ip4 = is_ip4;
9091 mp->mb_ip_table_id = ntohl (ip_table_id);
9092 mp->mb_mpls_table_id = 0;
9093 mp->mb_label = ntohl (local_label);
9094 mp->mb_address_length = address_length;
9097 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9099 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9104 /* Wait for a reply... */
9110 api_bier_table_add_del (vat_main_t * vam)
9112 unformat_input_t *i = vam->input;
9113 vl_api_bier_table_add_del_t *mp;
9115 u32 set = 0, sub_domain = 0, hdr_len = 3;
9116 mpls_label_t local_label = MPLS_LABEL_INVALID;
9119 /* Parse args required to build the message */
9120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9122 if (unformat (i, "sub-domain %d", &sub_domain))
9124 else if (unformat (i, "set %d", &set))
9126 else if (unformat (i, "label %d", &local_label))
9128 else if (unformat (i, "hdr-len %d", &hdr_len))
9130 else if (unformat (i, "add"))
9132 else if (unformat (i, "del"))
9136 clib_warning ("parse error '%U'", format_unformat_error, i);
9141 if (MPLS_LABEL_INVALID == local_label)
9143 errmsg ("missing label\n");
9147 /* Construct the API message */
9148 M (BIER_TABLE_ADD_DEL, mp);
9150 mp->bt_is_add = is_add;
9151 mp->bt_label = ntohl (local_label);
9152 mp->bt_tbl_id.bt_set = set;
9153 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9154 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9159 /* Wait for a reply... */
9166 api_bier_route_add_del (vat_main_t * vam)
9168 unformat_input_t *i = vam->input;
9169 vl_api_bier_route_add_del_t *mp;
9171 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9172 ip4_address_t v4_next_hop_address;
9173 ip6_address_t v6_next_hop_address;
9174 u8 next_hop_set = 0;
9175 u8 next_hop_proto_is_ip4 = 1;
9176 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9179 /* Parse args required to build the message */
9180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9182 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9184 next_hop_proto_is_ip4 = 1;
9187 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9189 next_hop_proto_is_ip4 = 0;
9192 if (unformat (i, "sub-domain %d", &sub_domain))
9194 else if (unformat (i, "set %d", &set))
9196 else if (unformat (i, "hdr-len %d", &hdr_len))
9198 else if (unformat (i, "bp %d", &bp))
9200 else if (unformat (i, "add"))
9202 else if (unformat (i, "del"))
9204 else if (unformat (i, "out-label %d", &next_hop_out_label))
9208 clib_warning ("parse error '%U'", format_unformat_error, i);
9213 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9215 errmsg ("next hop / label set\n");
9220 errmsg ("bit=position not set\n");
9224 /* Construct the API message */
9225 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9227 mp->br_is_add = is_add;
9228 mp->br_tbl_id.bt_set = set;
9229 mp->br_tbl_id.bt_sub_domain = sub_domain;
9230 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9231 mp->br_bp = ntohs (bp);
9233 mp->br_paths[0].n_labels = 1;
9234 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9235 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9237 if (next_hop_proto_is_ip4)
9239 clib_memcpy (mp->br_paths[0].next_hop,
9240 &v4_next_hop_address, sizeof (v4_next_hop_address));
9244 clib_memcpy (mp->br_paths[0].next_hop,
9245 &v6_next_hop_address, sizeof (v6_next_hop_address));
9251 /* Wait for a reply... */
9258 api_proxy_arp_add_del (vat_main_t * vam)
9260 unformat_input_t *i = vam->input;
9261 vl_api_proxy_arp_add_del_t *mp;
9264 ip4_address_t lo, hi;
9268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9270 if (unformat (i, "vrf %d", &vrf_id))
9272 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9273 unformat_ip4_address, &hi))
9275 else if (unformat (i, "del"))
9279 clib_warning ("parse error '%U'", format_unformat_error, i);
9286 errmsg ("address range not set");
9290 M (PROXY_ARP_ADD_DEL, mp);
9292 mp->proxy.vrf_id = ntohl (vrf_id);
9293 mp->is_add = is_add;
9294 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9295 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9303 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9305 unformat_input_t *i = vam->input;
9306 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9309 u8 sw_if_index_set = 0;
9312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9314 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9315 sw_if_index_set = 1;
9316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9317 sw_if_index_set = 1;
9318 else if (unformat (i, "enable"))
9320 else if (unformat (i, "disable"))
9324 clib_warning ("parse error '%U'", format_unformat_error, i);
9329 if (sw_if_index_set == 0)
9331 errmsg ("missing interface name or sw_if_index");
9335 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9337 mp->sw_if_index = ntohl (sw_if_index);
9338 mp->enable_disable = enable;
9346 api_mpls_tunnel_add_del (vat_main_t * vam)
9348 unformat_input_t *i = vam->input;
9349 vl_api_mpls_tunnel_add_del_t *mp;
9353 u32 sw_if_index = ~0;
9354 u32 next_hop_sw_if_index = ~0;
9355 u32 next_hop_proto_is_ip4 = 1;
9357 u32 next_hop_table_id = 0;
9358 ip4_address_t v4_next_hop_address = {
9361 ip6_address_t v6_next_hop_address = { {0} };
9362 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9367 if (unformat (i, "add"))
9369 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9371 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9373 else if (unformat (i, "via %U",
9374 unformat_ip4_address, &v4_next_hop_address))
9376 next_hop_proto_is_ip4 = 1;
9378 else if (unformat (i, "via %U",
9379 unformat_ip6_address, &v6_next_hop_address))
9381 next_hop_proto_is_ip4 = 0;
9383 else if (unformat (i, "l2-only"))
9385 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9387 else if (unformat (i, "out-label %d", &next_hop_out_label))
9388 vec_add1 (labels, ntohl (next_hop_out_label));
9391 clib_warning ("parse error '%U'", format_unformat_error, i);
9396 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9398 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9399 mp->mt_sw_if_index = ntohl (sw_if_index);
9400 mp->mt_is_add = is_add;
9401 mp->mt_l2_only = l2_only;
9402 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9403 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9405 mp->mt_next_hop_n_out_labels = vec_len (labels);
9407 if (0 != mp->mt_next_hop_n_out_labels)
9409 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9410 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9414 if (next_hop_proto_is_ip4)
9416 clib_memcpy (mp->mt_next_hop,
9417 &v4_next_hop_address, sizeof (v4_next_hop_address));
9421 clib_memcpy (mp->mt_next_hop,
9422 &v6_next_hop_address, sizeof (v6_next_hop_address));
9431 api_sw_interface_set_unnumbered (vat_main_t * vam)
9433 unformat_input_t *i = vam->input;
9434 vl_api_sw_interface_set_unnumbered_t *mp;
9436 u32 unnum_sw_index = ~0;
9438 u8 sw_if_index_set = 0;
9441 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9443 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9444 sw_if_index_set = 1;
9445 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9446 sw_if_index_set = 1;
9447 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9449 else if (unformat (i, "del"))
9453 clib_warning ("parse error '%U'", format_unformat_error, i);
9458 if (sw_if_index_set == 0)
9460 errmsg ("missing interface name or sw_if_index");
9464 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9466 mp->sw_if_index = ntohl (sw_if_index);
9467 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9468 mp->is_add = is_add;
9476 api_ip_neighbor_add_del (vat_main_t * vam)
9478 unformat_input_t *i = vam->input;
9479 vl_api_ip_neighbor_add_del_t *mp;
9481 u8 sw_if_index_set = 0;
9484 u8 is_no_fib_entry = 0;
9487 u8 v4_address_set = 0;
9488 u8 v6_address_set = 0;
9489 ip4_address_t v4address;
9490 ip6_address_t v6address;
9493 memset (mac_address, 0, sizeof (mac_address));
9495 /* Parse args required to build the message */
9496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9498 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9502 else if (unformat (i, "del"))
9505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9506 sw_if_index_set = 1;
9507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9508 sw_if_index_set = 1;
9509 else if (unformat (i, "is_static"))
9511 else if (unformat (i, "no-fib-entry"))
9512 is_no_fib_entry = 1;
9513 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9515 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9519 clib_warning ("parse error '%U'", format_unformat_error, i);
9524 if (sw_if_index_set == 0)
9526 errmsg ("missing interface name or sw_if_index");
9529 if (v4_address_set && v6_address_set)
9531 errmsg ("both v4 and v6 addresses set");
9534 if (!v4_address_set && !v6_address_set)
9536 errmsg ("no address set");
9540 /* Construct the API message */
9541 M (IP_NEIGHBOR_ADD_DEL, mp);
9543 mp->sw_if_index = ntohl (sw_if_index);
9544 mp->is_add = is_add;
9545 mp->is_static = is_static;
9546 mp->is_no_adj_fib = is_no_fib_entry;
9548 clib_memcpy (mp->mac_address, mac_address, 6);
9552 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9556 /* mp->is_ipv6 = 0; via memset in M macro above */
9557 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9563 /* Wait for a reply, return good/bad news */
9569 api_create_vlan_subif (vat_main_t * vam)
9571 unformat_input_t *i = vam->input;
9572 vl_api_create_vlan_subif_t *mp;
9574 u8 sw_if_index_set = 0;
9579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9581 if (unformat (i, "sw_if_index %d", &sw_if_index))
9582 sw_if_index_set = 1;
9584 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9585 sw_if_index_set = 1;
9586 else if (unformat (i, "vlan %d", &vlan_id))
9590 clib_warning ("parse error '%U'", format_unformat_error, i);
9595 if (sw_if_index_set == 0)
9597 errmsg ("missing interface name or sw_if_index");
9601 if (vlan_id_set == 0)
9603 errmsg ("missing vlan_id");
9606 M (CREATE_VLAN_SUBIF, mp);
9608 mp->sw_if_index = ntohl (sw_if_index);
9609 mp->vlan_id = ntohl (vlan_id);
9616 #define foreach_create_subif_bit \
9623 _(outer_vlan_id_any) \
9624 _(inner_vlan_id_any)
9627 api_create_subif (vat_main_t * vam)
9629 unformat_input_t *i = vam->input;
9630 vl_api_create_subif_t *mp;
9632 u8 sw_if_index_set = 0;
9639 u32 exact_match = 0;
9640 u32 default_sub = 0;
9641 u32 outer_vlan_id_any = 0;
9642 u32 inner_vlan_id_any = 0;
9644 u16 outer_vlan_id = 0;
9645 u16 inner_vlan_id = 0;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "sw_if_index %d", &sw_if_index))
9651 sw_if_index_set = 1;
9653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9654 sw_if_index_set = 1;
9655 else if (unformat (i, "sub_id %d", &sub_id))
9657 else if (unformat (i, "outer_vlan_id %d", &tmp))
9658 outer_vlan_id = tmp;
9659 else if (unformat (i, "inner_vlan_id %d", &tmp))
9660 inner_vlan_id = tmp;
9662 #define _(a) else if (unformat (i, #a)) a = 1 ;
9663 foreach_create_subif_bit
9667 clib_warning ("parse error '%U'", format_unformat_error, i);
9672 if (sw_if_index_set == 0)
9674 errmsg ("missing interface name or sw_if_index");
9678 if (sub_id_set == 0)
9680 errmsg ("missing sub_id");
9683 M (CREATE_SUBIF, mp);
9685 mp->sw_if_index = ntohl (sw_if_index);
9686 mp->sub_id = ntohl (sub_id);
9688 #define _(a) mp->a = a;
9689 foreach_create_subif_bit;
9692 mp->outer_vlan_id = ntohs (outer_vlan_id);
9693 mp->inner_vlan_id = ntohs (inner_vlan_id);
9701 api_oam_add_del (vat_main_t * vam)
9703 unformat_input_t *i = vam->input;
9704 vl_api_oam_add_del_t *mp;
9707 ip4_address_t src, dst;
9712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9714 if (unformat (i, "vrf %d", &vrf_id))
9716 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9718 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9720 else if (unformat (i, "del"))
9724 clib_warning ("parse error '%U'", format_unformat_error, i);
9731 errmsg ("missing src addr");
9737 errmsg ("missing dst addr");
9741 M (OAM_ADD_DEL, mp);
9743 mp->vrf_id = ntohl (vrf_id);
9744 mp->is_add = is_add;
9745 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9746 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9754 api_reset_fib (vat_main_t * vam)
9756 unformat_input_t *i = vam->input;
9757 vl_api_reset_fib_t *mp;
9763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9765 if (unformat (i, "vrf %d", &vrf_id))
9767 else if (unformat (i, "ipv6"))
9771 clib_warning ("parse error '%U'", format_unformat_error, i);
9776 if (vrf_id_set == 0)
9778 errmsg ("missing vrf id");
9784 mp->vrf_id = ntohl (vrf_id);
9785 mp->is_ipv6 = is_ipv6;
9793 api_dhcp_proxy_config (vat_main_t * vam)
9795 unformat_input_t *i = vam->input;
9796 vl_api_dhcp_proxy_config_t *mp;
9798 u32 server_vrf_id = 0;
9800 u8 v4_address_set = 0;
9801 u8 v6_address_set = 0;
9802 ip4_address_t v4address;
9803 ip6_address_t v6address;
9804 u8 v4_src_address_set = 0;
9805 u8 v6_src_address_set = 0;
9806 ip4_address_t v4srcaddress;
9807 ip6_address_t v6srcaddress;
9810 /* Parse args required to build the message */
9811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9813 if (unformat (i, "del"))
9815 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9817 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9819 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9821 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9823 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9824 v4_src_address_set = 1;
9825 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9826 v6_src_address_set = 1;
9831 if (v4_address_set && v6_address_set)
9833 errmsg ("both v4 and v6 server addresses set");
9836 if (!v4_address_set && !v6_address_set)
9838 errmsg ("no server addresses set");
9842 if (v4_src_address_set && v6_src_address_set)
9844 errmsg ("both v4 and v6 src addresses set");
9847 if (!v4_src_address_set && !v6_src_address_set)
9849 errmsg ("no src addresses set");
9853 if (!(v4_src_address_set && v4_address_set) &&
9854 !(v6_src_address_set && v6_address_set))
9856 errmsg ("no matching server and src addresses set");
9860 /* Construct the API message */
9861 M (DHCP_PROXY_CONFIG, mp);
9863 mp->is_add = is_add;
9864 mp->rx_vrf_id = ntohl (rx_vrf_id);
9865 mp->server_vrf_id = ntohl (server_vrf_id);
9869 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9870 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9874 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9875 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9881 /* Wait for a reply, return good/bad news */
9886 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9887 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9890 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9892 vat_main_t *vam = &vat_main;
9893 u32 i, count = mp->count;
9894 vl_api_dhcp_server_t *s;
9898 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9899 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9900 ntohl (mp->rx_vrf_id),
9901 format_ip6_address, mp->dhcp_src_address,
9902 mp->vss_type, mp->vss_vpn_ascii_id,
9903 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9906 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9907 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9908 ntohl (mp->rx_vrf_id),
9909 format_ip4_address, mp->dhcp_src_address,
9910 mp->vss_type, mp->vss_vpn_ascii_id,
9911 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9913 for (i = 0; i < count; i++)
9915 s = &mp->servers[i];
9919 " Server Table-ID %d, Server Address %U",
9920 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9923 " Server Table-ID %d, Server Address %U",
9924 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9928 static void vl_api_dhcp_proxy_details_t_handler_json
9929 (vl_api_dhcp_proxy_details_t * mp)
9931 vat_main_t *vam = &vat_main;
9932 vat_json_node_t *node = NULL;
9933 u32 i, count = mp->count;
9935 struct in6_addr ip6;
9936 vl_api_dhcp_server_t *s;
9938 if (VAT_JSON_ARRAY != vam->json_tree.type)
9940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9941 vat_json_init_array (&vam->json_tree);
9943 node = vat_json_array_add (&vam->json_tree);
9945 vat_json_init_object (node);
9946 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9947 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9948 sizeof (mp->vss_type));
9949 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9950 mp->vss_vpn_ascii_id);
9951 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9952 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9956 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9957 vat_json_object_add_ip6 (node, "src_address", ip6);
9961 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9962 vat_json_object_add_ip4 (node, "src_address", ip4);
9965 for (i = 0; i < count; i++)
9967 s = &mp->servers[i];
9969 vat_json_object_add_uint (node, "server-table-id",
9970 ntohl (s->server_vrf_id));
9974 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9975 vat_json_object_add_ip4 (node, "src_address", ip4);
9979 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9980 vat_json_object_add_ip6 (node, "server_address", ip6);
9986 api_dhcp_proxy_dump (vat_main_t * vam)
9988 unformat_input_t *i = vam->input;
9989 vl_api_control_ping_t *mp_ping;
9990 vl_api_dhcp_proxy_dump_t *mp;
9994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9996 if (unformat (i, "ipv6"))
10000 clib_warning ("parse error '%U'", format_unformat_error, i);
10005 M (DHCP_PROXY_DUMP, mp);
10007 mp->is_ip6 = is_ipv6;
10010 /* Use a control ping for synchronization */
10011 MPING (CONTROL_PING, mp_ping);
10019 api_dhcp_proxy_set_vss (vat_main_t * vam)
10021 unformat_input_t *i = vam->input;
10022 vl_api_dhcp_proxy_set_vss_t *mp;
10026 u8 vss_type = VSS_TYPE_DEFAULT;
10027 u8 *vpn_ascii_id = 0;
10032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10034 if (unformat (i, "tbl_id %d", &tbl_id))
10036 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10037 vss_type = VSS_TYPE_ASCII;
10038 else if (unformat (i, "fib_id %d", &fib_id))
10039 vss_type = VSS_TYPE_VPN_ID;
10040 else if (unformat (i, "oui %d", &oui))
10041 vss_type = VSS_TYPE_VPN_ID;
10042 else if (unformat (i, "ipv6"))
10044 else if (unformat (i, "del"))
10052 errmsg ("missing tbl_id ");
10053 vec_free (vpn_ascii_id);
10057 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10059 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10060 vec_free (vpn_ascii_id);
10064 M (DHCP_PROXY_SET_VSS, mp);
10065 mp->tbl_id = ntohl (tbl_id);
10066 mp->vss_type = vss_type;
10069 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10070 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10072 mp->vpn_index = ntohl (fib_id);
10073 mp->oui = ntohl (oui);
10074 mp->is_ipv6 = is_ipv6;
10075 mp->is_add = is_add;
10080 vec_free (vpn_ascii_id);
10085 api_dhcp_client_config (vat_main_t * vam)
10087 unformat_input_t *i = vam->input;
10088 vl_api_dhcp_client_config_t *mp;
10090 u8 sw_if_index_set = 0;
10093 u8 disable_event = 0;
10096 /* Parse args required to build the message */
10097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10099 if (unformat (i, "del"))
10102 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10103 sw_if_index_set = 1;
10104 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10105 sw_if_index_set = 1;
10106 else if (unformat (i, "hostname %s", &hostname))
10108 else if (unformat (i, "disable_event"))
10114 if (sw_if_index_set == 0)
10116 errmsg ("missing interface name or sw_if_index");
10120 if (vec_len (hostname) > 63)
10122 errmsg ("hostname too long");
10124 vec_add1 (hostname, 0);
10126 /* Construct the API message */
10127 M (DHCP_CLIENT_CONFIG, mp);
10129 mp->is_add = is_add;
10130 mp->client.sw_if_index = htonl (sw_if_index);
10131 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
10132 vec_free (hostname);
10133 mp->client.want_dhcp_event = disable_event ? 0 : 1;
10134 mp->client.pid = htonl (getpid ());
10139 /* Wait for a reply, return good/bad news */
10145 api_set_ip_flow_hash (vat_main_t * vam)
10147 unformat_input_t *i = vam->input;
10148 vl_api_set_ip_flow_hash_t *mp;
10160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10162 if (unformat (i, "vrf %d", &vrf_id))
10164 else if (unformat (i, "ipv6"))
10166 else if (unformat (i, "src"))
10168 else if (unformat (i, "dst"))
10170 else if (unformat (i, "sport"))
10172 else if (unformat (i, "dport"))
10174 else if (unformat (i, "proto"))
10176 else if (unformat (i, "reverse"))
10181 clib_warning ("parse error '%U'", format_unformat_error, i);
10186 if (vrf_id_set == 0)
10188 errmsg ("missing vrf id");
10192 M (SET_IP_FLOW_HASH, mp);
10198 mp->reverse = reverse;
10199 mp->vrf_id = ntohl (vrf_id);
10200 mp->is_ipv6 = is_ipv6;
10208 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10210 unformat_input_t *i = vam->input;
10211 vl_api_sw_interface_ip6_enable_disable_t *mp;
10213 u8 sw_if_index_set = 0;
10217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10220 sw_if_index_set = 1;
10221 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10222 sw_if_index_set = 1;
10223 else if (unformat (i, "enable"))
10225 else if (unformat (i, "disable"))
10229 clib_warning ("parse error '%U'", format_unformat_error, i);
10234 if (sw_if_index_set == 0)
10236 errmsg ("missing interface name or sw_if_index");
10240 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10242 mp->sw_if_index = ntohl (sw_if_index);
10243 mp->enable = enable;
10251 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10253 unformat_input_t *i = vam->input;
10254 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10256 u8 sw_if_index_set = 0;
10257 u8 v6_address_set = 0;
10258 ip6_address_t v6address;
10261 /* Parse args required to build the message */
10262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10264 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10265 sw_if_index_set = 1;
10266 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10267 sw_if_index_set = 1;
10268 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10269 v6_address_set = 1;
10274 if (sw_if_index_set == 0)
10276 errmsg ("missing interface name or sw_if_index");
10279 if (!v6_address_set)
10281 errmsg ("no address set");
10285 /* Construct the API message */
10286 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10288 mp->sw_if_index = ntohl (sw_if_index);
10289 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10294 /* Wait for a reply, return good/bad news */
10300 api_ip6nd_proxy_add_del (vat_main_t * vam)
10302 unformat_input_t *i = vam->input;
10303 vl_api_ip6nd_proxy_add_del_t *mp;
10304 u32 sw_if_index = ~0;
10305 u8 v6_address_set = 0;
10306 ip6_address_t v6address;
10310 /* Parse args required to build the message */
10311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10315 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10317 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10318 v6_address_set = 1;
10319 if (unformat (i, "del"))
10323 clib_warning ("parse error '%U'", format_unformat_error, i);
10328 if (sw_if_index == ~0)
10330 errmsg ("missing interface name or sw_if_index");
10333 if (!v6_address_set)
10335 errmsg ("no address set");
10339 /* Construct the API message */
10340 M (IP6ND_PROXY_ADD_DEL, mp);
10342 mp->is_del = is_del;
10343 mp->sw_if_index = ntohl (sw_if_index);
10344 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10349 /* Wait for a reply, return good/bad news */
10355 api_ip6nd_proxy_dump (vat_main_t * vam)
10357 vl_api_ip6nd_proxy_dump_t *mp;
10358 vl_api_control_ping_t *mp_ping;
10361 M (IP6ND_PROXY_DUMP, mp);
10365 /* Use a control ping for synchronization */
10366 MPING (CONTROL_PING, mp_ping);
10373 static void vl_api_ip6nd_proxy_details_t_handler
10374 (vl_api_ip6nd_proxy_details_t * mp)
10376 vat_main_t *vam = &vat_main;
10378 print (vam->ofp, "host %U sw_if_index %d",
10379 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10382 static void vl_api_ip6nd_proxy_details_t_handler_json
10383 (vl_api_ip6nd_proxy_details_t * mp)
10385 vat_main_t *vam = &vat_main;
10386 struct in6_addr ip6;
10387 vat_json_node_t *node = NULL;
10389 if (VAT_JSON_ARRAY != vam->json_tree.type)
10391 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10392 vat_json_init_array (&vam->json_tree);
10394 node = vat_json_array_add (&vam->json_tree);
10396 vat_json_init_object (node);
10397 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10399 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10400 vat_json_object_add_ip6 (node, "host", ip6);
10404 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10406 unformat_input_t *i = vam->input;
10407 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10409 u8 sw_if_index_set = 0;
10410 u32 address_length = 0;
10411 u8 v6_address_set = 0;
10412 ip6_address_t v6address;
10413 u8 use_default = 0;
10414 u8 no_advertise = 0;
10416 u8 no_autoconfig = 0;
10419 u32 val_lifetime = 0;
10420 u32 pref_lifetime = 0;
10423 /* Parse args required to build the message */
10424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10427 sw_if_index_set = 1;
10428 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10429 sw_if_index_set = 1;
10430 else if (unformat (i, "%U/%d",
10431 unformat_ip6_address, &v6address, &address_length))
10432 v6_address_set = 1;
10433 else if (unformat (i, "val_life %d", &val_lifetime))
10435 else if (unformat (i, "pref_life %d", &pref_lifetime))
10437 else if (unformat (i, "def"))
10439 else if (unformat (i, "noadv"))
10441 else if (unformat (i, "offl"))
10443 else if (unformat (i, "noauto"))
10445 else if (unformat (i, "nolink"))
10447 else if (unformat (i, "isno"))
10451 clib_warning ("parse error '%U'", format_unformat_error, i);
10456 if (sw_if_index_set == 0)
10458 errmsg ("missing interface name or sw_if_index");
10461 if (!v6_address_set)
10463 errmsg ("no address set");
10467 /* Construct the API message */
10468 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10470 mp->sw_if_index = ntohl (sw_if_index);
10471 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10472 mp->address_length = address_length;
10473 mp->use_default = use_default;
10474 mp->no_advertise = no_advertise;
10475 mp->off_link = off_link;
10476 mp->no_autoconfig = no_autoconfig;
10477 mp->no_onlink = no_onlink;
10479 mp->val_lifetime = ntohl (val_lifetime);
10480 mp->pref_lifetime = ntohl (pref_lifetime);
10485 /* Wait for a reply, return good/bad news */
10491 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10493 unformat_input_t *i = vam->input;
10494 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10496 u8 sw_if_index_set = 0;
10501 u8 send_unicast = 0;
10504 u8 default_router = 0;
10505 u32 max_interval = 0;
10506 u32 min_interval = 0;
10508 u32 initial_count = 0;
10509 u32 initial_interval = 0;
10513 /* Parse args required to build the message */
10514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10516 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10517 sw_if_index_set = 1;
10518 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10519 sw_if_index_set = 1;
10520 else if (unformat (i, "maxint %d", &max_interval))
10522 else if (unformat (i, "minint %d", &min_interval))
10524 else if (unformat (i, "life %d", &lifetime))
10526 else if (unformat (i, "count %d", &initial_count))
10528 else if (unformat (i, "interval %d", &initial_interval))
10530 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10532 else if (unformat (i, "managed"))
10534 else if (unformat (i, "other"))
10536 else if (unformat (i, "ll"))
10538 else if (unformat (i, "send"))
10540 else if (unformat (i, "cease"))
10542 else if (unformat (i, "isno"))
10544 else if (unformat (i, "def"))
10545 default_router = 1;
10548 clib_warning ("parse error '%U'", format_unformat_error, i);
10553 if (sw_if_index_set == 0)
10555 errmsg ("missing interface name or sw_if_index");
10559 /* Construct the API message */
10560 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10562 mp->sw_if_index = ntohl (sw_if_index);
10563 mp->max_interval = ntohl (max_interval);
10564 mp->min_interval = ntohl (min_interval);
10565 mp->lifetime = ntohl (lifetime);
10566 mp->initial_count = ntohl (initial_count);
10567 mp->initial_interval = ntohl (initial_interval);
10568 mp->suppress = suppress;
10569 mp->managed = managed;
10571 mp->ll_option = ll_option;
10572 mp->send_unicast = send_unicast;
10575 mp->default_router = default_router;
10580 /* Wait for a reply, return good/bad news */
10586 api_set_arp_neighbor_limit (vat_main_t * vam)
10588 unformat_input_t *i = vam->input;
10589 vl_api_set_arp_neighbor_limit_t *mp;
10595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10597 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10599 else if (unformat (i, "ipv6"))
10603 clib_warning ("parse error '%U'", format_unformat_error, i);
10608 if (limit_set == 0)
10610 errmsg ("missing limit value");
10614 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10616 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10617 mp->is_ipv6 = is_ipv6;
10625 api_l2_patch_add_del (vat_main_t * vam)
10627 unformat_input_t *i = vam->input;
10628 vl_api_l2_patch_add_del_t *mp;
10629 u32 rx_sw_if_index;
10630 u8 rx_sw_if_index_set = 0;
10631 u32 tx_sw_if_index;
10632 u8 tx_sw_if_index_set = 0;
10636 /* Parse args required to build the message */
10637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10639 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10640 rx_sw_if_index_set = 1;
10641 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10642 tx_sw_if_index_set = 1;
10643 else if (unformat (i, "rx"))
10645 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10647 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10649 rx_sw_if_index_set = 1;
10654 else if (unformat (i, "tx"))
10656 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10658 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10660 tx_sw_if_index_set = 1;
10665 else if (unformat (i, "del"))
10671 if (rx_sw_if_index_set == 0)
10673 errmsg ("missing rx interface name or rx_sw_if_index");
10677 if (tx_sw_if_index_set == 0)
10679 errmsg ("missing tx interface name or tx_sw_if_index");
10683 M (L2_PATCH_ADD_DEL, mp);
10685 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10686 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10687 mp->is_add = is_add;
10695 u8 localsid_addr[16];
10704 api_sr_localsid_add_del (vat_main_t * vam)
10706 unformat_input_t *i = vam->input;
10707 vl_api_sr_localsid_add_del_t *mp;
10710 ip6_address_t localsid;
10714 u32 fib_table = ~(u32) 0;
10715 ip6_address_t next_hop;
10717 bool nexthop_set = 0;
10721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10723 if (unformat (i, "del"))
10725 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10726 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10728 else if (unformat (i, "behavior %u", &behavior));
10729 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10730 else if (unformat (i, "fib-table %u", &fib_table));
10731 else if (unformat (i, "end.psp %u", &behavior));
10736 M (SR_LOCALSID_ADD_DEL, mp);
10738 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10740 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10741 mp->behavior = behavior;
10742 mp->sw_if_index = ntohl (sw_if_index);
10743 mp->fib_table = ntohl (fib_table);
10744 mp->end_psp = end_psp;
10745 mp->is_del = is_del;
10753 api_ioam_enable (vat_main_t * vam)
10755 unformat_input_t *input = vam->input;
10756 vl_api_ioam_enable_t *mp;
10758 int has_trace_option = 0;
10759 int has_pot_option = 0;
10760 int has_seqno_option = 0;
10761 int has_analyse_option = 0;
10764 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10766 if (unformat (input, "trace"))
10767 has_trace_option = 1;
10768 else if (unformat (input, "pot"))
10769 has_pot_option = 1;
10770 else if (unformat (input, "seqno"))
10771 has_seqno_option = 1;
10772 else if (unformat (input, "analyse"))
10773 has_analyse_option = 1;
10777 M (IOAM_ENABLE, mp);
10778 mp->id = htons (id);
10779 mp->seqno = has_seqno_option;
10780 mp->analyse = has_analyse_option;
10781 mp->pot_enable = has_pot_option;
10782 mp->trace_enable = has_trace_option;
10791 api_ioam_disable (vat_main_t * vam)
10793 vl_api_ioam_disable_t *mp;
10796 M (IOAM_DISABLE, mp);
10802 #define foreach_tcp_proto_field \
10806 #define foreach_udp_proto_field \
10810 #define foreach_ip4_proto_field \
10822 u16 src_port, dst_port;
10825 #if VPP_API_TEST_BUILTIN == 0
10827 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10829 u8 **maskp = va_arg (*args, u8 **);
10831 u8 found_something = 0;
10834 #define _(a) u8 a=0;
10835 foreach_tcp_proto_field;
10838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10841 #define _(a) else if (unformat (input, #a)) a=1;
10842 foreach_tcp_proto_field
10848 #define _(a) found_something += a;
10849 foreach_tcp_proto_field;
10852 if (found_something == 0)
10855 vec_validate (mask, sizeof (*tcp) - 1);
10857 tcp = (tcp_header_t *) mask;
10859 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10860 foreach_tcp_proto_field;
10868 unformat_udp_mask (unformat_input_t * input, va_list * args)
10870 u8 **maskp = va_arg (*args, u8 **);
10872 u8 found_something = 0;
10875 #define _(a) u8 a=0;
10876 foreach_udp_proto_field;
10879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10882 #define _(a) else if (unformat (input, #a)) a=1;
10883 foreach_udp_proto_field
10889 #define _(a) found_something += a;
10890 foreach_udp_proto_field;
10893 if (found_something == 0)
10896 vec_validate (mask, sizeof (*udp) - 1);
10898 udp = (udp_header_t *) mask;
10900 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10901 foreach_udp_proto_field;
10909 unformat_l4_mask (unformat_input_t * input, va_list * args)
10911 u8 **maskp = va_arg (*args, u8 **);
10912 u16 src_port = 0, dst_port = 0;
10913 tcpudp_header_t *tcpudp;
10915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10917 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10919 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10921 else if (unformat (input, "src_port"))
10923 else if (unformat (input, "dst_port"))
10929 if (!src_port && !dst_port)
10933 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10935 tcpudp = (tcpudp_header_t *) mask;
10936 tcpudp->src_port = src_port;
10937 tcpudp->dst_port = dst_port;
10945 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10947 u8 **maskp = va_arg (*args, u8 **);
10949 u8 found_something = 0;
10952 #define _(a) u8 a=0;
10953 foreach_ip4_proto_field;
10959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10961 if (unformat (input, "version"))
10963 else if (unformat (input, "hdr_length"))
10965 else if (unformat (input, "src"))
10967 else if (unformat (input, "dst"))
10969 else if (unformat (input, "proto"))
10972 #define _(a) else if (unformat (input, #a)) a=1;
10973 foreach_ip4_proto_field
10979 #define _(a) found_something += a;
10980 foreach_ip4_proto_field;
10983 if (found_something == 0)
10986 vec_validate (mask, sizeof (*ip) - 1);
10988 ip = (ip4_header_t *) mask;
10990 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10991 foreach_ip4_proto_field;
10994 ip->ip_version_and_header_length = 0;
10997 ip->ip_version_and_header_length |= 0xF0;
11000 ip->ip_version_and_header_length |= 0x0F;
11006 #define foreach_ip6_proto_field \
11009 _(payload_length) \
11014 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11016 u8 **maskp = va_arg (*args, u8 **);
11018 u8 found_something = 0;
11020 u32 ip_version_traffic_class_and_flow_label;
11022 #define _(a) u8 a=0;
11023 foreach_ip6_proto_field;
11026 u8 traffic_class = 0;
11029 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11031 if (unformat (input, "version"))
11033 else if (unformat (input, "traffic-class"))
11035 else if (unformat (input, "flow-label"))
11037 else if (unformat (input, "src"))
11039 else if (unformat (input, "dst"))
11041 else if (unformat (input, "proto"))
11044 #define _(a) else if (unformat (input, #a)) a=1;
11045 foreach_ip6_proto_field
11051 #define _(a) found_something += a;
11052 foreach_ip6_proto_field;
11055 if (found_something == 0)
11058 vec_validate (mask, sizeof (*ip) - 1);
11060 ip = (ip6_header_t *) mask;
11062 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11063 foreach_ip6_proto_field;
11066 ip_version_traffic_class_and_flow_label = 0;
11069 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11072 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11075 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11077 ip->ip_version_traffic_class_and_flow_label =
11078 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11085 unformat_l3_mask (unformat_input_t * input, va_list * args)
11087 u8 **maskp = va_arg (*args, u8 **);
11089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11091 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11093 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11102 unformat_l2_mask (unformat_input_t * input, va_list * args)
11104 u8 **maskp = va_arg (*args, u8 **);
11111 u8 ignore_tag1 = 0;
11112 u8 ignore_tag2 = 0;
11119 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11121 if (unformat (input, "src"))
11123 else if (unformat (input, "dst"))
11125 else if (unformat (input, "proto"))
11127 else if (unformat (input, "tag1"))
11129 else if (unformat (input, "tag2"))
11131 else if (unformat (input, "ignore-tag1"))
11133 else if (unformat (input, "ignore-tag2"))
11135 else if (unformat (input, "cos1"))
11137 else if (unformat (input, "cos2"))
11139 else if (unformat (input, "dot1q"))
11141 else if (unformat (input, "dot1ad"))
11146 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11147 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11150 if (tag1 || ignore_tag1 || cos1 || dot1q)
11152 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11155 vec_validate (mask, len - 1);
11158 memset (mask, 0xff, 6);
11161 memset (mask + 6, 0xff, 6);
11163 if (tag2 || dot1ad)
11165 /* inner vlan tag */
11174 mask[21] = mask[20] = 0xff;
11195 mask[16] = mask[17] = 0xff;
11205 mask[12] = mask[13] = 0xff;
11212 unformat_classify_mask (unformat_input_t * input, va_list * args)
11214 u8 **maskp = va_arg (*args, u8 **);
11215 u32 *skipp = va_arg (*args, u32 *);
11216 u32 *matchp = va_arg (*args, u32 *);
11224 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11226 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11228 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11230 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11232 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11246 if (mask || l2 || l3 || l4)
11248 if (l2 || l3 || l4)
11250 /* "With a free Ethernet header in every package" */
11252 vec_validate (l2, 13);
11256 vec_append (mask, l3);
11261 vec_append (mask, l4);
11266 /* Scan forward looking for the first significant mask octet */
11267 for (i = 0; i < vec_len (mask); i++)
11271 /* compute (skip, match) params */
11272 *skipp = i / sizeof (u32x4);
11273 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11275 /* Pad mask to an even multiple of the vector size */
11276 while (vec_len (mask) % sizeof (u32x4))
11277 vec_add1 (mask, 0);
11279 match = vec_len (mask) / sizeof (u32x4);
11281 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11283 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11284 if (*tmp || *(tmp + 1))
11289 clib_warning ("BUG: match 0");
11291 _vec_len (mask) = match * sizeof (u32x4);
11301 #endif /* VPP_API_TEST_BUILTIN */
11303 #define foreach_l2_next \
11305 _(ethernet, ETHERNET_INPUT) \
11306 _(ip4, IP4_INPUT) \
11310 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11312 u32 *miss_next_indexp = va_arg (*args, u32 *);
11313 u32 next_index = 0;
11317 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11321 if (unformat (input, "%d", &tmp))
11330 *miss_next_indexp = next_index;
11334 #define foreach_ip_next \
11337 _(rewrite, REWRITE)
11340 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11342 u32 *miss_next_indexp = va_arg (*args, u32 *);
11343 u32 next_index = 0;
11347 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11351 if (unformat (input, "%d", &tmp))
11360 *miss_next_indexp = next_index;
11364 #define foreach_acl_next \
11368 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11370 u32 *miss_next_indexp = va_arg (*args, u32 *);
11371 u32 next_index = 0;
11375 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11379 if (unformat (input, "permit"))
11384 else if (unformat (input, "%d", &tmp))
11393 *miss_next_indexp = next_index;
11398 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11400 u32 *r = va_arg (*args, u32 *);
11402 if (unformat (input, "conform-color"))
11403 *r = POLICE_CONFORM;
11404 else if (unformat (input, "exceed-color"))
11405 *r = POLICE_EXCEED;
11413 api_classify_add_del_table (vat_main_t * vam)
11415 unformat_input_t *i = vam->input;
11416 vl_api_classify_add_del_table_t *mp;
11423 u32 table_index = ~0;
11424 u32 next_table_index = ~0;
11425 u32 miss_next_index = ~0;
11426 u32 memory_size = 32 << 20;
11428 u32 current_data_flag = 0;
11429 int current_data_offset = 0;
11432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11434 if (unformat (i, "del"))
11436 else if (unformat (i, "del-chain"))
11441 else if (unformat (i, "buckets %d", &nbuckets))
11443 else if (unformat (i, "memory_size %d", &memory_size))
11445 else if (unformat (i, "skip %d", &skip))
11447 else if (unformat (i, "match %d", &match))
11449 else if (unformat (i, "table %d", &table_index))
11451 else if (unformat (i, "mask %U", unformat_classify_mask,
11452 &mask, &skip, &match))
11454 else if (unformat (i, "next-table %d", &next_table_index))
11456 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11459 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11462 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11465 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11467 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11473 if (is_add && mask == 0)
11475 errmsg ("Mask required");
11479 if (is_add && skip == ~0)
11481 errmsg ("skip count required");
11485 if (is_add && match == ~0)
11487 errmsg ("match count required");
11491 if (!is_add && table_index == ~0)
11493 errmsg ("table index required for delete");
11497 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11499 mp->is_add = is_add;
11500 mp->del_chain = del_chain;
11501 mp->table_index = ntohl (table_index);
11502 mp->nbuckets = ntohl (nbuckets);
11503 mp->memory_size = ntohl (memory_size);
11504 mp->skip_n_vectors = ntohl (skip);
11505 mp->match_n_vectors = ntohl (match);
11506 mp->next_table_index = ntohl (next_table_index);
11507 mp->miss_next_index = ntohl (miss_next_index);
11508 mp->current_data_flag = ntohl (current_data_flag);
11509 mp->current_data_offset = ntohl (current_data_offset);
11510 clib_memcpy (mp->mask, mask, vec_len (mask));
11519 #if VPP_API_TEST_BUILTIN == 0
11521 unformat_l4_match (unformat_input_t * input, va_list * args)
11523 u8 **matchp = va_arg (*args, u8 **);
11525 u8 *proto_header = 0;
11531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11533 if (unformat (input, "src_port %d", &src_port))
11535 else if (unformat (input, "dst_port %d", &dst_port))
11541 h.src_port = clib_host_to_net_u16 (src_port);
11542 h.dst_port = clib_host_to_net_u16 (dst_port);
11543 vec_validate (proto_header, sizeof (h) - 1);
11544 memcpy (proto_header, &h, sizeof (h));
11546 *matchp = proto_header;
11552 unformat_ip4_match (unformat_input_t * input, va_list * args)
11554 u8 **matchp = va_arg (*args, u8 **);
11559 int hdr_length = 0;
11560 u32 hdr_length_val;
11561 int src = 0, dst = 0;
11562 ip4_address_t src_val, dst_val;
11569 int fragment_id = 0;
11570 u32 fragment_id_val;
11576 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11578 if (unformat (input, "version %d", &version_val))
11580 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11582 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11584 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11586 else if (unformat (input, "proto %d", &proto_val))
11588 else if (unformat (input, "tos %d", &tos_val))
11590 else if (unformat (input, "length %d", &length_val))
11592 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11594 else if (unformat (input, "ttl %d", &ttl_val))
11596 else if (unformat (input, "checksum %d", &checksum_val))
11602 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11603 + ttl + checksum == 0)
11607 * Aligned because we use the real comparison functions
11609 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11611 ip = (ip4_header_t *) match;
11613 /* These are realistically matched in practice */
11615 ip->src_address.as_u32 = src_val.as_u32;
11618 ip->dst_address.as_u32 = dst_val.as_u32;
11621 ip->protocol = proto_val;
11624 /* These are not, but they're included for completeness */
11626 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11629 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11635 ip->length = clib_host_to_net_u16 (length_val);
11641 ip->checksum = clib_host_to_net_u16 (checksum_val);
11648 unformat_ip6_match (unformat_input_t * input, va_list * args)
11650 u8 **matchp = va_arg (*args, u8 **);
11655 u8 traffic_class = 0;
11656 u32 traffic_class_val = 0;
11659 int src = 0, dst = 0;
11660 ip6_address_t src_val, dst_val;
11663 int payload_length = 0;
11664 u32 payload_length_val;
11667 u32 ip_version_traffic_class_and_flow_label;
11669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11671 if (unformat (input, "version %d", &version_val))
11673 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11675 else if (unformat (input, "flow_label %d", &flow_label_val))
11677 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11679 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11681 else if (unformat (input, "proto %d", &proto_val))
11683 else if (unformat (input, "payload_length %d", &payload_length_val))
11684 payload_length = 1;
11685 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11691 if (version + traffic_class + flow_label + src + dst + proto +
11692 payload_length + hop_limit == 0)
11696 * Aligned because we use the real comparison functions
11698 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11700 ip = (ip6_header_t *) match;
11703 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11706 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11709 ip->protocol = proto_val;
11711 ip_version_traffic_class_and_flow_label = 0;
11714 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11717 ip_version_traffic_class_and_flow_label |=
11718 (traffic_class_val & 0xFF) << 20;
11721 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11723 ip->ip_version_traffic_class_and_flow_label =
11724 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11726 if (payload_length)
11727 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11730 ip->hop_limit = hop_limit_val;
11737 unformat_l3_match (unformat_input_t * input, va_list * args)
11739 u8 **matchp = va_arg (*args, u8 **);
11741 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11743 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11745 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11754 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11756 u8 *tagp = va_arg (*args, u8 *);
11759 if (unformat (input, "%d", &tag))
11761 tagp[0] = (tag >> 8) & 0x0F;
11762 tagp[1] = tag & 0xFF;
11770 unformat_l2_match (unformat_input_t * input, va_list * args)
11772 u8 **matchp = va_arg (*args, u8 **);
11785 u8 ignore_tag1 = 0;
11786 u8 ignore_tag2 = 0;
11792 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11794 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11797 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11799 else if (unformat (input, "proto %U",
11800 unformat_ethernet_type_host_byte_order, &proto_val))
11802 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11804 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11806 else if (unformat (input, "ignore-tag1"))
11808 else if (unformat (input, "ignore-tag2"))
11810 else if (unformat (input, "cos1 %d", &cos1_val))
11812 else if (unformat (input, "cos2 %d", &cos2_val))
11817 if ((src + dst + proto + tag1 + tag2 +
11818 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11821 if (tag1 || ignore_tag1 || cos1)
11823 if (tag2 || ignore_tag2 || cos2)
11826 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11829 clib_memcpy (match, dst_val, 6);
11832 clib_memcpy (match + 6, src_val, 6);
11836 /* inner vlan tag */
11837 match[19] = tag2_val[1];
11838 match[18] = tag2_val[0];
11840 match[18] |= (cos2_val & 0x7) << 5;
11843 match[21] = proto_val & 0xff;
11844 match[20] = proto_val >> 8;
11848 match[15] = tag1_val[1];
11849 match[14] = tag1_val[0];
11852 match[14] |= (cos1_val & 0x7) << 5;
11858 match[15] = tag1_val[1];
11859 match[14] = tag1_val[0];
11862 match[17] = proto_val & 0xff;
11863 match[16] = proto_val >> 8;
11866 match[14] |= (cos1_val & 0x7) << 5;
11872 match[18] |= (cos2_val & 0x7) << 5;
11874 match[14] |= (cos1_val & 0x7) << 5;
11877 match[13] = proto_val & 0xff;
11878 match[12] = proto_val >> 8;
11886 unformat_qos_source (unformat_input_t * input, va_list * args)
11888 int *qs = va_arg (*args, int *);
11890 if (unformat (input, "ip"))
11891 *qs = QOS_SOURCE_IP;
11892 else if (unformat (input, "mpls"))
11893 *qs = QOS_SOURCE_MPLS;
11894 else if (unformat (input, "ext"))
11895 *qs = QOS_SOURCE_EXT;
11896 else if (unformat (input, "vlan"))
11897 *qs = QOS_SOURCE_VLAN;
11906 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11908 u8 **matchp = va_arg (*args, u8 **);
11909 u32 skip_n_vectors = va_arg (*args, u32);
11910 u32 match_n_vectors = va_arg (*args, u32);
11917 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (input, "hex %U", unformat_hex_string, &match))
11921 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11923 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11925 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11939 if (match || l2 || l3 || l4)
11941 if (l2 || l3 || l4)
11943 /* "Win a free Ethernet header in every packet" */
11945 vec_validate_aligned (l2, 13, sizeof (u32x4));
11949 vec_append_aligned (match, l3, sizeof (u32x4));
11954 vec_append_aligned (match, l4, sizeof (u32x4));
11959 /* Make sure the vector is big enough even if key is all 0's */
11960 vec_validate_aligned
11961 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11964 /* Set size, include skipped vectors */
11965 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11976 api_classify_add_del_session (vat_main_t * vam)
11978 unformat_input_t *i = vam->input;
11979 vl_api_classify_add_del_session_t *mp;
11981 u32 table_index = ~0;
11982 u32 hit_next_index = ~0;
11983 u32 opaque_index = ~0;
11986 u32 skip_n_vectors = 0;
11987 u32 match_n_vectors = 0;
11993 * Warning: you have to supply skip_n and match_n
11994 * because the API client cant simply look at the classify
11998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12000 if (unformat (i, "del"))
12002 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12005 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12008 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12011 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12013 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12015 else if (unformat (i, "opaque-index %d", &opaque_index))
12017 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12019 else if (unformat (i, "match_n %d", &match_n_vectors))
12021 else if (unformat (i, "match %U", api_unformat_classify_match,
12022 &match, skip_n_vectors, match_n_vectors))
12024 else if (unformat (i, "advance %d", &advance))
12026 else if (unformat (i, "table-index %d", &table_index))
12028 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12030 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12032 else if (unformat (i, "action %d", &action))
12034 else if (unformat (i, "metadata %d", &metadata))
12040 if (table_index == ~0)
12042 errmsg ("Table index required");
12046 if (is_add && match == 0)
12048 errmsg ("Match value required");
12052 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12054 mp->is_add = is_add;
12055 mp->table_index = ntohl (table_index);
12056 mp->hit_next_index = ntohl (hit_next_index);
12057 mp->opaque_index = ntohl (opaque_index);
12058 mp->advance = ntohl (advance);
12059 mp->action = action;
12060 mp->metadata = ntohl (metadata);
12061 clib_memcpy (mp->match, match, vec_len (match));
12070 api_classify_set_interface_ip_table (vat_main_t * vam)
12072 unformat_input_t *i = vam->input;
12073 vl_api_classify_set_interface_ip_table_t *mp;
12075 int sw_if_index_set;
12076 u32 table_index = ~0;
12080 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12082 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12083 sw_if_index_set = 1;
12084 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12085 sw_if_index_set = 1;
12086 else if (unformat (i, "table %d", &table_index))
12090 clib_warning ("parse error '%U'", format_unformat_error, i);
12095 if (sw_if_index_set == 0)
12097 errmsg ("missing interface name or sw_if_index");
12102 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12104 mp->sw_if_index = ntohl (sw_if_index);
12105 mp->table_index = ntohl (table_index);
12106 mp->is_ipv6 = is_ipv6;
12114 api_classify_set_interface_l2_tables (vat_main_t * vam)
12116 unformat_input_t *i = vam->input;
12117 vl_api_classify_set_interface_l2_tables_t *mp;
12119 int sw_if_index_set;
12120 u32 ip4_table_index = ~0;
12121 u32 ip6_table_index = ~0;
12122 u32 other_table_index = ~0;
12126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12128 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12129 sw_if_index_set = 1;
12130 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12131 sw_if_index_set = 1;
12132 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12134 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12136 else if (unformat (i, "other-table %d", &other_table_index))
12138 else if (unformat (i, "is-input %d", &is_input))
12142 clib_warning ("parse error '%U'", format_unformat_error, i);
12147 if (sw_if_index_set == 0)
12149 errmsg ("missing interface name or sw_if_index");
12154 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12156 mp->sw_if_index = ntohl (sw_if_index);
12157 mp->ip4_table_index = ntohl (ip4_table_index);
12158 mp->ip6_table_index = ntohl (ip6_table_index);
12159 mp->other_table_index = ntohl (other_table_index);
12160 mp->is_input = (u8) is_input;
12168 api_set_ipfix_exporter (vat_main_t * vam)
12170 unformat_input_t *i = vam->input;
12171 vl_api_set_ipfix_exporter_t *mp;
12172 ip4_address_t collector_address;
12173 u8 collector_address_set = 0;
12174 u32 collector_port = ~0;
12175 ip4_address_t src_address;
12176 u8 src_address_set = 0;
12179 u32 template_interval = ~0;
12180 u8 udp_checksum = 0;
12183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12185 if (unformat (i, "collector_address %U", unformat_ip4_address,
12186 &collector_address))
12187 collector_address_set = 1;
12188 else if (unformat (i, "collector_port %d", &collector_port))
12190 else if (unformat (i, "src_address %U", unformat_ip4_address,
12192 src_address_set = 1;
12193 else if (unformat (i, "vrf_id %d", &vrf_id))
12195 else if (unformat (i, "path_mtu %d", &path_mtu))
12197 else if (unformat (i, "template_interval %d", &template_interval))
12199 else if (unformat (i, "udp_checksum"))
12205 if (collector_address_set == 0)
12207 errmsg ("collector_address required");
12211 if (src_address_set == 0)
12213 errmsg ("src_address required");
12217 M (SET_IPFIX_EXPORTER, mp);
12219 memcpy (mp->collector_address, collector_address.data,
12220 sizeof (collector_address.data));
12221 mp->collector_port = htons ((u16) collector_port);
12222 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12223 mp->vrf_id = htonl (vrf_id);
12224 mp->path_mtu = htonl (path_mtu);
12225 mp->template_interval = htonl (template_interval);
12226 mp->udp_checksum = udp_checksum;
12234 api_set_ipfix_classify_stream (vat_main_t * vam)
12236 unformat_input_t *i = vam->input;
12237 vl_api_set_ipfix_classify_stream_t *mp;
12239 u32 src_port = UDP_DST_PORT_ipfix;
12242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12244 if (unformat (i, "domain %d", &domain_id))
12246 else if (unformat (i, "src_port %d", &src_port))
12250 errmsg ("unknown input `%U'", format_unformat_error, i);
12255 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12257 mp->domain_id = htonl (domain_id);
12258 mp->src_port = htons ((u16) src_port);
12266 api_ipfix_classify_table_add_del (vat_main_t * vam)
12268 unformat_input_t *i = vam->input;
12269 vl_api_ipfix_classify_table_add_del_t *mp;
12271 u32 classify_table_index = ~0;
12273 u8 transport_protocol = 255;
12276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12278 if (unformat (i, "add"))
12280 else if (unformat (i, "del"))
12282 else if (unformat (i, "table %d", &classify_table_index))
12284 else if (unformat (i, "ip4"))
12286 else if (unformat (i, "ip6"))
12288 else if (unformat (i, "tcp"))
12289 transport_protocol = 6;
12290 else if (unformat (i, "udp"))
12291 transport_protocol = 17;
12294 errmsg ("unknown input `%U'", format_unformat_error, i);
12301 errmsg ("expecting: add|del");
12304 if (classify_table_index == ~0)
12306 errmsg ("classifier table not specified");
12309 if (ip_version == 0)
12311 errmsg ("IP version not specified");
12315 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12317 mp->is_add = is_add;
12318 mp->table_id = htonl (classify_table_index);
12319 mp->ip_version = ip_version;
12320 mp->transport_protocol = transport_protocol;
12328 api_get_node_index (vat_main_t * vam)
12330 unformat_input_t *i = vam->input;
12331 vl_api_get_node_index_t *mp;
12335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12337 if (unformat (i, "node %s", &name))
12344 errmsg ("node name required");
12347 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12349 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12353 M (GET_NODE_INDEX, mp);
12354 clib_memcpy (mp->node_name, name, vec_len (name));
12363 api_get_next_index (vat_main_t * vam)
12365 unformat_input_t *i = vam->input;
12366 vl_api_get_next_index_t *mp;
12367 u8 *node_name = 0, *next_node_name = 0;
12370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12372 if (unformat (i, "node-name %s", &node_name))
12374 else if (unformat (i, "next-node-name %s", &next_node_name))
12378 if (node_name == 0)
12380 errmsg ("node name required");
12383 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12385 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12389 if (next_node_name == 0)
12391 errmsg ("next node name required");
12394 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12396 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12400 M (GET_NEXT_INDEX, mp);
12401 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12402 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12403 vec_free (node_name);
12404 vec_free (next_node_name);
12412 api_add_node_next (vat_main_t * vam)
12414 unformat_input_t *i = vam->input;
12415 vl_api_add_node_next_t *mp;
12420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12422 if (unformat (i, "node %s", &name))
12424 else if (unformat (i, "next %s", &next))
12431 errmsg ("node name required");
12434 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12436 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12441 errmsg ("next node required");
12444 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12446 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12450 M (ADD_NODE_NEXT, mp);
12451 clib_memcpy (mp->node_name, name, vec_len (name));
12452 clib_memcpy (mp->next_name, next, vec_len (next));
12462 api_l2tpv3_create_tunnel (vat_main_t * vam)
12464 unformat_input_t *i = vam->input;
12465 ip6_address_t client_address, our_address;
12466 int client_address_set = 0;
12467 int our_address_set = 0;
12468 u32 local_session_id = 0;
12469 u32 remote_session_id = 0;
12470 u64 local_cookie = 0;
12471 u64 remote_cookie = 0;
12472 u8 l2_sublayer_present = 0;
12473 vl_api_l2tpv3_create_tunnel_t *mp;
12476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12478 if (unformat (i, "client_address %U", unformat_ip6_address,
12480 client_address_set = 1;
12481 else if (unformat (i, "our_address %U", unformat_ip6_address,
12483 our_address_set = 1;
12484 else if (unformat (i, "local_session_id %d", &local_session_id))
12486 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12488 else if (unformat (i, "local_cookie %lld", &local_cookie))
12490 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12492 else if (unformat (i, "l2-sublayer-present"))
12493 l2_sublayer_present = 1;
12498 if (client_address_set == 0)
12500 errmsg ("client_address required");
12504 if (our_address_set == 0)
12506 errmsg ("our_address required");
12510 M (L2TPV3_CREATE_TUNNEL, mp);
12512 clib_memcpy (mp->client_address, client_address.as_u8,
12513 sizeof (mp->client_address));
12515 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12517 mp->local_session_id = ntohl (local_session_id);
12518 mp->remote_session_id = ntohl (remote_session_id);
12519 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12520 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12521 mp->l2_sublayer_present = l2_sublayer_present;
12530 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12532 unformat_input_t *i = vam->input;
12534 u8 sw_if_index_set = 0;
12535 u64 new_local_cookie = 0;
12536 u64 new_remote_cookie = 0;
12537 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12543 sw_if_index_set = 1;
12544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12545 sw_if_index_set = 1;
12546 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12548 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12554 if (sw_if_index_set == 0)
12556 errmsg ("missing interface name or sw_if_index");
12560 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12562 mp->sw_if_index = ntohl (sw_if_index);
12563 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12564 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12572 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12574 unformat_input_t *i = vam->input;
12575 vl_api_l2tpv3_interface_enable_disable_t *mp;
12577 u8 sw_if_index_set = 0;
12578 u8 enable_disable = 1;
12581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12583 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12584 sw_if_index_set = 1;
12585 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12586 sw_if_index_set = 1;
12587 else if (unformat (i, "enable"))
12588 enable_disable = 1;
12589 else if (unformat (i, "disable"))
12590 enable_disable = 0;
12595 if (sw_if_index_set == 0)
12597 errmsg ("missing interface name or sw_if_index");
12601 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12603 mp->sw_if_index = ntohl (sw_if_index);
12604 mp->enable_disable = enable_disable;
12612 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12614 unformat_input_t *i = vam->input;
12615 vl_api_l2tpv3_set_lookup_key_t *mp;
12619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12621 if (unformat (i, "lookup_v6_src"))
12622 key = L2T_LOOKUP_SRC_ADDRESS;
12623 else if (unformat (i, "lookup_v6_dst"))
12624 key = L2T_LOOKUP_DST_ADDRESS;
12625 else if (unformat (i, "lookup_session_id"))
12626 key = L2T_LOOKUP_SESSION_ID;
12631 if (key == (u8) ~ 0)
12633 errmsg ("l2tp session lookup key unset");
12637 M (L2TPV3_SET_LOOKUP_KEY, mp);
12646 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12647 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12649 vat_main_t *vam = &vat_main;
12651 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12652 format_ip6_address, mp->our_address,
12653 format_ip6_address, mp->client_address,
12654 clib_net_to_host_u32 (mp->sw_if_index));
12657 " local cookies %016llx %016llx remote cookie %016llx",
12658 clib_net_to_host_u64 (mp->local_cookie[0]),
12659 clib_net_to_host_u64 (mp->local_cookie[1]),
12660 clib_net_to_host_u64 (mp->remote_cookie));
12662 print (vam->ofp, " local session-id %d remote session-id %d",
12663 clib_net_to_host_u32 (mp->local_session_id),
12664 clib_net_to_host_u32 (mp->remote_session_id));
12666 print (vam->ofp, " l2 specific sublayer %s\n",
12667 mp->l2_sublayer_present ? "preset" : "absent");
12671 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12672 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12674 vat_main_t *vam = &vat_main;
12675 vat_json_node_t *node = NULL;
12676 struct in6_addr addr;
12678 if (VAT_JSON_ARRAY != vam->json_tree.type)
12680 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12681 vat_json_init_array (&vam->json_tree);
12683 node = vat_json_array_add (&vam->json_tree);
12685 vat_json_init_object (node);
12687 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12688 vat_json_object_add_ip6 (node, "our_address", addr);
12689 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12690 vat_json_object_add_ip6 (node, "client_address", addr);
12692 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12693 vat_json_init_array (lc);
12694 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12695 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12696 vat_json_object_add_uint (node, "remote_cookie",
12697 clib_net_to_host_u64 (mp->remote_cookie));
12699 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12700 vat_json_object_add_uint (node, "local_session_id",
12701 clib_net_to_host_u32 (mp->local_session_id));
12702 vat_json_object_add_uint (node, "remote_session_id",
12703 clib_net_to_host_u32 (mp->remote_session_id));
12704 vat_json_object_add_string_copy (node, "l2_sublayer",
12705 mp->l2_sublayer_present ? (u8 *) "present"
12706 : (u8 *) "absent");
12710 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12712 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12713 vl_api_control_ping_t *mp_ping;
12716 /* Get list of l2tpv3-tunnel interfaces */
12717 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12720 /* Use a control ping for synchronization */
12721 MPING (CONTROL_PING, mp_ping);
12729 static void vl_api_sw_interface_tap_details_t_handler
12730 (vl_api_sw_interface_tap_details_t * mp)
12732 vat_main_t *vam = &vat_main;
12734 print (vam->ofp, "%-16s %d",
12735 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12738 static void vl_api_sw_interface_tap_details_t_handler_json
12739 (vl_api_sw_interface_tap_details_t * mp)
12741 vat_main_t *vam = &vat_main;
12742 vat_json_node_t *node = NULL;
12744 if (VAT_JSON_ARRAY != vam->json_tree.type)
12746 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12747 vat_json_init_array (&vam->json_tree);
12749 node = vat_json_array_add (&vam->json_tree);
12751 vat_json_init_object (node);
12752 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12753 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12757 api_sw_interface_tap_dump (vat_main_t * vam)
12759 vl_api_sw_interface_tap_dump_t *mp;
12760 vl_api_control_ping_t *mp_ping;
12763 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12764 /* Get list of tap interfaces */
12765 M (SW_INTERFACE_TAP_DUMP, mp);
12768 /* Use a control ping for synchronization */
12769 MPING (CONTROL_PING, mp_ping);
12776 static void vl_api_sw_interface_tap_v2_details_t_handler
12777 (vl_api_sw_interface_tap_v2_details_t * mp)
12779 vat_main_t *vam = &vat_main;
12781 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12782 mp->host_ip4_prefix_len);
12783 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12784 mp->host_ip6_prefix_len);
12787 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12788 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12789 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12790 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12791 mp->host_bridge, ip4, ip6);
12797 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12798 (vl_api_sw_interface_tap_v2_details_t * mp)
12800 vat_main_t *vam = &vat_main;
12801 vat_json_node_t *node = NULL;
12803 if (VAT_JSON_ARRAY != vam->json_tree.type)
12805 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12806 vat_json_init_array (&vam->json_tree);
12808 node = vat_json_array_add (&vam->json_tree);
12810 vat_json_init_object (node);
12811 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12812 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12813 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12814 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12815 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12816 vat_json_object_add_string_copy (node, "host_mac_addr",
12817 format (0, "%U", format_ethernet_address,
12818 &mp->host_mac_addr));
12819 vat_json_object_add_string_copy (node, "host_namespace",
12820 mp->host_namespace);
12821 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12822 vat_json_object_add_string_copy (node, "host_ip4_addr",
12823 format (0, "%U/%d", format_ip4_address,
12825 mp->host_ip4_prefix_len));
12826 vat_json_object_add_string_copy (node, "host_ip6_addr",
12827 format (0, "%U/%d", format_ip6_address,
12829 mp->host_ip6_prefix_len));
12834 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12836 vl_api_sw_interface_tap_v2_dump_t *mp;
12837 vl_api_control_ping_t *mp_ping;
12841 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12842 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12843 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12846 /* Get list of tap interfaces */
12847 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12850 /* Use a control ping for synchronization */
12851 MPING (CONTROL_PING, mp_ping);
12858 static uword unformat_vxlan_decap_next
12859 (unformat_input_t * input, va_list * args)
12861 u32 *result = va_arg (*args, u32 *);
12864 if (unformat (input, "l2"))
12865 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12866 else if (unformat (input, "%d", &tmp))
12874 api_vxlan_add_del_tunnel (vat_main_t * vam)
12876 unformat_input_t *line_input = vam->input;
12877 vl_api_vxlan_add_del_tunnel_t *mp;
12878 ip46_address_t src, dst;
12880 u8 ipv4_set = 0, ipv6_set = 0;
12885 u32 mcast_sw_if_index = ~0;
12886 u32 encap_vrf_id = 0;
12887 u32 decap_next_index = ~0;
12891 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12892 memset (&src, 0, sizeof src);
12893 memset (&dst, 0, sizeof dst);
12895 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12897 if (unformat (line_input, "del"))
12899 else if (unformat (line_input, "instance %d", &instance))
12902 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12908 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12914 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12920 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12925 else if (unformat (line_input, "group %U %U",
12926 unformat_ip4_address, &dst.ip4,
12927 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12929 grp_set = dst_set = 1;
12932 else if (unformat (line_input, "group %U",
12933 unformat_ip4_address, &dst.ip4))
12935 grp_set = dst_set = 1;
12938 else if (unformat (line_input, "group %U %U",
12939 unformat_ip6_address, &dst.ip6,
12940 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12942 grp_set = dst_set = 1;
12945 else if (unformat (line_input, "group %U",
12946 unformat_ip6_address, &dst.ip6))
12948 grp_set = dst_set = 1;
12952 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12954 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12956 else if (unformat (line_input, "decap-next %U",
12957 unformat_vxlan_decap_next, &decap_next_index))
12959 else if (unformat (line_input, "vni %d", &vni))
12963 errmsg ("parse error '%U'", format_unformat_error, line_input);
12970 errmsg ("tunnel src address not specified");
12975 errmsg ("tunnel dst address not specified");
12979 if (grp_set && !ip46_address_is_multicast (&dst))
12981 errmsg ("tunnel group address not multicast");
12984 if (grp_set && mcast_sw_if_index == ~0)
12986 errmsg ("tunnel nonexistent multicast device");
12989 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12991 errmsg ("tunnel dst address must be unicast");
12996 if (ipv4_set && ipv6_set)
12998 errmsg ("both IPv4 and IPv6 addresses specified");
13002 if ((vni == 0) || (vni >> 24))
13004 errmsg ("vni not specified or out of range");
13008 M (VXLAN_ADD_DEL_TUNNEL, mp);
13012 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13013 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13017 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13018 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13021 mp->instance = htonl (instance);
13022 mp->encap_vrf_id = ntohl (encap_vrf_id);
13023 mp->decap_next_index = ntohl (decap_next_index);
13024 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13025 mp->vni = ntohl (vni);
13026 mp->is_add = is_add;
13027 mp->is_ipv6 = ipv6_set;
13034 static void vl_api_vxlan_tunnel_details_t_handler
13035 (vl_api_vxlan_tunnel_details_t * mp)
13037 vat_main_t *vam = &vat_main;
13038 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13039 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13041 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13042 ntohl (mp->sw_if_index),
13043 ntohl (mp->instance),
13044 format_ip46_address, &src, IP46_TYPE_ANY,
13045 format_ip46_address, &dst, IP46_TYPE_ANY,
13046 ntohl (mp->encap_vrf_id),
13047 ntohl (mp->decap_next_index), ntohl (mp->vni),
13048 ntohl (mp->mcast_sw_if_index));
13051 static void vl_api_vxlan_tunnel_details_t_handler_json
13052 (vl_api_vxlan_tunnel_details_t * mp)
13054 vat_main_t *vam = &vat_main;
13055 vat_json_node_t *node = NULL;
13057 if (VAT_JSON_ARRAY != vam->json_tree.type)
13059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13060 vat_json_init_array (&vam->json_tree);
13062 node = vat_json_array_add (&vam->json_tree);
13064 vat_json_init_object (node);
13065 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13067 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13071 struct in6_addr ip6;
13073 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13074 vat_json_object_add_ip6 (node, "src_address", ip6);
13075 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13076 vat_json_object_add_ip6 (node, "dst_address", ip6);
13080 struct in_addr ip4;
13082 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13083 vat_json_object_add_ip4 (node, "src_address", ip4);
13084 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13085 vat_json_object_add_ip4 (node, "dst_address", ip4);
13087 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13088 vat_json_object_add_uint (node, "decap_next_index",
13089 ntohl (mp->decap_next_index));
13090 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13091 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13092 vat_json_object_add_uint (node, "mcast_sw_if_index",
13093 ntohl (mp->mcast_sw_if_index));
13097 api_vxlan_tunnel_dump (vat_main_t * vam)
13099 unformat_input_t *i = vam->input;
13100 vl_api_vxlan_tunnel_dump_t *mp;
13101 vl_api_control_ping_t *mp_ping;
13103 u8 sw_if_index_set = 0;
13106 /* Parse args required to build the message */
13107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13109 if (unformat (i, "sw_if_index %d", &sw_if_index))
13110 sw_if_index_set = 1;
13115 if (sw_if_index_set == 0)
13120 if (!vam->json_output)
13122 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13123 "sw_if_index", "instance", "src_address", "dst_address",
13124 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13127 /* Get list of vxlan-tunnel interfaces */
13128 M (VXLAN_TUNNEL_DUMP, mp);
13130 mp->sw_if_index = htonl (sw_if_index);
13134 /* Use a control ping for synchronization */
13135 MPING (CONTROL_PING, mp_ping);
13142 static uword unformat_geneve_decap_next
13143 (unformat_input_t * input, va_list * args)
13145 u32 *result = va_arg (*args, u32 *);
13148 if (unformat (input, "l2"))
13149 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13150 else if (unformat (input, "%d", &tmp))
13158 api_geneve_add_del_tunnel (vat_main_t * vam)
13160 unformat_input_t *line_input = vam->input;
13161 vl_api_geneve_add_del_tunnel_t *mp;
13162 ip46_address_t src, dst;
13164 u8 ipv4_set = 0, ipv6_set = 0;
13168 u32 mcast_sw_if_index = ~0;
13169 u32 encap_vrf_id = 0;
13170 u32 decap_next_index = ~0;
13174 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13175 memset (&src, 0, sizeof src);
13176 memset (&dst, 0, sizeof dst);
13178 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13180 if (unformat (line_input, "del"))
13183 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13189 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13195 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13201 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13206 else if (unformat (line_input, "group %U %U",
13207 unformat_ip4_address, &dst.ip4,
13208 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13210 grp_set = dst_set = 1;
13213 else if (unformat (line_input, "group %U",
13214 unformat_ip4_address, &dst.ip4))
13216 grp_set = dst_set = 1;
13219 else if (unformat (line_input, "group %U %U",
13220 unformat_ip6_address, &dst.ip6,
13221 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13223 grp_set = dst_set = 1;
13226 else if (unformat (line_input, "group %U",
13227 unformat_ip6_address, &dst.ip6))
13229 grp_set = dst_set = 1;
13233 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13235 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13237 else if (unformat (line_input, "decap-next %U",
13238 unformat_geneve_decap_next, &decap_next_index))
13240 else if (unformat (line_input, "vni %d", &vni))
13244 errmsg ("parse error '%U'", format_unformat_error, line_input);
13251 errmsg ("tunnel src address not specified");
13256 errmsg ("tunnel dst address not specified");
13260 if (grp_set && !ip46_address_is_multicast (&dst))
13262 errmsg ("tunnel group address not multicast");
13265 if (grp_set && mcast_sw_if_index == ~0)
13267 errmsg ("tunnel nonexistent multicast device");
13270 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13272 errmsg ("tunnel dst address must be unicast");
13277 if (ipv4_set && ipv6_set)
13279 errmsg ("both IPv4 and IPv6 addresses specified");
13283 if ((vni == 0) || (vni >> 24))
13285 errmsg ("vni not specified or out of range");
13289 M (GENEVE_ADD_DEL_TUNNEL, mp);
13293 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13294 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13298 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13299 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13301 mp->encap_vrf_id = ntohl (encap_vrf_id);
13302 mp->decap_next_index = ntohl (decap_next_index);
13303 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13304 mp->vni = ntohl (vni);
13305 mp->is_add = is_add;
13306 mp->is_ipv6 = ipv6_set;
13313 static void vl_api_geneve_tunnel_details_t_handler
13314 (vl_api_geneve_tunnel_details_t * mp)
13316 vat_main_t *vam = &vat_main;
13317 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13318 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13320 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13321 ntohl (mp->sw_if_index),
13322 format_ip46_address, &src, IP46_TYPE_ANY,
13323 format_ip46_address, &dst, IP46_TYPE_ANY,
13324 ntohl (mp->encap_vrf_id),
13325 ntohl (mp->decap_next_index), ntohl (mp->vni),
13326 ntohl (mp->mcast_sw_if_index));
13329 static void vl_api_geneve_tunnel_details_t_handler_json
13330 (vl_api_geneve_tunnel_details_t * mp)
13332 vat_main_t *vam = &vat_main;
13333 vat_json_node_t *node = NULL;
13335 if (VAT_JSON_ARRAY != vam->json_tree.type)
13337 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13338 vat_json_init_array (&vam->json_tree);
13340 node = vat_json_array_add (&vam->json_tree);
13342 vat_json_init_object (node);
13343 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13346 struct in6_addr ip6;
13348 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13349 vat_json_object_add_ip6 (node, "src_address", ip6);
13350 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13351 vat_json_object_add_ip6 (node, "dst_address", ip6);
13355 struct in_addr ip4;
13357 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13358 vat_json_object_add_ip4 (node, "src_address", ip4);
13359 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13360 vat_json_object_add_ip4 (node, "dst_address", ip4);
13362 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13363 vat_json_object_add_uint (node, "decap_next_index",
13364 ntohl (mp->decap_next_index));
13365 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13366 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13367 vat_json_object_add_uint (node, "mcast_sw_if_index",
13368 ntohl (mp->mcast_sw_if_index));
13372 api_geneve_tunnel_dump (vat_main_t * vam)
13374 unformat_input_t *i = vam->input;
13375 vl_api_geneve_tunnel_dump_t *mp;
13376 vl_api_control_ping_t *mp_ping;
13378 u8 sw_if_index_set = 0;
13381 /* Parse args required to build the message */
13382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13384 if (unformat (i, "sw_if_index %d", &sw_if_index))
13385 sw_if_index_set = 1;
13390 if (sw_if_index_set == 0)
13395 if (!vam->json_output)
13397 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13398 "sw_if_index", "local_address", "remote_address",
13399 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13402 /* Get list of geneve-tunnel interfaces */
13403 M (GENEVE_TUNNEL_DUMP, mp);
13405 mp->sw_if_index = htonl (sw_if_index);
13409 /* Use a control ping for synchronization */
13410 M (CONTROL_PING, mp_ping);
13418 api_gre_add_del_tunnel (vat_main_t * vam)
13420 unformat_input_t *line_input = vam->input;
13421 vl_api_gre_add_del_tunnel_t *mp;
13422 ip4_address_t src4, dst4;
13423 ip6_address_t src6, dst6;
13427 u8 t_type = GRE_TUNNEL_TYPE_L3;
13430 u32 outer_fib_id = 0;
13431 u32 session_id = 0;
13435 memset (&src4, 0, sizeof src4);
13436 memset (&dst4, 0, sizeof dst4);
13437 memset (&src6, 0, sizeof src6);
13438 memset (&dst6, 0, sizeof dst6);
13440 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13442 if (unformat (line_input, "del"))
13444 else if (unformat (line_input, "instance %d", &instance))
13446 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13451 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13456 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13461 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13466 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13468 else if (unformat (line_input, "teb"))
13469 t_type = GRE_TUNNEL_TYPE_TEB;
13470 else if (unformat (line_input, "erspan %d", &session_id))
13471 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13474 errmsg ("parse error '%U'", format_unformat_error, line_input);
13481 errmsg ("tunnel src address not specified");
13486 errmsg ("tunnel dst address not specified");
13489 if (ipv4_set && ipv6_set)
13491 errmsg ("both IPv4 and IPv6 addresses specified");
13496 M (GRE_ADD_DEL_TUNNEL, mp);
13500 clib_memcpy (&mp->src_address, &src4, 4);
13501 clib_memcpy (&mp->dst_address, &dst4, 4);
13505 clib_memcpy (&mp->src_address, &src6, 16);
13506 clib_memcpy (&mp->dst_address, &dst6, 16);
13508 mp->instance = htonl (instance);
13509 mp->outer_fib_id = htonl (outer_fib_id);
13510 mp->is_add = is_add;
13511 mp->session_id = htons ((u16) session_id);
13512 mp->tunnel_type = t_type;
13513 mp->is_ipv6 = ipv6_set;
13520 static void vl_api_gre_tunnel_details_t_handler
13521 (vl_api_gre_tunnel_details_t * mp)
13523 vat_main_t *vam = &vat_main;
13524 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13525 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13527 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13528 ntohl (mp->sw_if_index),
13529 ntohl (mp->instance),
13530 format_ip46_address, &src, IP46_TYPE_ANY,
13531 format_ip46_address, &dst, IP46_TYPE_ANY,
13532 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13535 static void vl_api_gre_tunnel_details_t_handler_json
13536 (vl_api_gre_tunnel_details_t * mp)
13538 vat_main_t *vam = &vat_main;
13539 vat_json_node_t *node = NULL;
13540 struct in_addr ip4;
13541 struct in6_addr ip6;
13543 if (VAT_JSON_ARRAY != vam->json_tree.type)
13545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13546 vat_json_init_array (&vam->json_tree);
13548 node = vat_json_array_add (&vam->json_tree);
13550 vat_json_init_object (node);
13551 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13552 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13555 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13556 vat_json_object_add_ip4 (node, "src_address", ip4);
13557 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13558 vat_json_object_add_ip4 (node, "dst_address", ip4);
13562 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13563 vat_json_object_add_ip6 (node, "src_address", ip6);
13564 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13565 vat_json_object_add_ip6 (node, "dst_address", ip6);
13567 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13568 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13569 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13570 vat_json_object_add_uint (node, "session_id", mp->session_id);
13574 api_gre_tunnel_dump (vat_main_t * vam)
13576 unformat_input_t *i = vam->input;
13577 vl_api_gre_tunnel_dump_t *mp;
13578 vl_api_control_ping_t *mp_ping;
13580 u8 sw_if_index_set = 0;
13583 /* Parse args required to build the message */
13584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13586 if (unformat (i, "sw_if_index %d", &sw_if_index))
13587 sw_if_index_set = 1;
13592 if (sw_if_index_set == 0)
13597 if (!vam->json_output)
13599 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13600 "sw_if_index", "instance", "src_address", "dst_address",
13601 "tunnel_type", "outer_fib_id", "session_id");
13604 /* Get list of gre-tunnel interfaces */
13605 M (GRE_TUNNEL_DUMP, mp);
13607 mp->sw_if_index = htonl (sw_if_index);
13611 /* Use a control ping for synchronization */
13612 MPING (CONTROL_PING, mp_ping);
13620 api_l2_fib_clear_table (vat_main_t * vam)
13622 // unformat_input_t * i = vam->input;
13623 vl_api_l2_fib_clear_table_t *mp;
13626 M (L2_FIB_CLEAR_TABLE, mp);
13634 api_l2_interface_efp_filter (vat_main_t * vam)
13636 unformat_input_t *i = vam->input;
13637 vl_api_l2_interface_efp_filter_t *mp;
13640 u8 sw_if_index_set = 0;
13643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13645 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13646 sw_if_index_set = 1;
13647 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13648 sw_if_index_set = 1;
13649 else if (unformat (i, "enable"))
13651 else if (unformat (i, "disable"))
13655 clib_warning ("parse error '%U'", format_unformat_error, i);
13660 if (sw_if_index_set == 0)
13662 errmsg ("missing sw_if_index");
13666 M (L2_INTERFACE_EFP_FILTER, mp);
13668 mp->sw_if_index = ntohl (sw_if_index);
13669 mp->enable_disable = enable;
13676 #define foreach_vtr_op \
13677 _("disable", L2_VTR_DISABLED) \
13678 _("push-1", L2_VTR_PUSH_1) \
13679 _("push-2", L2_VTR_PUSH_2) \
13680 _("pop-1", L2_VTR_POP_1) \
13681 _("pop-2", L2_VTR_POP_2) \
13682 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13683 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13684 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13685 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13688 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13690 unformat_input_t *i = vam->input;
13691 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13693 u8 sw_if_index_set = 0;
13696 u32 push_dot1q = 1;
13701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13703 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13704 sw_if_index_set = 1;
13705 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13706 sw_if_index_set = 1;
13707 else if (unformat (i, "vtr_op %d", &vtr_op))
13709 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13712 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13714 else if (unformat (i, "tag1 %d", &tag1))
13716 else if (unformat (i, "tag2 %d", &tag2))
13720 clib_warning ("parse error '%U'", format_unformat_error, i);
13725 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13727 errmsg ("missing vtr operation or sw_if_index");
13731 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13732 mp->sw_if_index = ntohl (sw_if_index);
13733 mp->vtr_op = ntohl (vtr_op);
13734 mp->push_dot1q = ntohl (push_dot1q);
13735 mp->tag1 = ntohl (tag1);
13736 mp->tag2 = ntohl (tag2);
13744 api_create_vhost_user_if (vat_main_t * vam)
13746 unformat_input_t *i = vam->input;
13747 vl_api_create_vhost_user_if_t *mp;
13750 u8 file_name_set = 0;
13751 u32 custom_dev_instance = ~0;
13753 u8 use_custom_mac = 0;
13757 /* Shut up coverity */
13758 memset (hwaddr, 0, sizeof (hwaddr));
13760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13762 if (unformat (i, "socket %s", &file_name))
13766 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13768 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13769 use_custom_mac = 1;
13770 else if (unformat (i, "server"))
13772 else if (unformat (i, "tag %s", &tag))
13778 if (file_name_set == 0)
13780 errmsg ("missing socket file name");
13784 if (vec_len (file_name) > 255)
13786 errmsg ("socket file name too long");
13789 vec_add1 (file_name, 0);
13791 M (CREATE_VHOST_USER_IF, mp);
13793 mp->is_server = is_server;
13794 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13795 vec_free (file_name);
13796 if (custom_dev_instance != ~0)
13799 mp->custom_dev_instance = ntohl (custom_dev_instance);
13801 mp->use_custom_mac = use_custom_mac;
13802 clib_memcpy (mp->mac_address, hwaddr, 6);
13804 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13813 api_modify_vhost_user_if (vat_main_t * vam)
13815 unformat_input_t *i = vam->input;
13816 vl_api_modify_vhost_user_if_t *mp;
13819 u8 file_name_set = 0;
13820 u32 custom_dev_instance = ~0;
13821 u8 sw_if_index_set = 0;
13822 u32 sw_if_index = (u32) ~ 0;
13825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13827 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13828 sw_if_index_set = 1;
13829 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13830 sw_if_index_set = 1;
13831 else if (unformat (i, "socket %s", &file_name))
13835 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13837 else if (unformat (i, "server"))
13843 if (sw_if_index_set == 0)
13845 errmsg ("missing sw_if_index or interface name");
13849 if (file_name_set == 0)
13851 errmsg ("missing socket file name");
13855 if (vec_len (file_name) > 255)
13857 errmsg ("socket file name too long");
13860 vec_add1 (file_name, 0);
13862 M (MODIFY_VHOST_USER_IF, mp);
13864 mp->sw_if_index = ntohl (sw_if_index);
13865 mp->is_server = is_server;
13866 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13867 vec_free (file_name);
13868 if (custom_dev_instance != ~0)
13871 mp->custom_dev_instance = ntohl (custom_dev_instance);
13880 api_delete_vhost_user_if (vat_main_t * vam)
13882 unformat_input_t *i = vam->input;
13883 vl_api_delete_vhost_user_if_t *mp;
13884 u32 sw_if_index = ~0;
13885 u8 sw_if_index_set = 0;
13888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13890 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13891 sw_if_index_set = 1;
13892 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13893 sw_if_index_set = 1;
13898 if (sw_if_index_set == 0)
13900 errmsg ("missing sw_if_index or interface name");
13905 M (DELETE_VHOST_USER_IF, mp);
13907 mp->sw_if_index = ntohl (sw_if_index);
13914 static void vl_api_sw_interface_vhost_user_details_t_handler
13915 (vl_api_sw_interface_vhost_user_details_t * mp)
13917 vat_main_t *vam = &vat_main;
13919 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13920 (char *) mp->interface_name,
13921 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13922 clib_net_to_host_u64 (mp->features), mp->is_server,
13923 ntohl (mp->num_regions), (char *) mp->sock_filename);
13924 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13927 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13928 (vl_api_sw_interface_vhost_user_details_t * mp)
13930 vat_main_t *vam = &vat_main;
13931 vat_json_node_t *node = NULL;
13933 if (VAT_JSON_ARRAY != vam->json_tree.type)
13935 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13936 vat_json_init_array (&vam->json_tree);
13938 node = vat_json_array_add (&vam->json_tree);
13940 vat_json_init_object (node);
13941 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13942 vat_json_object_add_string_copy (node, "interface_name",
13943 mp->interface_name);
13944 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13945 ntohl (mp->virtio_net_hdr_sz));
13946 vat_json_object_add_uint (node, "features",
13947 clib_net_to_host_u64 (mp->features));
13948 vat_json_object_add_uint (node, "is_server", mp->is_server);
13949 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13950 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13951 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13955 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13957 vl_api_sw_interface_vhost_user_dump_t *mp;
13958 vl_api_control_ping_t *mp_ping;
13961 "Interface name idx hdr_sz features server regions filename");
13963 /* Get list of vhost-user interfaces */
13964 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13967 /* Use a control ping for synchronization */
13968 MPING (CONTROL_PING, mp_ping);
13976 api_show_version (vat_main_t * vam)
13978 vl_api_show_version_t *mp;
13981 M (SHOW_VERSION, mp);
13990 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13992 unformat_input_t *line_input = vam->input;
13993 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13994 ip4_address_t local4, remote4;
13995 ip6_address_t local6, remote6;
13997 u8 ipv4_set = 0, ipv6_set = 0;
14001 u32 mcast_sw_if_index = ~0;
14002 u32 encap_vrf_id = 0;
14003 u32 decap_vrf_id = 0;
14009 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14010 memset (&local4, 0, sizeof local4);
14011 memset (&remote4, 0, sizeof remote4);
14012 memset (&local6, 0, sizeof local6);
14013 memset (&remote6, 0, sizeof remote6);
14015 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14017 if (unformat (line_input, "del"))
14019 else if (unformat (line_input, "local %U",
14020 unformat_ip4_address, &local4))
14025 else if (unformat (line_input, "remote %U",
14026 unformat_ip4_address, &remote4))
14031 else if (unformat (line_input, "local %U",
14032 unformat_ip6_address, &local6))
14037 else if (unformat (line_input, "remote %U",
14038 unformat_ip6_address, &remote6))
14043 else if (unformat (line_input, "group %U %U",
14044 unformat_ip4_address, &remote4,
14045 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14047 grp_set = remote_set = 1;
14050 else if (unformat (line_input, "group %U",
14051 unformat_ip4_address, &remote4))
14053 grp_set = remote_set = 1;
14056 else if (unformat (line_input, "group %U %U",
14057 unformat_ip6_address, &remote6,
14058 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14060 grp_set = remote_set = 1;
14063 else if (unformat (line_input, "group %U",
14064 unformat_ip6_address, &remote6))
14066 grp_set = remote_set = 1;
14070 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14072 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14074 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14076 else if (unformat (line_input, "vni %d", &vni))
14078 else if (unformat (line_input, "next-ip4"))
14080 else if (unformat (line_input, "next-ip6"))
14082 else if (unformat (line_input, "next-ethernet"))
14084 else if (unformat (line_input, "next-nsh"))
14088 errmsg ("parse error '%U'", format_unformat_error, line_input);
14093 if (local_set == 0)
14095 errmsg ("tunnel local address not specified");
14098 if (remote_set == 0)
14100 errmsg ("tunnel remote address not specified");
14103 if (grp_set && mcast_sw_if_index == ~0)
14105 errmsg ("tunnel nonexistent multicast device");
14108 if (ipv4_set && ipv6_set)
14110 errmsg ("both IPv4 and IPv6 addresses specified");
14116 errmsg ("vni not specified");
14120 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14125 clib_memcpy (&mp->local, &local6, sizeof (local6));
14126 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14130 clib_memcpy (&mp->local, &local4, sizeof (local4));
14131 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14134 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14135 mp->encap_vrf_id = ntohl (encap_vrf_id);
14136 mp->decap_vrf_id = ntohl (decap_vrf_id);
14137 mp->protocol = protocol;
14138 mp->vni = ntohl (vni);
14139 mp->is_add = is_add;
14140 mp->is_ipv6 = ipv6_set;
14147 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14148 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14150 vat_main_t *vam = &vat_main;
14151 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14152 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14154 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14155 ntohl (mp->sw_if_index),
14156 format_ip46_address, &local, IP46_TYPE_ANY,
14157 format_ip46_address, &remote, IP46_TYPE_ANY,
14158 ntohl (mp->vni), mp->protocol,
14159 ntohl (mp->mcast_sw_if_index),
14160 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14164 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14165 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14167 vat_main_t *vam = &vat_main;
14168 vat_json_node_t *node = NULL;
14169 struct in_addr ip4;
14170 struct in6_addr ip6;
14172 if (VAT_JSON_ARRAY != vam->json_tree.type)
14174 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14175 vat_json_init_array (&vam->json_tree);
14177 node = vat_json_array_add (&vam->json_tree);
14179 vat_json_init_object (node);
14180 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14183 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14184 vat_json_object_add_ip6 (node, "local", ip6);
14185 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14186 vat_json_object_add_ip6 (node, "remote", ip6);
14190 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14191 vat_json_object_add_ip4 (node, "local", ip4);
14192 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14193 vat_json_object_add_ip4 (node, "remote", ip4);
14195 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14196 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14197 vat_json_object_add_uint (node, "mcast_sw_if_index",
14198 ntohl (mp->mcast_sw_if_index));
14199 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14200 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14201 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14205 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14207 unformat_input_t *i = vam->input;
14208 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14209 vl_api_control_ping_t *mp_ping;
14211 u8 sw_if_index_set = 0;
14214 /* Parse args required to build the message */
14215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14217 if (unformat (i, "sw_if_index %d", &sw_if_index))
14218 sw_if_index_set = 1;
14223 if (sw_if_index_set == 0)
14228 if (!vam->json_output)
14230 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14231 "sw_if_index", "local", "remote", "vni",
14232 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14235 /* Get list of vxlan-tunnel interfaces */
14236 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14238 mp->sw_if_index = htonl (sw_if_index);
14242 /* Use a control ping for synchronization */
14243 MPING (CONTROL_PING, mp_ping);
14250 static void vl_api_l2_fib_table_details_t_handler
14251 (vl_api_l2_fib_table_details_t * mp)
14253 vat_main_t *vam = &vat_main;
14255 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14257 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14258 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14262 static void vl_api_l2_fib_table_details_t_handler_json
14263 (vl_api_l2_fib_table_details_t * mp)
14265 vat_main_t *vam = &vat_main;
14266 vat_json_node_t *node = NULL;
14268 if (VAT_JSON_ARRAY != vam->json_tree.type)
14270 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14271 vat_json_init_array (&vam->json_tree);
14273 node = vat_json_array_add (&vam->json_tree);
14275 vat_json_init_object (node);
14276 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14277 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14278 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14279 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14280 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14281 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14285 api_l2_fib_table_dump (vat_main_t * vam)
14287 unformat_input_t *i = vam->input;
14288 vl_api_l2_fib_table_dump_t *mp;
14289 vl_api_control_ping_t *mp_ping;
14294 /* Parse args required to build the message */
14295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14297 if (unformat (i, "bd_id %d", &bd_id))
14303 if (bd_id_set == 0)
14305 errmsg ("missing bridge domain");
14309 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14311 /* Get list of l2 fib entries */
14312 M (L2_FIB_TABLE_DUMP, mp);
14314 mp->bd_id = ntohl (bd_id);
14317 /* Use a control ping for synchronization */
14318 MPING (CONTROL_PING, mp_ping);
14327 api_interface_name_renumber (vat_main_t * vam)
14329 unformat_input_t *line_input = vam->input;
14330 vl_api_interface_name_renumber_t *mp;
14331 u32 sw_if_index = ~0;
14332 u32 new_show_dev_instance = ~0;
14335 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14337 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14340 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14342 else if (unformat (line_input, "new_show_dev_instance %d",
14343 &new_show_dev_instance))
14349 if (sw_if_index == ~0)
14351 errmsg ("missing interface name or sw_if_index");
14355 if (new_show_dev_instance == ~0)
14357 errmsg ("missing new_show_dev_instance");
14361 M (INTERFACE_NAME_RENUMBER, mp);
14363 mp->sw_if_index = ntohl (sw_if_index);
14364 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14372 api_ip_probe_neighbor (vat_main_t * vam)
14374 unformat_input_t *i = vam->input;
14375 vl_api_ip_probe_neighbor_t *mp;
14383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14385 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14387 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14389 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14391 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14402 errmsg ("missing interface");
14408 errmsg ("missing addresses");
14412 M (IP_PROBE_NEIGHBOR, mp);
14414 mp->sw_if_index = ntohl (sw_if_index);
14415 mp->is_ipv6 = is_ipv6;
14416 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14424 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14426 unformat_input_t *i = vam->input;
14427 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14428 u8 mode = IP_SCAN_V46_NEIGHBORS;
14429 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14434 if (unformat (i, "ip4"))
14435 mode = IP_SCAN_V4_NEIGHBORS;
14436 else if (unformat (i, "ip6"))
14437 mode = IP_SCAN_V6_NEIGHBORS;
14438 if (unformat (i, "both"))
14439 mode = IP_SCAN_V46_NEIGHBORS;
14440 else if (unformat (i, "disable"))
14441 mode = IP_SCAN_DISABLED;
14442 else if (unformat (i, "interval %d", &interval))
14444 else if (unformat (i, "max-time %d", &time))
14446 else if (unformat (i, "max-update %d", &update))
14448 else if (unformat (i, "delay %d", &delay))
14450 else if (unformat (i, "stale %d", &stale))
14456 if (interval > 255)
14458 errmsg ("interval cannot exceed 255 minutes.");
14463 errmsg ("max-time cannot exceed 255 usec.");
14468 errmsg ("max-update cannot exceed 255.");
14473 errmsg ("delay cannot exceed 255 msec.");
14478 errmsg ("stale cannot exceed 255 minutes.");
14482 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14484 mp->scan_interval = interval;
14485 mp->max_proc_time = time;
14486 mp->max_update = update;
14487 mp->scan_int_delay = delay;
14488 mp->stale_threshold = stale;
14496 api_want_ip4_arp_events (vat_main_t * vam)
14498 unformat_input_t *line_input = vam->input;
14499 vl_api_want_ip4_arp_events_t *mp;
14500 ip4_address_t address;
14501 int address_set = 0;
14502 u32 enable_disable = 1;
14505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14507 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14509 else if (unformat (line_input, "del"))
14510 enable_disable = 0;
14515 if (address_set == 0)
14517 errmsg ("missing addresses");
14521 M (WANT_IP4_ARP_EVENTS, mp);
14522 mp->enable_disable = enable_disable;
14523 mp->pid = htonl (getpid ());
14524 mp->address = address.as_u32;
14532 api_want_ip6_nd_events (vat_main_t * vam)
14534 unformat_input_t *line_input = vam->input;
14535 vl_api_want_ip6_nd_events_t *mp;
14536 ip6_address_t address;
14537 int address_set = 0;
14538 u32 enable_disable = 1;
14541 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14543 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14545 else if (unformat (line_input, "del"))
14546 enable_disable = 0;
14551 if (address_set == 0)
14553 errmsg ("missing addresses");
14557 M (WANT_IP6_ND_EVENTS, mp);
14558 mp->enable_disable = enable_disable;
14559 mp->pid = htonl (getpid ());
14560 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14568 api_want_l2_macs_events (vat_main_t * vam)
14570 unformat_input_t *line_input = vam->input;
14571 vl_api_want_l2_macs_events_t *mp;
14572 u8 enable_disable = 1;
14573 u32 scan_delay = 0;
14574 u32 max_macs_in_event = 0;
14575 u32 learn_limit = 0;
14578 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14580 if (unformat (line_input, "learn-limit %d", &learn_limit))
14582 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14584 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14586 else if (unformat (line_input, "disable"))
14587 enable_disable = 0;
14592 M (WANT_L2_MACS_EVENTS, mp);
14593 mp->enable_disable = enable_disable;
14594 mp->pid = htonl (getpid ());
14595 mp->learn_limit = htonl (learn_limit);
14596 mp->scan_delay = (u8) scan_delay;
14597 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14604 api_input_acl_set_interface (vat_main_t * vam)
14606 unformat_input_t *i = vam->input;
14607 vl_api_input_acl_set_interface_t *mp;
14609 int sw_if_index_set;
14610 u32 ip4_table_index = ~0;
14611 u32 ip6_table_index = ~0;
14612 u32 l2_table_index = ~0;
14616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14619 sw_if_index_set = 1;
14620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14621 sw_if_index_set = 1;
14622 else if (unformat (i, "del"))
14624 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14626 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14628 else if (unformat (i, "l2-table %d", &l2_table_index))
14632 clib_warning ("parse error '%U'", format_unformat_error, i);
14637 if (sw_if_index_set == 0)
14639 errmsg ("missing interface name or sw_if_index");
14643 M (INPUT_ACL_SET_INTERFACE, mp);
14645 mp->sw_if_index = ntohl (sw_if_index);
14646 mp->ip4_table_index = ntohl (ip4_table_index);
14647 mp->ip6_table_index = ntohl (ip6_table_index);
14648 mp->l2_table_index = ntohl (l2_table_index);
14649 mp->is_add = is_add;
14657 api_output_acl_set_interface (vat_main_t * vam)
14659 unformat_input_t *i = vam->input;
14660 vl_api_output_acl_set_interface_t *mp;
14662 int sw_if_index_set;
14663 u32 ip4_table_index = ~0;
14664 u32 ip6_table_index = ~0;
14665 u32 l2_table_index = ~0;
14669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14672 sw_if_index_set = 1;
14673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14674 sw_if_index_set = 1;
14675 else if (unformat (i, "del"))
14677 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14679 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14681 else if (unformat (i, "l2-table %d", &l2_table_index))
14685 clib_warning ("parse error '%U'", format_unformat_error, i);
14690 if (sw_if_index_set == 0)
14692 errmsg ("missing interface name or sw_if_index");
14696 M (OUTPUT_ACL_SET_INTERFACE, mp);
14698 mp->sw_if_index = ntohl (sw_if_index);
14699 mp->ip4_table_index = ntohl (ip4_table_index);
14700 mp->ip6_table_index = ntohl (ip6_table_index);
14701 mp->l2_table_index = ntohl (l2_table_index);
14702 mp->is_add = is_add;
14710 api_ip_address_dump (vat_main_t * vam)
14712 unformat_input_t *i = vam->input;
14713 vl_api_ip_address_dump_t *mp;
14714 vl_api_control_ping_t *mp_ping;
14715 u32 sw_if_index = ~0;
14716 u8 sw_if_index_set = 0;
14721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14723 if (unformat (i, "sw_if_index %d", &sw_if_index))
14724 sw_if_index_set = 1;
14726 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14727 sw_if_index_set = 1;
14728 else if (unformat (i, "ipv4"))
14730 else if (unformat (i, "ipv6"))
14736 if (ipv4_set && ipv6_set)
14738 errmsg ("ipv4 and ipv6 flags cannot be both set");
14742 if ((!ipv4_set) && (!ipv6_set))
14744 errmsg ("no ipv4 nor ipv6 flag set");
14748 if (sw_if_index_set == 0)
14750 errmsg ("missing interface name or sw_if_index");
14754 vam->current_sw_if_index = sw_if_index;
14755 vam->is_ipv6 = ipv6_set;
14757 M (IP_ADDRESS_DUMP, mp);
14758 mp->sw_if_index = ntohl (sw_if_index);
14759 mp->is_ipv6 = ipv6_set;
14762 /* Use a control ping for synchronization */
14763 MPING (CONTROL_PING, mp_ping);
14771 api_ip_dump (vat_main_t * vam)
14773 vl_api_ip_dump_t *mp;
14774 vl_api_control_ping_t *mp_ping;
14775 unformat_input_t *in = vam->input;
14782 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14784 if (unformat (in, "ipv4"))
14786 else if (unformat (in, "ipv6"))
14792 if (ipv4_set && ipv6_set)
14794 errmsg ("ipv4 and ipv6 flags cannot be both set");
14798 if ((!ipv4_set) && (!ipv6_set))
14800 errmsg ("no ipv4 nor ipv6 flag set");
14804 is_ipv6 = ipv6_set;
14805 vam->is_ipv6 = is_ipv6;
14807 /* free old data */
14808 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14810 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14812 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14815 mp->is_ipv6 = ipv6_set;
14818 /* Use a control ping for synchronization */
14819 MPING (CONTROL_PING, mp_ping);
14827 api_ipsec_spd_add_del (vat_main_t * vam)
14829 unformat_input_t *i = vam->input;
14830 vl_api_ipsec_spd_add_del_t *mp;
14835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14837 if (unformat (i, "spd_id %d", &spd_id))
14839 else if (unformat (i, "del"))
14843 clib_warning ("parse error '%U'", format_unformat_error, i);
14849 errmsg ("spd_id must be set");
14853 M (IPSEC_SPD_ADD_DEL, mp);
14855 mp->spd_id = ntohl (spd_id);
14856 mp->is_add = is_add;
14864 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14866 unformat_input_t *i = vam->input;
14867 vl_api_ipsec_interface_add_del_spd_t *mp;
14869 u8 sw_if_index_set = 0;
14870 u32 spd_id = (u32) ~ 0;
14874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14876 if (unformat (i, "del"))
14878 else if (unformat (i, "spd_id %d", &spd_id))
14881 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14882 sw_if_index_set = 1;
14883 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14884 sw_if_index_set = 1;
14887 clib_warning ("parse error '%U'", format_unformat_error, i);
14893 if (spd_id == (u32) ~ 0)
14895 errmsg ("spd_id must be set");
14899 if (sw_if_index_set == 0)
14901 errmsg ("missing interface name or sw_if_index");
14905 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14907 mp->spd_id = ntohl (spd_id);
14908 mp->sw_if_index = ntohl (sw_if_index);
14909 mp->is_add = is_add;
14917 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14919 unformat_input_t *i = vam->input;
14920 vl_api_ipsec_spd_add_del_entry_t *mp;
14921 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14922 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14924 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14925 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14926 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14927 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14930 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14931 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14932 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14933 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14934 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14935 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14937 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14939 if (unformat (i, "del"))
14941 if (unformat (i, "outbound"))
14943 if (unformat (i, "inbound"))
14945 else if (unformat (i, "spd_id %d", &spd_id))
14947 else if (unformat (i, "sa_id %d", &sa_id))
14949 else if (unformat (i, "priority %d", &priority))
14951 else if (unformat (i, "protocol %d", &protocol))
14953 else if (unformat (i, "lport_start %d", &lport_start))
14955 else if (unformat (i, "lport_stop %d", &lport_stop))
14957 else if (unformat (i, "rport_start %d", &rport_start))
14959 else if (unformat (i, "rport_stop %d", &rport_stop))
14963 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14969 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14976 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14982 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14989 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14995 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15002 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15008 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15014 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15016 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15018 clib_warning ("unsupported action: 'resolve'");
15024 clib_warning ("parse error '%U'", format_unformat_error, i);
15030 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15032 mp->spd_id = ntohl (spd_id);
15033 mp->priority = ntohl (priority);
15034 mp->is_outbound = is_outbound;
15036 mp->is_ipv6 = is_ipv6;
15037 if (is_ipv6 || is_ip_any)
15039 clib_memcpy (mp->remote_address_start, &raddr6_start,
15040 sizeof (ip6_address_t));
15041 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15042 sizeof (ip6_address_t));
15043 clib_memcpy (mp->local_address_start, &laddr6_start,
15044 sizeof (ip6_address_t));
15045 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15046 sizeof (ip6_address_t));
15050 clib_memcpy (mp->remote_address_start, &raddr4_start,
15051 sizeof (ip4_address_t));
15052 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15053 sizeof (ip4_address_t));
15054 clib_memcpy (mp->local_address_start, &laddr4_start,
15055 sizeof (ip4_address_t));
15056 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15057 sizeof (ip4_address_t));
15059 mp->protocol = (u8) protocol;
15060 mp->local_port_start = ntohs ((u16) lport_start);
15061 mp->local_port_stop = ntohs ((u16) lport_stop);
15062 mp->remote_port_start = ntohs ((u16) rport_start);
15063 mp->remote_port_stop = ntohs ((u16) rport_stop);
15064 mp->policy = (u8) policy;
15065 mp->sa_id = ntohl (sa_id);
15066 mp->is_add = is_add;
15067 mp->is_ip_any = is_ip_any;
15074 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15076 unformat_input_t *i = vam->input;
15077 vl_api_ipsec_sad_add_del_entry_t *mp;
15078 u32 sad_id = 0, spi = 0;
15079 u8 *ck = 0, *ik = 0;
15082 u8 protocol = IPSEC_PROTOCOL_AH;
15083 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15084 u32 crypto_alg = 0, integ_alg = 0;
15085 ip4_address_t tun_src4;
15086 ip4_address_t tun_dst4;
15087 ip6_address_t tun_src6;
15088 ip6_address_t tun_dst6;
15091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15093 if (unformat (i, "del"))
15095 else if (unformat (i, "sad_id %d", &sad_id))
15097 else if (unformat (i, "spi %d", &spi))
15099 else if (unformat (i, "esp"))
15100 protocol = IPSEC_PROTOCOL_ESP;
15101 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15104 is_tunnel_ipv6 = 0;
15106 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15109 is_tunnel_ipv6 = 0;
15111 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15114 is_tunnel_ipv6 = 1;
15116 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15119 is_tunnel_ipv6 = 1;
15123 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15125 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15126 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15128 clib_warning ("unsupported crypto-alg: '%U'",
15129 format_ipsec_crypto_alg, crypto_alg);
15133 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15137 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15139 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15140 integ_alg >= IPSEC_INTEG_N_ALG)
15142 clib_warning ("unsupported integ-alg: '%U'",
15143 format_ipsec_integ_alg, integ_alg);
15147 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15151 clib_warning ("parse error '%U'", format_unformat_error, i);
15157 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15159 mp->sad_id = ntohl (sad_id);
15160 mp->is_add = is_add;
15161 mp->protocol = protocol;
15162 mp->spi = ntohl (spi);
15163 mp->is_tunnel = is_tunnel;
15164 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15165 mp->crypto_algorithm = crypto_alg;
15166 mp->integrity_algorithm = integ_alg;
15167 mp->crypto_key_length = vec_len (ck);
15168 mp->integrity_key_length = vec_len (ik);
15170 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15171 mp->crypto_key_length = sizeof (mp->crypto_key);
15173 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15174 mp->integrity_key_length = sizeof (mp->integrity_key);
15177 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15179 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15183 if (is_tunnel_ipv6)
15185 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15186 sizeof (ip6_address_t));
15187 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15188 sizeof (ip6_address_t));
15192 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15193 sizeof (ip4_address_t));
15194 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15195 sizeof (ip4_address_t));
15205 api_ipsec_sa_set_key (vat_main_t * vam)
15207 unformat_input_t *i = vam->input;
15208 vl_api_ipsec_sa_set_key_t *mp;
15210 u8 *ck = 0, *ik = 0;
15213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15215 if (unformat (i, "sa_id %d", &sa_id))
15217 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15219 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15223 clib_warning ("parse error '%U'", format_unformat_error, i);
15228 M (IPSEC_SA_SET_KEY, mp);
15230 mp->sa_id = ntohl (sa_id);
15231 mp->crypto_key_length = vec_len (ck);
15232 mp->integrity_key_length = vec_len (ik);
15234 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15235 mp->crypto_key_length = sizeof (mp->crypto_key);
15237 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15238 mp->integrity_key_length = sizeof (mp->integrity_key);
15241 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15243 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15251 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15253 unformat_input_t *i = vam->input;
15254 vl_api_ipsec_tunnel_if_add_del_t *mp;
15255 u32 local_spi = 0, remote_spi = 0;
15256 u32 crypto_alg = 0, integ_alg = 0;
15257 u8 *lck = NULL, *rck = NULL;
15258 u8 *lik = NULL, *rik = NULL;
15259 ip4_address_t local_ip = { {0} };
15260 ip4_address_t remote_ip = { {0} };
15263 u8 anti_replay = 0;
15268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15270 if (unformat (i, "del"))
15272 else if (unformat (i, "esn"))
15274 else if (unformat (i, "anti_replay"))
15276 else if (unformat (i, "local_spi %d", &local_spi))
15278 else if (unformat (i, "remote_spi %d", &remote_spi))
15280 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15282 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15284 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15287 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15289 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15291 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15295 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15297 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15298 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15300 errmsg ("unsupported crypto-alg: '%U'\n",
15301 format_ipsec_crypto_alg, crypto_alg);
15307 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15309 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15310 integ_alg >= IPSEC_INTEG_N_ALG)
15312 errmsg ("unsupported integ-alg: '%U'\n",
15313 format_ipsec_integ_alg, integ_alg);
15317 else if (unformat (i, "instance %u", &instance))
15321 errmsg ("parse error '%U'\n", format_unformat_error, i);
15326 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15328 mp->is_add = is_add;
15330 mp->anti_replay = anti_replay;
15332 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15333 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15335 mp->local_spi = htonl (local_spi);
15336 mp->remote_spi = htonl (remote_spi);
15337 mp->crypto_alg = (u8) crypto_alg;
15339 mp->local_crypto_key_len = 0;
15342 mp->local_crypto_key_len = vec_len (lck);
15343 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15344 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15345 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15348 mp->remote_crypto_key_len = 0;
15351 mp->remote_crypto_key_len = vec_len (rck);
15352 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15353 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15354 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15357 mp->integ_alg = (u8) integ_alg;
15359 mp->local_integ_key_len = 0;
15362 mp->local_integ_key_len = vec_len (lik);
15363 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15364 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15365 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15368 mp->remote_integ_key_len = 0;
15371 mp->remote_integ_key_len = vec_len (rik);
15372 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15373 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15374 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15379 mp->renumber = renumber;
15380 mp->show_instance = ntohl (instance);
15389 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15391 vat_main_t *vam = &vat_main;
15393 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15394 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15395 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15396 "tunnel_src_addr %U tunnel_dst_addr %U "
15397 "salt %u seq_outbound %lu last_seq_inbound %lu "
15398 "replay_window %lu total_data_size %lu\n",
15399 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15401 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15402 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15403 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15404 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15405 mp->tunnel_src_addr,
15406 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15407 mp->tunnel_dst_addr,
15409 clib_net_to_host_u64 (mp->seq_outbound),
15410 clib_net_to_host_u64 (mp->last_seq_inbound),
15411 clib_net_to_host_u64 (mp->replay_window),
15412 clib_net_to_host_u64 (mp->total_data_size));
15415 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15416 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15418 static void vl_api_ipsec_sa_details_t_handler_json
15419 (vl_api_ipsec_sa_details_t * mp)
15421 vat_main_t *vam = &vat_main;
15422 vat_json_node_t *node = NULL;
15423 struct in_addr src_ip4, dst_ip4;
15424 struct in6_addr src_ip6, dst_ip6;
15426 if (VAT_JSON_ARRAY != vam->json_tree.type)
15428 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15429 vat_json_init_array (&vam->json_tree);
15431 node = vat_json_array_add (&vam->json_tree);
15433 vat_json_init_object (node);
15434 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15435 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15436 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15437 vat_json_object_add_uint (node, "proto", mp->protocol);
15438 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15439 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15440 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15441 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15442 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15443 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15444 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15445 mp->crypto_key_len);
15446 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15447 mp->integ_key_len);
15448 if (mp->is_tunnel_ip6)
15450 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15451 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15452 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15453 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15457 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15458 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15459 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15460 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15462 vat_json_object_add_uint (node, "replay_window",
15463 clib_net_to_host_u64 (mp->replay_window));
15464 vat_json_object_add_uint (node, "total_data_size",
15465 clib_net_to_host_u64 (mp->total_data_size));
15470 api_ipsec_sa_dump (vat_main_t * vam)
15472 unformat_input_t *i = vam->input;
15473 vl_api_ipsec_sa_dump_t *mp;
15474 vl_api_control_ping_t *mp_ping;
15478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15480 if (unformat (i, "sa_id %d", &sa_id))
15484 clib_warning ("parse error '%U'", format_unformat_error, i);
15489 M (IPSEC_SA_DUMP, mp);
15491 mp->sa_id = ntohl (sa_id);
15495 /* Use a control ping for synchronization */
15496 M (CONTROL_PING, mp_ping);
15504 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15506 unformat_input_t *i = vam->input;
15507 vl_api_ipsec_tunnel_if_set_key_t *mp;
15508 u32 sw_if_index = ~0;
15509 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15516 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15519 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15520 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15522 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15523 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15524 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15525 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15527 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15528 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15529 else if (unformat (i, "%U", unformat_hex_string, &key))
15533 clib_warning ("parse error '%U'", format_unformat_error, i);
15538 if (sw_if_index == ~0)
15540 errmsg ("interface must be specified");
15544 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15546 errmsg ("key type must be specified");
15552 errmsg ("algorithm must be specified");
15556 if (vec_len (key) == 0)
15558 errmsg ("key must be specified");
15562 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15564 mp->sw_if_index = htonl (sw_if_index);
15566 mp->key_type = key_type;
15567 mp->key_len = vec_len (key);
15568 clib_memcpy (mp->key, key, vec_len (key));
15577 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15579 unformat_input_t *i = vam->input;
15580 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15581 u32 sw_if_index = ~0;
15583 u8 is_outbound = (u8) ~ 0;
15586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15588 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15590 else if (unformat (i, "sa_id %d", &sa_id))
15592 else if (unformat (i, "outbound"))
15594 else if (unformat (i, "inbound"))
15598 clib_warning ("parse error '%U'", format_unformat_error, i);
15603 if (sw_if_index == ~0)
15605 errmsg ("interface must be specified");
15611 errmsg ("SA ID must be specified");
15615 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15617 mp->sw_if_index = htonl (sw_if_index);
15618 mp->sa_id = htonl (sa_id);
15619 mp->is_outbound = is_outbound;
15628 api_ikev2_profile_add_del (vat_main_t * vam)
15630 unformat_input_t *i = vam->input;
15631 vl_api_ikev2_profile_add_del_t *mp;
15636 const char *valid_chars = "a-zA-Z0-9_";
15638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15640 if (unformat (i, "del"))
15642 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15643 vec_add1 (name, 0);
15646 errmsg ("parse error '%U'", format_unformat_error, i);
15651 if (!vec_len (name))
15653 errmsg ("profile name must be specified");
15657 if (vec_len (name) > 64)
15659 errmsg ("profile name too long");
15663 M (IKEV2_PROFILE_ADD_DEL, mp);
15665 clib_memcpy (mp->name, name, vec_len (name));
15666 mp->is_add = is_add;
15675 api_ikev2_profile_set_auth (vat_main_t * vam)
15677 unformat_input_t *i = vam->input;
15678 vl_api_ikev2_profile_set_auth_t *mp;
15681 u32 auth_method = 0;
15685 const char *valid_chars = "a-zA-Z0-9_";
15687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15689 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15690 vec_add1 (name, 0);
15691 else if (unformat (i, "auth_method %U",
15692 unformat_ikev2_auth_method, &auth_method))
15694 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15696 else if (unformat (i, "auth_data %v", &data))
15700 errmsg ("parse error '%U'", format_unformat_error, i);
15705 if (!vec_len (name))
15707 errmsg ("profile name must be specified");
15711 if (vec_len (name) > 64)
15713 errmsg ("profile name too long");
15717 if (!vec_len (data))
15719 errmsg ("auth_data must be specified");
15725 errmsg ("auth_method must be specified");
15729 M (IKEV2_PROFILE_SET_AUTH, mp);
15731 mp->is_hex = is_hex;
15732 mp->auth_method = (u8) auth_method;
15733 mp->data_len = vec_len (data);
15734 clib_memcpy (mp->name, name, vec_len (name));
15735 clib_memcpy (mp->data, data, vec_len (data));
15745 api_ikev2_profile_set_id (vat_main_t * vam)
15747 unformat_input_t *i = vam->input;
15748 vl_api_ikev2_profile_set_id_t *mp;
15756 const char *valid_chars = "a-zA-Z0-9_";
15758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15760 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15761 vec_add1 (name, 0);
15762 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15764 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15766 data = vec_new (u8, 4);
15767 clib_memcpy (data, ip4.as_u8, 4);
15769 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15771 else if (unformat (i, "id_data %v", &data))
15773 else if (unformat (i, "local"))
15775 else if (unformat (i, "remote"))
15779 errmsg ("parse error '%U'", format_unformat_error, i);
15784 if (!vec_len (name))
15786 errmsg ("profile name must be specified");
15790 if (vec_len (name) > 64)
15792 errmsg ("profile name too long");
15796 if (!vec_len (data))
15798 errmsg ("id_data must be specified");
15804 errmsg ("id_type must be specified");
15808 M (IKEV2_PROFILE_SET_ID, mp);
15810 mp->is_local = is_local;
15811 mp->id_type = (u8) id_type;
15812 mp->data_len = vec_len (data);
15813 clib_memcpy (mp->name, name, vec_len (name));
15814 clib_memcpy (mp->data, data, vec_len (data));
15824 api_ikev2_profile_set_ts (vat_main_t * vam)
15826 unformat_input_t *i = vam->input;
15827 vl_api_ikev2_profile_set_ts_t *mp;
15830 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15831 ip4_address_t start_addr, end_addr;
15833 const char *valid_chars = "a-zA-Z0-9_";
15836 start_addr.as_u32 = 0;
15837 end_addr.as_u32 = (u32) ~ 0;
15839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15841 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15842 vec_add1 (name, 0);
15843 else if (unformat (i, "protocol %d", &proto))
15845 else if (unformat (i, "start_port %d", &start_port))
15847 else if (unformat (i, "end_port %d", &end_port))
15850 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15852 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15854 else if (unformat (i, "local"))
15856 else if (unformat (i, "remote"))
15860 errmsg ("parse error '%U'", format_unformat_error, i);
15865 if (!vec_len (name))
15867 errmsg ("profile name must be specified");
15871 if (vec_len (name) > 64)
15873 errmsg ("profile name too long");
15877 M (IKEV2_PROFILE_SET_TS, mp);
15879 mp->is_local = is_local;
15880 mp->proto = (u8) proto;
15881 mp->start_port = (u16) start_port;
15882 mp->end_port = (u16) end_port;
15883 mp->start_addr = start_addr.as_u32;
15884 mp->end_addr = end_addr.as_u32;
15885 clib_memcpy (mp->name, name, vec_len (name));
15894 api_ikev2_set_local_key (vat_main_t * vam)
15896 unformat_input_t *i = vam->input;
15897 vl_api_ikev2_set_local_key_t *mp;
15901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15903 if (unformat (i, "file %v", &file))
15904 vec_add1 (file, 0);
15907 errmsg ("parse error '%U'", format_unformat_error, i);
15912 if (!vec_len (file))
15914 errmsg ("RSA key file must be specified");
15918 if (vec_len (file) > 256)
15920 errmsg ("file name too long");
15924 M (IKEV2_SET_LOCAL_KEY, mp);
15926 clib_memcpy (mp->key_file, file, vec_len (file));
15935 api_ikev2_set_responder (vat_main_t * vam)
15937 unformat_input_t *i = vam->input;
15938 vl_api_ikev2_set_responder_t *mp;
15941 u32 sw_if_index = ~0;
15942 ip4_address_t address;
15944 const char *valid_chars = "a-zA-Z0-9_";
15946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15949 (i, "%U interface %d address %U", unformat_token, valid_chars,
15950 &name, &sw_if_index, unformat_ip4_address, &address))
15951 vec_add1 (name, 0);
15954 errmsg ("parse error '%U'", format_unformat_error, i);
15959 if (!vec_len (name))
15961 errmsg ("profile name must be specified");
15965 if (vec_len (name) > 64)
15967 errmsg ("profile name too long");
15971 M (IKEV2_SET_RESPONDER, mp);
15973 clib_memcpy (mp->name, name, vec_len (name));
15976 mp->sw_if_index = sw_if_index;
15977 clib_memcpy (mp->address, &address, sizeof (address));
15985 api_ikev2_set_ike_transforms (vat_main_t * vam)
15987 unformat_input_t *i = vam->input;
15988 vl_api_ikev2_set_ike_transforms_t *mp;
15991 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15993 const char *valid_chars = "a-zA-Z0-9_";
15995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15997 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15998 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15999 vec_add1 (name, 0);
16002 errmsg ("parse error '%U'", format_unformat_error, i);
16007 if (!vec_len (name))
16009 errmsg ("profile name must be specified");
16013 if (vec_len (name) > 64)
16015 errmsg ("profile name too long");
16019 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16021 clib_memcpy (mp->name, name, vec_len (name));
16023 mp->crypto_alg = crypto_alg;
16024 mp->crypto_key_size = crypto_key_size;
16025 mp->integ_alg = integ_alg;
16026 mp->dh_group = dh_group;
16035 api_ikev2_set_esp_transforms (vat_main_t * vam)
16037 unformat_input_t *i = vam->input;
16038 vl_api_ikev2_set_esp_transforms_t *mp;
16041 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16043 const char *valid_chars = "a-zA-Z0-9_";
16045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16047 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16048 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16049 vec_add1 (name, 0);
16052 errmsg ("parse error '%U'", format_unformat_error, i);
16057 if (!vec_len (name))
16059 errmsg ("profile name must be specified");
16063 if (vec_len (name) > 64)
16065 errmsg ("profile name too long");
16069 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16071 clib_memcpy (mp->name, name, vec_len (name));
16073 mp->crypto_alg = crypto_alg;
16074 mp->crypto_key_size = crypto_key_size;
16075 mp->integ_alg = integ_alg;
16076 mp->dh_group = dh_group;
16084 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16086 unformat_input_t *i = vam->input;
16087 vl_api_ikev2_set_sa_lifetime_t *mp;
16090 u64 lifetime, lifetime_maxdata;
16091 u32 lifetime_jitter, handover;
16093 const char *valid_chars = "a-zA-Z0-9_";
16095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16097 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16098 &lifetime, &lifetime_jitter, &handover,
16099 &lifetime_maxdata))
16100 vec_add1 (name, 0);
16103 errmsg ("parse error '%U'", format_unformat_error, i);
16108 if (!vec_len (name))
16110 errmsg ("profile name must be specified");
16114 if (vec_len (name) > 64)
16116 errmsg ("profile name too long");
16120 M (IKEV2_SET_SA_LIFETIME, mp);
16122 clib_memcpy (mp->name, name, vec_len (name));
16124 mp->lifetime = lifetime;
16125 mp->lifetime_jitter = lifetime_jitter;
16126 mp->handover = handover;
16127 mp->lifetime_maxdata = lifetime_maxdata;
16135 api_ikev2_initiate_sa_init (vat_main_t * vam)
16137 unformat_input_t *i = vam->input;
16138 vl_api_ikev2_initiate_sa_init_t *mp;
16142 const char *valid_chars = "a-zA-Z0-9_";
16144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16147 vec_add1 (name, 0);
16150 errmsg ("parse error '%U'", format_unformat_error, i);
16155 if (!vec_len (name))
16157 errmsg ("profile name must be specified");
16161 if (vec_len (name) > 64)
16163 errmsg ("profile name too long");
16167 M (IKEV2_INITIATE_SA_INIT, mp);
16169 clib_memcpy (mp->name, name, vec_len (name));
16178 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16180 unformat_input_t *i = vam->input;
16181 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16188 if (unformat (i, "%lx", &ispi))
16192 errmsg ("parse error '%U'", format_unformat_error, i);
16197 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16207 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16209 unformat_input_t *i = vam->input;
16210 vl_api_ikev2_initiate_del_child_sa_t *mp;
16215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16217 if (unformat (i, "%x", &ispi))
16221 errmsg ("parse error '%U'", format_unformat_error, i);
16226 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16236 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16238 unformat_input_t *i = vam->input;
16239 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16246 if (unformat (i, "%x", &ispi))
16250 errmsg ("parse error '%U'", format_unformat_error, i);
16255 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16268 api_map_add_domain (vat_main_t * vam)
16270 unformat_input_t *i = vam->input;
16271 vl_api_map_add_domain_t *mp;
16273 ip4_address_t ip4_prefix;
16274 ip6_address_t ip6_prefix;
16275 ip6_address_t ip6_src;
16276 u32 num_m_args = 0;
16277 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16278 0, psid_length = 0;
16279 u8 is_translation = 0;
16281 u32 ip6_src_len = 128;
16284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16286 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16287 &ip4_prefix, &ip4_prefix_len))
16289 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16290 &ip6_prefix, &ip6_prefix_len))
16294 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16297 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16299 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16301 else if (unformat (i, "psid-offset %d", &psid_offset))
16303 else if (unformat (i, "psid-len %d", &psid_length))
16305 else if (unformat (i, "mtu %d", &mtu))
16307 else if (unformat (i, "map-t"))
16308 is_translation = 1;
16311 clib_warning ("parse error '%U'", format_unformat_error, i);
16316 if (num_m_args < 3)
16318 errmsg ("mandatory argument(s) missing");
16322 /* Construct the API message */
16323 M (MAP_ADD_DOMAIN, mp);
16325 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16326 mp->ip4_prefix_len = ip4_prefix_len;
16328 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16329 mp->ip6_prefix_len = ip6_prefix_len;
16331 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16332 mp->ip6_src_prefix_len = ip6_src_len;
16334 mp->ea_bits_len = ea_bits_len;
16335 mp->psid_offset = psid_offset;
16336 mp->psid_length = psid_length;
16337 mp->is_translation = is_translation;
16338 mp->mtu = htons (mtu);
16343 /* Wait for a reply, return good/bad news */
16349 api_map_del_domain (vat_main_t * vam)
16351 unformat_input_t *i = vam->input;
16352 vl_api_map_del_domain_t *mp;
16354 u32 num_m_args = 0;
16358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16360 if (unformat (i, "index %d", &index))
16364 clib_warning ("parse error '%U'", format_unformat_error, i);
16369 if (num_m_args != 1)
16371 errmsg ("mandatory argument(s) missing");
16375 /* Construct the API message */
16376 M (MAP_DEL_DOMAIN, mp);
16378 mp->index = ntohl (index);
16383 /* Wait for a reply, return good/bad news */
16389 api_map_add_del_rule (vat_main_t * vam)
16391 unformat_input_t *i = vam->input;
16392 vl_api_map_add_del_rule_t *mp;
16394 ip6_address_t ip6_dst;
16395 u32 num_m_args = 0, index, psid = 0;
16398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16400 if (unformat (i, "index %d", &index))
16402 else if (unformat (i, "psid %d", &psid))
16404 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16406 else if (unformat (i, "del"))
16412 clib_warning ("parse error '%U'", format_unformat_error, i);
16417 /* Construct the API message */
16418 M (MAP_ADD_DEL_RULE, mp);
16420 mp->index = ntohl (index);
16421 mp->is_add = is_add;
16422 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16423 mp->psid = ntohs (psid);
16428 /* Wait for a reply, return good/bad news */
16434 api_map_domain_dump (vat_main_t * vam)
16436 vl_api_map_domain_dump_t *mp;
16437 vl_api_control_ping_t *mp_ping;
16440 /* Construct the API message */
16441 M (MAP_DOMAIN_DUMP, mp);
16446 /* Use a control ping for synchronization */
16447 MPING (CONTROL_PING, mp_ping);
16455 api_map_rule_dump (vat_main_t * vam)
16457 unformat_input_t *i = vam->input;
16458 vl_api_map_rule_dump_t *mp;
16459 vl_api_control_ping_t *mp_ping;
16460 u32 domain_index = ~0;
16463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16465 if (unformat (i, "index %u", &domain_index))
16471 if (domain_index == ~0)
16473 clib_warning ("parse error: domain index expected");
16477 /* Construct the API message */
16478 M (MAP_RULE_DUMP, mp);
16480 mp->domain_index = htonl (domain_index);
16485 /* Use a control ping for synchronization */
16486 MPING (CONTROL_PING, mp_ping);
16493 static void vl_api_map_add_domain_reply_t_handler
16494 (vl_api_map_add_domain_reply_t * mp)
16496 vat_main_t *vam = &vat_main;
16497 i32 retval = ntohl (mp->retval);
16499 if (vam->async_mode)
16501 vam->async_errors += (retval < 0);
16505 vam->retval = retval;
16506 vam->result_ready = 1;
16510 static void vl_api_map_add_domain_reply_t_handler_json
16511 (vl_api_map_add_domain_reply_t * mp)
16513 vat_main_t *vam = &vat_main;
16514 vat_json_node_t node;
16516 vat_json_init_object (&node);
16517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16518 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16520 vat_json_print (vam->ofp, &node);
16521 vat_json_free (&node);
16523 vam->retval = ntohl (mp->retval);
16524 vam->result_ready = 1;
16528 api_get_first_msg_id (vat_main_t * vam)
16530 vl_api_get_first_msg_id_t *mp;
16531 unformat_input_t *i = vam->input;
16536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16538 if (unformat (i, "client %s", &name))
16546 errmsg ("missing client name");
16549 vec_add1 (name, 0);
16551 if (vec_len (name) > 63)
16553 errmsg ("client name too long");
16557 M (GET_FIRST_MSG_ID, mp);
16558 clib_memcpy (mp->name, name, vec_len (name));
16565 api_cop_interface_enable_disable (vat_main_t * vam)
16567 unformat_input_t *line_input = vam->input;
16568 vl_api_cop_interface_enable_disable_t *mp;
16569 u32 sw_if_index = ~0;
16570 u8 enable_disable = 1;
16573 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16575 if (unformat (line_input, "disable"))
16576 enable_disable = 0;
16577 if (unformat (line_input, "enable"))
16578 enable_disable = 1;
16579 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16580 vam, &sw_if_index))
16582 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16588 if (sw_if_index == ~0)
16590 errmsg ("missing interface name or sw_if_index");
16594 /* Construct the API message */
16595 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16596 mp->sw_if_index = ntohl (sw_if_index);
16597 mp->enable_disable = enable_disable;
16601 /* Wait for the reply */
16607 api_cop_whitelist_enable_disable (vat_main_t * vam)
16609 unformat_input_t *line_input = vam->input;
16610 vl_api_cop_whitelist_enable_disable_t *mp;
16611 u32 sw_if_index = ~0;
16612 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16618 if (unformat (line_input, "ip4"))
16620 else if (unformat (line_input, "ip6"))
16622 else if (unformat (line_input, "default"))
16624 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16625 vam, &sw_if_index))
16627 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16629 else if (unformat (line_input, "fib-id %d", &fib_id))
16635 if (sw_if_index == ~0)
16637 errmsg ("missing interface name or sw_if_index");
16641 /* Construct the API message */
16642 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16643 mp->sw_if_index = ntohl (sw_if_index);
16644 mp->fib_id = ntohl (fib_id);
16647 mp->default_cop = default_cop;
16651 /* Wait for the reply */
16657 api_get_node_graph (vat_main_t * vam)
16659 vl_api_get_node_graph_t *mp;
16662 M (GET_NODE_GRAPH, mp);
16666 /* Wait for the reply */
16672 /** Used for parsing LISP eids */
16673 typedef CLIB_PACKED(struct{
16674 u8 addr[16]; /**< eid address */
16675 u32 len; /**< prefix length if IP */
16676 u8 type; /**< type of eid */
16681 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16683 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16685 memset (a, 0, sizeof (a[0]));
16687 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16689 a->type = 0; /* ipv4 type */
16691 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16693 a->type = 1; /* ipv6 type */
16695 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16697 a->type = 2; /* mac type */
16699 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16701 a->type = 3; /* NSH type */
16702 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16703 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16710 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16719 lisp_eid_size_vat (u8 type)
16736 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16738 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16742 api_one_add_del_locator_set (vat_main_t * vam)
16744 unformat_input_t *input = vam->input;
16745 vl_api_one_add_del_locator_set_t *mp;
16747 u8 *locator_set_name = NULL;
16748 u8 locator_set_name_set = 0;
16749 vl_api_local_locator_t locator, *locators = 0;
16750 u32 sw_if_index, priority, weight;
16754 /* Parse args required to build the message */
16755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16757 if (unformat (input, "del"))
16761 else if (unformat (input, "locator-set %s", &locator_set_name))
16763 locator_set_name_set = 1;
16765 else if (unformat (input, "sw_if_index %u p %u w %u",
16766 &sw_if_index, &priority, &weight))
16768 locator.sw_if_index = htonl (sw_if_index);
16769 locator.priority = priority;
16770 locator.weight = weight;
16771 vec_add1 (locators, locator);
16775 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16776 &sw_if_index, &priority, &weight))
16778 locator.sw_if_index = htonl (sw_if_index);
16779 locator.priority = priority;
16780 locator.weight = weight;
16781 vec_add1 (locators, locator);
16787 if (locator_set_name_set == 0)
16789 errmsg ("missing locator-set name");
16790 vec_free (locators);
16794 if (vec_len (locator_set_name) > 64)
16796 errmsg ("locator-set name too long");
16797 vec_free (locator_set_name);
16798 vec_free (locators);
16801 vec_add1 (locator_set_name, 0);
16803 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16805 /* Construct the API message */
16806 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16808 mp->is_add = is_add;
16809 clib_memcpy (mp->locator_set_name, locator_set_name,
16810 vec_len (locator_set_name));
16811 vec_free (locator_set_name);
16813 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16815 clib_memcpy (mp->locators, locators, data_len);
16816 vec_free (locators);
16821 /* Wait for a reply... */
16826 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16829 api_one_add_del_locator (vat_main_t * vam)
16831 unformat_input_t *input = vam->input;
16832 vl_api_one_add_del_locator_t *mp;
16833 u32 tmp_if_index = ~0;
16834 u32 sw_if_index = ~0;
16835 u8 sw_if_index_set = 0;
16836 u8 sw_if_index_if_name_set = 0;
16838 u8 priority_set = 0;
16842 u8 *locator_set_name = NULL;
16843 u8 locator_set_name_set = 0;
16846 /* Parse args required to build the message */
16847 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16849 if (unformat (input, "del"))
16853 else if (unformat (input, "locator-set %s", &locator_set_name))
16855 locator_set_name_set = 1;
16857 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16860 sw_if_index_if_name_set = 1;
16861 sw_if_index = tmp_if_index;
16863 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16865 sw_if_index_set = 1;
16866 sw_if_index = tmp_if_index;
16868 else if (unformat (input, "p %d", &priority))
16872 else if (unformat (input, "w %d", &weight))
16880 if (locator_set_name_set == 0)
16882 errmsg ("missing locator-set name");
16886 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16888 errmsg ("missing sw_if_index");
16889 vec_free (locator_set_name);
16893 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16895 errmsg ("cannot use both params interface name and sw_if_index");
16896 vec_free (locator_set_name);
16900 if (priority_set == 0)
16902 errmsg ("missing locator-set priority");
16903 vec_free (locator_set_name);
16907 if (weight_set == 0)
16909 errmsg ("missing locator-set weight");
16910 vec_free (locator_set_name);
16914 if (vec_len (locator_set_name) > 64)
16916 errmsg ("locator-set name too long");
16917 vec_free (locator_set_name);
16920 vec_add1 (locator_set_name, 0);
16922 /* Construct the API message */
16923 M (ONE_ADD_DEL_LOCATOR, mp);
16925 mp->is_add = is_add;
16926 mp->sw_if_index = ntohl (sw_if_index);
16927 mp->priority = priority;
16928 mp->weight = weight;
16929 clib_memcpy (mp->locator_set_name, locator_set_name,
16930 vec_len (locator_set_name));
16931 vec_free (locator_set_name);
16936 /* Wait for a reply... */
16941 #define api_lisp_add_del_locator api_one_add_del_locator
16944 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16946 u32 *key_id = va_arg (*args, u32 *);
16949 if (unformat (input, "%s", &s))
16951 if (!strcmp ((char *) s, "sha1"))
16952 key_id[0] = HMAC_SHA_1_96;
16953 else if (!strcmp ((char *) s, "sha256"))
16954 key_id[0] = HMAC_SHA_256_128;
16957 clib_warning ("invalid key_id: '%s'", s);
16958 key_id[0] = HMAC_NO_KEY;
16969 api_one_add_del_local_eid (vat_main_t * vam)
16971 unformat_input_t *input = vam->input;
16972 vl_api_one_add_del_local_eid_t *mp;
16975 lisp_eid_vat_t _eid, *eid = &_eid;
16976 u8 *locator_set_name = 0;
16977 u8 locator_set_name_set = 0;
16983 /* Parse args required to build the message */
16984 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16986 if (unformat (input, "del"))
16990 else if (unformat (input, "vni %d", &vni))
16994 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16998 else if (unformat (input, "locator-set %s", &locator_set_name))
17000 locator_set_name_set = 1;
17002 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17004 else if (unformat (input, "secret-key %_%v%_", &key))
17010 if (locator_set_name_set == 0)
17012 errmsg ("missing locator-set name");
17018 errmsg ("EID address not set!");
17019 vec_free (locator_set_name);
17023 if (key && (0 == key_id))
17025 errmsg ("invalid key_id!");
17029 if (vec_len (key) > 64)
17031 errmsg ("key too long");
17036 if (vec_len (locator_set_name) > 64)
17038 errmsg ("locator-set name too long");
17039 vec_free (locator_set_name);
17042 vec_add1 (locator_set_name, 0);
17044 /* Construct the API message */
17045 M (ONE_ADD_DEL_LOCAL_EID, mp);
17047 mp->is_add = is_add;
17048 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17049 mp->eid_type = eid->type;
17050 mp->prefix_len = eid->len;
17051 mp->vni = clib_host_to_net_u32 (vni);
17052 mp->key_id = clib_host_to_net_u16 (key_id);
17053 clib_memcpy (mp->locator_set_name, locator_set_name,
17054 vec_len (locator_set_name));
17055 clib_memcpy (mp->key, key, vec_len (key));
17057 vec_free (locator_set_name);
17063 /* Wait for a reply... */
17068 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17071 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17073 u32 dp_table = 0, vni = 0;;
17074 unformat_input_t *input = vam->input;
17075 vl_api_gpe_add_del_fwd_entry_t *mp;
17077 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17078 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17079 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17080 u32 action = ~0, w;
17081 ip4_address_t rmt_rloc4, lcl_rloc4;
17082 ip6_address_t rmt_rloc6, lcl_rloc6;
17083 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17086 memset (&rloc, 0, sizeof (rloc));
17088 /* Parse args required to build the message */
17089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17091 if (unformat (input, "del"))
17093 else if (unformat (input, "add"))
17095 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17099 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17103 else if (unformat (input, "vrf %d", &dp_table))
17105 else if (unformat (input, "bd %d", &dp_table))
17107 else if (unformat (input, "vni %d", &vni))
17109 else if (unformat (input, "w %d", &w))
17113 errmsg ("No RLOC configured for setting priority/weight!");
17116 curr_rloc->weight = w;
17118 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17119 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17123 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17125 vec_add1 (lcl_locs, rloc);
17127 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17128 vec_add1 (rmt_locs, rloc);
17129 /* weight saved in rmt loc */
17130 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17132 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17133 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17136 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17138 vec_add1 (lcl_locs, rloc);
17140 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17141 vec_add1 (rmt_locs, rloc);
17142 /* weight saved in rmt loc */
17143 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17145 else if (unformat (input, "action %d", &action))
17151 clib_warning ("parse error '%U'", format_unformat_error, input);
17158 errmsg ("remote eid addresses not set");
17162 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17164 errmsg ("eid types don't match");
17168 if (0 == rmt_locs && (u32) ~ 0 == action)
17170 errmsg ("action not set for negative mapping");
17174 /* Construct the API message */
17175 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17176 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17178 mp->is_add = is_add;
17179 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17180 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17181 mp->eid_type = rmt_eid->type;
17182 mp->dp_table = clib_host_to_net_u32 (dp_table);
17183 mp->vni = clib_host_to_net_u32 (vni);
17184 mp->rmt_len = rmt_eid->len;
17185 mp->lcl_len = lcl_eid->len;
17186 mp->action = action;
17188 if (0 != rmt_locs && 0 != lcl_locs)
17190 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17191 clib_memcpy (mp->locs, lcl_locs,
17192 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17194 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17195 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17196 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17198 vec_free (lcl_locs);
17199 vec_free (rmt_locs);
17204 /* Wait for a reply... */
17210 api_one_add_del_map_server (vat_main_t * vam)
17212 unformat_input_t *input = vam->input;
17213 vl_api_one_add_del_map_server_t *mp;
17217 ip4_address_t ipv4;
17218 ip6_address_t ipv6;
17221 /* Parse args required to build the message */
17222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17224 if (unformat (input, "del"))
17228 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17232 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17240 if (ipv4_set && ipv6_set)
17242 errmsg ("both eid v4 and v6 addresses set");
17246 if (!ipv4_set && !ipv6_set)
17248 errmsg ("eid addresses not set");
17252 /* Construct the API message */
17253 M (ONE_ADD_DEL_MAP_SERVER, mp);
17255 mp->is_add = is_add;
17259 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17264 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17270 /* Wait for a reply... */
17275 #define api_lisp_add_del_map_server api_one_add_del_map_server
17278 api_one_add_del_map_resolver (vat_main_t * vam)
17280 unformat_input_t *input = vam->input;
17281 vl_api_one_add_del_map_resolver_t *mp;
17285 ip4_address_t ipv4;
17286 ip6_address_t ipv6;
17289 /* Parse args required to build the message */
17290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17292 if (unformat (input, "del"))
17296 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17300 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17308 if (ipv4_set && ipv6_set)
17310 errmsg ("both eid v4 and v6 addresses set");
17314 if (!ipv4_set && !ipv6_set)
17316 errmsg ("eid addresses not set");
17320 /* Construct the API message */
17321 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17323 mp->is_add = is_add;
17327 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17332 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17338 /* Wait for a reply... */
17343 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17346 api_lisp_gpe_enable_disable (vat_main_t * vam)
17348 unformat_input_t *input = vam->input;
17349 vl_api_gpe_enable_disable_t *mp;
17354 /* Parse args required to build the message */
17355 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17357 if (unformat (input, "enable"))
17362 else if (unformat (input, "disable"))
17373 errmsg ("Value not set");
17377 /* Construct the API message */
17378 M (GPE_ENABLE_DISABLE, mp);
17385 /* Wait for a reply... */
17391 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17393 unformat_input_t *input = vam->input;
17394 vl_api_one_rloc_probe_enable_disable_t *mp;
17399 /* Parse args required to build the message */
17400 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17402 if (unformat (input, "enable"))
17407 else if (unformat (input, "disable"))
17415 errmsg ("Value not set");
17419 /* Construct the API message */
17420 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17422 mp->is_enabled = is_en;
17427 /* Wait for a reply... */
17432 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17435 api_one_map_register_enable_disable (vat_main_t * vam)
17437 unformat_input_t *input = vam->input;
17438 vl_api_one_map_register_enable_disable_t *mp;
17443 /* Parse args required to build the message */
17444 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17446 if (unformat (input, "enable"))
17451 else if (unformat (input, "disable"))
17459 errmsg ("Value not set");
17463 /* Construct the API message */
17464 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17466 mp->is_enabled = is_en;
17471 /* Wait for a reply... */
17476 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17479 api_one_enable_disable (vat_main_t * vam)
17481 unformat_input_t *input = vam->input;
17482 vl_api_one_enable_disable_t *mp;
17487 /* Parse args required to build the message */
17488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17490 if (unformat (input, "enable"))
17495 else if (unformat (input, "disable"))
17505 errmsg ("Value not set");
17509 /* Construct the API message */
17510 M (ONE_ENABLE_DISABLE, mp);
17517 /* Wait for a reply... */
17522 #define api_lisp_enable_disable api_one_enable_disable
17525 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17527 unformat_input_t *input = vam->input;
17528 vl_api_one_enable_disable_xtr_mode_t *mp;
17533 /* Parse args required to build the message */
17534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17536 if (unformat (input, "enable"))
17541 else if (unformat (input, "disable"))
17551 errmsg ("Value not set");
17555 /* Construct the API message */
17556 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17563 /* Wait for a reply... */
17569 api_one_show_xtr_mode (vat_main_t * vam)
17571 vl_api_one_show_xtr_mode_t *mp;
17574 /* Construct the API message */
17575 M (ONE_SHOW_XTR_MODE, mp);
17580 /* Wait for a reply... */
17586 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17588 unformat_input_t *input = vam->input;
17589 vl_api_one_enable_disable_pitr_mode_t *mp;
17594 /* Parse args required to build the message */
17595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17597 if (unformat (input, "enable"))
17602 else if (unformat (input, "disable"))
17612 errmsg ("Value not set");
17616 /* Construct the API message */
17617 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17624 /* Wait for a reply... */
17630 api_one_show_pitr_mode (vat_main_t * vam)
17632 vl_api_one_show_pitr_mode_t *mp;
17635 /* Construct the API message */
17636 M (ONE_SHOW_PITR_MODE, mp);
17641 /* Wait for a reply... */
17647 api_one_enable_disable_petr_mode (vat_main_t * vam)
17649 unformat_input_t *input = vam->input;
17650 vl_api_one_enable_disable_petr_mode_t *mp;
17655 /* Parse args required to build the message */
17656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17658 if (unformat (input, "enable"))
17663 else if (unformat (input, "disable"))
17673 errmsg ("Value not set");
17677 /* Construct the API message */
17678 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17685 /* Wait for a reply... */
17691 api_one_show_petr_mode (vat_main_t * vam)
17693 vl_api_one_show_petr_mode_t *mp;
17696 /* Construct the API message */
17697 M (ONE_SHOW_PETR_MODE, mp);
17702 /* Wait for a reply... */
17708 api_show_one_map_register_state (vat_main_t * vam)
17710 vl_api_show_one_map_register_state_t *mp;
17713 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17718 /* wait for reply */
17723 #define api_show_lisp_map_register_state api_show_one_map_register_state
17726 api_show_one_rloc_probe_state (vat_main_t * vam)
17728 vl_api_show_one_rloc_probe_state_t *mp;
17731 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17736 /* wait for reply */
17741 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17744 api_one_add_del_ndp_entry (vat_main_t * vam)
17746 vl_api_one_add_del_ndp_entry_t *mp;
17747 unformat_input_t *input = vam->input;
17752 u8 mac[6] = { 0, };
17753 u8 ip6[16] = { 0, };
17757 /* Parse args required to build the message */
17758 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17760 if (unformat (input, "del"))
17762 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17764 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17766 else if (unformat (input, "bd %d", &bd))
17770 errmsg ("parse error '%U'", format_unformat_error, input);
17775 if (!bd_set || !ip_set || (!mac_set && is_add))
17777 errmsg ("Missing BD, IP or MAC!");
17781 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17782 mp->is_add = is_add;
17783 clib_memcpy (mp->mac, mac, 6);
17784 mp->bd = clib_host_to_net_u32 (bd);
17785 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17790 /* wait for reply */
17796 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17798 vl_api_one_add_del_l2_arp_entry_t *mp;
17799 unformat_input_t *input = vam->input;
17804 u8 mac[6] = { 0, };
17805 u32 ip4 = 0, bd = ~0;
17808 /* Parse args required to build the message */
17809 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17811 if (unformat (input, "del"))
17813 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17815 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17817 else if (unformat (input, "bd %d", &bd))
17821 errmsg ("parse error '%U'", format_unformat_error, input);
17826 if (!bd_set || !ip_set || (!mac_set && is_add))
17828 errmsg ("Missing BD, IP or MAC!");
17832 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17833 mp->is_add = is_add;
17834 clib_memcpy (mp->mac, mac, 6);
17835 mp->bd = clib_host_to_net_u32 (bd);
17841 /* wait for reply */
17847 api_one_ndp_bd_get (vat_main_t * vam)
17849 vl_api_one_ndp_bd_get_t *mp;
17852 M (ONE_NDP_BD_GET, mp);
17857 /* wait for reply */
17863 api_one_ndp_entries_get (vat_main_t * vam)
17865 vl_api_one_ndp_entries_get_t *mp;
17866 unformat_input_t *input = vam->input;
17871 /* Parse args required to build the message */
17872 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17874 if (unformat (input, "bd %d", &bd))
17878 errmsg ("parse error '%U'", format_unformat_error, input);
17885 errmsg ("Expected bridge domain!");
17889 M (ONE_NDP_ENTRIES_GET, mp);
17890 mp->bd = clib_host_to_net_u32 (bd);
17895 /* wait for reply */
17901 api_one_l2_arp_bd_get (vat_main_t * vam)
17903 vl_api_one_l2_arp_bd_get_t *mp;
17906 M (ONE_L2_ARP_BD_GET, mp);
17911 /* wait for reply */
17917 api_one_l2_arp_entries_get (vat_main_t * vam)
17919 vl_api_one_l2_arp_entries_get_t *mp;
17920 unformat_input_t *input = vam->input;
17925 /* Parse args required to build the message */
17926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17928 if (unformat (input, "bd %d", &bd))
17932 errmsg ("parse error '%U'", format_unformat_error, input);
17939 errmsg ("Expected bridge domain!");
17943 M (ONE_L2_ARP_ENTRIES_GET, mp);
17944 mp->bd = clib_host_to_net_u32 (bd);
17949 /* wait for reply */
17955 api_one_stats_enable_disable (vat_main_t * vam)
17957 vl_api_one_stats_enable_disable_t *mp;
17958 unformat_input_t *input = vam->input;
17963 /* Parse args required to build the message */
17964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17966 if (unformat (input, "enable"))
17971 else if (unformat (input, "disable"))
17981 errmsg ("Value not set");
17985 M (ONE_STATS_ENABLE_DISABLE, mp);
17991 /* wait for reply */
17997 api_show_one_stats_enable_disable (vat_main_t * vam)
17999 vl_api_show_one_stats_enable_disable_t *mp;
18002 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18007 /* wait for reply */
18013 api_show_one_map_request_mode (vat_main_t * vam)
18015 vl_api_show_one_map_request_mode_t *mp;
18018 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18023 /* wait for reply */
18028 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18031 api_one_map_request_mode (vat_main_t * vam)
18033 unformat_input_t *input = vam->input;
18034 vl_api_one_map_request_mode_t *mp;
18038 /* Parse args required to build the message */
18039 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18041 if (unformat (input, "dst-only"))
18043 else if (unformat (input, "src-dst"))
18047 errmsg ("parse error '%U'", format_unformat_error, input);
18052 M (ONE_MAP_REQUEST_MODE, mp);
18059 /* wait for reply */
18064 #define api_lisp_map_request_mode api_one_map_request_mode
18067 * Enable/disable ONE proxy ITR.
18069 * @param vam vpp API test context
18070 * @return return code
18073 api_one_pitr_set_locator_set (vat_main_t * vam)
18075 u8 ls_name_set = 0;
18076 unformat_input_t *input = vam->input;
18077 vl_api_one_pitr_set_locator_set_t *mp;
18082 /* Parse args required to build the message */
18083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18085 if (unformat (input, "del"))
18087 else if (unformat (input, "locator-set %s", &ls_name))
18091 errmsg ("parse error '%U'", format_unformat_error, input);
18098 errmsg ("locator-set name not set!");
18102 M (ONE_PITR_SET_LOCATOR_SET, mp);
18104 mp->is_add = is_add;
18105 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18106 vec_free (ls_name);
18111 /* wait for reply */
18116 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18119 api_one_nsh_set_locator_set (vat_main_t * vam)
18121 u8 ls_name_set = 0;
18122 unformat_input_t *input = vam->input;
18123 vl_api_one_nsh_set_locator_set_t *mp;
18128 /* Parse args required to build the message */
18129 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18131 if (unformat (input, "del"))
18133 else if (unformat (input, "ls %s", &ls_name))
18137 errmsg ("parse error '%U'", format_unformat_error, input);
18142 if (!ls_name_set && is_add)
18144 errmsg ("locator-set name not set!");
18148 M (ONE_NSH_SET_LOCATOR_SET, mp);
18150 mp->is_add = is_add;
18151 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18152 vec_free (ls_name);
18157 /* wait for reply */
18163 api_show_one_pitr (vat_main_t * vam)
18165 vl_api_show_one_pitr_t *mp;
18168 if (!vam->json_output)
18170 print (vam->ofp, "%=20s", "lisp status:");
18173 M (SHOW_ONE_PITR, mp);
18177 /* Wait for a reply... */
18182 #define api_show_lisp_pitr api_show_one_pitr
18185 api_one_use_petr (vat_main_t * vam)
18187 unformat_input_t *input = vam->input;
18188 vl_api_one_use_petr_t *mp;
18193 memset (&ip, 0, sizeof (ip));
18195 /* Parse args required to build the message */
18196 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18198 if (unformat (input, "disable"))
18201 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18204 ip_addr_version (&ip) = IP4;
18207 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18210 ip_addr_version (&ip) = IP6;
18214 errmsg ("parse error '%U'", format_unformat_error, input);
18219 M (ONE_USE_PETR, mp);
18221 mp->is_add = is_add;
18224 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18226 clib_memcpy (mp->address, &ip, 4);
18228 clib_memcpy (mp->address, &ip, 16);
18234 /* wait for reply */
18239 #define api_lisp_use_petr api_one_use_petr
18242 api_show_one_nsh_mapping (vat_main_t * vam)
18244 vl_api_show_one_use_petr_t *mp;
18247 if (!vam->json_output)
18249 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18252 M (SHOW_ONE_NSH_MAPPING, mp);
18256 /* Wait for a reply... */
18262 api_show_one_use_petr (vat_main_t * vam)
18264 vl_api_show_one_use_petr_t *mp;
18267 if (!vam->json_output)
18269 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18272 M (SHOW_ONE_USE_PETR, mp);
18276 /* Wait for a reply... */
18281 #define api_show_lisp_use_petr api_show_one_use_petr
18284 * Add/delete mapping between vni and vrf
18287 api_one_eid_table_add_del_map (vat_main_t * vam)
18289 unformat_input_t *input = vam->input;
18290 vl_api_one_eid_table_add_del_map_t *mp;
18291 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18292 u32 vni, vrf, bd_index;
18295 /* Parse args required to build the message */
18296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18298 if (unformat (input, "del"))
18300 else if (unformat (input, "vrf %d", &vrf))
18302 else if (unformat (input, "bd_index %d", &bd_index))
18304 else if (unformat (input, "vni %d", &vni))
18310 if (!vni_set || (!vrf_set && !bd_index_set))
18312 errmsg ("missing arguments!");
18316 if (vrf_set && bd_index_set)
18318 errmsg ("error: both vrf and bd entered!");
18322 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18324 mp->is_add = is_add;
18325 mp->vni = htonl (vni);
18326 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18327 mp->is_l2 = bd_index_set;
18332 /* wait for reply */
18337 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18340 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18342 u32 *action = va_arg (*args, u32 *);
18345 if (unformat (input, "%s", &s))
18347 if (!strcmp ((char *) s, "no-action"))
18349 else if (!strcmp ((char *) s, "natively-forward"))
18351 else if (!strcmp ((char *) s, "send-map-request"))
18353 else if (!strcmp ((char *) s, "drop"))
18357 clib_warning ("invalid action: '%s'", s);
18369 * Add/del remote mapping to/from ONE control plane
18371 * @param vam vpp API test context
18372 * @return return code
18375 api_one_add_del_remote_mapping (vat_main_t * vam)
18377 unformat_input_t *input = vam->input;
18378 vl_api_one_add_del_remote_mapping_t *mp;
18380 lisp_eid_vat_t _eid, *eid = &_eid;
18381 lisp_eid_vat_t _seid, *seid = &_seid;
18382 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18383 u32 action = ~0, p, w, data_len;
18384 ip4_address_t rloc4;
18385 ip6_address_t rloc6;
18386 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18389 memset (&rloc, 0, sizeof (rloc));
18391 /* Parse args required to build the message */
18392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18394 if (unformat (input, "del-all"))
18398 else if (unformat (input, "del"))
18402 else if (unformat (input, "add"))
18406 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18410 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18414 else if (unformat (input, "vni %d", &vni))
18418 else if (unformat (input, "p %d w %d", &p, &w))
18422 errmsg ("No RLOC configured for setting priority/weight!");
18425 curr_rloc->priority = p;
18426 curr_rloc->weight = w;
18428 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18431 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18432 vec_add1 (rlocs, rloc);
18433 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18435 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18438 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18439 vec_add1 (rlocs, rloc);
18440 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18442 else if (unformat (input, "action %U",
18443 unformat_negative_mapping_action, &action))
18449 clib_warning ("parse error '%U'", format_unformat_error, input);
18456 errmsg ("missing params!");
18460 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18462 errmsg ("no action set for negative map-reply!");
18466 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18468 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18469 mp->is_add = is_add;
18470 mp->vni = htonl (vni);
18471 mp->action = (u8) action;
18472 mp->is_src_dst = seid_set;
18473 mp->eid_len = eid->len;
18474 mp->seid_len = seid->len;
18475 mp->del_all = del_all;
18476 mp->eid_type = eid->type;
18477 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18478 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18480 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18481 clib_memcpy (mp->rlocs, rlocs, data_len);
18487 /* Wait for a reply... */
18492 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18495 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18496 * forwarding entries in data-plane accordingly.
18498 * @param vam vpp API test context
18499 * @return return code
18502 api_one_add_del_adjacency (vat_main_t * vam)
18504 unformat_input_t *input = vam->input;
18505 vl_api_one_add_del_adjacency_t *mp;
18507 ip4_address_t leid4, reid4;
18508 ip6_address_t leid6, reid6;
18509 u8 reid_mac[6] = { 0 };
18510 u8 leid_mac[6] = { 0 };
18511 u8 reid_type, leid_type;
18512 u32 leid_len = 0, reid_len = 0, len;
18516 leid_type = reid_type = (u8) ~ 0;
18518 /* Parse args required to build the message */
18519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18521 if (unformat (input, "del"))
18525 else if (unformat (input, "add"))
18529 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18532 reid_type = 0; /* ipv4 */
18535 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18538 reid_type = 1; /* ipv6 */
18541 else if (unformat (input, "reid %U", unformat_ethernet_address,
18544 reid_type = 2; /* mac */
18546 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18549 leid_type = 0; /* ipv4 */
18552 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18555 leid_type = 1; /* ipv6 */
18558 else if (unformat (input, "leid %U", unformat_ethernet_address,
18561 leid_type = 2; /* mac */
18563 else if (unformat (input, "vni %d", &vni))
18569 errmsg ("parse error '%U'", format_unformat_error, input);
18574 if ((u8) ~ 0 == reid_type)
18576 errmsg ("missing params!");
18580 if (leid_type != reid_type)
18582 errmsg ("remote and local EIDs are of different types!");
18586 M (ONE_ADD_DEL_ADJACENCY, mp);
18587 mp->is_add = is_add;
18588 mp->vni = htonl (vni);
18589 mp->leid_len = leid_len;
18590 mp->reid_len = reid_len;
18591 mp->eid_type = reid_type;
18593 switch (mp->eid_type)
18596 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18597 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18600 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18601 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18604 clib_memcpy (mp->leid, leid_mac, 6);
18605 clib_memcpy (mp->reid, reid_mac, 6);
18608 errmsg ("unknown EID type %d!", mp->eid_type);
18615 /* Wait for a reply... */
18620 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18623 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18625 u32 *mode = va_arg (*args, u32 *);
18627 if (unformat (input, "lisp"))
18629 else if (unformat (input, "vxlan"))
18638 api_gpe_get_encap_mode (vat_main_t * vam)
18640 vl_api_gpe_get_encap_mode_t *mp;
18643 /* Construct the API message */
18644 M (GPE_GET_ENCAP_MODE, mp);
18649 /* Wait for a reply... */
18655 api_gpe_set_encap_mode (vat_main_t * vam)
18657 unformat_input_t *input = vam->input;
18658 vl_api_gpe_set_encap_mode_t *mp;
18662 /* Parse args required to build the message */
18663 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18665 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18671 /* Construct the API message */
18672 M (GPE_SET_ENCAP_MODE, mp);
18679 /* Wait for a reply... */
18685 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18687 unformat_input_t *input = vam->input;
18688 vl_api_gpe_add_del_iface_t *mp;
18689 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18690 u32 dp_table = 0, vni = 0;
18693 /* Parse args required to build the message */
18694 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18696 if (unformat (input, "up"))
18701 else if (unformat (input, "down"))
18706 else if (unformat (input, "table_id %d", &dp_table))
18710 else if (unformat (input, "bd_id %d", &dp_table))
18715 else if (unformat (input, "vni %d", &vni))
18723 if (action_set == 0)
18725 errmsg ("Action not set");
18728 if (dp_table_set == 0 || vni_set == 0)
18730 errmsg ("vni and dp_table must be set");
18734 /* Construct the API message */
18735 M (GPE_ADD_DEL_IFACE, mp);
18737 mp->is_add = is_add;
18738 mp->dp_table = clib_host_to_net_u32 (dp_table);
18740 mp->vni = clib_host_to_net_u32 (vni);
18745 /* Wait for a reply... */
18751 api_one_map_register_fallback_threshold (vat_main_t * vam)
18753 unformat_input_t *input = vam->input;
18754 vl_api_one_map_register_fallback_threshold_t *mp;
18759 /* Parse args required to build the message */
18760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18762 if (unformat (input, "%u", &value))
18766 clib_warning ("parse error '%U'", format_unformat_error, input);
18773 errmsg ("fallback threshold value is missing!");
18777 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18778 mp->value = clib_host_to_net_u32 (value);
18783 /* Wait for a reply... */
18789 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18791 vl_api_show_one_map_register_fallback_threshold_t *mp;
18794 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18799 /* Wait for a reply... */
18805 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18807 u32 *proto = va_arg (*args, u32 *);
18809 if (unformat (input, "udp"))
18811 else if (unformat (input, "api"))
18820 api_one_set_transport_protocol (vat_main_t * vam)
18822 unformat_input_t *input = vam->input;
18823 vl_api_one_set_transport_protocol_t *mp;
18828 /* Parse args required to build the message */
18829 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18831 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18835 clib_warning ("parse error '%U'", format_unformat_error, input);
18842 errmsg ("Transport protocol missing!");
18846 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18847 mp->protocol = (u8) protocol;
18852 /* Wait for a reply... */
18858 api_one_get_transport_protocol (vat_main_t * vam)
18860 vl_api_one_get_transport_protocol_t *mp;
18863 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18868 /* Wait for a reply... */
18874 api_one_map_register_set_ttl (vat_main_t * vam)
18876 unformat_input_t *input = vam->input;
18877 vl_api_one_map_register_set_ttl_t *mp;
18882 /* Parse args required to build the message */
18883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18885 if (unformat (input, "%u", &ttl))
18889 clib_warning ("parse error '%U'", format_unformat_error, input);
18896 errmsg ("TTL value missing!");
18900 M (ONE_MAP_REGISTER_SET_TTL, mp);
18901 mp->ttl = clib_host_to_net_u32 (ttl);
18906 /* Wait for a reply... */
18912 api_show_one_map_register_ttl (vat_main_t * vam)
18914 vl_api_show_one_map_register_ttl_t *mp;
18917 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18922 /* Wait for a reply... */
18928 * Add/del map request itr rlocs from ONE control plane and updates
18930 * @param vam vpp API test context
18931 * @return return code
18934 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18936 unformat_input_t *input = vam->input;
18937 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18938 u8 *locator_set_name = 0;
18939 u8 locator_set_name_set = 0;
18943 /* Parse args required to build the message */
18944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18946 if (unformat (input, "del"))
18950 else if (unformat (input, "%_%v%_", &locator_set_name))
18952 locator_set_name_set = 1;
18956 clib_warning ("parse error '%U'", format_unformat_error, input);
18961 if (is_add && !locator_set_name_set)
18963 errmsg ("itr-rloc is not set!");
18967 if (is_add && vec_len (locator_set_name) > 64)
18969 errmsg ("itr-rloc locator-set name too long");
18970 vec_free (locator_set_name);
18974 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18975 mp->is_add = is_add;
18978 clib_memcpy (mp->locator_set_name, locator_set_name,
18979 vec_len (locator_set_name));
18983 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18985 vec_free (locator_set_name);
18990 /* Wait for a reply... */
18995 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18998 api_one_locator_dump (vat_main_t * vam)
19000 unformat_input_t *input = vam->input;
19001 vl_api_one_locator_dump_t *mp;
19002 vl_api_control_ping_t *mp_ping;
19003 u8 is_index_set = 0, is_name_set = 0;
19008 /* Parse args required to build the message */
19009 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19011 if (unformat (input, "ls_name %_%v%_", &ls_name))
19015 else if (unformat (input, "ls_index %d", &ls_index))
19021 errmsg ("parse error '%U'", format_unformat_error, input);
19026 if (!is_index_set && !is_name_set)
19028 errmsg ("error: expected one of index or name!");
19032 if (is_index_set && is_name_set)
19034 errmsg ("error: only one param expected!");
19038 if (vec_len (ls_name) > 62)
19040 errmsg ("error: locator set name too long!");
19044 if (!vam->json_output)
19046 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19049 M (ONE_LOCATOR_DUMP, mp);
19050 mp->is_index_set = is_index_set;
19053 mp->ls_index = clib_host_to_net_u32 (ls_index);
19056 vec_add1 (ls_name, 0);
19057 strncpy ((char *) mp->ls_name, (char *) ls_name,
19058 sizeof (mp->ls_name) - 1);
19064 /* Use a control ping for synchronization */
19065 MPING (CONTROL_PING, mp_ping);
19068 /* Wait for a reply... */
19073 #define api_lisp_locator_dump api_one_locator_dump
19076 api_one_locator_set_dump (vat_main_t * vam)
19078 vl_api_one_locator_set_dump_t *mp;
19079 vl_api_control_ping_t *mp_ping;
19080 unformat_input_t *input = vam->input;
19084 /* Parse args required to build the message */
19085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19087 if (unformat (input, "local"))
19091 else if (unformat (input, "remote"))
19097 errmsg ("parse error '%U'", format_unformat_error, input);
19102 if (!vam->json_output)
19104 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19107 M (ONE_LOCATOR_SET_DUMP, mp);
19109 mp->filter = filter;
19114 /* Use a control ping for synchronization */
19115 MPING (CONTROL_PING, mp_ping);
19118 /* Wait for a reply... */
19123 #define api_lisp_locator_set_dump api_one_locator_set_dump
19126 api_one_eid_table_map_dump (vat_main_t * vam)
19130 unformat_input_t *input = vam->input;
19131 vl_api_one_eid_table_map_dump_t *mp;
19132 vl_api_control_ping_t *mp_ping;
19135 /* Parse args required to build the message */
19136 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19138 if (unformat (input, "l2"))
19143 else if (unformat (input, "l3"))
19150 errmsg ("parse error '%U'", format_unformat_error, input);
19157 errmsg ("expected one of 'l2' or 'l3' parameter!");
19161 if (!vam->json_output)
19163 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19166 M (ONE_EID_TABLE_MAP_DUMP, mp);
19172 /* Use a control ping for synchronization */
19173 MPING (CONTROL_PING, mp_ping);
19176 /* Wait for a reply... */
19181 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19184 api_one_eid_table_vni_dump (vat_main_t * vam)
19186 vl_api_one_eid_table_vni_dump_t *mp;
19187 vl_api_control_ping_t *mp_ping;
19190 if (!vam->json_output)
19192 print (vam->ofp, "VNI");
19195 M (ONE_EID_TABLE_VNI_DUMP, mp);
19200 /* Use a control ping for synchronization */
19201 MPING (CONTROL_PING, mp_ping);
19204 /* Wait for a reply... */
19209 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19212 api_one_eid_table_dump (vat_main_t * vam)
19214 unformat_input_t *i = vam->input;
19215 vl_api_one_eid_table_dump_t *mp;
19216 vl_api_control_ping_t *mp_ping;
19217 struct in_addr ip4;
19218 struct in6_addr ip6;
19220 u8 eid_type = ~0, eid_set = 0;
19221 u32 prefix_length = ~0, t, vni = 0;
19224 lisp_nsh_api_t nsh;
19226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19228 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19234 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19240 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19245 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19250 else if (unformat (i, "vni %d", &t))
19254 else if (unformat (i, "local"))
19258 else if (unformat (i, "remote"))
19264 errmsg ("parse error '%U'", format_unformat_error, i);
19269 if (!vam->json_output)
19271 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19272 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19275 M (ONE_EID_TABLE_DUMP, mp);
19277 mp->filter = filter;
19281 mp->vni = htonl (vni);
19282 mp->eid_type = eid_type;
19286 mp->prefix_length = prefix_length;
19287 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19290 mp->prefix_length = prefix_length;
19291 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19294 clib_memcpy (mp->eid, mac, sizeof (mac));
19297 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19300 errmsg ("unknown EID type %d!", eid_type);
19308 /* Use a control ping for synchronization */
19309 MPING (CONTROL_PING, mp_ping);
19312 /* Wait for a reply... */
19317 #define api_lisp_eid_table_dump api_one_eid_table_dump
19320 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19322 unformat_input_t *i = vam->input;
19323 vl_api_gpe_fwd_entries_get_t *mp;
19328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19330 if (unformat (i, "vni %d", &vni))
19336 errmsg ("parse error '%U'", format_unformat_error, i);
19343 errmsg ("vni not set!");
19347 if (!vam->json_output)
19349 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19353 M (GPE_FWD_ENTRIES_GET, mp);
19354 mp->vni = clib_host_to_net_u32 (vni);
19359 /* Wait for a reply... */
19364 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19365 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19366 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19367 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19368 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19369 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19370 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19371 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19374 api_one_adjacencies_get (vat_main_t * vam)
19376 unformat_input_t *i = vam->input;
19377 vl_api_one_adjacencies_get_t *mp;
19382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19384 if (unformat (i, "vni %d", &vni))
19390 errmsg ("parse error '%U'", format_unformat_error, i);
19397 errmsg ("vni not set!");
19401 if (!vam->json_output)
19403 print (vam->ofp, "%s %40s", "leid", "reid");
19406 M (ONE_ADJACENCIES_GET, mp);
19407 mp->vni = clib_host_to_net_u32 (vni);
19412 /* Wait for a reply... */
19417 #define api_lisp_adjacencies_get api_one_adjacencies_get
19420 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19422 unformat_input_t *i = vam->input;
19423 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19425 u8 ip_family_set = 0, is_ip4 = 1;
19427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19429 if (unformat (i, "ip4"))
19434 else if (unformat (i, "ip6"))
19441 errmsg ("parse error '%U'", format_unformat_error, i);
19446 if (!ip_family_set)
19448 errmsg ("ip family not set!");
19452 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19453 mp->is_ip4 = is_ip4;
19458 /* Wait for a reply... */
19464 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19466 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19469 if (!vam->json_output)
19471 print (vam->ofp, "VNIs");
19474 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19479 /* Wait for a reply... */
19485 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19487 unformat_input_t *i = vam->input;
19488 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19490 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19491 struct in_addr ip4;
19492 struct in6_addr ip6;
19493 u32 table_id = 0, nh_sw_if_index = ~0;
19495 memset (&ip4, 0, sizeof (ip4));
19496 memset (&ip6, 0, sizeof (ip6));
19498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19500 if (unformat (i, "del"))
19502 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19503 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19508 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19509 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19514 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19518 nh_sw_if_index = ~0;
19520 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19524 nh_sw_if_index = ~0;
19526 else if (unformat (i, "table %d", &table_id))
19530 errmsg ("parse error '%U'", format_unformat_error, i);
19537 errmsg ("nh addr not set!");
19541 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19542 mp->is_add = is_add;
19543 mp->table_id = clib_host_to_net_u32 (table_id);
19544 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19545 mp->is_ip4 = is_ip4;
19547 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19549 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19554 /* Wait for a reply... */
19560 api_one_map_server_dump (vat_main_t * vam)
19562 vl_api_one_map_server_dump_t *mp;
19563 vl_api_control_ping_t *mp_ping;
19566 if (!vam->json_output)
19568 print (vam->ofp, "%=20s", "Map server");
19571 M (ONE_MAP_SERVER_DUMP, mp);
19575 /* Use a control ping for synchronization */
19576 MPING (CONTROL_PING, mp_ping);
19579 /* Wait for a reply... */
19584 #define api_lisp_map_server_dump api_one_map_server_dump
19587 api_one_map_resolver_dump (vat_main_t * vam)
19589 vl_api_one_map_resolver_dump_t *mp;
19590 vl_api_control_ping_t *mp_ping;
19593 if (!vam->json_output)
19595 print (vam->ofp, "%=20s", "Map resolver");
19598 M (ONE_MAP_RESOLVER_DUMP, mp);
19602 /* Use a control ping for synchronization */
19603 MPING (CONTROL_PING, mp_ping);
19606 /* Wait for a reply... */
19611 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19614 api_one_stats_flush (vat_main_t * vam)
19616 vl_api_one_stats_flush_t *mp;
19619 M (ONE_STATS_FLUSH, mp);
19626 api_one_stats_dump (vat_main_t * vam)
19628 vl_api_one_stats_dump_t *mp;
19629 vl_api_control_ping_t *mp_ping;
19632 M (ONE_STATS_DUMP, mp);
19636 /* Use a control ping for synchronization */
19637 MPING (CONTROL_PING, mp_ping);
19640 /* Wait for a reply... */
19646 api_show_one_status (vat_main_t * vam)
19648 vl_api_show_one_status_t *mp;
19651 if (!vam->json_output)
19653 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19656 M (SHOW_ONE_STATUS, mp);
19659 /* Wait for a reply... */
19664 #define api_show_lisp_status api_show_one_status
19667 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19669 vl_api_gpe_fwd_entry_path_dump_t *mp;
19670 vl_api_control_ping_t *mp_ping;
19671 unformat_input_t *i = vam->input;
19672 u32 fwd_entry_index = ~0;
19675 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19677 if (unformat (i, "index %d", &fwd_entry_index))
19683 if (~0 == fwd_entry_index)
19685 errmsg ("no index specified!");
19689 if (!vam->json_output)
19691 print (vam->ofp, "first line");
19694 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19698 /* Use a control ping for synchronization */
19699 MPING (CONTROL_PING, mp_ping);
19702 /* Wait for a reply... */
19708 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19710 vl_api_one_get_map_request_itr_rlocs_t *mp;
19713 if (!vam->json_output)
19715 print (vam->ofp, "%=20s", "itr-rlocs:");
19718 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19721 /* Wait for a reply... */
19726 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19729 api_af_packet_create (vat_main_t * vam)
19731 unformat_input_t *i = vam->input;
19732 vl_api_af_packet_create_t *mp;
19733 u8 *host_if_name = 0;
19735 u8 random_hw_addr = 1;
19738 memset (hw_addr, 0, sizeof (hw_addr));
19740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19742 if (unformat (i, "name %s", &host_if_name))
19743 vec_add1 (host_if_name, 0);
19744 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19745 random_hw_addr = 0;
19750 if (!vec_len (host_if_name))
19752 errmsg ("host-interface name must be specified");
19756 if (vec_len (host_if_name) > 64)
19758 errmsg ("host-interface name too long");
19762 M (AF_PACKET_CREATE, mp);
19764 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19765 clib_memcpy (mp->hw_addr, hw_addr, 6);
19766 mp->use_random_hw_addr = random_hw_addr;
19767 vec_free (host_if_name);
19775 fprintf (vam->ofp ? vam->ofp : stderr,
19776 " new sw_if_index = %d\n", vam->sw_if_index);
19783 api_af_packet_delete (vat_main_t * vam)
19785 unformat_input_t *i = vam->input;
19786 vl_api_af_packet_delete_t *mp;
19787 u8 *host_if_name = 0;
19790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19792 if (unformat (i, "name %s", &host_if_name))
19793 vec_add1 (host_if_name, 0);
19798 if (!vec_len (host_if_name))
19800 errmsg ("host-interface name must be specified");
19804 if (vec_len (host_if_name) > 64)
19806 errmsg ("host-interface name too long");
19810 M (AF_PACKET_DELETE, mp);
19812 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19813 vec_free (host_if_name);
19820 static void vl_api_af_packet_details_t_handler
19821 (vl_api_af_packet_details_t * mp)
19823 vat_main_t *vam = &vat_main;
19825 print (vam->ofp, "%-16s %d",
19826 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19829 static void vl_api_af_packet_details_t_handler_json
19830 (vl_api_af_packet_details_t * mp)
19832 vat_main_t *vam = &vat_main;
19833 vat_json_node_t *node = NULL;
19835 if (VAT_JSON_ARRAY != vam->json_tree.type)
19837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19838 vat_json_init_array (&vam->json_tree);
19840 node = vat_json_array_add (&vam->json_tree);
19842 vat_json_init_object (node);
19843 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19844 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19848 api_af_packet_dump (vat_main_t * vam)
19850 vl_api_af_packet_dump_t *mp;
19851 vl_api_control_ping_t *mp_ping;
19854 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19855 /* Get list of tap interfaces */
19856 M (AF_PACKET_DUMP, mp);
19859 /* Use a control ping for synchronization */
19860 MPING (CONTROL_PING, mp_ping);
19868 api_policer_add_del (vat_main_t * vam)
19870 unformat_input_t *i = vam->input;
19871 vl_api_policer_add_del_t *mp;
19881 u8 color_aware = 0;
19882 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19885 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19886 conform_action.dscp = 0;
19887 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19888 exceed_action.dscp = 0;
19889 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19890 violate_action.dscp = 0;
19892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19894 if (unformat (i, "del"))
19896 else if (unformat (i, "name %s", &name))
19897 vec_add1 (name, 0);
19898 else if (unformat (i, "cir %u", &cir))
19900 else if (unformat (i, "eir %u", &eir))
19902 else if (unformat (i, "cb %u", &cb))
19904 else if (unformat (i, "eb %u", &eb))
19906 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19909 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19912 else if (unformat (i, "type %U", unformat_policer_type, &type))
19914 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19917 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19920 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19923 else if (unformat (i, "color-aware"))
19929 if (!vec_len (name))
19931 errmsg ("policer name must be specified");
19935 if (vec_len (name) > 64)
19937 errmsg ("policer name too long");
19941 M (POLICER_ADD_DEL, mp);
19943 clib_memcpy (mp->name, name, vec_len (name));
19945 mp->is_add = is_add;
19946 mp->cir = ntohl (cir);
19947 mp->eir = ntohl (eir);
19948 mp->cb = clib_net_to_host_u64 (cb);
19949 mp->eb = clib_net_to_host_u64 (eb);
19950 mp->rate_type = rate_type;
19951 mp->round_type = round_type;
19953 mp->conform_action_type = conform_action.action_type;
19954 mp->conform_dscp = conform_action.dscp;
19955 mp->exceed_action_type = exceed_action.action_type;
19956 mp->exceed_dscp = exceed_action.dscp;
19957 mp->violate_action_type = violate_action.action_type;
19958 mp->violate_dscp = violate_action.dscp;
19959 mp->color_aware = color_aware;
19967 api_policer_dump (vat_main_t * vam)
19969 unformat_input_t *i = vam->input;
19970 vl_api_policer_dump_t *mp;
19971 vl_api_control_ping_t *mp_ping;
19972 u8 *match_name = 0;
19973 u8 match_name_valid = 0;
19976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19978 if (unformat (i, "name %s", &match_name))
19980 vec_add1 (match_name, 0);
19981 match_name_valid = 1;
19987 M (POLICER_DUMP, mp);
19988 mp->match_name_valid = match_name_valid;
19989 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19990 vec_free (match_name);
19994 /* Use a control ping for synchronization */
19995 MPING (CONTROL_PING, mp_ping);
19998 /* Wait for a reply... */
20004 api_policer_classify_set_interface (vat_main_t * vam)
20006 unformat_input_t *i = vam->input;
20007 vl_api_policer_classify_set_interface_t *mp;
20009 int sw_if_index_set;
20010 u32 ip4_table_index = ~0;
20011 u32 ip6_table_index = ~0;
20012 u32 l2_table_index = ~0;
20016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20019 sw_if_index_set = 1;
20020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20021 sw_if_index_set = 1;
20022 else if (unformat (i, "del"))
20024 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20026 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20028 else if (unformat (i, "l2-table %d", &l2_table_index))
20032 clib_warning ("parse error '%U'", format_unformat_error, i);
20037 if (sw_if_index_set == 0)
20039 errmsg ("missing interface name or sw_if_index");
20043 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20045 mp->sw_if_index = ntohl (sw_if_index);
20046 mp->ip4_table_index = ntohl (ip4_table_index);
20047 mp->ip6_table_index = ntohl (ip6_table_index);
20048 mp->l2_table_index = ntohl (l2_table_index);
20049 mp->is_add = is_add;
20057 api_policer_classify_dump (vat_main_t * vam)
20059 unformat_input_t *i = vam->input;
20060 vl_api_policer_classify_dump_t *mp;
20061 vl_api_control_ping_t *mp_ping;
20062 u8 type = POLICER_CLASSIFY_N_TABLES;
20065 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20069 errmsg ("classify table type must be specified");
20073 if (!vam->json_output)
20075 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20078 M (POLICER_CLASSIFY_DUMP, mp);
20083 /* Use a control ping for synchronization */
20084 MPING (CONTROL_PING, mp_ping);
20087 /* Wait for a reply... */
20093 api_netmap_create (vat_main_t * vam)
20095 unformat_input_t *i = vam->input;
20096 vl_api_netmap_create_t *mp;
20099 u8 random_hw_addr = 1;
20104 memset (hw_addr, 0, sizeof (hw_addr));
20106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20108 if (unformat (i, "name %s", &if_name))
20109 vec_add1 (if_name, 0);
20110 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20111 random_hw_addr = 0;
20112 else if (unformat (i, "pipe"))
20114 else if (unformat (i, "master"))
20116 else if (unformat (i, "slave"))
20122 if (!vec_len (if_name))
20124 errmsg ("interface name must be specified");
20128 if (vec_len (if_name) > 64)
20130 errmsg ("interface name too long");
20134 M (NETMAP_CREATE, mp);
20136 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20137 clib_memcpy (mp->hw_addr, hw_addr, 6);
20138 mp->use_random_hw_addr = random_hw_addr;
20139 mp->is_pipe = is_pipe;
20140 mp->is_master = is_master;
20141 vec_free (if_name);
20149 api_netmap_delete (vat_main_t * vam)
20151 unformat_input_t *i = vam->input;
20152 vl_api_netmap_delete_t *mp;
20156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20158 if (unformat (i, "name %s", &if_name))
20159 vec_add1 (if_name, 0);
20164 if (!vec_len (if_name))
20166 errmsg ("interface name must be specified");
20170 if (vec_len (if_name) > 64)
20172 errmsg ("interface name too long");
20176 M (NETMAP_DELETE, mp);
20178 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20179 vec_free (if_name);
20187 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20189 if (fp->afi == IP46_TYPE_IP6)
20191 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20192 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20193 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20194 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20195 format_ip6_address, fp->next_hop);
20196 else if (fp->afi == IP46_TYPE_IP4)
20198 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20199 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20200 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20201 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20202 format_ip4_address, fp->next_hop);
20206 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20207 vl_api_fib_path_t * fp)
20209 struct in_addr ip4;
20210 struct in6_addr ip6;
20212 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20213 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20214 vat_json_object_add_uint (node, "is_local", fp->is_local);
20215 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20216 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20217 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20218 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20219 if (fp->afi == IP46_TYPE_IP4)
20221 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20222 vat_json_object_add_ip4 (node, "next_hop", ip4);
20224 else if (fp->afi == IP46_TYPE_IP6)
20226 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20227 vat_json_object_add_ip6 (node, "next_hop", ip6);
20232 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20234 vat_main_t *vam = &vat_main;
20235 int count = ntohl (mp->mt_count);
20236 vl_api_fib_path_t *fp;
20239 print (vam->ofp, "[%d]: sw_if_index %d via:",
20240 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20242 for (i = 0; i < count; i++)
20244 vl_api_mpls_fib_path_print (vam, fp);
20248 print (vam->ofp, "");
20251 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20252 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20255 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20257 vat_main_t *vam = &vat_main;
20258 vat_json_node_t *node = NULL;
20259 int count = ntohl (mp->mt_count);
20260 vl_api_fib_path_t *fp;
20263 if (VAT_JSON_ARRAY != vam->json_tree.type)
20265 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20266 vat_json_init_array (&vam->json_tree);
20268 node = vat_json_array_add (&vam->json_tree);
20270 vat_json_init_object (node);
20271 vat_json_object_add_uint (node, "tunnel_index",
20272 ntohl (mp->mt_tunnel_index));
20273 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20275 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20278 for (i = 0; i < count; i++)
20280 vl_api_mpls_fib_path_json_print (node, fp);
20286 api_mpls_tunnel_dump (vat_main_t * vam)
20288 vl_api_mpls_tunnel_dump_t *mp;
20289 vl_api_control_ping_t *mp_ping;
20293 /* Parse args required to build the message */
20294 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20296 if (!unformat (vam->input, "tunnel_index %d", &index))
20303 print (vam->ofp, " tunnel_index %d", index);
20305 M (MPLS_TUNNEL_DUMP, mp);
20306 mp->tunnel_index = htonl (index);
20309 /* Use a control ping for synchronization */
20310 MPING (CONTROL_PING, mp_ping);
20317 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20318 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20322 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20324 vat_main_t *vam = &vat_main;
20325 int count = ntohl (mp->count);
20326 vl_api_fib_path_t *fp;
20330 "table-id %d, label %u, ess_bit %u",
20331 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20333 for (i = 0; i < count; i++)
20335 vl_api_mpls_fib_path_print (vam, fp);
20340 static void vl_api_mpls_fib_details_t_handler_json
20341 (vl_api_mpls_fib_details_t * mp)
20343 vat_main_t *vam = &vat_main;
20344 int count = ntohl (mp->count);
20345 vat_json_node_t *node = NULL;
20346 vl_api_fib_path_t *fp;
20349 if (VAT_JSON_ARRAY != vam->json_tree.type)
20351 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20352 vat_json_init_array (&vam->json_tree);
20354 node = vat_json_array_add (&vam->json_tree);
20356 vat_json_init_object (node);
20357 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20358 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20359 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20360 vat_json_object_add_uint (node, "path_count", count);
20362 for (i = 0; i < count; i++)
20364 vl_api_mpls_fib_path_json_print (node, fp);
20370 api_mpls_fib_dump (vat_main_t * vam)
20372 vl_api_mpls_fib_dump_t *mp;
20373 vl_api_control_ping_t *mp_ping;
20376 M (MPLS_FIB_DUMP, mp);
20379 /* Use a control ping for synchronization */
20380 MPING (CONTROL_PING, mp_ping);
20387 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20388 #define vl_api_ip_fib_details_t_print vl_noop_handler
20391 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20393 vat_main_t *vam = &vat_main;
20394 int count = ntohl (mp->count);
20395 vl_api_fib_path_t *fp;
20399 "table-id %d, prefix %U/%d",
20400 ntohl (mp->table_id), format_ip4_address, mp->address,
20401 mp->address_length);
20403 for (i = 0; i < count; i++)
20405 if (fp->afi == IP46_TYPE_IP6)
20407 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20408 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20409 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20410 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20411 format_ip6_address, fp->next_hop);
20412 else if (fp->afi == IP46_TYPE_IP4)
20414 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20415 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20416 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20417 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20418 format_ip4_address, fp->next_hop);
20423 static void vl_api_ip_fib_details_t_handler_json
20424 (vl_api_ip_fib_details_t * mp)
20426 vat_main_t *vam = &vat_main;
20427 int count = ntohl (mp->count);
20428 vat_json_node_t *node = NULL;
20429 struct in_addr ip4;
20430 struct in6_addr ip6;
20431 vl_api_fib_path_t *fp;
20434 if (VAT_JSON_ARRAY != vam->json_tree.type)
20436 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20437 vat_json_init_array (&vam->json_tree);
20439 node = vat_json_array_add (&vam->json_tree);
20441 vat_json_init_object (node);
20442 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20443 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20444 vat_json_object_add_ip4 (node, "prefix", ip4);
20445 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20446 vat_json_object_add_uint (node, "path_count", count);
20448 for (i = 0; i < count; i++)
20450 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20451 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20452 vat_json_object_add_uint (node, "is_local", fp->is_local);
20453 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20454 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20455 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20456 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20457 if (fp->afi == IP46_TYPE_IP4)
20459 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20460 vat_json_object_add_ip4 (node, "next_hop", ip4);
20462 else if (fp->afi == IP46_TYPE_IP6)
20464 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20465 vat_json_object_add_ip6 (node, "next_hop", ip6);
20471 api_ip_fib_dump (vat_main_t * vam)
20473 vl_api_ip_fib_dump_t *mp;
20474 vl_api_control_ping_t *mp_ping;
20477 M (IP_FIB_DUMP, mp);
20480 /* Use a control ping for synchronization */
20481 MPING (CONTROL_PING, mp_ping);
20489 api_ip_mfib_dump (vat_main_t * vam)
20491 vl_api_ip_mfib_dump_t *mp;
20492 vl_api_control_ping_t *mp_ping;
20495 M (IP_MFIB_DUMP, mp);
20498 /* Use a control ping for synchronization */
20499 MPING (CONTROL_PING, mp_ping);
20506 static void vl_api_ip_neighbor_details_t_handler
20507 (vl_api_ip_neighbor_details_t * mp)
20509 vat_main_t *vam = &vat_main;
20511 print (vam->ofp, "%c %U %U",
20512 (mp->is_static) ? 'S' : 'D',
20513 format_ethernet_address, &mp->mac_address,
20514 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20518 static void vl_api_ip_neighbor_details_t_handler_json
20519 (vl_api_ip_neighbor_details_t * mp)
20522 vat_main_t *vam = &vat_main;
20523 vat_json_node_t *node;
20524 struct in_addr ip4;
20525 struct in6_addr ip6;
20527 if (VAT_JSON_ARRAY != vam->json_tree.type)
20529 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20530 vat_json_init_array (&vam->json_tree);
20532 node = vat_json_array_add (&vam->json_tree);
20534 vat_json_init_object (node);
20535 vat_json_object_add_string_copy (node, "flag",
20536 (mp->is_static) ? (u8 *) "static" : (u8 *)
20539 vat_json_object_add_string_copy (node, "link_layer",
20540 format (0, "%U", format_ethernet_address,
20541 &mp->mac_address));
20545 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20546 vat_json_object_add_ip6 (node, "ip_address", ip6);
20550 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20551 vat_json_object_add_ip4 (node, "ip_address", ip4);
20556 api_ip_neighbor_dump (vat_main_t * vam)
20558 unformat_input_t *i = vam->input;
20559 vl_api_ip_neighbor_dump_t *mp;
20560 vl_api_control_ping_t *mp_ping;
20562 u32 sw_if_index = ~0;
20565 /* Parse args required to build the message */
20566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20568 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20570 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20572 else if (unformat (i, "ip6"))
20578 if (sw_if_index == ~0)
20580 errmsg ("missing interface name or sw_if_index");
20584 M (IP_NEIGHBOR_DUMP, mp);
20585 mp->is_ipv6 = (u8) is_ipv6;
20586 mp->sw_if_index = ntohl (sw_if_index);
20589 /* Use a control ping for synchronization */
20590 MPING (CONTROL_PING, mp_ping);
20597 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20598 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20601 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20603 vat_main_t *vam = &vat_main;
20604 int count = ntohl (mp->count);
20605 vl_api_fib_path_t *fp;
20609 "table-id %d, prefix %U/%d",
20610 ntohl (mp->table_id), format_ip6_address, mp->address,
20611 mp->address_length);
20613 for (i = 0; i < count; i++)
20615 if (fp->afi == IP46_TYPE_IP6)
20617 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20618 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20619 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20620 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20621 format_ip6_address, fp->next_hop);
20622 else if (fp->afi == IP46_TYPE_IP4)
20624 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20625 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20626 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20627 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20628 format_ip4_address, fp->next_hop);
20633 static void vl_api_ip6_fib_details_t_handler_json
20634 (vl_api_ip6_fib_details_t * mp)
20636 vat_main_t *vam = &vat_main;
20637 int count = ntohl (mp->count);
20638 vat_json_node_t *node = NULL;
20639 struct in_addr ip4;
20640 struct in6_addr ip6;
20641 vl_api_fib_path_t *fp;
20644 if (VAT_JSON_ARRAY != vam->json_tree.type)
20646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20647 vat_json_init_array (&vam->json_tree);
20649 node = vat_json_array_add (&vam->json_tree);
20651 vat_json_init_object (node);
20652 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20653 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20654 vat_json_object_add_ip6 (node, "prefix", ip6);
20655 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20656 vat_json_object_add_uint (node, "path_count", count);
20658 for (i = 0; i < count; i++)
20660 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20661 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20662 vat_json_object_add_uint (node, "is_local", fp->is_local);
20663 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20664 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20665 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20666 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20667 if (fp->afi == IP46_TYPE_IP4)
20669 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20670 vat_json_object_add_ip4 (node, "next_hop", ip4);
20672 else if (fp->afi == IP46_TYPE_IP6)
20674 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20675 vat_json_object_add_ip6 (node, "next_hop", ip6);
20681 api_ip6_fib_dump (vat_main_t * vam)
20683 vl_api_ip6_fib_dump_t *mp;
20684 vl_api_control_ping_t *mp_ping;
20687 M (IP6_FIB_DUMP, mp);
20690 /* Use a control ping for synchronization */
20691 MPING (CONTROL_PING, mp_ping);
20699 api_ip6_mfib_dump (vat_main_t * vam)
20701 vl_api_ip6_mfib_dump_t *mp;
20702 vl_api_control_ping_t *mp_ping;
20705 M (IP6_MFIB_DUMP, mp);
20708 /* Use a control ping for synchronization */
20709 MPING (CONTROL_PING, mp_ping);
20717 api_classify_table_ids (vat_main_t * vam)
20719 vl_api_classify_table_ids_t *mp;
20722 /* Construct the API message */
20723 M (CLASSIFY_TABLE_IDS, mp);
20732 api_classify_table_by_interface (vat_main_t * vam)
20734 unformat_input_t *input = vam->input;
20735 vl_api_classify_table_by_interface_t *mp;
20737 u32 sw_if_index = ~0;
20739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20741 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20743 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20748 if (sw_if_index == ~0)
20750 errmsg ("missing interface name or sw_if_index");
20754 /* Construct the API message */
20755 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20757 mp->sw_if_index = ntohl (sw_if_index);
20765 api_classify_table_info (vat_main_t * vam)
20767 unformat_input_t *input = vam->input;
20768 vl_api_classify_table_info_t *mp;
20772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20774 if (unformat (input, "table_id %d", &table_id))
20779 if (table_id == ~0)
20781 errmsg ("missing table id");
20785 /* Construct the API message */
20786 M (CLASSIFY_TABLE_INFO, mp);
20788 mp->table_id = ntohl (table_id);
20796 api_classify_session_dump (vat_main_t * vam)
20798 unformat_input_t *input = vam->input;
20799 vl_api_classify_session_dump_t *mp;
20800 vl_api_control_ping_t *mp_ping;
20804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20806 if (unformat (input, "table_id %d", &table_id))
20811 if (table_id == ~0)
20813 errmsg ("missing table id");
20817 /* Construct the API message */
20818 M (CLASSIFY_SESSION_DUMP, mp);
20820 mp->table_id = ntohl (table_id);
20823 /* Use a control ping for synchronization */
20824 MPING (CONTROL_PING, mp_ping);
20832 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20834 vat_main_t *vam = &vat_main;
20836 print (vam->ofp, "collector_address %U, collector_port %d, "
20837 "src_address %U, vrf_id %d, path_mtu %u, "
20838 "template_interval %u, udp_checksum %d",
20839 format_ip4_address, mp->collector_address,
20840 ntohs (mp->collector_port),
20841 format_ip4_address, mp->src_address,
20842 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20843 ntohl (mp->template_interval), mp->udp_checksum);
20846 vam->result_ready = 1;
20850 vl_api_ipfix_exporter_details_t_handler_json
20851 (vl_api_ipfix_exporter_details_t * mp)
20853 vat_main_t *vam = &vat_main;
20854 vat_json_node_t node;
20855 struct in_addr collector_address;
20856 struct in_addr src_address;
20858 vat_json_init_object (&node);
20859 clib_memcpy (&collector_address, &mp->collector_address,
20860 sizeof (collector_address));
20861 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20862 vat_json_object_add_uint (&node, "collector_port",
20863 ntohs (mp->collector_port));
20864 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20865 vat_json_object_add_ip4 (&node, "src_address", src_address);
20866 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20867 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20868 vat_json_object_add_uint (&node, "template_interval",
20869 ntohl (mp->template_interval));
20870 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20872 vat_json_print (vam->ofp, &node);
20873 vat_json_free (&node);
20875 vam->result_ready = 1;
20879 api_ipfix_exporter_dump (vat_main_t * vam)
20881 vl_api_ipfix_exporter_dump_t *mp;
20884 /* Construct the API message */
20885 M (IPFIX_EXPORTER_DUMP, mp);
20894 api_ipfix_classify_stream_dump (vat_main_t * vam)
20896 vl_api_ipfix_classify_stream_dump_t *mp;
20899 /* Construct the API message */
20900 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20911 vl_api_ipfix_classify_stream_details_t_handler
20912 (vl_api_ipfix_classify_stream_details_t * mp)
20914 vat_main_t *vam = &vat_main;
20915 print (vam->ofp, "domain_id %d, src_port %d",
20916 ntohl (mp->domain_id), ntohs (mp->src_port));
20918 vam->result_ready = 1;
20922 vl_api_ipfix_classify_stream_details_t_handler_json
20923 (vl_api_ipfix_classify_stream_details_t * mp)
20925 vat_main_t *vam = &vat_main;
20926 vat_json_node_t node;
20928 vat_json_init_object (&node);
20929 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20930 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20932 vat_json_print (vam->ofp, &node);
20933 vat_json_free (&node);
20935 vam->result_ready = 1;
20939 api_ipfix_classify_table_dump (vat_main_t * vam)
20941 vl_api_ipfix_classify_table_dump_t *mp;
20942 vl_api_control_ping_t *mp_ping;
20945 if (!vam->json_output)
20947 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20948 "transport_protocol");
20951 /* Construct the API message */
20952 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20957 /* Use a control ping for synchronization */
20958 MPING (CONTROL_PING, mp_ping);
20966 vl_api_ipfix_classify_table_details_t_handler
20967 (vl_api_ipfix_classify_table_details_t * mp)
20969 vat_main_t *vam = &vat_main;
20970 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20971 mp->transport_protocol);
20975 vl_api_ipfix_classify_table_details_t_handler_json
20976 (vl_api_ipfix_classify_table_details_t * mp)
20978 vat_json_node_t *node = NULL;
20979 vat_main_t *vam = &vat_main;
20981 if (VAT_JSON_ARRAY != vam->json_tree.type)
20983 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20984 vat_json_init_array (&vam->json_tree);
20987 node = vat_json_array_add (&vam->json_tree);
20988 vat_json_init_object (node);
20990 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20991 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20992 vat_json_object_add_uint (node, "transport_protocol",
20993 mp->transport_protocol);
20997 api_sw_interface_span_enable_disable (vat_main_t * vam)
20999 unformat_input_t *i = vam->input;
21000 vl_api_sw_interface_span_enable_disable_t *mp;
21001 u32 src_sw_if_index = ~0;
21002 u32 dst_sw_if_index = ~0;
21007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21010 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21012 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21016 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21018 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21020 else if (unformat (i, "disable"))
21022 else if (unformat (i, "rx"))
21024 else if (unformat (i, "tx"))
21026 else if (unformat (i, "both"))
21028 else if (unformat (i, "l2"))
21034 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21036 mp->sw_if_index_from = htonl (src_sw_if_index);
21037 mp->sw_if_index_to = htonl (dst_sw_if_index);
21047 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21050 vat_main_t *vam = &vat_main;
21051 u8 *sw_if_from_name = 0;
21052 u8 *sw_if_to_name = 0;
21053 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21054 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21055 char *states[] = { "none", "rx", "tx", "both" };
21059 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21061 if ((u32) p->value[0] == sw_if_index_from)
21063 sw_if_from_name = (u8 *)(p->key);
21067 if ((u32) p->value[0] == sw_if_index_to)
21069 sw_if_to_name = (u8 *)(p->key);
21070 if (sw_if_from_name)
21075 print (vam->ofp, "%20s => %20s (%s) %s",
21076 sw_if_from_name, sw_if_to_name, states[mp->state],
21077 mp->is_l2 ? "l2" : "device");
21081 vl_api_sw_interface_span_details_t_handler_json
21082 (vl_api_sw_interface_span_details_t * mp)
21084 vat_main_t *vam = &vat_main;
21085 vat_json_node_t *node = NULL;
21086 u8 *sw_if_from_name = 0;
21087 u8 *sw_if_to_name = 0;
21088 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21089 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21093 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21095 if ((u32) p->value[0] == sw_if_index_from)
21097 sw_if_from_name = (u8 *)(p->key);
21101 if ((u32) p->value[0] == sw_if_index_to)
21103 sw_if_to_name = (u8 *)(p->key);
21104 if (sw_if_from_name)
21110 if (VAT_JSON_ARRAY != vam->json_tree.type)
21112 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21113 vat_json_init_array (&vam->json_tree);
21115 node = vat_json_array_add (&vam->json_tree);
21117 vat_json_init_object (node);
21118 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21119 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21120 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21121 if (0 != sw_if_to_name)
21123 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21125 vat_json_object_add_uint (node, "state", mp->state);
21126 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21130 api_sw_interface_span_dump (vat_main_t * vam)
21132 unformat_input_t *input = vam->input;
21133 vl_api_sw_interface_span_dump_t *mp;
21134 vl_api_control_ping_t *mp_ping;
21138 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21140 if (unformat (input, "l2"))
21146 M (SW_INTERFACE_SPAN_DUMP, mp);
21150 /* Use a control ping for synchronization */
21151 MPING (CONTROL_PING, mp_ping);
21159 api_pg_create_interface (vat_main_t * vam)
21161 unformat_input_t *input = vam->input;
21162 vl_api_pg_create_interface_t *mp;
21166 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21168 if (unformat (input, "if_id %d", &if_id))
21175 errmsg ("missing pg interface index");
21179 /* Construct the API message */
21180 M (PG_CREATE_INTERFACE, mp);
21182 mp->interface_id = ntohl (if_id);
21190 api_pg_capture (vat_main_t * vam)
21192 unformat_input_t *input = vam->input;
21193 vl_api_pg_capture_t *mp;
21198 u8 pcap_file_set = 0;
21201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21203 if (unformat (input, "if_id %d", &if_id))
21205 else if (unformat (input, "pcap %s", &pcap_file))
21207 else if (unformat (input, "count %d", &count))
21209 else if (unformat (input, "disable"))
21216 errmsg ("missing pg interface index");
21219 if (pcap_file_set > 0)
21221 if (vec_len (pcap_file) > 255)
21223 errmsg ("pcap file name is too long");
21228 u32 name_len = vec_len (pcap_file);
21229 /* Construct the API message */
21230 M (PG_CAPTURE, mp);
21232 mp->interface_id = ntohl (if_id);
21233 mp->is_enabled = enable;
21234 mp->count = ntohl (count);
21235 mp->pcap_name_length = ntohl (name_len);
21236 if (pcap_file_set != 0)
21238 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21240 vec_free (pcap_file);
21248 api_pg_enable_disable (vat_main_t * vam)
21250 unformat_input_t *input = vam->input;
21251 vl_api_pg_enable_disable_t *mp;
21254 u8 stream_name_set = 0;
21255 u8 *stream_name = 0;
21257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21259 if (unformat (input, "stream %s", &stream_name))
21260 stream_name_set = 1;
21261 else if (unformat (input, "disable"))
21267 if (stream_name_set > 0)
21269 if (vec_len (stream_name) > 255)
21271 errmsg ("stream name too long");
21276 u32 name_len = vec_len (stream_name);
21277 /* Construct the API message */
21278 M (PG_ENABLE_DISABLE, mp);
21280 mp->is_enabled = enable;
21281 if (stream_name_set != 0)
21283 mp->stream_name_length = ntohl (name_len);
21284 clib_memcpy (mp->stream_name, stream_name, name_len);
21286 vec_free (stream_name);
21294 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21296 unformat_input_t *input = vam->input;
21297 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21299 u16 *low_ports = 0;
21300 u16 *high_ports = 0;
21303 ip4_address_t ip4_addr;
21304 ip6_address_t ip6_addr;
21313 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21315 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21321 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21326 else if (unformat (input, "vrf %d", &vrf_id))
21328 else if (unformat (input, "del"))
21330 else if (unformat (input, "port %d", &tmp))
21332 if (tmp == 0 || tmp > 65535)
21334 errmsg ("port %d out of range", tmp);
21338 this_hi = this_low + 1;
21339 vec_add1 (low_ports, this_low);
21340 vec_add1 (high_ports, this_hi);
21342 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21344 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21346 errmsg ("incorrect range parameters");
21350 /* Note: in debug CLI +1 is added to high before
21351 passing to real fn that does "the work"
21352 (ip_source_and_port_range_check_add_del).
21353 This fn is a wrapper around the binary API fn a
21354 control plane will call, which expects this increment
21355 to have occurred. Hence letting the binary API control
21356 plane fn do the increment for consistency between VAT
21357 and other control planes.
21360 vec_add1 (low_ports, this_low);
21361 vec_add1 (high_ports, this_hi);
21367 if (prefix_set == 0)
21369 errmsg ("<address>/<mask> not specified");
21375 errmsg ("VRF ID required, not specified");
21382 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21386 if (vec_len (low_ports) == 0)
21388 errmsg ("At least one port or port range required");
21392 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21394 mp->is_add = is_add;
21399 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21404 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21407 mp->mask_length = length;
21408 mp->number_of_ranges = vec_len (low_ports);
21410 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21411 vec_free (low_ports);
21413 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21414 vec_free (high_ports);
21416 mp->vrf_id = ntohl (vrf_id);
21424 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21426 unformat_input_t *input = vam->input;
21427 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21428 u32 sw_if_index = ~0;
21430 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21431 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21437 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21439 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21441 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21443 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21445 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21447 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21449 else if (unformat (input, "del"))
21455 if (sw_if_index == ~0)
21457 errmsg ("Interface required but not specified");
21463 errmsg ("VRF ID required but not specified");
21467 if (tcp_out_vrf_id == 0
21468 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21471 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21475 /* Construct the API message */
21476 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21478 mp->sw_if_index = ntohl (sw_if_index);
21479 mp->is_add = is_add;
21480 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21481 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21482 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21483 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21488 /* Wait for a reply... */
21494 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21496 unformat_input_t *i = vam->input;
21497 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21498 u32 local_sa_id = 0;
21499 u32 remote_sa_id = 0;
21500 ip4_address_t src_address;
21501 ip4_address_t dst_address;
21505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21507 if (unformat (i, "local_sa %d", &local_sa_id))
21509 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21511 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21513 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21515 else if (unformat (i, "del"))
21519 clib_warning ("parse error '%U'", format_unformat_error, i);
21524 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21526 mp->local_sa_id = ntohl (local_sa_id);
21527 mp->remote_sa_id = ntohl (remote_sa_id);
21528 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21529 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21530 mp->is_add = is_add;
21538 api_punt (vat_main_t * vam)
21540 unformat_input_t *i = vam->input;
21548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21550 if (unformat (i, "ip %d", &ipv))
21552 else if (unformat (i, "protocol %d", &protocol))
21554 else if (unformat (i, "port %d", &port))
21556 else if (unformat (i, "del"))
21560 clib_warning ("parse error '%U'", format_unformat_error, i);
21567 mp->is_add = (u8) is_add;
21568 mp->ipv = (u8) ipv;
21569 mp->l4_protocol = (u8) protocol;
21570 mp->l4_port = htons ((u16) port);
21577 static void vl_api_ipsec_gre_tunnel_details_t_handler
21578 (vl_api_ipsec_gre_tunnel_details_t * mp)
21580 vat_main_t *vam = &vat_main;
21582 print (vam->ofp, "%11d%15U%15U%14d%14d",
21583 ntohl (mp->sw_if_index),
21584 format_ip4_address, &mp->src_address,
21585 format_ip4_address, &mp->dst_address,
21586 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21589 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21590 (vl_api_ipsec_gre_tunnel_details_t * mp)
21592 vat_main_t *vam = &vat_main;
21593 vat_json_node_t *node = NULL;
21594 struct in_addr ip4;
21596 if (VAT_JSON_ARRAY != vam->json_tree.type)
21598 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21599 vat_json_init_array (&vam->json_tree);
21601 node = vat_json_array_add (&vam->json_tree);
21603 vat_json_init_object (node);
21604 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21605 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21606 vat_json_object_add_ip4 (node, "src_address", ip4);
21607 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21608 vat_json_object_add_ip4 (node, "dst_address", ip4);
21609 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21610 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21614 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21616 unformat_input_t *i = vam->input;
21617 vl_api_ipsec_gre_tunnel_dump_t *mp;
21618 vl_api_control_ping_t *mp_ping;
21620 u8 sw_if_index_set = 0;
21623 /* Parse args required to build the message */
21624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21626 if (unformat (i, "sw_if_index %d", &sw_if_index))
21627 sw_if_index_set = 1;
21632 if (sw_if_index_set == 0)
21637 if (!vam->json_output)
21639 print (vam->ofp, "%11s%15s%15s%14s%14s",
21640 "sw_if_index", "src_address", "dst_address",
21641 "local_sa_id", "remote_sa_id");
21644 /* Get list of gre-tunnel interfaces */
21645 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21647 mp->sw_if_index = htonl (sw_if_index);
21651 /* Use a control ping for synchronization */
21652 MPING (CONTROL_PING, mp_ping);
21660 api_delete_subif (vat_main_t * vam)
21662 unformat_input_t *i = vam->input;
21663 vl_api_delete_subif_t *mp;
21664 u32 sw_if_index = ~0;
21667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21669 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21671 if (unformat (i, "sw_if_index %d", &sw_if_index))
21677 if (sw_if_index == ~0)
21679 errmsg ("missing sw_if_index");
21683 /* Construct the API message */
21684 M (DELETE_SUBIF, mp);
21685 mp->sw_if_index = ntohl (sw_if_index);
21692 #define foreach_pbb_vtr_op \
21693 _("disable", L2_VTR_DISABLED) \
21694 _("pop", L2_VTR_POP_2) \
21695 _("push", L2_VTR_PUSH_2)
21698 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21700 unformat_input_t *i = vam->input;
21701 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21702 u32 sw_if_index = ~0, vtr_op = ~0;
21703 u16 outer_tag = ~0;
21704 u8 dmac[6], smac[6];
21705 u8 dmac_set = 0, smac_set = 0;
21711 /* Shut up coverity */
21712 memset (dmac, 0, sizeof (dmac));
21713 memset (smac, 0, sizeof (smac));
21715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21717 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21719 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21721 else if (unformat (i, "vtr_op %d", &vtr_op))
21723 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21726 else if (unformat (i, "translate_pbb_stag"))
21728 if (unformat (i, "%d", &tmp))
21730 vtr_op = L2_VTR_TRANSLATE_2_1;
21736 ("translate_pbb_stag operation requires outer tag definition");
21740 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21742 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21744 else if (unformat (i, "sid %d", &sid))
21746 else if (unformat (i, "vlanid %d", &tmp))
21750 clib_warning ("parse error '%U'", format_unformat_error, i);
21755 if ((sw_if_index == ~0) || (vtr_op == ~0))
21757 errmsg ("missing sw_if_index or vtr operation");
21760 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21761 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21764 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21768 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21769 mp->sw_if_index = ntohl (sw_if_index);
21770 mp->vtr_op = ntohl (vtr_op);
21771 mp->outer_tag = ntohs (outer_tag);
21772 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21773 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21774 mp->b_vlanid = ntohs (vlanid);
21775 mp->i_sid = ntohl (sid);
21783 api_flow_classify_set_interface (vat_main_t * vam)
21785 unformat_input_t *i = vam->input;
21786 vl_api_flow_classify_set_interface_t *mp;
21788 int sw_if_index_set;
21789 u32 ip4_table_index = ~0;
21790 u32 ip6_table_index = ~0;
21794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21797 sw_if_index_set = 1;
21798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21799 sw_if_index_set = 1;
21800 else if (unformat (i, "del"))
21802 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21804 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21808 clib_warning ("parse error '%U'", format_unformat_error, i);
21813 if (sw_if_index_set == 0)
21815 errmsg ("missing interface name or sw_if_index");
21819 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21821 mp->sw_if_index = ntohl (sw_if_index);
21822 mp->ip4_table_index = ntohl (ip4_table_index);
21823 mp->ip6_table_index = ntohl (ip6_table_index);
21824 mp->is_add = is_add;
21832 api_flow_classify_dump (vat_main_t * vam)
21834 unformat_input_t *i = vam->input;
21835 vl_api_flow_classify_dump_t *mp;
21836 vl_api_control_ping_t *mp_ping;
21837 u8 type = FLOW_CLASSIFY_N_TABLES;
21840 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21844 errmsg ("classify table type must be specified");
21848 if (!vam->json_output)
21850 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21853 M (FLOW_CLASSIFY_DUMP, mp);
21858 /* Use a control ping for synchronization */
21859 MPING (CONTROL_PING, mp_ping);
21862 /* Wait for a reply... */
21868 api_feature_enable_disable (vat_main_t * vam)
21870 unformat_input_t *i = vam->input;
21871 vl_api_feature_enable_disable_t *mp;
21873 u8 *feature_name = 0;
21874 u32 sw_if_index = ~0;
21878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21880 if (unformat (i, "arc_name %s", &arc_name))
21882 else if (unformat (i, "feature_name %s", &feature_name))
21885 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21887 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21889 else if (unformat (i, "disable"))
21897 errmsg ("missing arc name");
21900 if (vec_len (arc_name) > 63)
21902 errmsg ("arc name too long");
21905 if (feature_name == 0)
21907 errmsg ("missing feature name");
21910 if (vec_len (feature_name) > 63)
21912 errmsg ("feature name too long");
21915 if (sw_if_index == ~0)
21917 errmsg ("missing interface name or sw_if_index");
21921 /* Construct the API message */
21922 M (FEATURE_ENABLE_DISABLE, mp);
21923 mp->sw_if_index = ntohl (sw_if_index);
21924 mp->enable = enable;
21925 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21926 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21927 vec_free (arc_name);
21928 vec_free (feature_name);
21936 api_sw_interface_tag_add_del (vat_main_t * vam)
21938 unformat_input_t *i = vam->input;
21939 vl_api_sw_interface_tag_add_del_t *mp;
21940 u32 sw_if_index = ~0;
21945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21947 if (unformat (i, "tag %s", &tag))
21949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21953 else if (unformat (i, "del"))
21959 if (sw_if_index == ~0)
21961 errmsg ("missing interface name or sw_if_index");
21965 if (enable && (tag == 0))
21967 errmsg ("no tag specified");
21971 /* Construct the API message */
21972 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21973 mp->sw_if_index = ntohl (sw_if_index);
21974 mp->is_add = enable;
21976 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21984 static void vl_api_l2_xconnect_details_t_handler
21985 (vl_api_l2_xconnect_details_t * mp)
21987 vat_main_t *vam = &vat_main;
21989 print (vam->ofp, "%15d%15d",
21990 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21993 static void vl_api_l2_xconnect_details_t_handler_json
21994 (vl_api_l2_xconnect_details_t * mp)
21996 vat_main_t *vam = &vat_main;
21997 vat_json_node_t *node = NULL;
21999 if (VAT_JSON_ARRAY != vam->json_tree.type)
22001 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22002 vat_json_init_array (&vam->json_tree);
22004 node = vat_json_array_add (&vam->json_tree);
22006 vat_json_init_object (node);
22007 vat_json_object_add_uint (node, "rx_sw_if_index",
22008 ntohl (mp->rx_sw_if_index));
22009 vat_json_object_add_uint (node, "tx_sw_if_index",
22010 ntohl (mp->tx_sw_if_index));
22014 api_l2_xconnect_dump (vat_main_t * vam)
22016 vl_api_l2_xconnect_dump_t *mp;
22017 vl_api_control_ping_t *mp_ping;
22020 if (!vam->json_output)
22022 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22025 M (L2_XCONNECT_DUMP, mp);
22029 /* Use a control ping for synchronization */
22030 MPING (CONTROL_PING, mp_ping);
22038 api_sw_interface_set_mtu (vat_main_t * vam)
22040 unformat_input_t *i = vam->input;
22041 vl_api_sw_interface_set_mtu_t *mp;
22042 u32 sw_if_index = ~0;
22046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22048 if (unformat (i, "mtu %d", &mtu))
22050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22058 if (sw_if_index == ~0)
22060 errmsg ("missing interface name or sw_if_index");
22066 errmsg ("no mtu specified");
22070 /* Construct the API message */
22071 M (SW_INTERFACE_SET_MTU, mp);
22072 mp->sw_if_index = ntohl (sw_if_index);
22073 mp->mtu = ntohs ((u16) mtu);
22081 api_p2p_ethernet_add (vat_main_t * vam)
22083 unformat_input_t *i = vam->input;
22084 vl_api_p2p_ethernet_add_t *mp;
22085 u32 parent_if_index = ~0;
22091 memset (remote_mac, 0, sizeof (remote_mac));
22092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22096 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22100 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22102 else if (unformat (i, "sub_id %d", &sub_id))
22106 clib_warning ("parse error '%U'", format_unformat_error, i);
22111 if (parent_if_index == ~0)
22113 errmsg ("missing interface name or sw_if_index");
22118 errmsg ("missing remote mac address");
22123 errmsg ("missing sub-interface id");
22127 M (P2P_ETHERNET_ADD, mp);
22128 mp->parent_if_index = ntohl (parent_if_index);
22129 mp->subif_id = ntohl (sub_id);
22130 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22138 api_p2p_ethernet_del (vat_main_t * vam)
22140 unformat_input_t *i = vam->input;
22141 vl_api_p2p_ethernet_del_t *mp;
22142 u32 parent_if_index = ~0;
22147 memset (remote_mac, 0, sizeof (remote_mac));
22148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22152 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22156 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22160 clib_warning ("parse error '%U'", format_unformat_error, i);
22165 if (parent_if_index == ~0)
22167 errmsg ("missing interface name or sw_if_index");
22172 errmsg ("missing remote mac address");
22176 M (P2P_ETHERNET_DEL, mp);
22177 mp->parent_if_index = ntohl (parent_if_index);
22178 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22186 api_lldp_config (vat_main_t * vam)
22188 unformat_input_t *i = vam->input;
22189 vl_api_lldp_config_t *mp;
22191 int tx_interval = 0;
22192 u8 *sys_name = NULL;
22195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22197 if (unformat (i, "system-name %s", &sys_name))
22199 else if (unformat (i, "tx-hold %d", &tx_hold))
22201 else if (unformat (i, "tx-interval %d", &tx_interval))
22205 clib_warning ("parse error '%U'", format_unformat_error, i);
22210 vec_add1 (sys_name, 0);
22212 M (LLDP_CONFIG, mp);
22213 mp->tx_hold = htonl (tx_hold);
22214 mp->tx_interval = htonl (tx_interval);
22215 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22216 vec_free (sys_name);
22224 api_sw_interface_set_lldp (vat_main_t * vam)
22226 unformat_input_t *i = vam->input;
22227 vl_api_sw_interface_set_lldp_t *mp;
22228 u32 sw_if_index = ~0;
22230 u8 *port_desc = NULL, *mgmt_oid = NULL;
22231 ip4_address_t ip4_addr;
22232 ip6_address_t ip6_addr;
22235 memset (&ip4_addr, 0, sizeof (ip4_addr));
22236 memset (&ip6_addr, 0, sizeof (ip6_addr));
22238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22240 if (unformat (i, "disable"))
22243 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22245 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22247 else if (unformat (i, "port-desc %s", &port_desc))
22249 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22251 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22253 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22259 if (sw_if_index == ~0)
22261 errmsg ("missing interface name or sw_if_index");
22265 /* Construct the API message */
22266 vec_add1 (port_desc, 0);
22267 vec_add1 (mgmt_oid, 0);
22268 M (SW_INTERFACE_SET_LLDP, mp);
22269 mp->sw_if_index = ntohl (sw_if_index);
22270 mp->enable = enable;
22271 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22272 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22273 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22274 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22275 vec_free (port_desc);
22276 vec_free (mgmt_oid);
22284 api_tcp_configure_src_addresses (vat_main_t * vam)
22286 vl_api_tcp_configure_src_addresses_t *mp;
22287 unformat_input_t *i = vam->input;
22288 ip4_address_t v4first, v4last;
22289 ip6_address_t v6first, v6last;
22294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22296 if (unformat (i, "%U - %U",
22297 unformat_ip4_address, &v4first,
22298 unformat_ip4_address, &v4last))
22302 errmsg ("one range per message (range already set)");
22307 else if (unformat (i, "%U - %U",
22308 unformat_ip6_address, &v6first,
22309 unformat_ip6_address, &v6last))
22313 errmsg ("one range per message (range already set)");
22318 else if (unformat (i, "vrf %d", &vrf_id))
22324 if (range_set == 0)
22326 errmsg ("address range not set");
22330 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22331 mp->vrf_id = ntohl (vrf_id);
22333 if (range_set == 2)
22336 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22337 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22342 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22343 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22350 static void vl_api_app_namespace_add_del_reply_t_handler
22351 (vl_api_app_namespace_add_del_reply_t * mp)
22353 vat_main_t *vam = &vat_main;
22354 i32 retval = ntohl (mp->retval);
22355 if (vam->async_mode)
22357 vam->async_errors += (retval < 0);
22361 vam->retval = retval;
22363 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22364 vam->result_ready = 1;
22368 static void vl_api_app_namespace_add_del_reply_t_handler_json
22369 (vl_api_app_namespace_add_del_reply_t * mp)
22371 vat_main_t *vam = &vat_main;
22372 vat_json_node_t node;
22374 vat_json_init_object (&node);
22375 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22376 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22378 vat_json_print (vam->ofp, &node);
22379 vat_json_free (&node);
22381 vam->retval = ntohl (mp->retval);
22382 vam->result_ready = 1;
22386 api_app_namespace_add_del (vat_main_t * vam)
22388 vl_api_app_namespace_add_del_t *mp;
22389 unformat_input_t *i = vam->input;
22390 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22391 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22397 if (unformat (i, "id %_%v%_", &ns_id))
22399 else if (unformat (i, "secret %lu", &secret))
22401 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22402 sw_if_index_set = 1;
22403 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22405 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22410 if (!ns_id || !secret_set || !sw_if_index_set)
22412 errmsg ("namespace id, secret and sw_if_index must be set");
22415 if (vec_len (ns_id) > 64)
22417 errmsg ("namespace id too long");
22420 M (APP_NAMESPACE_ADD_DEL, mp);
22422 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22423 mp->namespace_id_len = vec_len (ns_id);
22424 mp->secret = clib_host_to_net_u64 (secret);
22425 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22426 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22427 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22435 api_sock_init_shm (vat_main_t * vam)
22437 #if VPP_API_TEST_BUILTIN == 0
22438 unformat_input_t *i = vam->input;
22439 vl_api_shm_elem_config_t *config = 0;
22440 u64 size = 64 << 20;
22443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22445 if (unformat (i, "size %U", unformat_memory_size, &size))
22452 * Canned custom ring allocator config.
22453 * Should probably parse all of this
22455 vec_validate (config, 6);
22456 config[0].type = VL_API_VLIB_RING;
22457 config[0].size = 256;
22458 config[0].count = 32;
22460 config[1].type = VL_API_VLIB_RING;
22461 config[1].size = 1024;
22462 config[1].count = 16;
22464 config[2].type = VL_API_VLIB_RING;
22465 config[2].size = 4096;
22466 config[2].count = 2;
22468 config[3].type = VL_API_CLIENT_RING;
22469 config[3].size = 256;
22470 config[3].count = 32;
22472 config[4].type = VL_API_CLIENT_RING;
22473 config[4].size = 1024;
22474 config[4].count = 16;
22476 config[5].type = VL_API_CLIENT_RING;
22477 config[5].size = 4096;
22478 config[5].count = 2;
22480 config[6].type = VL_API_QUEUE;
22481 config[6].count = 128;
22482 config[6].size = sizeof (uword);
22484 rv = vl_socket_client_init_shm (config);
22486 vam->client_index_invalid = 1;
22494 api_dns_enable_disable (vat_main_t * vam)
22496 unformat_input_t *line_input = vam->input;
22497 vl_api_dns_enable_disable_t *mp;
22498 u8 enable_disable = 1;
22501 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22503 if (unformat (line_input, "disable"))
22504 enable_disable = 0;
22505 if (unformat (line_input, "enable"))
22506 enable_disable = 1;
22511 /* Construct the API message */
22512 M (DNS_ENABLE_DISABLE, mp);
22513 mp->enable = enable_disable;
22517 /* Wait for the reply */
22523 api_dns_resolve_name (vat_main_t * vam)
22525 unformat_input_t *line_input = vam->input;
22526 vl_api_dns_resolve_name_t *mp;
22530 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22532 if (unformat (line_input, "%s", &name))
22538 if (vec_len (name) > 127)
22540 errmsg ("name too long");
22544 /* Construct the API message */
22545 M (DNS_RESOLVE_NAME, mp);
22546 memcpy (mp->name, name, vec_len (name));
22551 /* Wait for the reply */
22557 api_dns_resolve_ip (vat_main_t * vam)
22559 unformat_input_t *line_input = vam->input;
22560 vl_api_dns_resolve_ip_t *mp;
22562 ip4_address_t addr4;
22563 ip6_address_t addr6;
22566 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22568 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22570 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22578 errmsg ("missing address");
22582 /* Construct the API message */
22583 M (DNS_RESOLVE_IP, mp);
22584 mp->is_ip6 = is_ip6;
22586 memcpy (mp->address, &addr6, sizeof (addr6));
22588 memcpy (mp->address, &addr4, sizeof (addr4));
22592 /* Wait for the reply */
22598 api_dns_name_server_add_del (vat_main_t * vam)
22600 unformat_input_t *i = vam->input;
22601 vl_api_dns_name_server_add_del_t *mp;
22603 ip6_address_t ip6_server;
22604 ip4_address_t ip4_server;
22609 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22611 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22613 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22615 else if (unformat (i, "del"))
22619 clib_warning ("parse error '%U'", format_unformat_error, i);
22624 if (ip4_set && ip6_set)
22626 errmsg ("Only one server address allowed per message");
22629 if ((ip4_set + ip6_set) == 0)
22631 errmsg ("Server address required");
22635 /* Construct the API message */
22636 M (DNS_NAME_SERVER_ADD_DEL, mp);
22640 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22645 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22649 mp->is_add = is_add;
22654 /* Wait for a reply, return good/bad news */
22660 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22662 vat_main_t *vam = &vat_main;
22667 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22668 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22669 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22670 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22671 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22672 clib_net_to_host_u32 (mp->action_index), mp->tag);
22677 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22678 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22679 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22680 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22681 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22682 clib_net_to_host_u32 (mp->action_index), mp->tag);
22687 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22690 vat_main_t *vam = &vat_main;
22691 vat_json_node_t *node = NULL;
22692 struct in6_addr ip6;
22693 struct in_addr ip4;
22695 if (VAT_JSON_ARRAY != vam->json_tree.type)
22697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22698 vat_json_init_array (&vam->json_tree);
22700 node = vat_json_array_add (&vam->json_tree);
22701 vat_json_init_object (node);
22703 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22704 vat_json_object_add_uint (node, "appns_index",
22705 clib_net_to_host_u32 (mp->appns_index));
22706 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22707 vat_json_object_add_uint (node, "scope", mp->scope);
22708 vat_json_object_add_uint (node, "action_index",
22709 clib_net_to_host_u32 (mp->action_index));
22710 vat_json_object_add_uint (node, "lcl_port",
22711 clib_net_to_host_u16 (mp->lcl_port));
22712 vat_json_object_add_uint (node, "rmt_port",
22713 clib_net_to_host_u16 (mp->rmt_port));
22714 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22715 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22716 vat_json_object_add_string_copy (node, "tag", mp->tag);
22719 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22720 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22721 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22722 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22726 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22727 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22728 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22729 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22734 api_session_rule_add_del (vat_main_t * vam)
22736 vl_api_session_rule_add_del_t *mp;
22737 unformat_input_t *i = vam->input;
22738 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22739 u32 appns_index = 0, scope = 0;
22740 ip4_address_t lcl_ip4, rmt_ip4;
22741 ip6_address_t lcl_ip6, rmt_ip6;
22742 u8 is_ip4 = 1, conn_set = 0;
22743 u8 is_add = 1, *tag = 0;
22746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22748 if (unformat (i, "del"))
22750 else if (unformat (i, "add"))
22752 else if (unformat (i, "proto tcp"))
22754 else if (unformat (i, "proto udp"))
22756 else if (unformat (i, "appns %d", &appns_index))
22758 else if (unformat (i, "scope %d", &scope))
22760 else if (unformat (i, "tag %_%v%_", &tag))
22764 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22765 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22773 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22774 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22780 else if (unformat (i, "action %d", &action))
22785 if (proto == ~0 || !conn_set || action == ~0)
22787 errmsg ("transport proto, connection and action must be set");
22793 errmsg ("scope should be 0-3");
22797 M (SESSION_RULE_ADD_DEL, mp);
22799 mp->is_ip4 = is_ip4;
22800 mp->transport_proto = proto;
22801 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22802 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22803 mp->lcl_plen = lcl_plen;
22804 mp->rmt_plen = rmt_plen;
22805 mp->action_index = clib_host_to_net_u32 (action);
22806 mp->appns_index = clib_host_to_net_u32 (appns_index);
22808 mp->is_add = is_add;
22811 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22812 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22816 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22817 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22821 clib_memcpy (mp->tag, tag, vec_len (tag));
22831 api_session_rules_dump (vat_main_t * vam)
22833 vl_api_session_rules_dump_t *mp;
22834 vl_api_control_ping_t *mp_ping;
22837 if (!vam->json_output)
22839 print (vam->ofp, "%=20s", "Session Rules");
22842 M (SESSION_RULES_DUMP, mp);
22846 /* Use a control ping for synchronization */
22847 MPING (CONTROL_PING, mp_ping);
22850 /* Wait for a reply... */
22856 api_ip_container_proxy_add_del (vat_main_t * vam)
22858 vl_api_ip_container_proxy_add_del_t *mp;
22859 unformat_input_t *i = vam->input;
22860 u32 plen = ~0, sw_if_index = ~0;
22867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22869 if (unformat (i, "del"))
22871 else if (unformat (i, "add"))
22873 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22878 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22883 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22888 if (sw_if_index == ~0 || plen == ~0)
22890 errmsg ("address and sw_if_index must be set");
22894 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22896 mp->is_ip4 = is_ip4;
22897 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22899 mp->is_add = is_add;
22901 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22903 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22911 api_qos_record_enable_disable (vat_main_t * vam)
22913 unformat_input_t *i = vam->input;
22914 vl_api_qos_record_enable_disable_t *mp;
22915 u32 sw_if_index, qs = 0xff;
22916 u8 sw_if_index_set = 0;
22920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22923 sw_if_index_set = 1;
22924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22925 sw_if_index_set = 1;
22926 else if (unformat (i, "%U", unformat_qos_source, &qs))
22928 else if (unformat (i, "disable"))
22932 clib_warning ("parse error '%U'", format_unformat_error, i);
22937 if (sw_if_index_set == 0)
22939 errmsg ("missing interface name or sw_if_index");
22944 errmsg ("input location must be specified");
22948 M (QOS_RECORD_ENABLE_DISABLE, mp);
22950 mp->sw_if_index = ntohl (sw_if_index);
22951 mp->input_source = qs;
22952 mp->enable = enable;
22960 q_or_quit (vat_main_t * vam)
22962 #if VPP_API_TEST_BUILTIN == 0
22963 longjmp (vam->jump_buf, 1);
22965 return 0; /* not so much */
22969 q (vat_main_t * vam)
22971 return q_or_quit (vam);
22975 quit (vat_main_t * vam)
22977 return q_or_quit (vam);
22981 comment (vat_main_t * vam)
22987 cmd_cmp (void *a1, void *a2)
22992 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22996 help (vat_main_t * vam)
23001 unformat_input_t *i = vam->input;
23004 if (unformat (i, "%s", &name))
23008 vec_add1 (name, 0);
23010 hs = hash_get_mem (vam->help_by_name, name);
23012 print (vam->ofp, "usage: %s %s", name, hs[0]);
23014 print (vam->ofp, "No such msg / command '%s'", name);
23019 print (vam->ofp, "Help is available for the following:");
23022 hash_foreach_pair (p, vam->function_by_name,
23024 vec_add1 (cmds, (u8 *)(p->key));
23028 vec_sort_with_function (cmds, cmd_cmp);
23030 for (j = 0; j < vec_len (cmds); j++)
23031 print (vam->ofp, "%s", cmds[j]);
23038 set (vat_main_t * vam)
23040 u8 *name = 0, *value = 0;
23041 unformat_input_t *i = vam->input;
23043 if (unformat (i, "%s", &name))
23045 /* The input buffer is a vector, not a string. */
23046 value = vec_dup (i->buffer);
23047 vec_delete (value, i->index, 0);
23048 /* Almost certainly has a trailing newline */
23049 if (value[vec_len (value) - 1] == '\n')
23050 value[vec_len (value) - 1] = 0;
23051 /* Make sure it's a proper string, one way or the other */
23052 vec_add1 (value, 0);
23053 (void) clib_macro_set_value (&vam->macro_main,
23054 (char *) name, (char *) value);
23057 errmsg ("usage: set <name> <value>");
23065 unset (vat_main_t * vam)
23069 if (unformat (vam->input, "%s", &name))
23070 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23071 errmsg ("unset: %s wasn't set", name);
23084 macro_sort_cmp (void *a1, void *a2)
23086 macro_sort_t *s1 = a1;
23087 macro_sort_t *s2 = a2;
23089 return strcmp ((char *) (s1->name), (char *) (s2->name));
23093 dump_macro_table (vat_main_t * vam)
23095 macro_sort_t *sort_me = 0, *sm;
23100 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23102 vec_add2 (sort_me, sm, 1);
23103 sm->name = (u8 *)(p->key);
23104 sm->value = (u8 *) (p->value[0]);
23108 vec_sort_with_function (sort_me, macro_sort_cmp);
23110 if (vec_len (sort_me))
23111 print (vam->ofp, "%-15s%s", "Name", "Value");
23113 print (vam->ofp, "The macro table is empty...");
23115 for (i = 0; i < vec_len (sort_me); i++)
23116 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23121 dump_node_table (vat_main_t * vam)
23124 vlib_node_t *node, *next_node;
23126 if (vec_len (vam->graph_nodes) == 0)
23128 print (vam->ofp, "Node table empty, issue get_node_graph...");
23132 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23134 node = vam->graph_nodes[i];
23135 print (vam->ofp, "[%d] %s", i, node->name);
23136 for (j = 0; j < vec_len (node->next_nodes); j++)
23138 if (node->next_nodes[j] != ~0)
23140 next_node = vam->graph_nodes[node->next_nodes[j]];
23141 print (vam->ofp, " [%d] %s", j, next_node->name);
23149 value_sort_cmp (void *a1, void *a2)
23151 name_sort_t *n1 = a1;
23152 name_sort_t *n2 = a2;
23154 if (n1->value < n2->value)
23156 if (n1->value > n2->value)
23163 dump_msg_api_table (vat_main_t * vam)
23165 api_main_t *am = &api_main;
23166 name_sort_t *nses = 0, *ns;
23171 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23173 vec_add2 (nses, ns, 1);
23174 ns->name = (u8 *)(hp->key);
23175 ns->value = (u32) hp->value[0];
23179 vec_sort_with_function (nses, value_sort_cmp);
23181 for (i = 0; i < vec_len (nses); i++)
23182 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23188 get_msg_id (vat_main_t * vam)
23193 if (unformat (vam->input, "%s", &name_and_crc))
23195 message_index = vl_msg_api_get_msg_index (name_and_crc);
23196 if (message_index == ~0)
23198 print (vam->ofp, " '%s' not found", name_and_crc);
23201 print (vam->ofp, " '%s' has message index %d",
23202 name_and_crc, message_index);
23205 errmsg ("name_and_crc required...");
23210 search_node_table (vat_main_t * vam)
23212 unformat_input_t *line_input = vam->input;
23215 vlib_node_t *node, *next_node;
23218 if (vam->graph_node_index_by_name == 0)
23220 print (vam->ofp, "Node table empty, issue get_node_graph...");
23224 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23226 if (unformat (line_input, "%s", &node_to_find))
23228 vec_add1 (node_to_find, 0);
23229 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23232 print (vam->ofp, "%s not found...", node_to_find);
23235 node = vam->graph_nodes[p[0]];
23236 print (vam->ofp, "[%d] %s", p[0], node->name);
23237 for (j = 0; j < vec_len (node->next_nodes); j++)
23239 if (node->next_nodes[j] != ~0)
23241 next_node = vam->graph_nodes[node->next_nodes[j]];
23242 print (vam->ofp, " [%d] %s", j, next_node->name);
23249 clib_warning ("parse error '%U'", format_unformat_error,
23255 vec_free (node_to_find);
23264 script (vat_main_t * vam)
23266 #if (VPP_API_TEST_BUILTIN==0)
23268 char *save_current_file;
23269 unformat_input_t save_input;
23270 jmp_buf save_jump_buf;
23271 u32 save_line_number;
23273 FILE *new_fp, *save_ifp;
23275 if (unformat (vam->input, "%s", &s))
23277 new_fp = fopen ((char *) s, "r");
23280 errmsg ("Couldn't open script file %s", s);
23287 errmsg ("Missing script name");
23291 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23292 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23293 save_ifp = vam->ifp;
23294 save_line_number = vam->input_line_number;
23295 save_current_file = (char *) vam->current_file;
23297 vam->input_line_number = 0;
23299 vam->current_file = s;
23302 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23303 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23304 vam->ifp = save_ifp;
23305 vam->input_line_number = save_line_number;
23306 vam->current_file = (u8 *) save_current_file;
23311 clib_warning ("use the exec command...");
23317 echo (vat_main_t * vam)
23319 print (vam->ofp, "%v", vam->input->buffer);
23323 /* List of API message constructors, CLI names map to api_xxx */
23324 #define foreach_vpe_api_msg \
23325 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23326 _(sw_interface_dump,"") \
23327 _(sw_interface_set_flags, \
23328 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23329 _(sw_interface_add_del_address, \
23330 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23331 _(sw_interface_set_rx_mode, \
23332 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23333 _(sw_interface_set_table, \
23334 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23335 _(sw_interface_set_mpls_enable, \
23336 "<intfc> | sw_if_index [disable | dis]") \
23337 _(sw_interface_set_vpath, \
23338 "<intfc> | sw_if_index <id> enable | disable") \
23339 _(sw_interface_set_vxlan_bypass, \
23340 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23341 _(sw_interface_set_geneve_bypass, \
23342 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23343 _(sw_interface_set_l2_xconnect, \
23344 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23345 "enable | disable") \
23346 _(sw_interface_set_l2_bridge, \
23347 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23348 "[shg <split-horizon-group>] [bvi]\n" \
23349 "enable | disable") \
23350 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23351 _(bridge_domain_add_del, \
23352 "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") \
23353 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23355 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23356 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23357 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23359 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23361 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23363 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23365 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23367 "<vpp-if-name> | sw_if_index <id>") \
23368 _(sw_interface_tap_dump, "") \
23370 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23372 "<vpp-if-name> | sw_if_index <id>") \
23373 _(sw_interface_tap_v2_dump, "") \
23375 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23376 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23378 "<vpp-if-name> | sw_if_index <id>") \
23380 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23381 _(bond_detach_slave, \
23382 "sw_if_index <n>") \
23383 _(sw_interface_bond_dump, "") \
23384 _(sw_interface_slave_dump, \
23385 "<vpp-if-name> | sw_if_index <id>") \
23386 _(ip_table_add_del, \
23387 "table-id <n> [ipv6]\n") \
23388 _(ip_add_del_route, \
23389 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23390 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23391 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23392 "[multipath] [count <n>]") \
23393 _(ip_mroute_add_del, \
23394 "<src> <grp>/<mask> [table-id <n>]\n" \
23395 "[<intfc> | sw_if_index <id>] [local] [del]") \
23396 _(mpls_table_add_del, \
23397 "table-id <n>\n") \
23398 _(mpls_route_add_del, \
23399 "<label> <eos> via <addr> [table-id <n>]\n" \
23400 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23401 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23402 "[multipath] [count <n>]") \
23403 _(mpls_ip_bind_unbind, \
23404 "<label> <addr/len>") \
23405 _(mpls_tunnel_add_del, \
23406 " via <addr> [table-id <n>]\n" \
23407 "sw_if_index <id>] [l2] [del]") \
23408 _(bier_table_add_del, \
23409 "<label> <sub-domain> <set> <bsl> [del]") \
23410 _(bier_route_add_del, \
23411 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23412 "[<intfc> | sw_if_index <id>]" \
23413 "[weight <n>] [del] [multipath]") \
23414 _(proxy_arp_add_del, \
23415 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23416 _(proxy_arp_intfc_enable_disable, \
23417 "<intfc> | sw_if_index <id> enable | disable") \
23418 _(sw_interface_set_unnumbered, \
23419 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23420 _(ip_neighbor_add_del, \
23421 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23422 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23423 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23424 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23425 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23426 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23427 "[outer_vlan_id_any][inner_vlan_id_any]") \
23428 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23429 _(reset_fib, "vrf <n> [ipv6]") \
23430 _(dhcp_proxy_config, \
23431 "svr <v46-address> src <v46-address>\n" \
23432 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23433 _(dhcp_proxy_set_vss, \
23434 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23435 _(dhcp_proxy_dump, "ip6") \
23436 _(dhcp_client_config, \
23437 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23438 _(set_ip_flow_hash, \
23439 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23440 _(sw_interface_ip6_enable_disable, \
23441 "<intfc> | sw_if_index <id> enable | disable") \
23442 _(sw_interface_ip6_set_link_local_address, \
23443 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23444 _(ip6nd_proxy_add_del, \
23445 "<intfc> | sw_if_index <id> <ip6-address>") \
23446 _(ip6nd_proxy_dump, "") \
23447 _(sw_interface_ip6nd_ra_prefix, \
23448 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23449 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23450 "[nolink] [isno]") \
23451 _(sw_interface_ip6nd_ra_config, \
23452 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23453 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23454 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23455 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23456 _(l2_patch_add_del, \
23457 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23458 "enable | disable") \
23459 _(sr_localsid_add_del, \
23460 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23461 "fib-table <num> (end.psp) sw_if_index <num>") \
23462 _(classify_add_del_table, \
23463 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23464 " [del] [del-chain] mask <mask-value>\n" \
23465 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23466 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23467 _(classify_add_del_session, \
23468 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23469 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23470 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23471 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23472 _(classify_set_interface_ip_table, \
23473 "<intfc> | sw_if_index <nn> table <nn>") \
23474 _(classify_set_interface_l2_tables, \
23475 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23476 " [other-table <nn>]") \
23477 _(get_node_index, "node <node-name") \
23478 _(add_node_next, "node <node-name> next <next-node-name>") \
23479 _(l2tpv3_create_tunnel, \
23480 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23481 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23482 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23483 _(l2tpv3_set_tunnel_cookies, \
23484 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23485 "[new_remote_cookie <nn>]\n") \
23486 _(l2tpv3_interface_enable_disable, \
23487 "<intfc> | sw_if_index <nn> enable | disable") \
23488 _(l2tpv3_set_lookup_key, \
23489 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23490 _(sw_if_l2tpv3_tunnel_dump, "") \
23491 _(vxlan_add_del_tunnel, \
23492 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23493 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23494 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23495 _(geneve_add_del_tunnel, \
23496 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23497 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23498 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23499 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23500 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23501 _(gre_add_del_tunnel, \
23502 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23503 "[teb | erspan <session-id>] [del]") \
23504 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23505 _(l2_fib_clear_table, "") \
23506 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23507 _(l2_interface_vlan_tag_rewrite, \
23508 "<intfc> | sw_if_index <nn> \n" \
23509 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23510 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23511 _(create_vhost_user_if, \
23512 "socket <filename> [server] [renumber <dev_instance>] " \
23513 "[mac <mac_address>]") \
23514 _(modify_vhost_user_if, \
23515 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23516 "[server] [renumber <dev_instance>]") \
23517 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23518 _(sw_interface_vhost_user_dump, "") \
23519 _(show_version, "") \
23520 _(vxlan_gpe_add_del_tunnel, \
23521 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23522 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23523 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23524 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23525 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23526 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23527 _(interface_name_renumber, \
23528 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23529 _(input_acl_set_interface, \
23530 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23531 " [l2-table <nn>] [del]") \
23532 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23533 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23534 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23535 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23536 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23537 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23538 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23539 _(ip_dump, "ipv4 | ipv6") \
23540 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23541 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23543 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23544 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23545 " integ_alg <alg> integ_key <hex>") \
23546 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23547 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23548 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23549 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23550 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23551 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23552 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23553 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23554 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23555 " [instance <n>]") \
23556 _(ipsec_sa_dump, "[sa_id <n>]") \
23557 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23558 " <alg> <hex>\n") \
23559 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23560 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23561 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23562 "(auth_data 0x<data> | auth_data <data>)") \
23563 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23564 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23565 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23566 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23567 "(local|remote)") \
23568 _(ikev2_set_local_key, "file <absolute_file_path>") \
23569 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23570 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23571 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23572 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23573 _(ikev2_initiate_sa_init, "<profile_name>") \
23574 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23575 _(ikev2_initiate_del_child_sa, "<ispi>") \
23576 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23577 _(delete_loopback,"sw_if_index <nn>") \
23578 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23579 _(map_add_domain, \
23580 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23581 "ip6-src <ip6addr> " \
23582 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23583 _(map_del_domain, "index <n>") \
23584 _(map_add_del_rule, \
23585 "index <n> psid <n> dst <ip6addr> [del]") \
23586 _(map_domain_dump, "") \
23587 _(map_rule_dump, "index <map-domain>") \
23588 _(want_interface_events, "enable|disable") \
23589 _(want_stats,"enable|disable") \
23590 _(get_first_msg_id, "client <name>") \
23591 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23592 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23593 "fib-id <nn> [ip4][ip6][default]") \
23594 _(get_node_graph, " ") \
23595 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23596 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23597 _(ioam_disable, "") \
23598 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23599 " sw_if_index <sw_if_index> p <priority> " \
23600 "w <weight>] [del]") \
23601 _(one_add_del_locator, "locator-set <locator_name> " \
23602 "iface <intf> | sw_if_index <sw_if_index> " \
23603 "p <priority> w <weight> [del]") \
23604 _(one_add_del_local_eid,"vni <vni> eid " \
23605 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23606 "locator-set <locator_name> [del]" \
23607 "[key-id sha1|sha256 secret-key <secret-key>]")\
23608 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23609 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23610 _(one_enable_disable, "enable|disable") \
23611 _(one_map_register_enable_disable, "enable|disable") \
23612 _(one_map_register_fallback_threshold, "<value>") \
23613 _(one_rloc_probe_enable_disable, "enable|disable") \
23614 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23616 "rloc <locator> p <prio> " \
23617 "w <weight> [rloc <loc> ... ] " \
23618 "action <action> [del-all]") \
23619 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23621 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23622 _(one_use_petr, "ip-address> | disable") \
23623 _(one_map_request_mode, "src-dst|dst-only") \
23624 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23625 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23626 _(one_locator_set_dump, "[local | remote]") \
23627 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23628 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23629 "[local] | [remote]") \
23630 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23631 _(one_ndp_bd_get, "") \
23632 _(one_ndp_entries_get, "bd <bridge-domain>") \
23633 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23634 _(one_l2_arp_bd_get, "") \
23635 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23636 _(one_stats_enable_disable, "enable|disalbe") \
23637 _(show_one_stats_enable_disable, "") \
23638 _(one_eid_table_vni_dump, "") \
23639 _(one_eid_table_map_dump, "l2|l3") \
23640 _(one_map_resolver_dump, "") \
23641 _(one_map_server_dump, "") \
23642 _(one_adjacencies_get, "vni <vni>") \
23643 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23644 _(show_one_rloc_probe_state, "") \
23645 _(show_one_map_register_state, "") \
23646 _(show_one_status, "") \
23647 _(one_stats_dump, "") \
23648 _(one_stats_flush, "") \
23649 _(one_get_map_request_itr_rlocs, "") \
23650 _(one_map_register_set_ttl, "<ttl>") \
23651 _(one_set_transport_protocol, "udp|api") \
23652 _(one_get_transport_protocol, "") \
23653 _(one_enable_disable_xtr_mode, "enable|disable") \
23654 _(one_show_xtr_mode, "") \
23655 _(one_enable_disable_pitr_mode, "enable|disable") \
23656 _(one_show_pitr_mode, "") \
23657 _(one_enable_disable_petr_mode, "enable|disable") \
23658 _(one_show_petr_mode, "") \
23659 _(show_one_nsh_mapping, "") \
23660 _(show_one_pitr, "") \
23661 _(show_one_use_petr, "") \
23662 _(show_one_map_request_mode, "") \
23663 _(show_one_map_register_ttl, "") \
23664 _(show_one_map_register_fallback_threshold, "") \
23665 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23666 " sw_if_index <sw_if_index> p <priority> " \
23667 "w <weight>] [del]") \
23668 _(lisp_add_del_locator, "locator-set <locator_name> " \
23669 "iface <intf> | sw_if_index <sw_if_index> " \
23670 "p <priority> w <weight> [del]") \
23671 _(lisp_add_del_local_eid,"vni <vni> eid " \
23672 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23673 "locator-set <locator_name> [del]" \
23674 "[key-id sha1|sha256 secret-key <secret-key>]") \
23675 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23676 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23677 _(lisp_enable_disable, "enable|disable") \
23678 _(lisp_map_register_enable_disable, "enable|disable") \
23679 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23680 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23682 "rloc <locator> p <prio> " \
23683 "w <weight> [rloc <loc> ... ] " \
23684 "action <action> [del-all]") \
23685 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23687 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23688 _(lisp_use_petr, "<ip-address> | disable") \
23689 _(lisp_map_request_mode, "src-dst|dst-only") \
23690 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23691 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23692 _(lisp_locator_set_dump, "[local | remote]") \
23693 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23694 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23695 "[local] | [remote]") \
23696 _(lisp_eid_table_vni_dump, "") \
23697 _(lisp_eid_table_map_dump, "l2|l3") \
23698 _(lisp_map_resolver_dump, "") \
23699 _(lisp_map_server_dump, "") \
23700 _(lisp_adjacencies_get, "vni <vni>") \
23701 _(gpe_fwd_entry_vnis_get, "") \
23702 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23703 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23704 "[table <table-id>]") \
23705 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23706 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23707 _(gpe_set_encap_mode, "lisp|vxlan") \
23708 _(gpe_get_encap_mode, "") \
23709 _(lisp_gpe_add_del_iface, "up|down") \
23710 _(lisp_gpe_enable_disable, "enable|disable") \
23711 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23712 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23713 _(show_lisp_rloc_probe_state, "") \
23714 _(show_lisp_map_register_state, "") \
23715 _(show_lisp_status, "") \
23716 _(lisp_get_map_request_itr_rlocs, "") \
23717 _(show_lisp_pitr, "") \
23718 _(show_lisp_use_petr, "") \
23719 _(show_lisp_map_request_mode, "") \
23720 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23721 _(af_packet_delete, "name <host interface name>") \
23722 _(af_packet_dump, "") \
23723 _(policer_add_del, "name <policer name> <params> [del]") \
23724 _(policer_dump, "[name <policer name>]") \
23725 _(policer_classify_set_interface, \
23726 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23727 " [l2-table <nn>] [del]") \
23728 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23729 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23730 "[master|slave]") \
23731 _(netmap_delete, "name <interface name>") \
23732 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23733 _(mpls_fib_dump, "") \
23734 _(classify_table_ids, "") \
23735 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23736 _(classify_table_info, "table_id <nn>") \
23737 _(classify_session_dump, "table_id <nn>") \
23738 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23739 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23740 "[template_interval <nn>] [udp_checksum]") \
23741 _(ipfix_exporter_dump, "") \
23742 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23743 _(ipfix_classify_stream_dump, "") \
23744 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23745 _(ipfix_classify_table_dump, "") \
23746 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23747 _(sw_interface_span_dump, "[l2]") \
23748 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23749 _(pg_create_interface, "if_id <nn>") \
23750 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23751 _(pg_enable_disable, "[stream <id>] disable") \
23752 _(ip_source_and_port_range_check_add_del, \
23753 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23754 _(ip_source_and_port_range_check_interface_add_del, \
23755 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23756 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23757 _(ipsec_gre_add_del_tunnel, \
23758 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23759 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23760 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23761 _(l2_interface_pbb_tag_rewrite, \
23762 "<intfc> | sw_if_index <nn> \n" \
23763 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23764 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23765 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23766 _(flow_classify_set_interface, \
23767 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23768 _(flow_classify_dump, "type [ip4|ip6]") \
23769 _(ip_fib_dump, "") \
23770 _(ip_mfib_dump, "") \
23771 _(ip6_fib_dump, "") \
23772 _(ip6_mfib_dump, "") \
23773 _(feature_enable_disable, "arc_name <arc_name> " \
23774 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23775 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23777 _(l2_xconnect_dump, "") \
23778 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23779 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23780 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23781 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23782 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23783 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23784 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23785 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23786 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23787 _(sock_init_shm, "size <nnn>") \
23788 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23789 _(dns_enable_disable, "[enable][disable]") \
23790 _(dns_name_server_add_del, "<ip-address> [del]") \
23791 _(dns_resolve_name, "<hostname>") \
23792 _(dns_resolve_ip, "<ip4|ip6>") \
23793 _(dns_name_server_add_del, "<ip-address> [del]") \
23794 _(dns_resolve_name, "<hostname>") \
23795 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23796 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23797 _(session_rules_dump, "") \
23798 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23799 _(output_acl_set_interface, \
23800 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23801 " [l2-table <nn>] [del]") \
23802 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23804 /* List of command functions, CLI names map directly to functions */
23805 #define foreach_cli_function \
23806 _(comment, "usage: comment <ignore-rest-of-line>") \
23807 _(dump_interface_table, "usage: dump_interface_table") \
23808 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23809 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23810 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23811 _(dump_stats_table, "usage: dump_stats_table") \
23812 _(dump_macro_table, "usage: dump_macro_table ") \
23813 _(dump_node_table, "usage: dump_node_table") \
23814 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23815 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23816 _(echo, "usage: echo <message>") \
23817 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23818 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23819 _(help, "usage: help") \
23820 _(q, "usage: quit") \
23821 _(quit, "usage: quit") \
23822 _(search_node_table, "usage: search_node_table <name>...") \
23823 _(set, "usage: set <variable-name> <value>") \
23824 _(script, "usage: script <file-name>") \
23825 _(unset, "usage: unset <variable-name>")
23827 static void vl_api_##n##_t_handler_uni \
23828 (vl_api_##n##_t * mp) \
23830 vat_main_t * vam = &vat_main; \
23831 if (vam->json_output) { \
23832 vl_api_##n##_t_handler_json(mp); \
23834 vl_api_##n##_t_handler(mp); \
23837 foreach_vpe_api_reply_msg;
23838 #if VPP_API_TEST_BUILTIN == 0
23839 foreach_standalone_reply_msg;
23844 vat_api_hookup (vat_main_t * vam)
23847 vl_msg_api_set_handlers(VL_API_##N, #n, \
23848 vl_api_##n##_t_handler_uni, \
23850 vl_api_##n##_t_endian, \
23851 vl_api_##n##_t_print, \
23852 sizeof(vl_api_##n##_t), 1);
23853 foreach_vpe_api_reply_msg;
23854 #if VPP_API_TEST_BUILTIN == 0
23855 foreach_standalone_reply_msg;
23859 #if (VPP_API_TEST_BUILTIN==0)
23860 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23862 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23864 vam->function_by_name = hash_create_string (0, sizeof (uword));
23866 vam->help_by_name = hash_create_string (0, sizeof (uword));
23869 /* API messages we can send */
23870 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23871 foreach_vpe_api_msg;
23875 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23876 foreach_vpe_api_msg;
23879 /* CLI functions */
23880 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23881 foreach_cli_function;
23885 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23886 foreach_cli_function;
23890 #if VPP_API_TEST_BUILTIN
23891 static clib_error_t *
23892 vat_api_hookup_shim (vlib_main_t * vm)
23894 vat_api_hookup (&vat_main);
23898 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23902 * fd.io coding-style-patch-verification: ON
23905 * eval: (c-set-style "gnu")