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->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2673 format_ip4_address, &mp->host_address,
2674 format_ip4_address, &mp->router_address,
2675 format_ethernet_address, mp->host_mac);
2678 static void vl_api_dhcp_compl_event_t_handler_json
2679 (vl_api_dhcp_compl_event_t * mp)
2681 /* JSON output not supported */
2685 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2688 vat_main_t *vam = &vat_main;
2689 static u64 default_counter = 0;
2691 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2693 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2694 sw_if_index, default_counter);
2695 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2699 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2700 interface_counter_t counter)
2702 vat_main_t *vam = &vat_main;
2703 static interface_counter_t default_counter = { 0, };
2705 vec_validate_init_empty (vam->combined_interface_counters,
2706 vnet_counter_type, NULL);
2707 vec_validate_init_empty (vam->combined_interface_counters
2708 [vnet_counter_type], sw_if_index, default_counter);
2709 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2712 static void vl_api_vnet_interface_simple_counters_t_handler
2713 (vl_api_vnet_interface_simple_counters_t * mp)
2718 static void vl_api_vnet_interface_combined_counters_t_handler
2719 (vl_api_vnet_interface_combined_counters_t * mp)
2724 static void vl_api_vnet_interface_simple_counters_t_handler_json
2725 (vl_api_vnet_interface_simple_counters_t * mp)
2730 u32 first_sw_if_index;
2733 count = ntohl (mp->count);
2734 first_sw_if_index = ntohl (mp->first_sw_if_index);
2736 v_packets = (u64 *) & mp->data;
2737 for (i = 0; i < count; i++)
2739 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2740 set_simple_interface_counter (mp->vnet_counter_type,
2741 first_sw_if_index + i, packets);
2746 static void vl_api_vnet_interface_combined_counters_t_handler_json
2747 (vl_api_vnet_interface_combined_counters_t * mp)
2749 interface_counter_t counter;
2751 u32 first_sw_if_index;
2755 count = ntohl (mp->count);
2756 first_sw_if_index = ntohl (mp->first_sw_if_index);
2758 v = (vlib_counter_t *) & mp->data;
2759 for (i = 0; i < count; i++)
2762 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2764 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2765 set_combined_interface_counter (mp->vnet_counter_type,
2766 first_sw_if_index + i, counter);
2772 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2774 vat_main_t *vam = &vat_main;
2777 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2779 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2788 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2790 vat_main_t *vam = &vat_main;
2793 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2795 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2803 static void vl_api_vnet_ip4_fib_counters_t_handler
2804 (vl_api_vnet_ip4_fib_counters_t * mp)
2809 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2810 (vl_api_vnet_ip4_fib_counters_t * mp)
2812 vat_main_t *vam = &vat_main;
2813 vl_api_ip4_fib_counter_t *v;
2814 ip4_fib_counter_t *counter;
2821 vrf_id = ntohl (mp->vrf_id);
2822 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2823 if (~0 == vrf_index)
2825 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2826 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2827 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2828 vec_validate (vam->ip4_fib_counters, vrf_index);
2829 vam->ip4_fib_counters[vrf_index] = NULL;
2832 vec_free (vam->ip4_fib_counters[vrf_index]);
2833 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2834 count = ntohl (mp->count);
2835 for (i = 0; i < count; i++)
2837 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2838 counter = &vam->ip4_fib_counters[vrf_index][i];
2839 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2840 counter->address = ip4;
2841 counter->address_length = v->address_length;
2842 counter->packets = clib_net_to_host_u64 (v->packets);
2843 counter->bytes = clib_net_to_host_u64 (v->bytes);
2848 static void vl_api_vnet_ip4_nbr_counters_t_handler
2849 (vl_api_vnet_ip4_nbr_counters_t * mp)
2854 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2855 (vl_api_vnet_ip4_nbr_counters_t * mp)
2857 vat_main_t *vam = &vat_main;
2858 vl_api_ip4_nbr_counter_t *v;
2859 ip4_nbr_counter_t *counter;
2864 sw_if_index = ntohl (mp->sw_if_index);
2865 count = ntohl (mp->count);
2866 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2869 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2871 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2872 for (i = 0; i < count; i++)
2874 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2875 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2876 counter->address.s_addr = v->address;
2877 counter->packets = clib_net_to_host_u64 (v->packets);
2878 counter->bytes = clib_net_to_host_u64 (v->bytes);
2879 counter->linkt = v->link_type;
2884 static void vl_api_vnet_ip6_fib_counters_t_handler
2885 (vl_api_vnet_ip6_fib_counters_t * mp)
2890 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2891 (vl_api_vnet_ip6_fib_counters_t * mp)
2893 vat_main_t *vam = &vat_main;
2894 vl_api_ip6_fib_counter_t *v;
2895 ip6_fib_counter_t *counter;
2896 struct in6_addr ip6;
2902 vrf_id = ntohl (mp->vrf_id);
2903 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2904 if (~0 == vrf_index)
2906 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2907 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2908 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2909 vec_validate (vam->ip6_fib_counters, vrf_index);
2910 vam->ip6_fib_counters[vrf_index] = NULL;
2913 vec_free (vam->ip6_fib_counters[vrf_index]);
2914 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2915 count = ntohl (mp->count);
2916 for (i = 0; i < count; i++)
2918 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2919 counter = &vam->ip6_fib_counters[vrf_index][i];
2920 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2921 counter->address = ip6;
2922 counter->address_length = v->address_length;
2923 counter->packets = clib_net_to_host_u64 (v->packets);
2924 counter->bytes = clib_net_to_host_u64 (v->bytes);
2929 static void vl_api_vnet_ip6_nbr_counters_t_handler
2930 (vl_api_vnet_ip6_nbr_counters_t * mp)
2935 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2936 (vl_api_vnet_ip6_nbr_counters_t * mp)
2938 vat_main_t *vam = &vat_main;
2939 vl_api_ip6_nbr_counter_t *v;
2940 ip6_nbr_counter_t *counter;
2941 struct in6_addr ip6;
2946 sw_if_index = ntohl (mp->sw_if_index);
2947 count = ntohl (mp->count);
2948 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2951 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2953 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2954 for (i = 0; i < count; i++)
2956 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2957 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2958 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2959 counter->address = ip6;
2960 counter->packets = clib_net_to_host_u64 (v->packets);
2961 counter->bytes = clib_net_to_host_u64 (v->bytes);
2966 static void vl_api_get_first_msg_id_reply_t_handler
2967 (vl_api_get_first_msg_id_reply_t * mp)
2969 vat_main_t *vam = &vat_main;
2970 i32 retval = ntohl (mp->retval);
2972 if (vam->async_mode)
2974 vam->async_errors += (retval < 0);
2978 vam->retval = retval;
2979 vam->result_ready = 1;
2983 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2987 static void vl_api_get_first_msg_id_reply_t_handler_json
2988 (vl_api_get_first_msg_id_reply_t * mp)
2990 vat_main_t *vam = &vat_main;
2991 vat_json_node_t node;
2993 vat_json_init_object (&node);
2994 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2995 vat_json_object_add_uint (&node, "first_msg_id",
2996 (uint) ntohs (mp->first_msg_id));
2998 vat_json_print (vam->ofp, &node);
2999 vat_json_free (&node);
3001 vam->retval = ntohl (mp->retval);
3002 vam->result_ready = 1;
3005 static void vl_api_get_node_graph_reply_t_handler
3006 (vl_api_get_node_graph_reply_t * mp)
3008 vat_main_t *vam = &vat_main;
3009 api_main_t *am = &api_main;
3010 i32 retval = ntohl (mp->retval);
3011 u8 *pvt_copy, *reply;
3016 if (vam->async_mode)
3018 vam->async_errors += (retval < 0);
3022 vam->retval = retval;
3023 vam->result_ready = 1;
3026 /* "Should never happen..." */
3030 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3031 pvt_copy = vec_dup (reply);
3033 /* Toss the shared-memory original... */
3034 pthread_mutex_lock (&am->vlib_rp->mutex);
3035 oldheap = svm_push_data_heap (am->vlib_rp);
3039 svm_pop_heap (oldheap);
3040 pthread_mutex_unlock (&am->vlib_rp->mutex);
3042 if (vam->graph_nodes)
3044 hash_free (vam->graph_node_index_by_name);
3046 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3048 node = vam->graph_nodes[i];
3049 vec_free (node->name);
3050 vec_free (node->next_nodes);
3053 vec_free (vam->graph_nodes);
3056 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
3057 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
3058 vec_free (pvt_copy);
3060 for (i = 0; i < vec_len (vam->graph_nodes); i++)
3062 node = vam->graph_nodes[i];
3063 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
3067 static void vl_api_get_node_graph_reply_t_handler_json
3068 (vl_api_get_node_graph_reply_t * mp)
3070 vat_main_t *vam = &vat_main;
3071 api_main_t *am = &api_main;
3073 vat_json_node_t node;
3076 /* $$$$ make this real? */
3077 vat_json_init_object (&node);
3078 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3079 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
3081 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
3083 /* Toss the shared-memory original... */
3084 pthread_mutex_lock (&am->vlib_rp->mutex);
3085 oldheap = svm_push_data_heap (am->vlib_rp);
3089 svm_pop_heap (oldheap);
3090 pthread_mutex_unlock (&am->vlib_rp->mutex);
3092 vat_json_print (vam->ofp, &node);
3093 vat_json_free (&node);
3095 vam->retval = ntohl (mp->retval);
3096 vam->result_ready = 1;
3100 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
3102 vat_main_t *vam = &vat_main;
3107 s = format (s, "%=16d%=16d%=16d",
3108 ntohl (mp->sw_if_index), mp->priority, mp->weight);
3112 s = format (s, "%=16U%=16d%=16d",
3113 mp->is_ipv6 ? format_ip6_address :
3115 mp->ip_address, mp->priority, mp->weight);
3118 print (vam->ofp, "%v", s);
3123 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
3125 vat_main_t *vam = &vat_main;
3126 vat_json_node_t *node = NULL;
3127 struct in6_addr ip6;
3130 if (VAT_JSON_ARRAY != vam->json_tree.type)
3132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3133 vat_json_init_array (&vam->json_tree);
3135 node = vat_json_array_add (&vam->json_tree);
3136 vat_json_init_object (node);
3138 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
3139 vat_json_object_add_uint (node, "priority", mp->priority);
3140 vat_json_object_add_uint (node, "weight", mp->weight);
3143 vat_json_object_add_uint (node, "sw_if_index",
3144 clib_net_to_host_u32 (mp->sw_if_index));
3149 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3150 vat_json_object_add_ip6 (node, "address", ip6);
3154 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3155 vat_json_object_add_ip4 (node, "address", ip4);
3161 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
3164 vat_main_t *vam = &vat_main;
3167 ls_name = format (0, "%s", mp->ls_name);
3169 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
3175 vl_api_one_locator_set_details_t_handler_json
3176 (vl_api_one_locator_set_details_t * mp)
3178 vat_main_t *vam = &vat_main;
3179 vat_json_node_t *node = 0;
3182 ls_name = format (0, "%s", mp->ls_name);
3183 vec_add1 (ls_name, 0);
3185 if (VAT_JSON_ARRAY != vam->json_tree.type)
3187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3188 vat_json_init_array (&vam->json_tree);
3190 node = vat_json_array_add (&vam->json_tree);
3192 vat_json_init_object (node);
3193 vat_json_object_add_string_copy (node, "ls_name", ls_name);
3194 vat_json_object_add_uint (node, "ls_index",
3195 clib_net_to_host_u32 (mp->ls_index));
3203 } __attribute__ ((__packed__)) lisp_nsh_api_t;
3206 unformat_nsh_address (unformat_input_t * input, va_list * args)
3208 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
3209 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
3213 format_nsh_address_vat (u8 * s, va_list * args)
3215 nsh_t *a = va_arg (*args, nsh_t *);
3216 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
3220 format_lisp_flat_eid (u8 * s, va_list * args)
3222 u32 type = va_arg (*args, u32);
3223 u8 *eid = va_arg (*args, u8 *);
3224 u32 eid_len = va_arg (*args, u32);
3229 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
3231 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
3233 return format (s, "%U", format_ethernet_address, eid);
3235 return format (s, "%U", format_nsh_address_vat, eid);
3241 format_lisp_eid_vat (u8 * s, va_list * args)
3243 u32 type = va_arg (*args, u32);
3244 u8 *eid = va_arg (*args, u8 *);
3245 u32 eid_len = va_arg (*args, u32);
3246 u8 *seid = va_arg (*args, u8 *);
3247 u32 seid_len = va_arg (*args, u32);
3248 u32 is_src_dst = va_arg (*args, u32);
3251 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3253 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3259 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3261 vat_main_t *vam = &vat_main;
3262 u8 *s = 0, *eid = 0;
3264 if (~0 == mp->locator_set_index)
3265 s = format (0, "action: %d", mp->action);
3267 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3269 eid = format (0, "%U", format_lisp_eid_vat,
3273 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3276 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3277 clib_net_to_host_u32 (mp->vni),
3279 mp->is_local ? "local" : "remote",
3280 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3281 clib_net_to_host_u16 (mp->key_id), mp->key);
3288 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3291 vat_main_t *vam = &vat_main;
3292 vat_json_node_t *node = 0;
3295 if (VAT_JSON_ARRAY != vam->json_tree.type)
3297 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3298 vat_json_init_array (&vam->json_tree);
3300 node = vat_json_array_add (&vam->json_tree);
3302 vat_json_init_object (node);
3303 if (~0 == mp->locator_set_index)
3304 vat_json_object_add_uint (node, "action", mp->action);
3306 vat_json_object_add_uint (node, "locator_set_index",
3307 clib_net_to_host_u32 (mp->locator_set_index));
3309 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3310 if (mp->eid_type == 3)
3312 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3313 vat_json_init_object (nsh_json);
3314 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3315 vat_json_object_add_uint (nsh_json, "spi",
3316 clib_net_to_host_u32 (nsh->spi));
3317 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3321 eid = format (0, "%U", format_lisp_eid_vat,
3325 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3327 vat_json_object_add_string_copy (node, "eid", eid);
3330 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3331 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3332 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3336 vat_json_object_add_uint (node, "key_id",
3337 clib_net_to_host_u16 (mp->key_id));
3338 vat_json_object_add_string_copy (node, "key", mp->key);
3343 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3345 vat_main_t *vam = &vat_main;
3346 u8 *seid = 0, *deid = 0;
3347 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3349 deid = format (0, "%U", format_lisp_eid_vat,
3350 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3352 seid = format (0, "%U", format_lisp_eid_vat,
3353 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3359 format_ip_address_fcn = format_ip4_address;
3361 format_ip_address_fcn = format_ip6_address;
3364 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3365 clib_net_to_host_u32 (mp->vni),
3367 format_ip_address_fcn, mp->lloc,
3368 format_ip_address_fcn, mp->rloc,
3369 clib_net_to_host_u32 (mp->pkt_count),
3370 clib_net_to_host_u32 (mp->bytes));
3377 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3379 struct in6_addr ip6;
3381 vat_main_t *vam = &vat_main;
3382 vat_json_node_t *node = 0;
3383 u8 *deid = 0, *seid = 0;
3385 if (VAT_JSON_ARRAY != vam->json_tree.type)
3387 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3388 vat_json_init_array (&vam->json_tree);
3390 node = vat_json_array_add (&vam->json_tree);
3392 vat_json_init_object (node);
3393 deid = format (0, "%U", format_lisp_eid_vat,
3394 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3396 seid = format (0, "%U", format_lisp_eid_vat,
3397 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3402 vat_json_object_add_string_copy (node, "seid", seid);
3403 vat_json_object_add_string_copy (node, "deid", deid);
3404 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3408 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3409 vat_json_object_add_ip4 (node, "lloc", ip4);
3410 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3411 vat_json_object_add_ip4 (node, "rloc", ip4);
3415 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3416 vat_json_object_add_ip6 (node, "lloc", ip6);
3417 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3418 vat_json_object_add_ip6 (node, "rloc", ip6);
3420 vat_json_object_add_uint (node, "pkt_count",
3421 clib_net_to_host_u32 (mp->pkt_count));
3422 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3429 vl_api_one_eid_table_map_details_t_handler
3430 (vl_api_one_eid_table_map_details_t * mp)
3432 vat_main_t *vam = &vat_main;
3434 u8 *line = format (0, "%=10d%=10d",
3435 clib_net_to_host_u32 (mp->vni),
3436 clib_net_to_host_u32 (mp->dp_table));
3437 print (vam->ofp, "%v", line);
3442 vl_api_one_eid_table_map_details_t_handler_json
3443 (vl_api_one_eid_table_map_details_t * mp)
3445 vat_main_t *vam = &vat_main;
3446 vat_json_node_t *node = NULL;
3448 if (VAT_JSON_ARRAY != vam->json_tree.type)
3450 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3451 vat_json_init_array (&vam->json_tree);
3453 node = vat_json_array_add (&vam->json_tree);
3454 vat_json_init_object (node);
3455 vat_json_object_add_uint (node, "dp_table",
3456 clib_net_to_host_u32 (mp->dp_table));
3457 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3461 vl_api_one_eid_table_vni_details_t_handler
3462 (vl_api_one_eid_table_vni_details_t * mp)
3464 vat_main_t *vam = &vat_main;
3466 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3467 print (vam->ofp, "%v", line);
3472 vl_api_one_eid_table_vni_details_t_handler_json
3473 (vl_api_one_eid_table_vni_details_t * mp)
3475 vat_main_t *vam = &vat_main;
3476 vat_json_node_t *node = NULL;
3478 if (VAT_JSON_ARRAY != vam->json_tree.type)
3480 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3481 vat_json_init_array (&vam->json_tree);
3483 node = vat_json_array_add (&vam->json_tree);
3484 vat_json_init_object (node);
3485 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3489 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3490 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3492 vat_main_t *vam = &vat_main;
3493 int retval = clib_net_to_host_u32 (mp->retval);
3495 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3496 print (vam->ofp, "fallback threshold value: %d", mp->value);
3498 vam->retval = retval;
3499 vam->result_ready = 1;
3503 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3504 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3506 vat_main_t *vam = &vat_main;
3507 vat_json_node_t _node, *node = &_node;
3508 int retval = clib_net_to_host_u32 (mp->retval);
3510 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3511 vat_json_init_object (node);
3512 vat_json_object_add_uint (node, "value", mp->value);
3514 vat_json_print (vam->ofp, node);
3515 vat_json_free (node);
3517 vam->retval = retval;
3518 vam->result_ready = 1;
3522 vl_api_show_one_map_register_state_reply_t_handler
3523 (vl_api_show_one_map_register_state_reply_t * mp)
3525 vat_main_t *vam = &vat_main;
3526 int retval = clib_net_to_host_u32 (mp->retval);
3528 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3530 vam->retval = retval;
3531 vam->result_ready = 1;
3535 vl_api_show_one_map_register_state_reply_t_handler_json
3536 (vl_api_show_one_map_register_state_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 vat_json_node_t _node, *node = &_node;
3540 int retval = clib_net_to_host_u32 (mp->retval);
3542 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3544 vat_json_init_object (node);
3545 vat_json_object_add_string_copy (node, "state", s);
3547 vat_json_print (vam->ofp, node);
3548 vat_json_free (node);
3550 vam->retval = retval;
3551 vam->result_ready = 1;
3556 vl_api_show_one_rloc_probe_state_reply_t_handler
3557 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3559 vat_main_t *vam = &vat_main;
3560 int retval = clib_net_to_host_u32 (mp->retval);
3565 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3567 vam->retval = retval;
3568 vam->result_ready = 1;
3572 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3573 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3575 vat_main_t *vam = &vat_main;
3576 vat_json_node_t _node, *node = &_node;
3577 int retval = clib_net_to_host_u32 (mp->retval);
3579 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3580 vat_json_init_object (node);
3581 vat_json_object_add_string_copy (node, "state", s);
3583 vat_json_print (vam->ofp, node);
3584 vat_json_free (node);
3586 vam->retval = retval;
3587 vam->result_ready = 1;
3592 vl_api_show_one_stats_enable_disable_reply_t_handler
3593 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 int retval = clib_net_to_host_u32 (mp->retval);
3601 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3603 vam->retval = retval;
3604 vam->result_ready = 1;
3608 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3609 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3611 vat_main_t *vam = &vat_main;
3612 vat_json_node_t _node, *node = &_node;
3613 int retval = clib_net_to_host_u32 (mp->retval);
3615 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3616 vat_json_init_object (node);
3617 vat_json_object_add_string_copy (node, "state", s);
3619 vat_json_print (vam->ofp, node);
3620 vat_json_free (node);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3628 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3630 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3631 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3632 e->vni = clib_net_to_host_u32 (e->vni);
3636 gpe_fwd_entries_get_reply_t_net_to_host
3637 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3641 mp->count = clib_net_to_host_u32 (mp->count);
3642 for (i = 0; i < mp->count; i++)
3644 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3649 format_gpe_encap_mode (u8 * s, va_list * args)
3651 u32 mode = va_arg (*args, u32);
3656 return format (s, "lisp");
3658 return format (s, "vxlan");
3664 vl_api_gpe_get_encap_mode_reply_t_handler
3665 (vl_api_gpe_get_encap_mode_reply_t * mp)
3667 vat_main_t *vam = &vat_main;
3669 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3670 vam->retval = ntohl (mp->retval);
3671 vam->result_ready = 1;
3675 vl_api_gpe_get_encap_mode_reply_t_handler_json
3676 (vl_api_gpe_get_encap_mode_reply_t * mp)
3678 vat_main_t *vam = &vat_main;
3679 vat_json_node_t node;
3681 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3682 vec_add1 (encap_mode, 0);
3684 vat_json_init_object (&node);
3685 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3687 vec_free (encap_mode);
3688 vat_json_print (vam->ofp, &node);
3689 vat_json_free (&node);
3691 vam->retval = ntohl (mp->retval);
3692 vam->result_ready = 1;
3696 vl_api_gpe_fwd_entry_path_details_t_handler
3697 (vl_api_gpe_fwd_entry_path_details_t * mp)
3699 vat_main_t *vam = &vat_main;
3700 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3702 if (mp->lcl_loc.is_ip4)
3703 format_ip_address_fcn = format_ip4_address;
3705 format_ip_address_fcn = format_ip6_address;
3707 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3708 format_ip_address_fcn, &mp->lcl_loc,
3709 format_ip_address_fcn, &mp->rmt_loc);
3713 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3715 struct in6_addr ip6;
3720 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3721 vat_json_object_add_ip4 (n, "address", ip4);
3725 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3726 vat_json_object_add_ip6 (n, "address", ip6);
3728 vat_json_object_add_uint (n, "weight", loc->weight);
3732 vl_api_gpe_fwd_entry_path_details_t_handler_json
3733 (vl_api_gpe_fwd_entry_path_details_t * mp)
3735 vat_main_t *vam = &vat_main;
3736 vat_json_node_t *node = NULL;
3737 vat_json_node_t *loc_node;
3739 if (VAT_JSON_ARRAY != vam->json_tree.type)
3741 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3742 vat_json_init_array (&vam->json_tree);
3744 node = vat_json_array_add (&vam->json_tree);
3745 vat_json_init_object (node);
3747 loc_node = vat_json_object_add (node, "local_locator");
3748 vat_json_init_object (loc_node);
3749 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3751 loc_node = vat_json_object_add (node, "remote_locator");
3752 vat_json_init_object (loc_node);
3753 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3757 vl_api_gpe_fwd_entries_get_reply_t_handler
3758 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3760 vat_main_t *vam = &vat_main;
3762 int retval = clib_net_to_host_u32 (mp->retval);
3763 vl_api_gpe_fwd_entry_t *e;
3768 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3770 for (i = 0; i < mp->count; i++)
3772 e = &mp->entries[i];
3773 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3774 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3775 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3779 vam->retval = retval;
3780 vam->result_ready = 1;
3784 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3785 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3789 vat_json_node_t *e = 0, root;
3791 int retval = clib_net_to_host_u32 (mp->retval);
3792 vl_api_gpe_fwd_entry_t *fwd;
3797 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3798 vat_json_init_array (&root);
3800 for (i = 0; i < mp->count; i++)
3802 e = vat_json_array_add (&root);
3803 fwd = &mp->entries[i];
3805 vat_json_init_object (e);
3806 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3807 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3808 vat_json_object_add_int (e, "vni", fwd->vni);
3809 vat_json_object_add_int (e, "action", fwd->action);
3811 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3812 fwd->leid_prefix_len);
3814 vat_json_object_add_string_copy (e, "leid", s);
3817 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3818 fwd->reid_prefix_len);
3820 vat_json_object_add_string_copy (e, "reid", s);
3824 vat_json_print (vam->ofp, &root);
3825 vat_json_free (&root);
3828 vam->retval = retval;
3829 vam->result_ready = 1;
3833 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3834 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3836 vat_main_t *vam = &vat_main;
3838 int retval = clib_net_to_host_u32 (mp->retval);
3839 vl_api_gpe_native_fwd_rpath_t *r;
3844 n = clib_net_to_host_u32 (mp->count);
3846 for (i = 0; i < n; i++)
3848 r = &mp->entries[i];
3849 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3850 clib_net_to_host_u32 (r->fib_index),
3851 clib_net_to_host_u32 (r->nh_sw_if_index),
3852 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3856 vam->retval = retval;
3857 vam->result_ready = 1;
3861 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3862 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3864 vat_main_t *vam = &vat_main;
3865 vat_json_node_t root, *e;
3867 int retval = clib_net_to_host_u32 (mp->retval);
3868 vl_api_gpe_native_fwd_rpath_t *r;
3874 n = clib_net_to_host_u32 (mp->count);
3875 vat_json_init_array (&root);
3877 for (i = 0; i < n; i++)
3879 e = vat_json_array_add (&root);
3880 vat_json_init_object (e);
3881 r = &mp->entries[i];
3883 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3886 vat_json_object_add_string_copy (e, "ip4", s);
3889 vat_json_object_add_uint (e, "fib_index",
3890 clib_net_to_host_u32 (r->fib_index));
3891 vat_json_object_add_uint (e, "nh_sw_if_index",
3892 clib_net_to_host_u32 (r->nh_sw_if_index));
3895 vat_json_print (vam->ofp, &root);
3896 vat_json_free (&root);
3899 vam->retval = retval;
3900 vam->result_ready = 1;
3904 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3905 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3907 vat_main_t *vam = &vat_main;
3909 int retval = clib_net_to_host_u32 (mp->retval);
3914 n = clib_net_to_host_u32 (mp->count);
3916 for (i = 0; i < n; i++)
3917 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3920 vam->retval = retval;
3921 vam->result_ready = 1;
3925 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3926 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3928 vat_main_t *vam = &vat_main;
3929 vat_json_node_t root;
3931 int retval = clib_net_to_host_u32 (mp->retval);
3936 n = clib_net_to_host_u32 (mp->count);
3937 vat_json_init_array (&root);
3939 for (i = 0; i < n; i++)
3940 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3942 vat_json_print (vam->ofp, &root);
3943 vat_json_free (&root);
3946 vam->retval = retval;
3947 vam->result_ready = 1;
3951 vl_api_one_ndp_entries_get_reply_t_handler
3952 (vl_api_one_ndp_entries_get_reply_t * mp)
3954 vat_main_t *vam = &vat_main;
3956 int retval = clib_net_to_host_u32 (mp->retval);
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3964 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3965 format_ethernet_address, mp->entries[i].mac);
3968 vam->retval = retval;
3969 vam->result_ready = 1;
3973 vl_api_one_ndp_entries_get_reply_t_handler_json
3974 (vl_api_one_ndp_entries_get_reply_t * mp)
3977 vat_main_t *vam = &vat_main;
3978 vat_json_node_t *e = 0, root;
3980 int retval = clib_net_to_host_u32 (mp->retval);
3981 vl_api_one_ndp_entry_t *arp_entry;
3986 n = clib_net_to_host_u32 (mp->count);
3987 vat_json_init_array (&root);
3989 for (i = 0; i < n; i++)
3991 e = vat_json_array_add (&root);
3992 arp_entry = &mp->entries[i];
3994 vat_json_init_object (e);
3995 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3998 vat_json_object_add_string_copy (e, "mac", s);
4001 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
4003 vat_json_object_add_string_copy (e, "ip6", s);
4007 vat_json_print (vam->ofp, &root);
4008 vat_json_free (&root);
4011 vam->retval = retval;
4012 vam->result_ready = 1;
4016 vl_api_one_l2_arp_entries_get_reply_t_handler
4017 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4019 vat_main_t *vam = &vat_main;
4021 int retval = clib_net_to_host_u32 (mp->retval);
4026 n = clib_net_to_host_u32 (mp->count);
4028 for (i = 0; i < n; i++)
4029 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
4030 format_ethernet_address, mp->entries[i].mac);
4033 vam->retval = retval;
4034 vam->result_ready = 1;
4038 vl_api_one_l2_arp_entries_get_reply_t_handler_json
4039 (vl_api_one_l2_arp_entries_get_reply_t * mp)
4042 vat_main_t *vam = &vat_main;
4043 vat_json_node_t *e = 0, root;
4045 int retval = clib_net_to_host_u32 (mp->retval);
4046 vl_api_one_l2_arp_entry_t *arp_entry;
4051 n = clib_net_to_host_u32 (mp->count);
4052 vat_json_init_array (&root);
4054 for (i = 0; i < n; i++)
4056 e = vat_json_array_add (&root);
4057 arp_entry = &mp->entries[i];
4059 vat_json_init_object (e);
4060 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
4063 vat_json_object_add_string_copy (e, "mac", s);
4066 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
4068 vat_json_object_add_string_copy (e, "ip4", s);
4072 vat_json_print (vam->ofp, &root);
4073 vat_json_free (&root);
4076 vam->retval = retval;
4077 vam->result_ready = 1;
4081 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
4083 vat_main_t *vam = &vat_main;
4085 int retval = clib_net_to_host_u32 (mp->retval);
4090 n = clib_net_to_host_u32 (mp->count);
4092 for (i = 0; i < n; i++)
4094 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4098 vam->retval = retval;
4099 vam->result_ready = 1;
4103 vl_api_one_ndp_bd_get_reply_t_handler_json
4104 (vl_api_one_ndp_bd_get_reply_t * mp)
4106 vat_main_t *vam = &vat_main;
4107 vat_json_node_t root;
4109 int retval = clib_net_to_host_u32 (mp->retval);
4114 n = clib_net_to_host_u32 (mp->count);
4115 vat_json_init_array (&root);
4117 for (i = 0; i < n; i++)
4119 vat_json_array_add_uint (&root,
4120 clib_net_to_host_u32 (mp->bridge_domains[i]));
4123 vat_json_print (vam->ofp, &root);
4124 vat_json_free (&root);
4127 vam->retval = retval;
4128 vam->result_ready = 1;
4132 vl_api_one_l2_arp_bd_get_reply_t_handler
4133 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4135 vat_main_t *vam = &vat_main;
4137 int retval = clib_net_to_host_u32 (mp->retval);
4142 n = clib_net_to_host_u32 (mp->count);
4144 for (i = 0; i < n; i++)
4146 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
4150 vam->retval = retval;
4151 vam->result_ready = 1;
4155 vl_api_one_l2_arp_bd_get_reply_t_handler_json
4156 (vl_api_one_l2_arp_bd_get_reply_t * mp)
4158 vat_main_t *vam = &vat_main;
4159 vat_json_node_t root;
4161 int retval = clib_net_to_host_u32 (mp->retval);
4166 n = clib_net_to_host_u32 (mp->count);
4167 vat_json_init_array (&root);
4169 for (i = 0; i < n; i++)
4171 vat_json_array_add_uint (&root,
4172 clib_net_to_host_u32 (mp->bridge_domains[i]));
4175 vat_json_print (vam->ofp, &root);
4176 vat_json_free (&root);
4179 vam->retval = retval;
4180 vam->result_ready = 1;
4184 vl_api_one_adjacencies_get_reply_t_handler
4185 (vl_api_one_adjacencies_get_reply_t * mp)
4187 vat_main_t *vam = &vat_main;
4189 int retval = clib_net_to_host_u32 (mp->retval);
4190 vl_api_one_adjacency_t *a;
4195 n = clib_net_to_host_u32 (mp->count);
4197 for (i = 0; i < n; i++)
4199 a = &mp->adjacencies[i];
4200 print (vam->ofp, "%U %40U",
4201 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
4202 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
4206 vam->retval = retval;
4207 vam->result_ready = 1;
4211 vl_api_one_adjacencies_get_reply_t_handler_json
4212 (vl_api_one_adjacencies_get_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 vat_json_node_t *e = 0, root;
4218 int retval = clib_net_to_host_u32 (mp->retval);
4219 vl_api_one_adjacency_t *a;
4224 n = clib_net_to_host_u32 (mp->count);
4225 vat_json_init_array (&root);
4227 for (i = 0; i < n; i++)
4229 e = vat_json_array_add (&root);
4230 a = &mp->adjacencies[i];
4232 vat_json_init_object (e);
4233 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4234 a->leid_prefix_len);
4236 vat_json_object_add_string_copy (e, "leid", s);
4239 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4240 a->reid_prefix_len);
4242 vat_json_object_add_string_copy (e, "reid", s);
4246 vat_json_print (vam->ofp, &root);
4247 vat_json_free (&root);
4250 vam->retval = retval;
4251 vam->result_ready = 1;
4255 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4257 vat_main_t *vam = &vat_main;
4259 print (vam->ofp, "%=20U",
4260 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4265 vl_api_one_map_server_details_t_handler_json
4266 (vl_api_one_map_server_details_t * mp)
4268 vat_main_t *vam = &vat_main;
4269 vat_json_node_t *node = NULL;
4270 struct in6_addr ip6;
4273 if (VAT_JSON_ARRAY != vam->json_tree.type)
4275 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4276 vat_json_init_array (&vam->json_tree);
4278 node = vat_json_array_add (&vam->json_tree);
4280 vat_json_init_object (node);
4283 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4284 vat_json_object_add_ip6 (node, "map-server", ip6);
4288 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4289 vat_json_object_add_ip4 (node, "map-server", ip4);
4294 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4297 vat_main_t *vam = &vat_main;
4299 print (vam->ofp, "%=20U",
4300 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4305 vl_api_one_map_resolver_details_t_handler_json
4306 (vl_api_one_map_resolver_details_t * mp)
4308 vat_main_t *vam = &vat_main;
4309 vat_json_node_t *node = NULL;
4310 struct in6_addr ip6;
4313 if (VAT_JSON_ARRAY != vam->json_tree.type)
4315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4316 vat_json_init_array (&vam->json_tree);
4318 node = vat_json_array_add (&vam->json_tree);
4320 vat_json_init_object (node);
4323 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4324 vat_json_object_add_ip6 (node, "map resolver", ip6);
4328 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4329 vat_json_object_add_ip4 (node, "map resolver", ip4);
4334 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4336 vat_main_t *vam = &vat_main;
4337 i32 retval = ntohl (mp->retval);
4341 print (vam->ofp, "feature: %s\ngpe: %s",
4342 mp->feature_status ? "enabled" : "disabled",
4343 mp->gpe_status ? "enabled" : "disabled");
4346 vam->retval = retval;
4347 vam->result_ready = 1;
4351 vl_api_show_one_status_reply_t_handler_json
4352 (vl_api_show_one_status_reply_t * mp)
4354 vat_main_t *vam = &vat_main;
4355 vat_json_node_t node;
4356 u8 *gpe_status = NULL;
4357 u8 *feature_status = NULL;
4359 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4360 feature_status = format (0, "%s",
4361 mp->feature_status ? "enabled" : "disabled");
4362 vec_add1 (gpe_status, 0);
4363 vec_add1 (feature_status, 0);
4365 vat_json_init_object (&node);
4366 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4367 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4369 vec_free (gpe_status);
4370 vec_free (feature_status);
4372 vat_json_print (vam->ofp, &node);
4373 vat_json_free (&node);
4375 vam->retval = ntohl (mp->retval);
4376 vam->result_ready = 1;
4380 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4381 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4383 vat_main_t *vam = &vat_main;
4384 i32 retval = ntohl (mp->retval);
4388 print (vam->ofp, "%=20s", mp->locator_set_name);
4391 vam->retval = retval;
4392 vam->result_ready = 1;
4396 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4397 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4399 vat_main_t *vam = &vat_main;
4400 vat_json_node_t *node = NULL;
4402 if (VAT_JSON_ARRAY != vam->json_tree.type)
4404 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4405 vat_json_init_array (&vam->json_tree);
4407 node = vat_json_array_add (&vam->json_tree);
4409 vat_json_init_object (node);
4410 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4412 vat_json_print (vam->ofp, node);
4413 vat_json_free (node);
4415 vam->retval = ntohl (mp->retval);
4416 vam->result_ready = 1;
4420 format_lisp_map_request_mode (u8 * s, va_list * args)
4422 u32 mode = va_arg (*args, u32);
4427 return format (0, "dst-only");
4429 return format (0, "src-dst");
4435 vl_api_show_one_map_request_mode_reply_t_handler
4436 (vl_api_show_one_map_request_mode_reply_t * mp)
4438 vat_main_t *vam = &vat_main;
4439 i32 retval = ntohl (mp->retval);
4443 u32 mode = mp->mode;
4444 print (vam->ofp, "map_request_mode: %U",
4445 format_lisp_map_request_mode, mode);
4448 vam->retval = retval;
4449 vam->result_ready = 1;
4453 vl_api_show_one_map_request_mode_reply_t_handler_json
4454 (vl_api_show_one_map_request_mode_reply_t * mp)
4456 vat_main_t *vam = &vat_main;
4457 vat_json_node_t node;
4462 s = format (0, "%U", format_lisp_map_request_mode, mode);
4465 vat_json_init_object (&node);
4466 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4467 vat_json_print (vam->ofp, &node);
4468 vat_json_free (&node);
4471 vam->retval = ntohl (mp->retval);
4472 vam->result_ready = 1;
4476 vl_api_one_show_xtr_mode_reply_t_handler
4477 (vl_api_one_show_xtr_mode_reply_t * mp)
4479 vat_main_t *vam = &vat_main;
4480 i32 retval = ntohl (mp->retval);
4484 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4487 vam->retval = retval;
4488 vam->result_ready = 1;
4492 vl_api_one_show_xtr_mode_reply_t_handler_json
4493 (vl_api_one_show_xtr_mode_reply_t * mp)
4495 vat_main_t *vam = &vat_main;
4496 vat_json_node_t node;
4499 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4500 vec_add1 (status, 0);
4502 vat_json_init_object (&node);
4503 vat_json_object_add_string_copy (&node, "status", status);
4507 vat_json_print (vam->ofp, &node);
4508 vat_json_free (&node);
4510 vam->retval = ntohl (mp->retval);
4511 vam->result_ready = 1;
4515 vl_api_one_show_pitr_mode_reply_t_handler
4516 (vl_api_one_show_pitr_mode_reply_t * mp)
4518 vat_main_t *vam = &vat_main;
4519 i32 retval = ntohl (mp->retval);
4523 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4526 vam->retval = retval;
4527 vam->result_ready = 1;
4531 vl_api_one_show_pitr_mode_reply_t_handler_json
4532 (vl_api_one_show_pitr_mode_reply_t * mp)
4534 vat_main_t *vam = &vat_main;
4535 vat_json_node_t node;
4538 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4539 vec_add1 (status, 0);
4541 vat_json_init_object (&node);
4542 vat_json_object_add_string_copy (&node, "status", status);
4546 vat_json_print (vam->ofp, &node);
4547 vat_json_free (&node);
4549 vam->retval = ntohl (mp->retval);
4550 vam->result_ready = 1;
4554 vl_api_one_show_petr_mode_reply_t_handler
4555 (vl_api_one_show_petr_mode_reply_t * mp)
4557 vat_main_t *vam = &vat_main;
4558 i32 retval = ntohl (mp->retval);
4562 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4565 vam->retval = retval;
4566 vam->result_ready = 1;
4570 vl_api_one_show_petr_mode_reply_t_handler_json
4571 (vl_api_one_show_petr_mode_reply_t * mp)
4573 vat_main_t *vam = &vat_main;
4574 vat_json_node_t node;
4577 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4578 vec_add1 (status, 0);
4580 vat_json_init_object (&node);
4581 vat_json_object_add_string_copy (&node, "status", status);
4585 vat_json_print (vam->ofp, &node);
4586 vat_json_free (&node);
4588 vam->retval = ntohl (mp->retval);
4589 vam->result_ready = 1;
4593 vl_api_show_one_use_petr_reply_t_handler
4594 (vl_api_show_one_use_petr_reply_t * mp)
4596 vat_main_t *vam = &vat_main;
4597 i32 retval = ntohl (mp->retval);
4601 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4604 print (vam->ofp, "Proxy-ETR address; %U",
4605 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4610 vam->retval = retval;
4611 vam->result_ready = 1;
4615 vl_api_show_one_use_petr_reply_t_handler_json
4616 (vl_api_show_one_use_petr_reply_t * mp)
4618 vat_main_t *vam = &vat_main;
4619 vat_json_node_t node;
4622 struct in6_addr ip6;
4624 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4625 vec_add1 (status, 0);
4627 vat_json_init_object (&node);
4628 vat_json_object_add_string_copy (&node, "status", status);
4633 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4634 vat_json_object_add_ip6 (&node, "address", ip6);
4638 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4639 vat_json_object_add_ip4 (&node, "address", ip4);
4645 vat_json_print (vam->ofp, &node);
4646 vat_json_free (&node);
4648 vam->retval = ntohl (mp->retval);
4649 vam->result_ready = 1;
4653 vl_api_show_one_nsh_mapping_reply_t_handler
4654 (vl_api_show_one_nsh_mapping_reply_t * mp)
4656 vat_main_t *vam = &vat_main;
4657 i32 retval = ntohl (mp->retval);
4661 print (vam->ofp, "%-20s%-16s",
4662 mp->is_set ? "set" : "not-set",
4663 mp->is_set ? (char *) mp->locator_set_name : "");
4666 vam->retval = retval;
4667 vam->result_ready = 1;
4671 vl_api_show_one_nsh_mapping_reply_t_handler_json
4672 (vl_api_show_one_nsh_mapping_reply_t * mp)
4674 vat_main_t *vam = &vat_main;
4675 vat_json_node_t node;
4678 status = format (0, "%s", mp->is_set ? "yes" : "no");
4679 vec_add1 (status, 0);
4681 vat_json_init_object (&node);
4682 vat_json_object_add_string_copy (&node, "is_set", status);
4685 vat_json_object_add_string_copy (&node, "locator_set",
4686 mp->locator_set_name);
4691 vat_json_print (vam->ofp, &node);
4692 vat_json_free (&node);
4694 vam->retval = ntohl (mp->retval);
4695 vam->result_ready = 1;
4699 vl_api_show_one_map_register_ttl_reply_t_handler
4700 (vl_api_show_one_map_register_ttl_reply_t * mp)
4702 vat_main_t *vam = &vat_main;
4703 i32 retval = ntohl (mp->retval);
4705 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4709 print (vam->ofp, "ttl: %u", mp->ttl);
4712 vam->retval = retval;
4713 vam->result_ready = 1;
4717 vl_api_show_one_map_register_ttl_reply_t_handler_json
4718 (vl_api_show_one_map_register_ttl_reply_t * mp)
4720 vat_main_t *vam = &vat_main;
4721 vat_json_node_t node;
4723 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4724 vat_json_init_object (&node);
4725 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4727 vat_json_print (vam->ofp, &node);
4728 vat_json_free (&node);
4730 vam->retval = ntohl (mp->retval);
4731 vam->result_ready = 1;
4735 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4737 vat_main_t *vam = &vat_main;
4738 i32 retval = ntohl (mp->retval);
4742 print (vam->ofp, "%-20s%-16s",
4743 mp->status ? "enabled" : "disabled",
4744 mp->status ? (char *) mp->locator_set_name : "");
4747 vam->retval = retval;
4748 vam->result_ready = 1;
4752 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4754 vat_main_t *vam = &vat_main;
4755 vat_json_node_t node;
4758 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4759 vec_add1 (status, 0);
4761 vat_json_init_object (&node);
4762 vat_json_object_add_string_copy (&node, "status", status);
4765 vat_json_object_add_string_copy (&node, "locator_set",
4766 mp->locator_set_name);
4771 vat_json_print (vam->ofp, &node);
4772 vat_json_free (&node);
4774 vam->retval = ntohl (mp->retval);
4775 vam->result_ready = 1;
4779 format_policer_type (u8 * s, va_list * va)
4781 u32 i = va_arg (*va, u32);
4783 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4784 s = format (s, "1r2c");
4785 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4786 s = format (s, "1r3c");
4787 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4788 s = format (s, "2r3c-2698");
4789 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4790 s = format (s, "2r3c-4115");
4791 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4792 s = format (s, "2r3c-mef5cf1");
4794 s = format (s, "ILLEGAL");
4799 format_policer_rate_type (u8 * s, va_list * va)
4801 u32 i = va_arg (*va, u32);
4803 if (i == SSE2_QOS_RATE_KBPS)
4804 s = format (s, "kbps");
4805 else if (i == SSE2_QOS_RATE_PPS)
4806 s = format (s, "pps");
4808 s = format (s, "ILLEGAL");
4813 format_policer_round_type (u8 * s, va_list * va)
4815 u32 i = va_arg (*va, u32);
4817 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4818 s = format (s, "closest");
4819 else if (i == SSE2_QOS_ROUND_TO_UP)
4820 s = format (s, "up");
4821 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4822 s = format (s, "down");
4824 s = format (s, "ILLEGAL");
4829 format_policer_action_type (u8 * s, va_list * va)
4831 u32 i = va_arg (*va, u32);
4833 if (i == SSE2_QOS_ACTION_DROP)
4834 s = format (s, "drop");
4835 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4836 s = format (s, "transmit");
4837 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4838 s = format (s, "mark-and-transmit");
4840 s = format (s, "ILLEGAL");
4845 format_dscp (u8 * s, va_list * va)
4847 u32 i = va_arg (*va, u32);
4852 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4856 return format (s, "ILLEGAL");
4858 s = format (s, "%s", t);
4863 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4865 vat_main_t *vam = &vat_main;
4866 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4868 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4869 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4871 conform_dscp_str = format (0, "");
4873 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4874 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4876 exceed_dscp_str = format (0, "");
4878 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4879 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4881 violate_dscp_str = format (0, "");
4883 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4884 "rate type %U, round type %U, %s rate, %s color-aware, "
4885 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4886 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4887 "conform action %U%s, exceed action %U%s, violate action %U%s",
4889 format_policer_type, mp->type,
4892 clib_net_to_host_u64 (mp->cb),
4893 clib_net_to_host_u64 (mp->eb),
4894 format_policer_rate_type, mp->rate_type,
4895 format_policer_round_type, mp->round_type,
4896 mp->single_rate ? "single" : "dual",
4897 mp->color_aware ? "is" : "not",
4898 ntohl (mp->cir_tokens_per_period),
4899 ntohl (mp->pir_tokens_per_period),
4901 ntohl (mp->current_limit),
4902 ntohl (mp->current_bucket),
4903 ntohl (mp->extended_limit),
4904 ntohl (mp->extended_bucket),
4905 clib_net_to_host_u64 (mp->last_update_time),
4906 format_policer_action_type, mp->conform_action_type,
4908 format_policer_action_type, mp->exceed_action_type,
4910 format_policer_action_type, mp->violate_action_type,
4913 vec_free (conform_dscp_str);
4914 vec_free (exceed_dscp_str);
4915 vec_free (violate_dscp_str);
4918 static void vl_api_policer_details_t_handler_json
4919 (vl_api_policer_details_t * mp)
4921 vat_main_t *vam = &vat_main;
4922 vat_json_node_t *node;
4923 u8 *rate_type_str, *round_type_str, *type_str;
4924 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4926 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4928 format (0, "%U", format_policer_round_type, mp->round_type);
4929 type_str = format (0, "%U", format_policer_type, mp->type);
4930 conform_action_str = format (0, "%U", format_policer_action_type,
4931 mp->conform_action_type);
4932 exceed_action_str = format (0, "%U", format_policer_action_type,
4933 mp->exceed_action_type);
4934 violate_action_str = format (0, "%U", format_policer_action_type,
4935 mp->violate_action_type);
4937 if (VAT_JSON_ARRAY != vam->json_tree.type)
4939 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4940 vat_json_init_array (&vam->json_tree);
4942 node = vat_json_array_add (&vam->json_tree);
4944 vat_json_init_object (node);
4945 vat_json_object_add_string_copy (node, "name", mp->name);
4946 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4947 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4948 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4949 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4950 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4951 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4952 vat_json_object_add_string_copy (node, "type", type_str);
4953 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4954 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4955 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4956 vat_json_object_add_uint (node, "cir_tokens_per_period",
4957 ntohl (mp->cir_tokens_per_period));
4958 vat_json_object_add_uint (node, "eir_tokens_per_period",
4959 ntohl (mp->pir_tokens_per_period));
4960 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4961 vat_json_object_add_uint (node, "current_bucket",
4962 ntohl (mp->current_bucket));
4963 vat_json_object_add_uint (node, "extended_limit",
4964 ntohl (mp->extended_limit));
4965 vat_json_object_add_uint (node, "extended_bucket",
4966 ntohl (mp->extended_bucket));
4967 vat_json_object_add_uint (node, "last_update_time",
4968 ntohl (mp->last_update_time));
4969 vat_json_object_add_string_copy (node, "conform_action",
4970 conform_action_str);
4971 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4973 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4974 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4975 vec_free (dscp_str);
4977 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4978 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4980 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4981 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4982 vec_free (dscp_str);
4984 vat_json_object_add_string_copy (node, "violate_action",
4985 violate_action_str);
4986 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4988 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4989 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4990 vec_free (dscp_str);
4993 vec_free (rate_type_str);
4994 vec_free (round_type_str);
4995 vec_free (type_str);
4996 vec_free (conform_action_str);
4997 vec_free (exceed_action_str);
4998 vec_free (violate_action_str);
5002 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
5005 vat_main_t *vam = &vat_main;
5006 int i, count = ntohl (mp->count);
5009 print (vam->ofp, "classify table ids (%d) : ", count);
5010 for (i = 0; i < count; i++)
5012 print (vam->ofp, "%d", ntohl (mp->ids[i]));
5013 print (vam->ofp, (i < count - 1) ? "," : "");
5015 vam->retval = ntohl (mp->retval);
5016 vam->result_ready = 1;
5020 vl_api_classify_table_ids_reply_t_handler_json
5021 (vl_api_classify_table_ids_reply_t * mp)
5023 vat_main_t *vam = &vat_main;
5024 int i, count = ntohl (mp->count);
5028 vat_json_node_t node;
5030 vat_json_init_object (&node);
5031 for (i = 0; i < count; i++)
5033 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
5035 vat_json_print (vam->ofp, &node);
5036 vat_json_free (&node);
5038 vam->retval = ntohl (mp->retval);
5039 vam->result_ready = 1;
5043 vl_api_classify_table_by_interface_reply_t_handler
5044 (vl_api_classify_table_by_interface_reply_t * mp)
5046 vat_main_t *vam = &vat_main;
5049 table_id = ntohl (mp->l2_table_id);
5051 print (vam->ofp, "l2 table id : %d", table_id);
5053 print (vam->ofp, "l2 table id : No input ACL tables configured");
5054 table_id = ntohl (mp->ip4_table_id);
5056 print (vam->ofp, "ip4 table id : %d", table_id);
5058 print (vam->ofp, "ip4 table id : No input ACL tables configured");
5059 table_id = ntohl (mp->ip6_table_id);
5061 print (vam->ofp, "ip6 table id : %d", table_id);
5063 print (vam->ofp, "ip6 table id : No input ACL tables configured");
5064 vam->retval = ntohl (mp->retval);
5065 vam->result_ready = 1;
5069 vl_api_classify_table_by_interface_reply_t_handler_json
5070 (vl_api_classify_table_by_interface_reply_t * mp)
5072 vat_main_t *vam = &vat_main;
5073 vat_json_node_t node;
5075 vat_json_init_object (&node);
5077 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
5078 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
5079 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
5081 vat_json_print (vam->ofp, &node);
5082 vat_json_free (&node);
5084 vam->retval = ntohl (mp->retval);
5085 vam->result_ready = 1;
5088 static void vl_api_policer_add_del_reply_t_handler
5089 (vl_api_policer_add_del_reply_t * mp)
5091 vat_main_t *vam = &vat_main;
5092 i32 retval = ntohl (mp->retval);
5093 if (vam->async_mode)
5095 vam->async_errors += (retval < 0);
5099 vam->retval = retval;
5100 vam->result_ready = 1;
5101 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
5103 * Note: this is just barely thread-safe, depends on
5104 * the main thread spinning waiting for an answer...
5106 errmsg ("policer index %d", ntohl (mp->policer_index));
5110 static void vl_api_policer_add_del_reply_t_handler_json
5111 (vl_api_policer_add_del_reply_t * mp)
5113 vat_main_t *vam = &vat_main;
5114 vat_json_node_t node;
5116 vat_json_init_object (&node);
5117 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5118 vat_json_object_add_uint (&node, "policer_index",
5119 ntohl (mp->policer_index));
5121 vat_json_print (vam->ofp, &node);
5122 vat_json_free (&node);
5124 vam->retval = ntohl (mp->retval);
5125 vam->result_ready = 1;
5128 /* Format hex dump. */
5130 format_hex_bytes (u8 * s, va_list * va)
5132 u8 *bytes = va_arg (*va, u8 *);
5133 int n_bytes = va_arg (*va, int);
5136 /* Print short or long form depending on byte count. */
5137 uword short_form = n_bytes <= 32;
5138 u32 indent = format_get_indent (s);
5143 for (i = 0; i < n_bytes; i++)
5145 if (!short_form && (i % 32) == 0)
5146 s = format (s, "%08x: ", i);
5147 s = format (s, "%02x", bytes[i]);
5148 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
5149 s = format (s, "\n%U", format_white_space, indent);
5156 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
5159 vat_main_t *vam = &vat_main;
5160 i32 retval = ntohl (mp->retval);
5163 print (vam->ofp, "classify table info :");
5164 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
5165 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
5166 ntohl (mp->miss_next_index));
5167 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
5168 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
5169 ntohl (mp->match_n_vectors));
5170 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
5171 ntohl (mp->mask_length));
5173 vam->retval = retval;
5174 vam->result_ready = 1;
5178 vl_api_classify_table_info_reply_t_handler_json
5179 (vl_api_classify_table_info_reply_t * mp)
5181 vat_main_t *vam = &vat_main;
5182 vat_json_node_t node;
5184 i32 retval = ntohl (mp->retval);
5187 vat_json_init_object (&node);
5189 vat_json_object_add_int (&node, "sessions",
5190 ntohl (mp->active_sessions));
5191 vat_json_object_add_int (&node, "nexttbl",
5192 ntohl (mp->next_table_index));
5193 vat_json_object_add_int (&node, "nextnode",
5194 ntohl (mp->miss_next_index));
5195 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
5196 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
5197 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
5198 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
5199 ntohl (mp->mask_length), 0);
5200 vat_json_object_add_string_copy (&node, "mask", s);
5202 vat_json_print (vam->ofp, &node);
5203 vat_json_free (&node);
5205 vam->retval = ntohl (mp->retval);
5206 vam->result_ready = 1;
5210 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
5213 vat_main_t *vam = &vat_main;
5215 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
5216 ntohl (mp->hit_next_index), ntohl (mp->advance),
5217 ntohl (mp->opaque_index));
5218 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
5219 ntohl (mp->match_length));
5223 vl_api_classify_session_details_t_handler_json
5224 (vl_api_classify_session_details_t * mp)
5226 vat_main_t *vam = &vat_main;
5227 vat_json_node_t *node = NULL;
5229 if (VAT_JSON_ARRAY != vam->json_tree.type)
5231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5232 vat_json_init_array (&vam->json_tree);
5234 node = vat_json_array_add (&vam->json_tree);
5236 vat_json_init_object (node);
5237 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5238 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5239 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5241 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5243 vat_json_object_add_string_copy (node, "match", s);
5246 static void vl_api_pg_create_interface_reply_t_handler
5247 (vl_api_pg_create_interface_reply_t * mp)
5249 vat_main_t *vam = &vat_main;
5251 vam->retval = ntohl (mp->retval);
5252 vam->result_ready = 1;
5255 static void vl_api_pg_create_interface_reply_t_handler_json
5256 (vl_api_pg_create_interface_reply_t * mp)
5258 vat_main_t *vam = &vat_main;
5259 vat_json_node_t node;
5261 i32 retval = ntohl (mp->retval);
5264 vat_json_init_object (&node);
5266 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5268 vat_json_print (vam->ofp, &node);
5269 vat_json_free (&node);
5271 vam->retval = ntohl (mp->retval);
5272 vam->result_ready = 1;
5275 static void vl_api_policer_classify_details_t_handler
5276 (vl_api_policer_classify_details_t * mp)
5278 vat_main_t *vam = &vat_main;
5280 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5281 ntohl (mp->table_index));
5284 static void vl_api_policer_classify_details_t_handler_json
5285 (vl_api_policer_classify_details_t * mp)
5287 vat_main_t *vam = &vat_main;
5288 vat_json_node_t *node;
5290 if (VAT_JSON_ARRAY != vam->json_tree.type)
5292 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5293 vat_json_init_array (&vam->json_tree);
5295 node = vat_json_array_add (&vam->json_tree);
5297 vat_json_init_object (node);
5298 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5299 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5302 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5303 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5305 vat_main_t *vam = &vat_main;
5306 i32 retval = ntohl (mp->retval);
5307 if (vam->async_mode)
5309 vam->async_errors += (retval < 0);
5313 vam->retval = retval;
5314 vam->sw_if_index = ntohl (mp->sw_if_index);
5315 vam->result_ready = 1;
5317 vam->regenerate_interface_table = 1;
5320 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5321 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5323 vat_main_t *vam = &vat_main;
5324 vat_json_node_t node;
5326 vat_json_init_object (&node);
5327 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5328 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5330 vat_json_print (vam->ofp, &node);
5331 vat_json_free (&node);
5333 vam->retval = ntohl (mp->retval);
5334 vam->result_ready = 1;
5337 static void vl_api_flow_classify_details_t_handler
5338 (vl_api_flow_classify_details_t * mp)
5340 vat_main_t *vam = &vat_main;
5342 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5343 ntohl (mp->table_index));
5346 static void vl_api_flow_classify_details_t_handler_json
5347 (vl_api_flow_classify_details_t * mp)
5349 vat_main_t *vam = &vat_main;
5350 vat_json_node_t *node;
5352 if (VAT_JSON_ARRAY != vam->json_tree.type)
5354 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5355 vat_json_init_array (&vam->json_tree);
5357 node = vat_json_array_add (&vam->json_tree);
5359 vat_json_init_object (node);
5360 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5361 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5364 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5365 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5366 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5367 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5368 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5369 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5370 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5371 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5372 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5373 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5374 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5375 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5376 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5377 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5378 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5379 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5380 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5381 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5382 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5383 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5384 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5385 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5388 * Generate boilerplate reply handlers, which
5389 * dig the return value out of the xxx_reply_t API message,
5390 * stick it into vam->retval, and set vam->result_ready
5392 * Could also do this by pointing N message decode slots at
5393 * a single function, but that could break in subtle ways.
5396 #define foreach_standard_reply_retval_handler \
5397 _(sw_interface_set_flags_reply) \
5398 _(sw_interface_add_del_address_reply) \
5399 _(sw_interface_set_rx_mode_reply) \
5400 _(sw_interface_set_table_reply) \
5401 _(sw_interface_set_mpls_enable_reply) \
5402 _(sw_interface_set_vpath_reply) \
5403 _(sw_interface_set_vxlan_bypass_reply) \
5404 _(sw_interface_set_geneve_bypass_reply) \
5405 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5406 _(sw_interface_set_l2_bridge_reply) \
5407 _(bridge_domain_add_del_reply) \
5408 _(sw_interface_set_l2_xconnect_reply) \
5409 _(l2fib_add_del_reply) \
5410 _(l2fib_flush_int_reply) \
5411 _(l2fib_flush_bd_reply) \
5412 _(ip_add_del_route_reply) \
5413 _(ip_table_add_del_reply) \
5414 _(ip_mroute_add_del_reply) \
5415 _(mpls_route_add_del_reply) \
5416 _(mpls_table_add_del_reply) \
5417 _(mpls_ip_bind_unbind_reply) \
5418 _(bier_route_add_del_reply) \
5419 _(bier_table_add_del_reply) \
5420 _(proxy_arp_add_del_reply) \
5421 _(proxy_arp_intfc_enable_disable_reply) \
5422 _(sw_interface_set_unnumbered_reply) \
5423 _(ip_neighbor_add_del_reply) \
5424 _(oam_add_del_reply) \
5425 _(reset_fib_reply) \
5426 _(dhcp_proxy_config_reply) \
5427 _(dhcp_proxy_set_vss_reply) \
5428 _(dhcp_client_config_reply) \
5429 _(set_ip_flow_hash_reply) \
5430 _(sw_interface_ip6_enable_disable_reply) \
5431 _(sw_interface_ip6_set_link_local_address_reply) \
5432 _(ip6nd_proxy_add_del_reply) \
5433 _(sw_interface_ip6nd_ra_prefix_reply) \
5434 _(sw_interface_ip6nd_ra_config_reply) \
5435 _(set_arp_neighbor_limit_reply) \
5436 _(l2_patch_add_del_reply) \
5437 _(sr_policy_add_reply) \
5438 _(sr_policy_mod_reply) \
5439 _(sr_policy_del_reply) \
5440 _(sr_localsid_add_del_reply) \
5441 _(sr_steering_add_del_reply) \
5442 _(classify_add_del_session_reply) \
5443 _(classify_set_interface_ip_table_reply) \
5444 _(classify_set_interface_l2_tables_reply) \
5445 _(l2tpv3_set_tunnel_cookies_reply) \
5446 _(l2tpv3_interface_enable_disable_reply) \
5447 _(l2tpv3_set_lookup_key_reply) \
5448 _(l2_fib_clear_table_reply) \
5449 _(l2_interface_efp_filter_reply) \
5450 _(l2_interface_vlan_tag_rewrite_reply) \
5451 _(modify_vhost_user_if_reply) \
5452 _(delete_vhost_user_if_reply) \
5453 _(ip_probe_neighbor_reply) \
5454 _(ip_scan_neighbor_enable_disable_reply) \
5455 _(want_ip4_arp_events_reply) \
5456 _(want_ip6_nd_events_reply) \
5457 _(want_l2_macs_events_reply) \
5458 _(input_acl_set_interface_reply) \
5459 _(ipsec_spd_add_del_reply) \
5460 _(ipsec_interface_add_del_spd_reply) \
5461 _(ipsec_spd_add_del_entry_reply) \
5462 _(ipsec_sad_add_del_entry_reply) \
5463 _(ipsec_sa_set_key_reply) \
5464 _(ipsec_tunnel_if_add_del_reply) \
5465 _(ipsec_tunnel_if_set_key_reply) \
5466 _(ipsec_tunnel_if_set_sa_reply) \
5467 _(ikev2_profile_add_del_reply) \
5468 _(ikev2_profile_set_auth_reply) \
5469 _(ikev2_profile_set_id_reply) \
5470 _(ikev2_profile_set_ts_reply) \
5471 _(ikev2_set_local_key_reply) \
5472 _(ikev2_set_responder_reply) \
5473 _(ikev2_set_ike_transforms_reply) \
5474 _(ikev2_set_esp_transforms_reply) \
5475 _(ikev2_set_sa_lifetime_reply) \
5476 _(ikev2_initiate_sa_init_reply) \
5477 _(ikev2_initiate_del_ike_sa_reply) \
5478 _(ikev2_initiate_del_child_sa_reply) \
5479 _(ikev2_initiate_rekey_child_sa_reply) \
5480 _(delete_loopback_reply) \
5481 _(bd_ip_mac_add_del_reply) \
5482 _(map_del_domain_reply) \
5483 _(map_add_del_rule_reply) \
5484 _(want_interface_events_reply) \
5485 _(want_stats_reply) \
5486 _(cop_interface_enable_disable_reply) \
5487 _(cop_whitelist_enable_disable_reply) \
5488 _(sw_interface_clear_stats_reply) \
5489 _(ioam_enable_reply) \
5490 _(ioam_disable_reply) \
5491 _(one_add_del_locator_reply) \
5492 _(one_add_del_local_eid_reply) \
5493 _(one_add_del_remote_mapping_reply) \
5494 _(one_add_del_adjacency_reply) \
5495 _(one_add_del_map_resolver_reply) \
5496 _(one_add_del_map_server_reply) \
5497 _(one_enable_disable_reply) \
5498 _(one_rloc_probe_enable_disable_reply) \
5499 _(one_map_register_enable_disable_reply) \
5500 _(one_map_register_set_ttl_reply) \
5501 _(one_set_transport_protocol_reply) \
5502 _(one_map_register_fallback_threshold_reply) \
5503 _(one_pitr_set_locator_set_reply) \
5504 _(one_map_request_mode_reply) \
5505 _(one_add_del_map_request_itr_rlocs_reply) \
5506 _(one_eid_table_add_del_map_reply) \
5507 _(one_use_petr_reply) \
5508 _(one_stats_enable_disable_reply) \
5509 _(one_add_del_l2_arp_entry_reply) \
5510 _(one_add_del_ndp_entry_reply) \
5511 _(one_stats_flush_reply) \
5512 _(one_enable_disable_xtr_mode_reply) \
5513 _(one_enable_disable_pitr_mode_reply) \
5514 _(one_enable_disable_petr_mode_reply) \
5515 _(gpe_enable_disable_reply) \
5516 _(gpe_set_encap_mode_reply) \
5517 _(gpe_add_del_iface_reply) \
5518 _(gpe_add_del_native_fwd_rpath_reply) \
5519 _(af_packet_delete_reply) \
5520 _(policer_classify_set_interface_reply) \
5521 _(netmap_create_reply) \
5522 _(netmap_delete_reply) \
5523 _(set_ipfix_exporter_reply) \
5524 _(set_ipfix_classify_stream_reply) \
5525 _(ipfix_classify_table_add_del_reply) \
5526 _(flow_classify_set_interface_reply) \
5527 _(sw_interface_span_enable_disable_reply) \
5528 _(pg_capture_reply) \
5529 _(pg_enable_disable_reply) \
5530 _(ip_source_and_port_range_check_add_del_reply) \
5531 _(ip_source_and_port_range_check_interface_add_del_reply)\
5532 _(delete_subif_reply) \
5533 _(l2_interface_pbb_tag_rewrite_reply) \
5535 _(feature_enable_disable_reply) \
5536 _(sw_interface_tag_add_del_reply) \
5537 _(sw_interface_set_mtu_reply) \
5538 _(p2p_ethernet_add_reply) \
5539 _(p2p_ethernet_del_reply) \
5540 _(lldp_config_reply) \
5541 _(sw_interface_set_lldp_reply) \
5542 _(tcp_configure_src_addresses_reply) \
5543 _(dns_enable_disable_reply) \
5544 _(dns_name_server_add_del_reply) \
5545 _(session_rule_add_del_reply) \
5546 _(ip_container_proxy_add_del_reply) \
5547 _(output_acl_set_interface_reply) \
5548 _(qos_record_enable_disable_reply)
5551 static void vl_api_##n##_t_handler \
5552 (vl_api_##n##_t * mp) \
5554 vat_main_t * vam = &vat_main; \
5555 i32 retval = ntohl(mp->retval); \
5556 if (vam->async_mode) { \
5557 vam->async_errors += (retval < 0); \
5559 vam->retval = retval; \
5560 vam->result_ready = 1; \
5563 foreach_standard_reply_retval_handler;
5567 static void vl_api_##n##_t_handler_json \
5568 (vl_api_##n##_t * mp) \
5570 vat_main_t * vam = &vat_main; \
5571 vat_json_node_t node; \
5572 vat_json_init_object(&node); \
5573 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5574 vat_json_print(vam->ofp, &node); \
5575 vam->retval = ntohl(mp->retval); \
5576 vam->result_ready = 1; \
5578 foreach_standard_reply_retval_handler;
5582 * Table of message reply handlers, must include boilerplate handlers
5586 #define foreach_vpe_api_reply_msg \
5587 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5588 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5589 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5590 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5591 _(CONTROL_PING_REPLY, control_ping_reply) \
5592 _(CLI_REPLY, cli_reply) \
5593 _(CLI_INBAND_REPLY, cli_inband_reply) \
5594 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5595 sw_interface_add_del_address_reply) \
5596 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5597 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5598 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5599 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5600 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5601 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5602 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5603 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5604 sw_interface_set_l2_xconnect_reply) \
5605 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5606 sw_interface_set_l2_bridge_reply) \
5607 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5608 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5609 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5610 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5611 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5612 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5613 _(L2_FLAGS_REPLY, l2_flags_reply) \
5614 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5615 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5616 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5617 _(TAP_DELETE_REPLY, tap_delete_reply) \
5618 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5619 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5620 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5621 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5622 _(BOND_CREATE_REPLY, bond_create_reply) \
5623 _(BOND_DELETE_REPLY, bond_delete_reply) \
5624 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5625 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5626 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5627 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5628 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5629 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5630 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5631 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5632 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5633 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5634 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5635 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5636 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5637 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5638 proxy_arp_intfc_enable_disable_reply) \
5639 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5640 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5641 sw_interface_set_unnumbered_reply) \
5642 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5643 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5644 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5645 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5646 _(RESET_FIB_REPLY, reset_fib_reply) \
5647 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5648 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5649 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5650 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5651 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5652 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5653 sw_interface_ip6_enable_disable_reply) \
5654 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5655 sw_interface_ip6_set_link_local_address_reply) \
5656 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5657 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5658 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5659 sw_interface_ip6nd_ra_prefix_reply) \
5660 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5661 sw_interface_ip6nd_ra_config_reply) \
5662 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5663 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5664 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5665 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5666 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5667 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5668 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5669 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5670 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5671 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5672 classify_set_interface_ip_table_reply) \
5673 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5674 classify_set_interface_l2_tables_reply) \
5675 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5676 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5677 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5678 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5679 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5680 l2tpv3_interface_enable_disable_reply) \
5681 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5682 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5683 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5684 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5685 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5686 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5687 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5688 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5689 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5690 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5691 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5692 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5693 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5694 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5695 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5696 _(SHOW_VERSION_REPLY, show_version_reply) \
5697 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5698 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5699 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5700 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5701 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5702 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5703 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5704 _(IP4_ARP_EVENT, ip4_arp_event) \
5705 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5706 _(IP6_ND_EVENT, ip6_nd_event) \
5707 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5708 _(L2_MACS_EVENT, l2_macs_event) \
5709 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5710 _(IP_ADDRESS_DETAILS, ip_address_details) \
5711 _(IP_DETAILS, ip_details) \
5712 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5713 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5714 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5715 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5716 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5717 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5718 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5719 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5720 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5721 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5722 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5723 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5724 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5725 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5726 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5727 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5728 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5729 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5730 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5731 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5732 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5733 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5734 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5735 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5736 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5737 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5738 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5739 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5740 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5741 _(MAP_RULE_DETAILS, map_rule_details) \
5742 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5743 _(WANT_STATS_REPLY, want_stats_reply) \
5744 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5745 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5746 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5747 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5748 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5749 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5750 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5751 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5752 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5753 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5754 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5755 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5756 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5757 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5758 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5759 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5760 one_map_register_enable_disable_reply) \
5761 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5762 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5763 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5764 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5765 one_map_register_fallback_threshold_reply) \
5766 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5767 one_rloc_probe_enable_disable_reply) \
5768 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5769 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5770 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5771 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5772 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5773 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5774 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5775 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5776 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5777 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5778 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5779 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5780 _(ONE_STATS_DETAILS, one_stats_details) \
5781 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5782 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5783 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5784 show_one_stats_enable_disable_reply) \
5785 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5786 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5787 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5788 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5789 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5790 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5791 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5792 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5793 one_enable_disable_pitr_mode_reply) \
5794 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5795 one_enable_disable_petr_mode_reply) \
5796 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5797 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5798 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5799 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5800 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5801 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5802 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5803 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5804 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5805 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5806 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5807 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5808 gpe_add_del_native_fwd_rpath_reply) \
5809 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5810 gpe_fwd_entry_path_details) \
5811 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5812 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5813 one_add_del_map_request_itr_rlocs_reply) \
5814 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5815 one_get_map_request_itr_rlocs_reply) \
5816 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5817 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5818 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5819 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5820 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5821 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5822 show_one_map_register_state_reply) \
5823 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5824 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5825 show_one_map_register_fallback_threshold_reply) \
5826 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5827 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5828 _(AF_PACKET_DETAILS, af_packet_details) \
5829 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5830 _(POLICER_DETAILS, policer_details) \
5831 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5832 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5833 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5834 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5835 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5836 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5837 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5838 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5839 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5840 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5841 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5842 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5843 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5844 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5845 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5846 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5847 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5848 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5849 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5850 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5851 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5852 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5853 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5854 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5855 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5856 ip_source_and_port_range_check_add_del_reply) \
5857 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5858 ip_source_and_port_range_check_interface_add_del_reply) \
5859 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5860 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5861 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5862 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5863 _(PUNT_REPLY, punt_reply) \
5864 _(IP_FIB_DETAILS, ip_fib_details) \
5865 _(IP6_FIB_DETAILS, ip6_fib_details) \
5866 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5867 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5868 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5869 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5870 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5871 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5872 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5873 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5874 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5875 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5876 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5877 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5878 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5879 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5880 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5881 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5882 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5883 _(SESSION_RULES_DETAILS, session_rules_details) \
5884 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5885 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5886 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5888 #define foreach_standalone_reply_msg \
5889 _(SW_INTERFACE_EVENT, sw_interface_event) \
5890 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5891 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5892 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5893 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5894 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5895 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5903 #define STR_VTR_OP_CASE(op) \
5904 case L2_VTR_ ## op: \
5908 str_vtr_op (u32 vtr_op)
5912 STR_VTR_OP_CASE (DISABLED);
5913 STR_VTR_OP_CASE (PUSH_1);
5914 STR_VTR_OP_CASE (PUSH_2);
5915 STR_VTR_OP_CASE (POP_1);
5916 STR_VTR_OP_CASE (POP_2);
5917 STR_VTR_OP_CASE (TRANSLATE_1_1);
5918 STR_VTR_OP_CASE (TRANSLATE_1_2);
5919 STR_VTR_OP_CASE (TRANSLATE_2_1);
5920 STR_VTR_OP_CASE (TRANSLATE_2_2);
5927 dump_sub_interface_table (vat_main_t * vam)
5929 const sw_interface_subif_t *sub = NULL;
5931 if (vam->json_output)
5934 ("JSON output supported only for VPE API calls and dump_stats_table");
5939 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5940 "Interface", "sw_if_index",
5941 "sub id", "dot1ad", "tags", "outer id",
5942 "inner id", "exact", "default", "outer any", "inner any");
5944 vec_foreach (sub, vam->sw_if_subif_table)
5947 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5948 sub->interface_name,
5950 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5951 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5952 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5953 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5954 if (sub->vtr_op != L2_VTR_DISABLED)
5957 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5958 "tag1: %d tag2: %d ]",
5959 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5960 sub->vtr_tag1, sub->vtr_tag2);
5968 name_sort_cmp (void *a1, void *a2)
5970 name_sort_t *n1 = a1;
5971 name_sort_t *n2 = a2;
5973 return strcmp ((char *) n1->name, (char *) n2->name);
5977 dump_interface_table (vat_main_t * vam)
5980 name_sort_t *nses = 0, *ns;
5982 if (vam->json_output)
5985 ("JSON output supported only for VPE API calls and dump_stats_table");
5990 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5992 vec_add2 (nses, ns, 1);
5993 ns->name = (u8 *)(p->key);
5994 ns->value = (u32) p->value[0];
5998 vec_sort_with_function (nses, name_sort_cmp);
6000 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6001 vec_foreach (ns, nses)
6003 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6010 dump_ip_table (vat_main_t * vam, int is_ipv6)
6012 const ip_details_t *det = NULL;
6013 const ip_address_details_t *address = NULL;
6016 print (vam->ofp, "%-12s", "sw_if_index");
6018 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6025 print (vam->ofp, "%-12d", i);
6026 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6031 vec_foreach (address, det->addr)
6035 is_ipv6 ? format_ip6_address : format_ip4_address,
6036 address->ip, address->prefix_length);
6044 dump_ipv4_table (vat_main_t * vam)
6046 if (vam->json_output)
6049 ("JSON output supported only for VPE API calls and dump_stats_table");
6053 return dump_ip_table (vam, 0);
6057 dump_ipv6_table (vat_main_t * vam)
6059 if (vam->json_output)
6062 ("JSON output supported only for VPE API calls and dump_stats_table");
6066 return dump_ip_table (vam, 1);
6070 counter_type_to_str (u8 counter_type, u8 is_combined)
6074 switch (counter_type)
6076 case VNET_INTERFACE_COUNTER_DROP:
6078 case VNET_INTERFACE_COUNTER_PUNT:
6080 case VNET_INTERFACE_COUNTER_IP4:
6082 case VNET_INTERFACE_COUNTER_IP6:
6084 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6086 case VNET_INTERFACE_COUNTER_RX_MISS:
6088 case VNET_INTERFACE_COUNTER_RX_ERROR:
6090 case VNET_INTERFACE_COUNTER_TX_ERROR:
6093 return "INVALID-COUNTER-TYPE";
6098 switch (counter_type)
6100 case VNET_INTERFACE_COUNTER_RX:
6102 case VNET_INTERFACE_COUNTER_TX:
6105 return "INVALID-COUNTER-TYPE";
6111 dump_stats_table (vat_main_t * vam)
6113 vat_json_node_t node;
6114 vat_json_node_t *msg_array;
6115 vat_json_node_t *msg;
6116 vat_json_node_t *counter_array;
6117 vat_json_node_t *counter;
6118 interface_counter_t c;
6120 ip4_fib_counter_t *c4;
6121 ip6_fib_counter_t *c6;
6122 ip4_nbr_counter_t *n4;
6123 ip6_nbr_counter_t *n6;
6126 if (!vam->json_output)
6128 clib_warning ("dump_stats_table supported only in JSON format");
6132 vat_json_init_object (&node);
6134 /* interface counters */
6135 msg_array = vat_json_object_add (&node, "interface_counters");
6136 vat_json_init_array (msg_array);
6137 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6139 msg = vat_json_array_add (msg_array);
6140 vat_json_init_object (msg);
6141 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6142 (u8 *) counter_type_to_str (i, 0));
6143 vat_json_object_add_int (msg, "is_combined", 0);
6144 counter_array = vat_json_object_add (msg, "data");
6145 vat_json_init_array (counter_array);
6146 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6148 packets = vam->simple_interface_counters[i][j];
6149 vat_json_array_add_uint (counter_array, packets);
6152 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6154 msg = vat_json_array_add (msg_array);
6155 vat_json_init_object (msg);
6156 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6157 (u8 *) counter_type_to_str (i, 1));
6158 vat_json_object_add_int (msg, "is_combined", 1);
6159 counter_array = vat_json_object_add (msg, "data");
6160 vat_json_init_array (counter_array);
6161 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6163 c = vam->combined_interface_counters[i][j];
6164 counter = vat_json_array_add (counter_array);
6165 vat_json_init_object (counter);
6166 vat_json_object_add_uint (counter, "packets", c.packets);
6167 vat_json_object_add_uint (counter, "bytes", c.bytes);
6171 /* ip4 fib counters */
6172 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6173 vat_json_init_array (msg_array);
6174 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6176 msg = vat_json_array_add (msg_array);
6177 vat_json_init_object (msg);
6178 vat_json_object_add_uint (msg, "vrf_id",
6179 vam->ip4_fib_counters_vrf_id_by_index[i]);
6180 counter_array = vat_json_object_add (msg, "c");
6181 vat_json_init_array (counter_array);
6182 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6184 counter = vat_json_array_add (counter_array);
6185 vat_json_init_object (counter);
6186 c4 = &vam->ip4_fib_counters[i][j];
6187 vat_json_object_add_ip4 (counter, "address", c4->address);
6188 vat_json_object_add_uint (counter, "address_length",
6189 c4->address_length);
6190 vat_json_object_add_uint (counter, "packets", c4->packets);
6191 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6195 /* ip6 fib counters */
6196 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6197 vat_json_init_array (msg_array);
6198 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6200 msg = vat_json_array_add (msg_array);
6201 vat_json_init_object (msg);
6202 vat_json_object_add_uint (msg, "vrf_id",
6203 vam->ip6_fib_counters_vrf_id_by_index[i]);
6204 counter_array = vat_json_object_add (msg, "c");
6205 vat_json_init_array (counter_array);
6206 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6208 counter = vat_json_array_add (counter_array);
6209 vat_json_init_object (counter);
6210 c6 = &vam->ip6_fib_counters[i][j];
6211 vat_json_object_add_ip6 (counter, "address", c6->address);
6212 vat_json_object_add_uint (counter, "address_length",
6213 c6->address_length);
6214 vat_json_object_add_uint (counter, "packets", c6->packets);
6215 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6219 /* ip4 nbr counters */
6220 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6221 vat_json_init_array (msg_array);
6222 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6224 msg = vat_json_array_add (msg_array);
6225 vat_json_init_object (msg);
6226 vat_json_object_add_uint (msg, "sw_if_index", i);
6227 counter_array = vat_json_object_add (msg, "c");
6228 vat_json_init_array (counter_array);
6229 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6231 counter = vat_json_array_add (counter_array);
6232 vat_json_init_object (counter);
6233 n4 = &vam->ip4_nbr_counters[i][j];
6234 vat_json_object_add_ip4 (counter, "address", n4->address);
6235 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6236 vat_json_object_add_uint (counter, "packets", n4->packets);
6237 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6241 /* ip6 nbr counters */
6242 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6243 vat_json_init_array (msg_array);
6244 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6246 msg = vat_json_array_add (msg_array);
6247 vat_json_init_object (msg);
6248 vat_json_object_add_uint (msg, "sw_if_index", i);
6249 counter_array = vat_json_object_add (msg, "c");
6250 vat_json_init_array (counter_array);
6251 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6253 counter = vat_json_array_add (counter_array);
6254 vat_json_init_object (counter);
6255 n6 = &vam->ip6_nbr_counters[i][j];
6256 vat_json_object_add_ip6 (counter, "address", n6->address);
6257 vat_json_object_add_uint (counter, "packets", n6->packets);
6258 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6262 vat_json_print (vam->ofp, &node);
6263 vat_json_free (&node);
6269 * Pass CLI buffers directly in the CLI_INBAND API message,
6270 * instead of an additional shared memory area.
6273 exec_inband (vat_main_t * vam)
6275 vl_api_cli_inband_t *mp;
6276 unformat_input_t *i = vam->input;
6279 if (vec_len (i->buffer) == 0)
6282 if (vam->exec_mode == 0 && unformat (i, "mode"))
6287 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6294 * In order for the CLI command to work, it
6295 * must be a vector ending in \n, not a C-string ending
6298 u32 len = vec_len (vam->input->buffer);
6299 M2 (CLI_INBAND, mp, len);
6300 clib_memcpy (mp->cmd, vam->input->buffer, len);
6301 mp->length = htonl (len);
6305 /* json responses may or may not include a useful reply... */
6306 if (vec_len (vam->cmd_reply))
6307 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6312 exec (vat_main_t * vam)
6314 return exec_inband (vam);
6318 api_create_loopback (vat_main_t * vam)
6320 unformat_input_t *i = vam->input;
6321 vl_api_create_loopback_t *mp;
6322 vl_api_create_loopback_instance_t *mp_lbi;
6325 u8 is_specified = 0;
6326 u32 user_instance = 0;
6329 memset (mac_address, 0, sizeof (mac_address));
6331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6333 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6335 if (unformat (i, "instance %d", &user_instance))
6343 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6344 mp_lbi->is_specified = is_specified;
6346 mp_lbi->user_instance = htonl (user_instance);
6348 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6353 /* Construct the API message */
6354 M (CREATE_LOOPBACK, mp);
6356 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6365 api_delete_loopback (vat_main_t * vam)
6367 unformat_input_t *i = vam->input;
6368 vl_api_delete_loopback_t *mp;
6369 u32 sw_if_index = ~0;
6372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6374 if (unformat (i, "sw_if_index %d", &sw_if_index))
6380 if (sw_if_index == ~0)
6382 errmsg ("missing sw_if_index");
6386 /* Construct the API message */
6387 M (DELETE_LOOPBACK, mp);
6388 mp->sw_if_index = ntohl (sw_if_index);
6396 api_want_stats (vat_main_t * vam)
6398 unformat_input_t *i = vam->input;
6399 vl_api_want_stats_t *mp;
6403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6405 if (unformat (i, "enable"))
6407 else if (unformat (i, "disable"))
6415 errmsg ("missing enable|disable");
6420 mp->enable_disable = enable;
6428 api_want_interface_events (vat_main_t * vam)
6430 unformat_input_t *i = vam->input;
6431 vl_api_want_interface_events_t *mp;
6435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6437 if (unformat (i, "enable"))
6439 else if (unformat (i, "disable"))
6447 errmsg ("missing enable|disable");
6451 M (WANT_INTERFACE_EVENTS, mp);
6452 mp->enable_disable = enable;
6454 vam->interface_event_display = enable;
6462 /* Note: non-static, called once to set up the initial intfc table */
6464 api_sw_interface_dump (vat_main_t * vam)
6466 vl_api_sw_interface_dump_t *mp;
6467 vl_api_control_ping_t *mp_ping;
6469 name_sort_t *nses = 0, *ns;
6470 sw_interface_subif_t *sub = NULL;
6473 /* Toss the old name table */
6475 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6477 vec_add2 (nses, ns, 1);
6478 ns->name = (u8 *)(p->key);
6479 ns->value = (u32) p->value[0];
6483 hash_free (vam->sw_if_index_by_interface_name);
6485 vec_foreach (ns, nses) vec_free (ns->name);
6489 vec_foreach (sub, vam->sw_if_subif_table)
6491 vec_free (sub->interface_name);
6493 vec_free (vam->sw_if_subif_table);
6495 /* recreate the interface name hash table */
6496 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6499 * Ask for all interface names. Otherwise, the epic catalog of
6500 * name filters becomes ridiculously long, and vat ends up needing
6501 * to be taught about new interface types.
6503 M (SW_INTERFACE_DUMP, mp);
6506 /* Use a control ping for synchronization */
6507 MPING (CONTROL_PING, mp_ping);
6515 api_sw_interface_set_flags (vat_main_t * vam)
6517 unformat_input_t *i = vam->input;
6518 vl_api_sw_interface_set_flags_t *mp;
6520 u8 sw_if_index_set = 0;
6524 /* Parse args required to build the message */
6525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6527 if (unformat (i, "admin-up"))
6529 else if (unformat (i, "admin-down"))
6532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6533 sw_if_index_set = 1;
6534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6535 sw_if_index_set = 1;
6540 if (sw_if_index_set == 0)
6542 errmsg ("missing interface name or sw_if_index");
6546 /* Construct the API message */
6547 M (SW_INTERFACE_SET_FLAGS, mp);
6548 mp->sw_if_index = ntohl (sw_if_index);
6549 mp->admin_up_down = admin_up;
6554 /* Wait for a reply, return the good/bad news... */
6560 api_sw_interface_set_rx_mode (vat_main_t * vam)
6562 unformat_input_t *i = vam->input;
6563 vl_api_sw_interface_set_rx_mode_t *mp;
6565 u8 sw_if_index_set = 0;
6567 u8 queue_id_valid = 0;
6569 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6571 /* Parse args required to build the message */
6572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6574 if (unformat (i, "queue %d", &queue_id))
6576 else if (unformat (i, "polling"))
6577 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6578 else if (unformat (i, "interrupt"))
6579 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6580 else if (unformat (i, "adaptive"))
6581 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6583 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6584 sw_if_index_set = 1;
6585 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6586 sw_if_index_set = 1;
6591 if (sw_if_index_set == 0)
6593 errmsg ("missing interface name or sw_if_index");
6596 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6598 errmsg ("missing rx-mode");
6602 /* Construct the API message */
6603 M (SW_INTERFACE_SET_RX_MODE, mp);
6604 mp->sw_if_index = ntohl (sw_if_index);
6606 mp->queue_id_valid = queue_id_valid;
6607 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6612 /* Wait for a reply, return the good/bad news... */
6618 api_sw_interface_clear_stats (vat_main_t * vam)
6620 unformat_input_t *i = vam->input;
6621 vl_api_sw_interface_clear_stats_t *mp;
6623 u8 sw_if_index_set = 0;
6626 /* Parse args required to build the message */
6627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6629 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6630 sw_if_index_set = 1;
6631 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6632 sw_if_index_set = 1;
6637 /* Construct the API message */
6638 M (SW_INTERFACE_CLEAR_STATS, mp);
6640 if (sw_if_index_set == 1)
6641 mp->sw_if_index = ntohl (sw_if_index);
6643 mp->sw_if_index = ~0;
6648 /* Wait for a reply, return the good/bad news... */
6654 api_sw_interface_add_del_address (vat_main_t * vam)
6656 unformat_input_t *i = vam->input;
6657 vl_api_sw_interface_add_del_address_t *mp;
6659 u8 sw_if_index_set = 0;
6660 u8 is_add = 1, del_all = 0;
6661 u32 address_length = 0;
6662 u8 v4_address_set = 0;
6663 u8 v6_address_set = 0;
6664 ip4_address_t v4address;
6665 ip6_address_t v6address;
6668 /* Parse args required to build the message */
6669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6671 if (unformat (i, "del-all"))
6673 else if (unformat (i, "del"))
6676 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6677 sw_if_index_set = 1;
6678 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6679 sw_if_index_set = 1;
6680 else if (unformat (i, "%U/%d",
6681 unformat_ip4_address, &v4address, &address_length))
6683 else if (unformat (i, "%U/%d",
6684 unformat_ip6_address, &v6address, &address_length))
6690 if (sw_if_index_set == 0)
6692 errmsg ("missing interface name or sw_if_index");
6695 if (v4_address_set && v6_address_set)
6697 errmsg ("both v4 and v6 addresses set");
6700 if (!v4_address_set && !v6_address_set && !del_all)
6702 errmsg ("no addresses set");
6706 /* Construct the API message */
6707 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6709 mp->sw_if_index = ntohl (sw_if_index);
6710 mp->is_add = is_add;
6711 mp->del_all = del_all;
6715 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6719 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6721 mp->address_length = address_length;
6726 /* Wait for a reply, return good/bad news */
6732 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6734 unformat_input_t *i = vam->input;
6735 vl_api_sw_interface_set_mpls_enable_t *mp;
6737 u8 sw_if_index_set = 0;
6741 /* Parse args required to build the message */
6742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6745 sw_if_index_set = 1;
6746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6747 sw_if_index_set = 1;
6748 else if (unformat (i, "disable"))
6750 else if (unformat (i, "dis"))
6756 if (sw_if_index_set == 0)
6758 errmsg ("missing interface name or sw_if_index");
6762 /* Construct the API message */
6763 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6765 mp->sw_if_index = ntohl (sw_if_index);
6766 mp->enable = enable;
6771 /* Wait for a reply... */
6777 api_sw_interface_set_table (vat_main_t * vam)
6779 unformat_input_t *i = vam->input;
6780 vl_api_sw_interface_set_table_t *mp;
6781 u32 sw_if_index, vrf_id = 0;
6782 u8 sw_if_index_set = 0;
6786 /* Parse args required to build the message */
6787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6790 sw_if_index_set = 1;
6791 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6792 sw_if_index_set = 1;
6793 else if (unformat (i, "vrf %d", &vrf_id))
6795 else if (unformat (i, "ipv6"))
6801 if (sw_if_index_set == 0)
6803 errmsg ("missing interface name or sw_if_index");
6807 /* Construct the API message */
6808 M (SW_INTERFACE_SET_TABLE, mp);
6810 mp->sw_if_index = ntohl (sw_if_index);
6811 mp->is_ipv6 = is_ipv6;
6812 mp->vrf_id = ntohl (vrf_id);
6817 /* Wait for a reply... */
6822 static void vl_api_sw_interface_get_table_reply_t_handler
6823 (vl_api_sw_interface_get_table_reply_t * mp)
6825 vat_main_t *vam = &vat_main;
6827 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6829 vam->retval = ntohl (mp->retval);
6830 vam->result_ready = 1;
6834 static void vl_api_sw_interface_get_table_reply_t_handler_json
6835 (vl_api_sw_interface_get_table_reply_t * mp)
6837 vat_main_t *vam = &vat_main;
6838 vat_json_node_t node;
6840 vat_json_init_object (&node);
6841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6842 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6844 vat_json_print (vam->ofp, &node);
6845 vat_json_free (&node);
6847 vam->retval = ntohl (mp->retval);
6848 vam->result_ready = 1;
6852 api_sw_interface_get_table (vat_main_t * vam)
6854 unformat_input_t *i = vam->input;
6855 vl_api_sw_interface_get_table_t *mp;
6857 u8 sw_if_index_set = 0;
6861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6864 sw_if_index_set = 1;
6865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6866 sw_if_index_set = 1;
6867 else if (unformat (i, "ipv6"))
6873 if (sw_if_index_set == 0)
6875 errmsg ("missing interface name or sw_if_index");
6879 M (SW_INTERFACE_GET_TABLE, mp);
6880 mp->sw_if_index = htonl (sw_if_index);
6881 mp->is_ipv6 = is_ipv6;
6889 api_sw_interface_set_vpath (vat_main_t * vam)
6891 unformat_input_t *i = vam->input;
6892 vl_api_sw_interface_set_vpath_t *mp;
6893 u32 sw_if_index = 0;
6894 u8 sw_if_index_set = 0;
6898 /* Parse args required to build the message */
6899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6902 sw_if_index_set = 1;
6903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6904 sw_if_index_set = 1;
6905 else if (unformat (i, "enable"))
6907 else if (unformat (i, "disable"))
6913 if (sw_if_index_set == 0)
6915 errmsg ("missing interface name or sw_if_index");
6919 /* Construct the API message */
6920 M (SW_INTERFACE_SET_VPATH, mp);
6922 mp->sw_if_index = ntohl (sw_if_index);
6923 mp->enable = is_enable;
6928 /* Wait for a reply... */
6934 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6936 unformat_input_t *i = vam->input;
6937 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6938 u32 sw_if_index = 0;
6939 u8 sw_if_index_set = 0;
6944 /* Parse args required to build the message */
6945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6947 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6948 sw_if_index_set = 1;
6949 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6950 sw_if_index_set = 1;
6951 else if (unformat (i, "enable"))
6953 else if (unformat (i, "disable"))
6955 else if (unformat (i, "ip4"))
6957 else if (unformat (i, "ip6"))
6963 if (sw_if_index_set == 0)
6965 errmsg ("missing interface name or sw_if_index");
6969 /* Construct the API message */
6970 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6972 mp->sw_if_index = ntohl (sw_if_index);
6973 mp->enable = is_enable;
6974 mp->is_ipv6 = is_ipv6;
6979 /* Wait for a reply... */
6985 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6987 unformat_input_t *i = vam->input;
6988 vl_api_sw_interface_set_geneve_bypass_t *mp;
6989 u32 sw_if_index = 0;
6990 u8 sw_if_index_set = 0;
6995 /* Parse args required to build the message */
6996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6999 sw_if_index_set = 1;
7000 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7001 sw_if_index_set = 1;
7002 else if (unformat (i, "enable"))
7004 else if (unformat (i, "disable"))
7006 else if (unformat (i, "ip4"))
7008 else if (unformat (i, "ip6"))
7014 if (sw_if_index_set == 0)
7016 errmsg ("missing interface name or sw_if_index");
7020 /* Construct the API message */
7021 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7023 mp->sw_if_index = ntohl (sw_if_index);
7024 mp->enable = is_enable;
7025 mp->is_ipv6 = is_ipv6;
7030 /* Wait for a reply... */
7036 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7038 unformat_input_t *i = vam->input;
7039 vl_api_sw_interface_set_l2_xconnect_t *mp;
7041 u8 rx_sw_if_index_set = 0;
7043 u8 tx_sw_if_index_set = 0;
7047 /* Parse args required to build the message */
7048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7050 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7051 rx_sw_if_index_set = 1;
7052 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7053 tx_sw_if_index_set = 1;
7054 else if (unformat (i, "rx"))
7056 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7058 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7060 rx_sw_if_index_set = 1;
7065 else if (unformat (i, "tx"))
7067 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7069 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7071 tx_sw_if_index_set = 1;
7076 else if (unformat (i, "enable"))
7078 else if (unformat (i, "disable"))
7084 if (rx_sw_if_index_set == 0)
7086 errmsg ("missing rx interface name or rx_sw_if_index");
7090 if (enable && (tx_sw_if_index_set == 0))
7092 errmsg ("missing tx interface name or tx_sw_if_index");
7096 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7098 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7099 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7100 mp->enable = enable;
7108 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7110 unformat_input_t *i = vam->input;
7111 vl_api_sw_interface_set_l2_bridge_t *mp;
7113 u8 rx_sw_if_index_set = 0;
7121 /* Parse args required to build the message */
7122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7124 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7125 rx_sw_if_index_set = 1;
7126 else if (unformat (i, "bd_id %d", &bd_id))
7130 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7131 rx_sw_if_index_set = 1;
7132 else if (unformat (i, "shg %d", &shg))
7134 else if (unformat (i, "bvi"))
7136 else if (unformat (i, "enable"))
7138 else if (unformat (i, "disable"))
7144 if (rx_sw_if_index_set == 0)
7146 errmsg ("missing rx interface name or sw_if_index");
7150 if (enable && (bd_id_set == 0))
7152 errmsg ("missing bridge domain");
7156 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7158 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7159 mp->bd_id = ntohl (bd_id);
7162 mp->enable = enable;
7170 api_bridge_domain_dump (vat_main_t * vam)
7172 unformat_input_t *i = vam->input;
7173 vl_api_bridge_domain_dump_t *mp;
7174 vl_api_control_ping_t *mp_ping;
7178 /* Parse args required to build the message */
7179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7181 if (unformat (i, "bd_id %d", &bd_id))
7187 M (BRIDGE_DOMAIN_DUMP, mp);
7188 mp->bd_id = ntohl (bd_id);
7191 /* Use a control ping for synchronization */
7192 MPING (CONTROL_PING, mp_ping);
7200 api_bridge_domain_add_del (vat_main_t * vam)
7202 unformat_input_t *i = vam->input;
7203 vl_api_bridge_domain_add_del_t *mp;
7206 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7211 /* Parse args required to build the message */
7212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7214 if (unformat (i, "bd_id %d", &bd_id))
7216 else if (unformat (i, "flood %d", &flood))
7218 else if (unformat (i, "uu-flood %d", &uu_flood))
7220 else if (unformat (i, "forward %d", &forward))
7222 else if (unformat (i, "learn %d", &learn))
7224 else if (unformat (i, "arp-term %d", &arp_term))
7226 else if (unformat (i, "mac-age %d", &mac_age))
7228 else if (unformat (i, "bd-tag %s", &bd_tag))
7230 else if (unformat (i, "del"))
7233 flood = uu_flood = forward = learn = 0;
7241 errmsg ("missing bridge domain");
7248 errmsg ("mac age must be less than 256 ");
7253 if ((bd_tag) && (vec_len (bd_tag) > 63))
7255 errmsg ("bd-tag cannot be longer than 63");
7260 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7262 mp->bd_id = ntohl (bd_id);
7264 mp->uu_flood = uu_flood;
7265 mp->forward = forward;
7267 mp->arp_term = arp_term;
7268 mp->is_add = is_add;
7269 mp->mac_age = (u8) mac_age;
7272 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7273 mp->bd_tag[vec_len (bd_tag)] = 0;
7284 api_l2fib_flush_bd (vat_main_t * vam)
7286 unformat_input_t *i = vam->input;
7287 vl_api_l2fib_flush_bd_t *mp;
7291 /* Parse args required to build the message */
7292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7294 if (unformat (i, "bd_id %d", &bd_id));
7301 errmsg ("missing bridge domain");
7305 M (L2FIB_FLUSH_BD, mp);
7307 mp->bd_id = htonl (bd_id);
7315 api_l2fib_flush_int (vat_main_t * vam)
7317 unformat_input_t *i = vam->input;
7318 vl_api_l2fib_flush_int_t *mp;
7319 u32 sw_if_index = ~0;
7322 /* Parse args required to build the message */
7323 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7325 if (unformat (i, "sw_if_index %d", &sw_if_index));
7327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7332 if (sw_if_index == ~0)
7334 errmsg ("missing interface name or sw_if_index");
7338 M (L2FIB_FLUSH_INT, mp);
7340 mp->sw_if_index = ntohl (sw_if_index);
7348 api_l2fib_add_del (vat_main_t * vam)
7350 unformat_input_t *i = vam->input;
7351 vl_api_l2fib_add_del_t *mp;
7357 u32 sw_if_index = 0;
7358 u8 sw_if_index_set = 0;
7367 /* Parse args required to build the message */
7368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7370 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7372 else if (unformat (i, "bd_id %d", &bd_id))
7374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7375 sw_if_index_set = 1;
7376 else if (unformat (i, "sw_if"))
7378 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7381 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7382 sw_if_index_set = 1;
7387 else if (unformat (i, "static"))
7389 else if (unformat (i, "filter"))
7394 else if (unformat (i, "bvi"))
7399 else if (unformat (i, "del"))
7401 else if (unformat (i, "count %d", &count))
7409 errmsg ("missing mac address");
7415 errmsg ("missing bridge domain");
7419 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7421 errmsg ("missing interface name or sw_if_index");
7427 /* Turn on async mode */
7428 vam->async_mode = 1;
7429 vam->async_errors = 0;
7430 before = vat_time_now (vam);
7433 for (j = 0; j < count; j++)
7435 M (L2FIB_ADD_DEL, mp);
7437 clib_memcpy (mp->mac, mac, 6);
7438 mp->bd_id = ntohl (bd_id);
7439 mp->is_add = is_add;
7440 mp->sw_if_index = ntohl (sw_if_index);
7444 mp->static_mac = static_mac;
7445 mp->filter_mac = filter_mac;
7446 mp->bvi_mac = bvi_mac;
7448 increment_mac_address (mac);
7455 vl_api_control_ping_t *mp_ping;
7458 /* Shut off async mode */
7459 vam->async_mode = 0;
7461 MPING (CONTROL_PING, mp_ping);
7464 timeout = vat_time_now (vam) + 1.0;
7465 while (vat_time_now (vam) < timeout)
7466 if (vam->result_ready == 1)
7471 if (vam->retval == -99)
7474 if (vam->async_errors > 0)
7476 errmsg ("%d asynchronous errors", vam->async_errors);
7479 vam->async_errors = 0;
7480 after = vat_time_now (vam);
7482 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7483 count, after - before, count / (after - before));
7489 /* Wait for a reply... */
7493 /* Return the good/bad news */
7494 return (vam->retval);
7498 api_bridge_domain_set_mac_age (vat_main_t * vam)
7500 unformat_input_t *i = vam->input;
7501 vl_api_bridge_domain_set_mac_age_t *mp;
7506 /* Parse args required to build the message */
7507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7509 if (unformat (i, "bd_id %d", &bd_id));
7510 else if (unformat (i, "mac-age %d", &mac_age));
7517 errmsg ("missing bridge domain");
7523 errmsg ("mac age must be less than 256 ");
7527 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7529 mp->bd_id = htonl (bd_id);
7530 mp->mac_age = (u8) mac_age;
7538 api_l2_flags (vat_main_t * vam)
7540 unformat_input_t *i = vam->input;
7541 vl_api_l2_flags_t *mp;
7544 u8 sw_if_index_set = 0;
7548 /* Parse args required to build the message */
7549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7551 if (unformat (i, "sw_if_index %d", &sw_if_index))
7552 sw_if_index_set = 1;
7553 else if (unformat (i, "sw_if"))
7555 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7558 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7559 sw_if_index_set = 1;
7564 else if (unformat (i, "learn"))
7566 else if (unformat (i, "forward"))
7568 else if (unformat (i, "flood"))
7570 else if (unformat (i, "uu-flood"))
7571 flags |= L2_UU_FLOOD;
7572 else if (unformat (i, "arp-term"))
7573 flags |= L2_ARP_TERM;
7574 else if (unformat (i, "off"))
7576 else if (unformat (i, "disable"))
7582 if (sw_if_index_set == 0)
7584 errmsg ("missing interface name or sw_if_index");
7590 mp->sw_if_index = ntohl (sw_if_index);
7591 mp->feature_bitmap = ntohl (flags);
7592 mp->is_set = is_set;
7600 api_bridge_flags (vat_main_t * vam)
7602 unformat_input_t *i = vam->input;
7603 vl_api_bridge_flags_t *mp;
7610 /* Parse args required to build the message */
7611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7613 if (unformat (i, "bd_id %d", &bd_id))
7615 else if (unformat (i, "learn"))
7617 else if (unformat (i, "forward"))
7619 else if (unformat (i, "flood"))
7621 else if (unformat (i, "uu-flood"))
7622 flags |= L2_UU_FLOOD;
7623 else if (unformat (i, "arp-term"))
7624 flags |= L2_ARP_TERM;
7625 else if (unformat (i, "off"))
7627 else if (unformat (i, "disable"))
7635 errmsg ("missing bridge domain");
7639 M (BRIDGE_FLAGS, mp);
7641 mp->bd_id = ntohl (bd_id);
7642 mp->feature_bitmap = ntohl (flags);
7643 mp->is_set = is_set;
7651 api_bd_ip_mac_add_del (vat_main_t * vam)
7653 unformat_input_t *i = vam->input;
7654 vl_api_bd_ip_mac_add_del_t *mp;
7661 ip4_address_t v4addr;
7662 ip6_address_t v6addr;
7667 /* Parse args required to build the message */
7668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7670 if (unformat (i, "bd_id %d", &bd_id))
7674 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7678 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7683 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7687 else if (unformat (i, "del"))
7695 errmsg ("missing bridge domain");
7698 else if (ip_set == 0)
7700 errmsg ("missing IP address");
7703 else if (mac_set == 0)
7705 errmsg ("missing MAC address");
7709 M (BD_IP_MAC_ADD_DEL, mp);
7711 mp->bd_id = ntohl (bd_id);
7712 mp->is_ipv6 = is_ipv6;
7713 mp->is_add = is_add;
7715 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7717 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7718 clib_memcpy (mp->mac_address, macaddr, 6);
7725 api_tap_connect (vat_main_t * vam)
7727 unformat_input_t *i = vam->input;
7728 vl_api_tap_connect_t *mp;
7734 ip4_address_t ip4_address;
7736 int ip4_address_set = 0;
7737 ip6_address_t ip6_address;
7739 int ip6_address_set = 0;
7742 memset (mac_address, 0, sizeof (mac_address));
7744 /* Parse args required to build the message */
7745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7747 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7751 else if (unformat (i, "random-mac"))
7753 else if (unformat (i, "tapname %s", &tap_name))
7755 else if (unformat (i, "tag %s", &tag))
7757 else if (unformat (i, "address %U/%d",
7758 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7759 ip4_address_set = 1;
7760 else if (unformat (i, "address %U/%d",
7761 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7762 ip6_address_set = 1;
7769 errmsg ("missing tap name");
7772 if (vec_len (tap_name) > 63)
7774 errmsg ("tap name too long");
7777 vec_add1 (tap_name, 0);
7779 if (vec_len (tag) > 63)
7781 errmsg ("tag too long");
7785 /* Construct the API message */
7786 M (TAP_CONNECT, mp);
7788 mp->use_random_mac = random_mac;
7789 clib_memcpy (mp->mac_address, mac_address, 6);
7790 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7792 clib_memcpy (mp->tag, tag, vec_len (tag));
7794 if (ip4_address_set)
7796 mp->ip4_address_set = 1;
7797 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7798 mp->ip4_mask_width = ip4_mask_width;
7800 if (ip6_address_set)
7802 mp->ip6_address_set = 1;
7803 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7804 mp->ip6_mask_width = ip6_mask_width;
7807 vec_free (tap_name);
7813 /* Wait for a reply... */
7819 api_tap_modify (vat_main_t * vam)
7821 unformat_input_t *i = vam->input;
7822 vl_api_tap_modify_t *mp;
7827 u32 sw_if_index = ~0;
7828 u8 sw_if_index_set = 0;
7831 memset (mac_address, 0, sizeof (mac_address));
7833 /* Parse args required to build the message */
7834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7836 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7837 sw_if_index_set = 1;
7838 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7839 sw_if_index_set = 1;
7840 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7844 else if (unformat (i, "random-mac"))
7846 else if (unformat (i, "tapname %s", &tap_name))
7852 if (sw_if_index_set == 0)
7854 errmsg ("missing vpp interface name");
7859 errmsg ("missing tap name");
7862 if (vec_len (tap_name) > 63)
7864 errmsg ("tap name too long");
7866 vec_add1 (tap_name, 0);
7868 /* Construct the API message */
7871 mp->use_random_mac = random_mac;
7872 mp->sw_if_index = ntohl (sw_if_index);
7873 clib_memcpy (mp->mac_address, mac_address, 6);
7874 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7875 vec_free (tap_name);
7880 /* Wait for a reply... */
7886 api_tap_delete (vat_main_t * vam)
7888 unformat_input_t *i = vam->input;
7889 vl_api_tap_delete_t *mp;
7890 u32 sw_if_index = ~0;
7891 u8 sw_if_index_set = 0;
7894 /* Parse args required to build the message */
7895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7897 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7898 sw_if_index_set = 1;
7899 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7900 sw_if_index_set = 1;
7905 if (sw_if_index_set == 0)
7907 errmsg ("missing vpp interface name");
7911 /* Construct the API message */
7914 mp->sw_if_index = ntohl (sw_if_index);
7919 /* Wait for a reply... */
7925 api_tap_create_v2 (vat_main_t * vam)
7927 unformat_input_t *i = vam->input;
7928 vl_api_tap_create_v2_t *mp;
7932 u8 *host_if_name = 0;
7934 u8 host_mac_addr[6];
7935 u8 host_mac_addr_set = 0;
7936 u8 *host_bridge = 0;
7937 ip4_address_t host_ip4_addr;
7938 ip4_address_t host_ip4_gw;
7939 u8 host_ip4_gw_set = 0;
7940 u32 host_ip4_prefix_len = 0;
7941 ip6_address_t host_ip6_addr;
7942 ip6_address_t host_ip6_gw;
7943 u8 host_ip6_gw_set = 0;
7944 u32 host_ip6_prefix_len = 0;
7946 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7948 memset (mac_address, 0, sizeof (mac_address));
7950 /* Parse args required to build the message */
7951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7953 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7957 else if (unformat (i, "id %u", &id))
7959 else if (unformat (i, "host-if-name %s", &host_if_name))
7961 else if (unformat (i, "host-ns %s", &host_ns))
7963 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7965 host_mac_addr_set = 1;
7966 else if (unformat (i, "host-bridge %s", &host_bridge))
7968 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7969 &host_ip4_addr, &host_ip4_prefix_len))
7971 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7972 &host_ip6_addr, &host_ip6_prefix_len))
7974 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7976 host_ip4_gw_set = 1;
7977 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7979 host_ip6_gw_set = 1;
7980 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7982 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7988 if (vec_len (host_if_name) > 63)
7990 errmsg ("tap name too long. ");
7993 if (vec_len (host_ns) > 63)
7995 errmsg ("host name space too long. ");
7998 if (vec_len (host_bridge) > 63)
8000 errmsg ("host bridge name too long. ");
8003 if (host_ip4_prefix_len > 32)
8005 errmsg ("host ip4 prefix length not valid. ");
8008 if (host_ip6_prefix_len > 128)
8010 errmsg ("host ip6 prefix length not valid. ");
8013 if (!is_pow2 (rx_ring_sz))
8015 errmsg ("rx ring size must be power of 2. ");
8018 if (rx_ring_sz > 32768)
8020 errmsg ("rx ring size must be 32768 or lower. ");
8023 if (!is_pow2 (tx_ring_sz))
8025 errmsg ("tx ring size must be power of 2. ");
8028 if (tx_ring_sz > 32768)
8030 errmsg ("tx ring size must be 32768 or lower. ");
8034 /* Construct the API message */
8035 M (TAP_CREATE_V2, mp);
8037 mp->use_random_mac = random_mac;
8039 mp->id = ntohl (id);
8040 mp->host_namespace_set = host_ns != 0;
8041 mp->host_bridge_set = host_bridge != 0;
8042 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8043 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8044 mp->rx_ring_sz = ntohs (rx_ring_sz);
8045 mp->tx_ring_sz = ntohs (tx_ring_sz);
8047 if (random_mac == 0)
8048 clib_memcpy (mp->mac_address, mac_address, 6);
8049 if (host_mac_addr_set)
8050 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8052 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8054 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8056 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8057 if (host_ip4_prefix_len)
8058 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8059 if (host_ip4_prefix_len)
8060 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8061 if (host_ip4_gw_set)
8062 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8063 if (host_ip6_gw_set)
8064 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8067 vec_free (host_if_name);
8068 vec_free (host_bridge);
8073 /* Wait for a reply... */
8079 api_tap_delete_v2 (vat_main_t * vam)
8081 unformat_input_t *i = vam->input;
8082 vl_api_tap_delete_v2_t *mp;
8083 u32 sw_if_index = ~0;
8084 u8 sw_if_index_set = 0;
8087 /* Parse args required to build the message */
8088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8091 sw_if_index_set = 1;
8092 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8093 sw_if_index_set = 1;
8098 if (sw_if_index_set == 0)
8100 errmsg ("missing vpp interface name. ");
8104 /* Construct the API message */
8105 M (TAP_DELETE_V2, mp);
8107 mp->sw_if_index = ntohl (sw_if_index);
8112 /* Wait for a reply... */
8118 api_bond_create (vat_main_t * vam)
8120 unformat_input_t *i = vam->input;
8121 vl_api_bond_create_t *mp;
8129 memset (mac_address, 0, sizeof (mac_address));
8132 /* Parse args required to build the message */
8133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8135 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8137 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8138 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8140 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8147 if (mode_is_set == 0)
8149 errmsg ("Missing bond mode. ");
8153 /* Construct the API message */
8154 M (BOND_CREATE, mp);
8156 mp->use_custom_mac = custom_mac;
8162 clib_memcpy (mp->mac_address, mac_address, 6);
8167 /* Wait for a reply... */
8173 api_bond_delete (vat_main_t * vam)
8175 unformat_input_t *i = vam->input;
8176 vl_api_bond_delete_t *mp;
8177 u32 sw_if_index = ~0;
8178 u8 sw_if_index_set = 0;
8181 /* Parse args required to build the message */
8182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8185 sw_if_index_set = 1;
8186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8187 sw_if_index_set = 1;
8192 if (sw_if_index_set == 0)
8194 errmsg ("missing vpp interface name. ");
8198 /* Construct the API message */
8199 M (BOND_DELETE, mp);
8201 mp->sw_if_index = ntohl (sw_if_index);
8206 /* Wait for a reply... */
8212 api_bond_enslave (vat_main_t * vam)
8214 unformat_input_t *i = vam->input;
8215 vl_api_bond_enslave_t *mp;
8216 u32 bond_sw_if_index;
8220 u32 bond_sw_if_index_is_set = 0;
8222 u8 sw_if_index_is_set = 0;
8224 /* Parse args required to build the message */
8225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8227 if (unformat (i, "sw_if_index %d", &sw_if_index))
8228 sw_if_index_is_set = 1;
8229 else if (unformat (i, "bond %u", &bond_sw_if_index))
8230 bond_sw_if_index_is_set = 1;
8231 else if (unformat (i, "passive %d", &is_passive))
8233 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8239 if (bond_sw_if_index_is_set == 0)
8241 errmsg ("Missing bond sw_if_index. ");
8244 if (sw_if_index_is_set == 0)
8246 errmsg ("Missing slave sw_if_index. ");
8250 /* Construct the API message */
8251 M (BOND_ENSLAVE, mp);
8253 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8254 mp->sw_if_index = ntohl (sw_if_index);
8255 mp->is_long_timeout = is_long_timeout;
8256 mp->is_passive = is_passive;
8261 /* Wait for a reply... */
8267 api_bond_detach_slave (vat_main_t * vam)
8269 unformat_input_t *i = vam->input;
8270 vl_api_bond_detach_slave_t *mp;
8271 u32 sw_if_index = ~0;
8272 u8 sw_if_index_set = 0;
8275 /* Parse args required to build the message */
8276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8278 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8279 sw_if_index_set = 1;
8280 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8281 sw_if_index_set = 1;
8286 if (sw_if_index_set == 0)
8288 errmsg ("missing vpp interface name. ");
8292 /* Construct the API message */
8293 M (BOND_DETACH_SLAVE, mp);
8295 mp->sw_if_index = ntohl (sw_if_index);
8300 /* Wait for a reply... */
8306 api_ip_table_add_del (vat_main_t * vam)
8308 unformat_input_t *i = vam->input;
8309 vl_api_ip_table_add_del_t *mp;
8315 /* Parse args required to build the message */
8316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8318 if (unformat (i, "ipv6"))
8320 else if (unformat (i, "del"))
8322 else if (unformat (i, "add"))
8324 else if (unformat (i, "table %d", &table_id))
8328 clib_warning ("parse error '%U'", format_unformat_error, i);
8335 errmsg ("missing table-ID");
8339 /* Construct the API message */
8340 M (IP_TABLE_ADD_DEL, mp);
8342 mp->table_id = ntohl (table_id);
8343 mp->is_ipv6 = is_ipv6;
8344 mp->is_add = is_add;
8349 /* Wait for a reply... */
8356 api_ip_add_del_route (vat_main_t * vam)
8358 unformat_input_t *i = vam->input;
8359 vl_api_ip_add_del_route_t *mp;
8360 u32 sw_if_index = ~0, vrf_id = 0;
8362 u8 is_local = 0, is_drop = 0;
8363 u8 is_unreach = 0, is_prohibit = 0;
8365 u32 next_hop_weight = 1;
8366 u8 is_multipath = 0;
8368 u8 address_length_set = 0;
8369 u32 next_hop_table_id = 0;
8370 u32 resolve_attempts = 0;
8371 u32 dst_address_length = 0;
8372 u8 next_hop_set = 0;
8373 ip4_address_t v4_dst_address, v4_next_hop_address;
8374 ip6_address_t v6_dst_address, v6_next_hop_address;
8378 u32 random_add_del = 0;
8379 u32 *random_vector = 0;
8381 u32 random_seed = 0xdeaddabe;
8382 u32 classify_table_index = ~0;
8384 u8 resolve_host = 0, resolve_attached = 0;
8385 mpls_label_t *next_hop_out_label_stack = NULL;
8386 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8387 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8389 /* Parse args required to build the message */
8390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8394 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8396 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8401 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8406 else if (unformat (i, "/%d", &dst_address_length))
8408 address_length_set = 1;
8411 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8412 &v4_next_hop_address))
8416 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8417 &v6_next_hop_address))
8421 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8423 else if (unformat (i, "weight %d", &next_hop_weight))
8425 else if (unformat (i, "drop"))
8429 else if (unformat (i, "null-send-unreach"))
8433 else if (unformat (i, "null-send-prohibit"))
8437 else if (unformat (i, "local"))
8441 else if (unformat (i, "classify %d", &classify_table_index))
8445 else if (unformat (i, "del"))
8447 else if (unformat (i, "add"))
8449 else if (unformat (i, "resolve-via-host"))
8451 else if (unformat (i, "resolve-via-attached"))
8452 resolve_attached = 1;
8453 else if (unformat (i, "multipath"))
8455 else if (unformat (i, "vrf %d", &vrf_id))
8457 else if (unformat (i, "count %d", &count))
8459 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8461 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8463 else if (unformat (i, "out-label %d", &next_hop_out_label))
8464 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8465 else if (unformat (i, "via-label %d", &next_hop_via_label))
8467 else if (unformat (i, "random"))
8469 else if (unformat (i, "seed %d", &random_seed))
8473 clib_warning ("parse error '%U'", format_unformat_error, i);
8478 if (!next_hop_set && !is_drop && !is_local &&
8479 !is_classify && !is_unreach && !is_prohibit &&
8480 MPLS_LABEL_INVALID == next_hop_via_label)
8483 ("next hop / local / drop / unreach / prohibit / classify not set");
8487 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8489 errmsg ("next hop and next-hop via label set");
8492 if (address_set == 0)
8494 errmsg ("missing addresses");
8498 if (address_length_set == 0)
8500 errmsg ("missing address length");
8504 /* Generate a pile of unique, random routes */
8507 u32 this_random_address;
8508 random_hash = hash_create (count, sizeof (uword));
8510 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8511 for (j = 0; j <= count; j++)
8515 this_random_address = random_u32 (&random_seed);
8516 this_random_address =
8517 clib_host_to_net_u32 (this_random_address);
8519 while (hash_get (random_hash, this_random_address));
8520 vec_add1 (random_vector, this_random_address);
8521 hash_set (random_hash, this_random_address, 1);
8523 hash_free (random_hash);
8524 v4_dst_address.as_u32 = random_vector[0];
8529 /* Turn on async mode */
8530 vam->async_mode = 1;
8531 vam->async_errors = 0;
8532 before = vat_time_now (vam);
8535 for (j = 0; j < count; j++)
8537 /* Construct the API message */
8538 M2 (IP_ADD_DEL_ROUTE, mp,
8539 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8541 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8542 mp->table_id = ntohl (vrf_id);
8544 mp->is_add = is_add;
8545 mp->is_drop = is_drop;
8546 mp->is_unreach = is_unreach;
8547 mp->is_prohibit = is_prohibit;
8548 mp->is_ipv6 = is_ipv6;
8549 mp->is_local = is_local;
8550 mp->is_classify = is_classify;
8551 mp->is_multipath = is_multipath;
8552 mp->is_resolve_host = resolve_host;
8553 mp->is_resolve_attached = resolve_attached;
8554 mp->next_hop_weight = next_hop_weight;
8555 mp->dst_address_length = dst_address_length;
8556 mp->next_hop_table_id = ntohl (next_hop_table_id);
8557 mp->classify_table_index = ntohl (classify_table_index);
8558 mp->next_hop_via_label = ntohl (next_hop_via_label);
8559 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8560 if (0 != mp->next_hop_n_out_labels)
8562 memcpy (mp->next_hop_out_label_stack,
8563 next_hop_out_label_stack,
8564 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8565 vec_free (next_hop_out_label_stack);
8570 clib_memcpy (mp->dst_address, &v6_dst_address,
8571 sizeof (v6_dst_address));
8573 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8574 sizeof (v6_next_hop_address));
8575 increment_v6_address (&v6_dst_address);
8579 clib_memcpy (mp->dst_address, &v4_dst_address,
8580 sizeof (v4_dst_address));
8582 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8583 sizeof (v4_next_hop_address));
8585 v4_dst_address.as_u32 = random_vector[j + 1];
8587 increment_v4_address (&v4_dst_address);
8591 /* If we receive SIGTERM, stop now... */
8596 /* When testing multiple add/del ops, use a control-ping to sync */
8599 vl_api_control_ping_t *mp_ping;
8603 /* Shut off async mode */
8604 vam->async_mode = 0;
8606 MPING (CONTROL_PING, mp_ping);
8609 timeout = vat_time_now (vam) + 1.0;
8610 while (vat_time_now (vam) < timeout)
8611 if (vam->result_ready == 1)
8616 if (vam->retval == -99)
8619 if (vam->async_errors > 0)
8621 errmsg ("%d asynchronous errors", vam->async_errors);
8624 vam->async_errors = 0;
8625 after = vat_time_now (vam);
8627 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8631 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8632 count, after - before, count / (after - before));
8638 /* Wait for a reply... */
8643 /* Return the good/bad news */
8644 return (vam->retval);
8648 api_ip_mroute_add_del (vat_main_t * vam)
8650 unformat_input_t *i = vam->input;
8651 vl_api_ip_mroute_add_del_t *mp;
8652 u32 sw_if_index = ~0, vrf_id = 0;
8657 u32 grp_address_length = 0;
8658 ip4_address_t v4_grp_address, v4_src_address;
8659 ip6_address_t v6_grp_address, v6_src_address;
8660 mfib_itf_flags_t iflags = 0;
8661 mfib_entry_flags_t eflags = 0;
8664 /* Parse args required to build the message */
8665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8667 if (unformat (i, "sw_if_index %d", &sw_if_index))
8669 else if (unformat (i, "%U %U",
8670 unformat_ip4_address, &v4_src_address,
8671 unformat_ip4_address, &v4_grp_address))
8673 grp_address_length = 64;
8677 else if (unformat (i, "%U %U",
8678 unformat_ip6_address, &v6_src_address,
8679 unformat_ip6_address, &v6_grp_address))
8681 grp_address_length = 256;
8685 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8687 memset (&v4_src_address, 0, sizeof (v4_src_address));
8688 grp_address_length = 32;
8692 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8694 memset (&v6_src_address, 0, sizeof (v6_src_address));
8695 grp_address_length = 128;
8699 else if (unformat (i, "/%d", &grp_address_length))
8701 else if (unformat (i, "local"))
8705 else if (unformat (i, "del"))
8707 else if (unformat (i, "add"))
8709 else if (unformat (i, "vrf %d", &vrf_id))
8711 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8713 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8717 clib_warning ("parse error '%U'", format_unformat_error, i);
8722 if (address_set == 0)
8724 errmsg ("missing addresses\n");
8728 /* Construct the API message */
8729 M (IP_MROUTE_ADD_DEL, mp);
8731 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8732 mp->table_id = ntohl (vrf_id);
8734 mp->is_add = is_add;
8735 mp->is_ipv6 = is_ipv6;
8736 mp->is_local = is_local;
8737 mp->itf_flags = ntohl (iflags);
8738 mp->entry_flags = ntohl (eflags);
8739 mp->grp_address_length = grp_address_length;
8740 mp->grp_address_length = ntohs (mp->grp_address_length);
8744 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8745 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8749 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8750 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8756 /* Wait for a reply... */
8762 api_mpls_table_add_del (vat_main_t * vam)
8764 unformat_input_t *i = vam->input;
8765 vl_api_mpls_table_add_del_t *mp;
8770 /* Parse args required to build the message */
8771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8773 if (unformat (i, "table %d", &table_id))
8775 else if (unformat (i, "del"))
8777 else if (unformat (i, "add"))
8781 clib_warning ("parse error '%U'", format_unformat_error, i);
8788 errmsg ("missing table-ID");
8792 /* Construct the API message */
8793 M (MPLS_TABLE_ADD_DEL, mp);
8795 mp->mt_table_id = ntohl (table_id);
8796 mp->mt_is_add = is_add;
8801 /* Wait for a reply... */
8808 api_mpls_route_add_del (vat_main_t * vam)
8810 unformat_input_t *i = vam->input;
8811 vl_api_mpls_route_add_del_t *mp;
8812 u32 sw_if_index = ~0, table_id = 0;
8814 u32 next_hop_weight = 1;
8815 u8 is_multipath = 0;
8816 u32 next_hop_table_id = 0;
8817 u8 next_hop_set = 0;
8818 ip4_address_t v4_next_hop_address = {
8821 ip6_address_t v6_next_hop_address = { {0} };
8825 u32 classify_table_index = ~0;
8827 u8 resolve_host = 0, resolve_attached = 0;
8828 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8829 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8830 mpls_label_t *next_hop_out_label_stack = NULL;
8831 mpls_label_t local_label = MPLS_LABEL_INVALID;
8833 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8835 /* Parse args required to build the message */
8836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8838 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8840 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8842 else if (unformat (i, "%d", &local_label))
8844 else if (unformat (i, "eos"))
8846 else if (unformat (i, "non-eos"))
8848 else if (unformat (i, "via %U", unformat_ip4_address,
8849 &v4_next_hop_address))
8852 next_hop_proto = DPO_PROTO_IP4;
8854 else if (unformat (i, "via %U", unformat_ip6_address,
8855 &v6_next_hop_address))
8858 next_hop_proto = DPO_PROTO_IP6;
8860 else if (unformat (i, "weight %d", &next_hop_weight))
8862 else if (unformat (i, "classify %d", &classify_table_index))
8866 else if (unformat (i, "del"))
8868 else if (unformat (i, "add"))
8870 else if (unformat (i, "resolve-via-host"))
8872 else if (unformat (i, "resolve-via-attached"))
8873 resolve_attached = 1;
8874 else if (unformat (i, "multipath"))
8876 else if (unformat (i, "count %d", &count))
8878 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8881 next_hop_proto = DPO_PROTO_IP4;
8883 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8886 next_hop_proto = DPO_PROTO_IP6;
8888 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8890 else if (unformat (i, "via-label %d", &next_hop_via_label))
8892 else if (unformat (i, "out-label %d", &next_hop_out_label))
8893 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8896 clib_warning ("parse error '%U'", format_unformat_error, i);
8901 if (!next_hop_set && !is_classify)
8903 errmsg ("next hop / classify not set");
8907 if (MPLS_LABEL_INVALID == local_label)
8909 errmsg ("missing label");
8915 /* Turn on async mode */
8916 vam->async_mode = 1;
8917 vam->async_errors = 0;
8918 before = vat_time_now (vam);
8921 for (j = 0; j < count; j++)
8923 /* Construct the API message */
8924 M2 (MPLS_ROUTE_ADD_DEL, mp,
8925 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8927 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8928 mp->mr_table_id = ntohl (table_id);
8930 mp->mr_is_add = is_add;
8931 mp->mr_next_hop_proto = next_hop_proto;
8932 mp->mr_is_classify = is_classify;
8933 mp->mr_is_multipath = is_multipath;
8934 mp->mr_is_resolve_host = resolve_host;
8935 mp->mr_is_resolve_attached = resolve_attached;
8936 mp->mr_next_hop_weight = next_hop_weight;
8937 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8938 mp->mr_classify_table_index = ntohl (classify_table_index);
8939 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8940 mp->mr_label = ntohl (local_label);
8941 mp->mr_eos = is_eos;
8943 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8944 if (0 != mp->mr_next_hop_n_out_labels)
8946 memcpy (mp->mr_next_hop_out_label_stack,
8947 next_hop_out_label_stack,
8948 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8949 vec_free (next_hop_out_label_stack);
8954 if (DPO_PROTO_IP4 == next_hop_proto)
8956 clib_memcpy (mp->mr_next_hop,
8957 &v4_next_hop_address,
8958 sizeof (v4_next_hop_address));
8960 else if (DPO_PROTO_IP6 == next_hop_proto)
8963 clib_memcpy (mp->mr_next_hop,
8964 &v6_next_hop_address,
8965 sizeof (v6_next_hop_address));
8972 /* If we receive SIGTERM, stop now... */
8977 /* When testing multiple add/del ops, use a control-ping to sync */
8980 vl_api_control_ping_t *mp_ping;
8984 /* Shut off async mode */
8985 vam->async_mode = 0;
8987 MPING (CONTROL_PING, mp_ping);
8990 timeout = vat_time_now (vam) + 1.0;
8991 while (vat_time_now (vam) < timeout)
8992 if (vam->result_ready == 1)
8997 if (vam->retval == -99)
9000 if (vam->async_errors > 0)
9002 errmsg ("%d asynchronous errors", vam->async_errors);
9005 vam->async_errors = 0;
9006 after = vat_time_now (vam);
9008 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9012 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9013 count, after - before, count / (after - before));
9019 /* Wait for a reply... */
9024 /* Return the good/bad news */
9025 return (vam->retval);
9029 api_mpls_ip_bind_unbind (vat_main_t * vam)
9031 unformat_input_t *i = vam->input;
9032 vl_api_mpls_ip_bind_unbind_t *mp;
9033 u32 ip_table_id = 0;
9036 ip4_address_t v4_address;
9037 ip6_address_t v6_address;
9040 mpls_label_t local_label = MPLS_LABEL_INVALID;
9043 /* Parse args required to build the message */
9044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9046 if (unformat (i, "%U/%d", unformat_ip4_address,
9047 &v4_address, &address_length))
9052 else if (unformat (i, "%U/%d", unformat_ip6_address,
9053 &v6_address, &address_length))
9058 else if (unformat (i, "%d", &local_label))
9060 else if (unformat (i, "table-id %d", &ip_table_id))
9062 else if (unformat (i, "unbind"))
9064 else if (unformat (i, "bind"))
9068 clib_warning ("parse error '%U'", format_unformat_error, i);
9075 errmsg ("IP addres not set");
9079 if (MPLS_LABEL_INVALID == local_label)
9081 errmsg ("missing label");
9085 /* Construct the API message */
9086 M (MPLS_IP_BIND_UNBIND, mp);
9088 mp->mb_is_bind = is_bind;
9089 mp->mb_is_ip4 = is_ip4;
9090 mp->mb_ip_table_id = ntohl (ip_table_id);
9091 mp->mb_mpls_table_id = 0;
9092 mp->mb_label = ntohl (local_label);
9093 mp->mb_address_length = address_length;
9096 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9098 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9103 /* Wait for a reply... */
9109 api_bier_table_add_del (vat_main_t * vam)
9111 unformat_input_t *i = vam->input;
9112 vl_api_bier_table_add_del_t *mp;
9114 u32 set = 0, sub_domain = 0, hdr_len = 3;
9115 mpls_label_t local_label = MPLS_LABEL_INVALID;
9118 /* Parse args required to build the message */
9119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9121 if (unformat (i, "sub-domain %d", &sub_domain))
9123 else if (unformat (i, "set %d", &set))
9125 else if (unformat (i, "label %d", &local_label))
9127 else if (unformat (i, "hdr-len %d", &hdr_len))
9129 else if (unformat (i, "add"))
9131 else if (unformat (i, "del"))
9135 clib_warning ("parse error '%U'", format_unformat_error, i);
9140 if (MPLS_LABEL_INVALID == local_label)
9142 errmsg ("missing label\n");
9146 /* Construct the API message */
9147 M (BIER_TABLE_ADD_DEL, mp);
9149 mp->bt_is_add = is_add;
9150 mp->bt_label = ntohl (local_label);
9151 mp->bt_tbl_id.bt_set = set;
9152 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9153 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9158 /* Wait for a reply... */
9165 api_bier_route_add_del (vat_main_t * vam)
9167 unformat_input_t *i = vam->input;
9168 vl_api_bier_route_add_del_t *mp;
9170 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9171 ip4_address_t v4_next_hop_address;
9172 ip6_address_t v6_next_hop_address;
9173 u8 next_hop_set = 0;
9174 u8 next_hop_proto_is_ip4 = 1;
9175 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9178 /* Parse args required to build the message */
9179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9181 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9183 next_hop_proto_is_ip4 = 1;
9186 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9188 next_hop_proto_is_ip4 = 0;
9191 if (unformat (i, "sub-domain %d", &sub_domain))
9193 else if (unformat (i, "set %d", &set))
9195 else if (unformat (i, "hdr-len %d", &hdr_len))
9197 else if (unformat (i, "bp %d", &bp))
9199 else if (unformat (i, "add"))
9201 else if (unformat (i, "del"))
9203 else if (unformat (i, "out-label %d", &next_hop_out_label))
9207 clib_warning ("parse error '%U'", format_unformat_error, i);
9212 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9214 errmsg ("next hop / label set\n");
9219 errmsg ("bit=position not set\n");
9223 /* Construct the API message */
9224 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9226 mp->br_is_add = is_add;
9227 mp->br_tbl_id.bt_set = set;
9228 mp->br_tbl_id.bt_sub_domain = sub_domain;
9229 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9230 mp->br_bp = ntohs (bp);
9232 mp->br_paths[0].n_labels = 1;
9233 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9234 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9236 if (next_hop_proto_is_ip4)
9238 clib_memcpy (mp->br_paths[0].next_hop,
9239 &v4_next_hop_address, sizeof (v4_next_hop_address));
9243 clib_memcpy (mp->br_paths[0].next_hop,
9244 &v6_next_hop_address, sizeof (v6_next_hop_address));
9250 /* Wait for a reply... */
9257 api_proxy_arp_add_del (vat_main_t * vam)
9259 unformat_input_t *i = vam->input;
9260 vl_api_proxy_arp_add_del_t *mp;
9263 ip4_address_t lo, hi;
9267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9269 if (unformat (i, "vrf %d", &vrf_id))
9271 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9272 unformat_ip4_address, &hi))
9274 else if (unformat (i, "del"))
9278 clib_warning ("parse error '%U'", format_unformat_error, i);
9285 errmsg ("address range not set");
9289 M (PROXY_ARP_ADD_DEL, mp);
9291 mp->proxy.vrf_id = ntohl (vrf_id);
9292 mp->is_add = is_add;
9293 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9294 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9302 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9304 unformat_input_t *i = vam->input;
9305 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9308 u8 sw_if_index_set = 0;
9311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9314 sw_if_index_set = 1;
9315 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9316 sw_if_index_set = 1;
9317 else if (unformat (i, "enable"))
9319 else if (unformat (i, "disable"))
9323 clib_warning ("parse error '%U'", format_unformat_error, i);
9328 if (sw_if_index_set == 0)
9330 errmsg ("missing interface name or sw_if_index");
9334 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9336 mp->sw_if_index = ntohl (sw_if_index);
9337 mp->enable_disable = enable;
9345 api_mpls_tunnel_add_del (vat_main_t * vam)
9347 unformat_input_t *i = vam->input;
9348 vl_api_mpls_tunnel_add_del_t *mp;
9352 u32 sw_if_index = ~0;
9353 u32 next_hop_sw_if_index = ~0;
9354 u32 next_hop_proto_is_ip4 = 1;
9356 u32 next_hop_table_id = 0;
9357 ip4_address_t v4_next_hop_address = {
9360 ip6_address_t v6_next_hop_address = { {0} };
9361 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9366 if (unformat (i, "add"))
9368 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9370 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9372 else if (unformat (i, "via %U",
9373 unformat_ip4_address, &v4_next_hop_address))
9375 next_hop_proto_is_ip4 = 1;
9377 else if (unformat (i, "via %U",
9378 unformat_ip6_address, &v6_next_hop_address))
9380 next_hop_proto_is_ip4 = 0;
9382 else if (unformat (i, "l2-only"))
9384 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9386 else if (unformat (i, "out-label %d", &next_hop_out_label))
9387 vec_add1 (labels, ntohl (next_hop_out_label));
9390 clib_warning ("parse error '%U'", format_unformat_error, i);
9395 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9397 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9398 mp->mt_sw_if_index = ntohl (sw_if_index);
9399 mp->mt_is_add = is_add;
9400 mp->mt_l2_only = l2_only;
9401 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9402 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9404 mp->mt_next_hop_n_out_labels = vec_len (labels);
9406 if (0 != mp->mt_next_hop_n_out_labels)
9408 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9409 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9413 if (next_hop_proto_is_ip4)
9415 clib_memcpy (mp->mt_next_hop,
9416 &v4_next_hop_address, sizeof (v4_next_hop_address));
9420 clib_memcpy (mp->mt_next_hop,
9421 &v6_next_hop_address, sizeof (v6_next_hop_address));
9430 api_sw_interface_set_unnumbered (vat_main_t * vam)
9432 unformat_input_t *i = vam->input;
9433 vl_api_sw_interface_set_unnumbered_t *mp;
9435 u32 unnum_sw_index = ~0;
9437 u8 sw_if_index_set = 0;
9440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9442 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9443 sw_if_index_set = 1;
9444 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9445 sw_if_index_set = 1;
9446 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9448 else if (unformat (i, "del"))
9452 clib_warning ("parse error '%U'", format_unformat_error, i);
9457 if (sw_if_index_set == 0)
9459 errmsg ("missing interface name or sw_if_index");
9463 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9465 mp->sw_if_index = ntohl (sw_if_index);
9466 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9467 mp->is_add = is_add;
9475 api_ip_neighbor_add_del (vat_main_t * vam)
9477 unformat_input_t *i = vam->input;
9478 vl_api_ip_neighbor_add_del_t *mp;
9480 u8 sw_if_index_set = 0;
9483 u8 is_no_fib_entry = 0;
9486 u8 v4_address_set = 0;
9487 u8 v6_address_set = 0;
9488 ip4_address_t v4address;
9489 ip6_address_t v6address;
9492 memset (mac_address, 0, sizeof (mac_address));
9494 /* Parse args required to build the message */
9495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9497 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9501 else if (unformat (i, "del"))
9504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9505 sw_if_index_set = 1;
9506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9507 sw_if_index_set = 1;
9508 else if (unformat (i, "is_static"))
9510 else if (unformat (i, "no-fib-entry"))
9511 is_no_fib_entry = 1;
9512 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9514 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9518 clib_warning ("parse error '%U'", format_unformat_error, i);
9523 if (sw_if_index_set == 0)
9525 errmsg ("missing interface name or sw_if_index");
9528 if (v4_address_set && v6_address_set)
9530 errmsg ("both v4 and v6 addresses set");
9533 if (!v4_address_set && !v6_address_set)
9535 errmsg ("no address set");
9539 /* Construct the API message */
9540 M (IP_NEIGHBOR_ADD_DEL, mp);
9542 mp->sw_if_index = ntohl (sw_if_index);
9543 mp->is_add = is_add;
9544 mp->is_static = is_static;
9545 mp->is_no_adj_fib = is_no_fib_entry;
9547 clib_memcpy (mp->mac_address, mac_address, 6);
9551 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9555 /* mp->is_ipv6 = 0; via memset in M macro above */
9556 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9562 /* Wait for a reply, return good/bad news */
9568 api_create_vlan_subif (vat_main_t * vam)
9570 unformat_input_t *i = vam->input;
9571 vl_api_create_vlan_subif_t *mp;
9573 u8 sw_if_index_set = 0;
9578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9580 if (unformat (i, "sw_if_index %d", &sw_if_index))
9581 sw_if_index_set = 1;
9583 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9584 sw_if_index_set = 1;
9585 else if (unformat (i, "vlan %d", &vlan_id))
9589 clib_warning ("parse error '%U'", format_unformat_error, i);
9594 if (sw_if_index_set == 0)
9596 errmsg ("missing interface name or sw_if_index");
9600 if (vlan_id_set == 0)
9602 errmsg ("missing vlan_id");
9605 M (CREATE_VLAN_SUBIF, mp);
9607 mp->sw_if_index = ntohl (sw_if_index);
9608 mp->vlan_id = ntohl (vlan_id);
9615 #define foreach_create_subif_bit \
9622 _(outer_vlan_id_any) \
9623 _(inner_vlan_id_any)
9626 api_create_subif (vat_main_t * vam)
9628 unformat_input_t *i = vam->input;
9629 vl_api_create_subif_t *mp;
9631 u8 sw_if_index_set = 0;
9638 u32 exact_match = 0;
9639 u32 default_sub = 0;
9640 u32 outer_vlan_id_any = 0;
9641 u32 inner_vlan_id_any = 0;
9643 u16 outer_vlan_id = 0;
9644 u16 inner_vlan_id = 0;
9647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9649 if (unformat (i, "sw_if_index %d", &sw_if_index))
9650 sw_if_index_set = 1;
9652 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9653 sw_if_index_set = 1;
9654 else if (unformat (i, "sub_id %d", &sub_id))
9656 else if (unformat (i, "outer_vlan_id %d", &tmp))
9657 outer_vlan_id = tmp;
9658 else if (unformat (i, "inner_vlan_id %d", &tmp))
9659 inner_vlan_id = tmp;
9661 #define _(a) else if (unformat (i, #a)) a = 1 ;
9662 foreach_create_subif_bit
9666 clib_warning ("parse error '%U'", format_unformat_error, i);
9671 if (sw_if_index_set == 0)
9673 errmsg ("missing interface name or sw_if_index");
9677 if (sub_id_set == 0)
9679 errmsg ("missing sub_id");
9682 M (CREATE_SUBIF, mp);
9684 mp->sw_if_index = ntohl (sw_if_index);
9685 mp->sub_id = ntohl (sub_id);
9687 #define _(a) mp->a = a;
9688 foreach_create_subif_bit;
9691 mp->outer_vlan_id = ntohs (outer_vlan_id);
9692 mp->inner_vlan_id = ntohs (inner_vlan_id);
9700 api_oam_add_del (vat_main_t * vam)
9702 unformat_input_t *i = vam->input;
9703 vl_api_oam_add_del_t *mp;
9706 ip4_address_t src, dst;
9711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9713 if (unformat (i, "vrf %d", &vrf_id))
9715 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9717 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9719 else if (unformat (i, "del"))
9723 clib_warning ("parse error '%U'", format_unformat_error, i);
9730 errmsg ("missing src addr");
9736 errmsg ("missing dst addr");
9740 M (OAM_ADD_DEL, mp);
9742 mp->vrf_id = ntohl (vrf_id);
9743 mp->is_add = is_add;
9744 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9745 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9753 api_reset_fib (vat_main_t * vam)
9755 unformat_input_t *i = vam->input;
9756 vl_api_reset_fib_t *mp;
9762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9764 if (unformat (i, "vrf %d", &vrf_id))
9766 else if (unformat (i, "ipv6"))
9770 clib_warning ("parse error '%U'", format_unformat_error, i);
9775 if (vrf_id_set == 0)
9777 errmsg ("missing vrf id");
9783 mp->vrf_id = ntohl (vrf_id);
9784 mp->is_ipv6 = is_ipv6;
9792 api_dhcp_proxy_config (vat_main_t * vam)
9794 unformat_input_t *i = vam->input;
9795 vl_api_dhcp_proxy_config_t *mp;
9797 u32 server_vrf_id = 0;
9799 u8 v4_address_set = 0;
9800 u8 v6_address_set = 0;
9801 ip4_address_t v4address;
9802 ip6_address_t v6address;
9803 u8 v4_src_address_set = 0;
9804 u8 v6_src_address_set = 0;
9805 ip4_address_t v4srcaddress;
9806 ip6_address_t v6srcaddress;
9809 /* Parse args required to build the message */
9810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9812 if (unformat (i, "del"))
9814 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9816 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9818 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9820 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9822 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9823 v4_src_address_set = 1;
9824 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9825 v6_src_address_set = 1;
9830 if (v4_address_set && v6_address_set)
9832 errmsg ("both v4 and v6 server addresses set");
9835 if (!v4_address_set && !v6_address_set)
9837 errmsg ("no server addresses set");
9841 if (v4_src_address_set && v6_src_address_set)
9843 errmsg ("both v4 and v6 src addresses set");
9846 if (!v4_src_address_set && !v6_src_address_set)
9848 errmsg ("no src addresses set");
9852 if (!(v4_src_address_set && v4_address_set) &&
9853 !(v6_src_address_set && v6_address_set))
9855 errmsg ("no matching server and src addresses set");
9859 /* Construct the API message */
9860 M (DHCP_PROXY_CONFIG, mp);
9862 mp->is_add = is_add;
9863 mp->rx_vrf_id = ntohl (rx_vrf_id);
9864 mp->server_vrf_id = ntohl (server_vrf_id);
9868 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9869 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9873 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9874 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9880 /* Wait for a reply, return good/bad news */
9885 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9886 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9889 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9891 vat_main_t *vam = &vat_main;
9892 u32 i, count = mp->count;
9893 vl_api_dhcp_server_t *s;
9897 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9898 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9899 ntohl (mp->rx_vrf_id),
9900 format_ip6_address, mp->dhcp_src_address,
9901 mp->vss_type, mp->vss_vpn_ascii_id,
9902 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9905 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9906 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9907 ntohl (mp->rx_vrf_id),
9908 format_ip4_address, mp->dhcp_src_address,
9909 mp->vss_type, mp->vss_vpn_ascii_id,
9910 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9912 for (i = 0; i < count; i++)
9914 s = &mp->servers[i];
9918 " Server Table-ID %d, Server Address %U",
9919 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9922 " Server Table-ID %d, Server Address %U",
9923 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9927 static void vl_api_dhcp_proxy_details_t_handler_json
9928 (vl_api_dhcp_proxy_details_t * mp)
9930 vat_main_t *vam = &vat_main;
9931 vat_json_node_t *node = NULL;
9932 u32 i, count = mp->count;
9934 struct in6_addr ip6;
9935 vl_api_dhcp_server_t *s;
9937 if (VAT_JSON_ARRAY != vam->json_tree.type)
9939 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9940 vat_json_init_array (&vam->json_tree);
9942 node = vat_json_array_add (&vam->json_tree);
9944 vat_json_init_object (node);
9945 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9946 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9947 sizeof (mp->vss_type));
9948 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9949 mp->vss_vpn_ascii_id);
9950 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9951 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9955 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9956 vat_json_object_add_ip6 (node, "src_address", ip6);
9960 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9961 vat_json_object_add_ip4 (node, "src_address", ip4);
9964 for (i = 0; i < count; i++)
9966 s = &mp->servers[i];
9968 vat_json_object_add_uint (node, "server-table-id",
9969 ntohl (s->server_vrf_id));
9973 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9974 vat_json_object_add_ip4 (node, "src_address", ip4);
9978 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9979 vat_json_object_add_ip6 (node, "server_address", ip6);
9985 api_dhcp_proxy_dump (vat_main_t * vam)
9987 unformat_input_t *i = vam->input;
9988 vl_api_control_ping_t *mp_ping;
9989 vl_api_dhcp_proxy_dump_t *mp;
9993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9995 if (unformat (i, "ipv6"))
9999 clib_warning ("parse error '%U'", format_unformat_error, i);
10004 M (DHCP_PROXY_DUMP, mp);
10006 mp->is_ip6 = is_ipv6;
10009 /* Use a control ping for synchronization */
10010 MPING (CONTROL_PING, mp_ping);
10018 api_dhcp_proxy_set_vss (vat_main_t * vam)
10020 unformat_input_t *i = vam->input;
10021 vl_api_dhcp_proxy_set_vss_t *mp;
10025 u8 vss_type = VSS_TYPE_DEFAULT;
10026 u8 *vpn_ascii_id = 0;
10031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10033 if (unformat (i, "tbl_id %d", &tbl_id))
10035 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10036 vss_type = VSS_TYPE_ASCII;
10037 else if (unformat (i, "fib_id %d", &fib_id))
10038 vss_type = VSS_TYPE_VPN_ID;
10039 else if (unformat (i, "oui %d", &oui))
10040 vss_type = VSS_TYPE_VPN_ID;
10041 else if (unformat (i, "ipv6"))
10043 else if (unformat (i, "del"))
10051 errmsg ("missing tbl_id ");
10052 vec_free (vpn_ascii_id);
10056 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10058 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10059 vec_free (vpn_ascii_id);
10063 M (DHCP_PROXY_SET_VSS, mp);
10064 mp->tbl_id = ntohl (tbl_id);
10065 mp->vss_type = vss_type;
10068 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10069 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10071 mp->vpn_index = ntohl (fib_id);
10072 mp->oui = ntohl (oui);
10073 mp->is_ipv6 = is_ipv6;
10074 mp->is_add = is_add;
10079 vec_free (vpn_ascii_id);
10084 api_dhcp_client_config (vat_main_t * vam)
10086 unformat_input_t *i = vam->input;
10087 vl_api_dhcp_client_config_t *mp;
10089 u8 sw_if_index_set = 0;
10092 u8 disable_event = 0;
10095 /* Parse args required to build the message */
10096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10098 if (unformat (i, "del"))
10101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10102 sw_if_index_set = 1;
10103 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10104 sw_if_index_set = 1;
10105 else if (unformat (i, "hostname %s", &hostname))
10107 else if (unformat (i, "disable_event"))
10113 if (sw_if_index_set == 0)
10115 errmsg ("missing interface name or sw_if_index");
10119 if (vec_len (hostname) > 63)
10121 errmsg ("hostname too long");
10123 vec_add1 (hostname, 0);
10125 /* Construct the API message */
10126 M (DHCP_CLIENT_CONFIG, mp);
10128 mp->sw_if_index = htonl (sw_if_index);
10129 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
10130 vec_free (hostname);
10131 mp->is_add = is_add;
10132 mp->want_dhcp_event = disable_event ? 0 : 1;
10133 mp->pid = htonl (getpid ());
10138 /* Wait for a reply, return good/bad news */
10144 api_set_ip_flow_hash (vat_main_t * vam)
10146 unformat_input_t *i = vam->input;
10147 vl_api_set_ip_flow_hash_t *mp;
10159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10161 if (unformat (i, "vrf %d", &vrf_id))
10163 else if (unformat (i, "ipv6"))
10165 else if (unformat (i, "src"))
10167 else if (unformat (i, "dst"))
10169 else if (unformat (i, "sport"))
10171 else if (unformat (i, "dport"))
10173 else if (unformat (i, "proto"))
10175 else if (unformat (i, "reverse"))
10180 clib_warning ("parse error '%U'", format_unformat_error, i);
10185 if (vrf_id_set == 0)
10187 errmsg ("missing vrf id");
10191 M (SET_IP_FLOW_HASH, mp);
10197 mp->reverse = reverse;
10198 mp->vrf_id = ntohl (vrf_id);
10199 mp->is_ipv6 = is_ipv6;
10207 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10209 unformat_input_t *i = vam->input;
10210 vl_api_sw_interface_ip6_enable_disable_t *mp;
10212 u8 sw_if_index_set = 0;
10216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10219 sw_if_index_set = 1;
10220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10221 sw_if_index_set = 1;
10222 else if (unformat (i, "enable"))
10224 else if (unformat (i, "disable"))
10228 clib_warning ("parse error '%U'", format_unformat_error, i);
10233 if (sw_if_index_set == 0)
10235 errmsg ("missing interface name or sw_if_index");
10239 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10241 mp->sw_if_index = ntohl (sw_if_index);
10242 mp->enable = enable;
10250 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10252 unformat_input_t *i = vam->input;
10253 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10255 u8 sw_if_index_set = 0;
10256 u8 v6_address_set = 0;
10257 ip6_address_t v6address;
10260 /* Parse args required to build the message */
10261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10263 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10264 sw_if_index_set = 1;
10265 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10266 sw_if_index_set = 1;
10267 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10268 v6_address_set = 1;
10273 if (sw_if_index_set == 0)
10275 errmsg ("missing interface name or sw_if_index");
10278 if (!v6_address_set)
10280 errmsg ("no address set");
10284 /* Construct the API message */
10285 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10287 mp->sw_if_index = ntohl (sw_if_index);
10288 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10293 /* Wait for a reply, return good/bad news */
10299 api_ip6nd_proxy_add_del (vat_main_t * vam)
10301 unformat_input_t *i = vam->input;
10302 vl_api_ip6nd_proxy_add_del_t *mp;
10303 u32 sw_if_index = ~0;
10304 u8 v6_address_set = 0;
10305 ip6_address_t v6address;
10309 /* Parse args required to build the message */
10310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10312 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10314 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10316 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10317 v6_address_set = 1;
10318 if (unformat (i, "del"))
10322 clib_warning ("parse error '%U'", format_unformat_error, i);
10327 if (sw_if_index == ~0)
10329 errmsg ("missing interface name or sw_if_index");
10332 if (!v6_address_set)
10334 errmsg ("no address set");
10338 /* Construct the API message */
10339 M (IP6ND_PROXY_ADD_DEL, mp);
10341 mp->is_del = is_del;
10342 mp->sw_if_index = ntohl (sw_if_index);
10343 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10348 /* Wait for a reply, return good/bad news */
10354 api_ip6nd_proxy_dump (vat_main_t * vam)
10356 vl_api_ip6nd_proxy_dump_t *mp;
10357 vl_api_control_ping_t *mp_ping;
10360 M (IP6ND_PROXY_DUMP, mp);
10364 /* Use a control ping for synchronization */
10365 MPING (CONTROL_PING, mp_ping);
10372 static void vl_api_ip6nd_proxy_details_t_handler
10373 (vl_api_ip6nd_proxy_details_t * mp)
10375 vat_main_t *vam = &vat_main;
10377 print (vam->ofp, "host %U sw_if_index %d",
10378 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10381 static void vl_api_ip6nd_proxy_details_t_handler_json
10382 (vl_api_ip6nd_proxy_details_t * mp)
10384 vat_main_t *vam = &vat_main;
10385 struct in6_addr ip6;
10386 vat_json_node_t *node = NULL;
10388 if (VAT_JSON_ARRAY != vam->json_tree.type)
10390 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10391 vat_json_init_array (&vam->json_tree);
10393 node = vat_json_array_add (&vam->json_tree);
10395 vat_json_init_object (node);
10396 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10398 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10399 vat_json_object_add_ip6 (node, "host", ip6);
10403 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10405 unformat_input_t *i = vam->input;
10406 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10408 u8 sw_if_index_set = 0;
10409 u32 address_length = 0;
10410 u8 v6_address_set = 0;
10411 ip6_address_t v6address;
10412 u8 use_default = 0;
10413 u8 no_advertise = 0;
10415 u8 no_autoconfig = 0;
10418 u32 val_lifetime = 0;
10419 u32 pref_lifetime = 0;
10422 /* Parse args required to build the message */
10423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10425 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10426 sw_if_index_set = 1;
10427 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10428 sw_if_index_set = 1;
10429 else if (unformat (i, "%U/%d",
10430 unformat_ip6_address, &v6address, &address_length))
10431 v6_address_set = 1;
10432 else if (unformat (i, "val_life %d", &val_lifetime))
10434 else if (unformat (i, "pref_life %d", &pref_lifetime))
10436 else if (unformat (i, "def"))
10438 else if (unformat (i, "noadv"))
10440 else if (unformat (i, "offl"))
10442 else if (unformat (i, "noauto"))
10444 else if (unformat (i, "nolink"))
10446 else if (unformat (i, "isno"))
10450 clib_warning ("parse error '%U'", format_unformat_error, i);
10455 if (sw_if_index_set == 0)
10457 errmsg ("missing interface name or sw_if_index");
10460 if (!v6_address_set)
10462 errmsg ("no address set");
10466 /* Construct the API message */
10467 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10469 mp->sw_if_index = ntohl (sw_if_index);
10470 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10471 mp->address_length = address_length;
10472 mp->use_default = use_default;
10473 mp->no_advertise = no_advertise;
10474 mp->off_link = off_link;
10475 mp->no_autoconfig = no_autoconfig;
10476 mp->no_onlink = no_onlink;
10478 mp->val_lifetime = ntohl (val_lifetime);
10479 mp->pref_lifetime = ntohl (pref_lifetime);
10484 /* Wait for a reply, return good/bad news */
10490 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10492 unformat_input_t *i = vam->input;
10493 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10495 u8 sw_if_index_set = 0;
10500 u8 send_unicast = 0;
10503 u8 default_router = 0;
10504 u32 max_interval = 0;
10505 u32 min_interval = 0;
10507 u32 initial_count = 0;
10508 u32 initial_interval = 0;
10512 /* Parse args required to build the message */
10513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10516 sw_if_index_set = 1;
10517 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10518 sw_if_index_set = 1;
10519 else if (unformat (i, "maxint %d", &max_interval))
10521 else if (unformat (i, "minint %d", &min_interval))
10523 else if (unformat (i, "life %d", &lifetime))
10525 else if (unformat (i, "count %d", &initial_count))
10527 else if (unformat (i, "interval %d", &initial_interval))
10529 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10531 else if (unformat (i, "managed"))
10533 else if (unformat (i, "other"))
10535 else if (unformat (i, "ll"))
10537 else if (unformat (i, "send"))
10539 else if (unformat (i, "cease"))
10541 else if (unformat (i, "isno"))
10543 else if (unformat (i, "def"))
10544 default_router = 1;
10547 clib_warning ("parse error '%U'", format_unformat_error, i);
10552 if (sw_if_index_set == 0)
10554 errmsg ("missing interface name or sw_if_index");
10558 /* Construct the API message */
10559 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10561 mp->sw_if_index = ntohl (sw_if_index);
10562 mp->max_interval = ntohl (max_interval);
10563 mp->min_interval = ntohl (min_interval);
10564 mp->lifetime = ntohl (lifetime);
10565 mp->initial_count = ntohl (initial_count);
10566 mp->initial_interval = ntohl (initial_interval);
10567 mp->suppress = suppress;
10568 mp->managed = managed;
10570 mp->ll_option = ll_option;
10571 mp->send_unicast = send_unicast;
10574 mp->default_router = default_router;
10579 /* Wait for a reply, return good/bad news */
10585 api_set_arp_neighbor_limit (vat_main_t * vam)
10587 unformat_input_t *i = vam->input;
10588 vl_api_set_arp_neighbor_limit_t *mp;
10594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10596 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10598 else if (unformat (i, "ipv6"))
10602 clib_warning ("parse error '%U'", format_unformat_error, i);
10607 if (limit_set == 0)
10609 errmsg ("missing limit value");
10613 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10615 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10616 mp->is_ipv6 = is_ipv6;
10624 api_l2_patch_add_del (vat_main_t * vam)
10626 unformat_input_t *i = vam->input;
10627 vl_api_l2_patch_add_del_t *mp;
10628 u32 rx_sw_if_index;
10629 u8 rx_sw_if_index_set = 0;
10630 u32 tx_sw_if_index;
10631 u8 tx_sw_if_index_set = 0;
10635 /* Parse args required to build the message */
10636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10638 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10639 rx_sw_if_index_set = 1;
10640 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10641 tx_sw_if_index_set = 1;
10642 else if (unformat (i, "rx"))
10644 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10646 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10648 rx_sw_if_index_set = 1;
10653 else if (unformat (i, "tx"))
10655 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10657 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10659 tx_sw_if_index_set = 1;
10664 else if (unformat (i, "del"))
10670 if (rx_sw_if_index_set == 0)
10672 errmsg ("missing rx interface name or rx_sw_if_index");
10676 if (tx_sw_if_index_set == 0)
10678 errmsg ("missing tx interface name or tx_sw_if_index");
10682 M (L2_PATCH_ADD_DEL, mp);
10684 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10685 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10686 mp->is_add = is_add;
10694 u8 localsid_addr[16];
10703 api_sr_localsid_add_del (vat_main_t * vam)
10705 unformat_input_t *i = vam->input;
10706 vl_api_sr_localsid_add_del_t *mp;
10709 ip6_address_t localsid;
10713 u32 fib_table = ~(u32) 0;
10714 ip6_address_t next_hop;
10716 bool nexthop_set = 0;
10720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10722 if (unformat (i, "del"))
10724 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10725 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10727 else if (unformat (i, "behavior %u", &behavior));
10728 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10729 else if (unformat (i, "fib-table %u", &fib_table));
10730 else if (unformat (i, "end.psp %u", &behavior));
10735 M (SR_LOCALSID_ADD_DEL, mp);
10737 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10739 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10740 mp->behavior = behavior;
10741 mp->sw_if_index = ntohl (sw_if_index);
10742 mp->fib_table = ntohl (fib_table);
10743 mp->end_psp = end_psp;
10744 mp->is_del = is_del;
10752 api_ioam_enable (vat_main_t * vam)
10754 unformat_input_t *input = vam->input;
10755 vl_api_ioam_enable_t *mp;
10757 int has_trace_option = 0;
10758 int has_pot_option = 0;
10759 int has_seqno_option = 0;
10760 int has_analyse_option = 0;
10763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10765 if (unformat (input, "trace"))
10766 has_trace_option = 1;
10767 else if (unformat (input, "pot"))
10768 has_pot_option = 1;
10769 else if (unformat (input, "seqno"))
10770 has_seqno_option = 1;
10771 else if (unformat (input, "analyse"))
10772 has_analyse_option = 1;
10776 M (IOAM_ENABLE, mp);
10777 mp->id = htons (id);
10778 mp->seqno = has_seqno_option;
10779 mp->analyse = has_analyse_option;
10780 mp->pot_enable = has_pot_option;
10781 mp->trace_enable = has_trace_option;
10790 api_ioam_disable (vat_main_t * vam)
10792 vl_api_ioam_disable_t *mp;
10795 M (IOAM_DISABLE, mp);
10801 #define foreach_tcp_proto_field \
10805 #define foreach_udp_proto_field \
10809 #define foreach_ip4_proto_field \
10821 u16 src_port, dst_port;
10824 #if VPP_API_TEST_BUILTIN == 0
10826 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10828 u8 **maskp = va_arg (*args, u8 **);
10830 u8 found_something = 0;
10833 #define _(a) u8 a=0;
10834 foreach_tcp_proto_field;
10837 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10840 #define _(a) else if (unformat (input, #a)) a=1;
10841 foreach_tcp_proto_field
10847 #define _(a) found_something += a;
10848 foreach_tcp_proto_field;
10851 if (found_something == 0)
10854 vec_validate (mask, sizeof (*tcp) - 1);
10856 tcp = (tcp_header_t *) mask;
10858 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10859 foreach_tcp_proto_field;
10867 unformat_udp_mask (unformat_input_t * input, va_list * args)
10869 u8 **maskp = va_arg (*args, u8 **);
10871 u8 found_something = 0;
10874 #define _(a) u8 a=0;
10875 foreach_udp_proto_field;
10878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10881 #define _(a) else if (unformat (input, #a)) a=1;
10882 foreach_udp_proto_field
10888 #define _(a) found_something += a;
10889 foreach_udp_proto_field;
10892 if (found_something == 0)
10895 vec_validate (mask, sizeof (*udp) - 1);
10897 udp = (udp_header_t *) mask;
10899 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10900 foreach_udp_proto_field;
10908 unformat_l4_mask (unformat_input_t * input, va_list * args)
10910 u8 **maskp = va_arg (*args, u8 **);
10911 u16 src_port = 0, dst_port = 0;
10912 tcpudp_header_t *tcpudp;
10914 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10916 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10918 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10920 else if (unformat (input, "src_port"))
10922 else if (unformat (input, "dst_port"))
10928 if (!src_port && !dst_port)
10932 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10934 tcpudp = (tcpudp_header_t *) mask;
10935 tcpudp->src_port = src_port;
10936 tcpudp->dst_port = dst_port;
10944 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10946 u8 **maskp = va_arg (*args, u8 **);
10948 u8 found_something = 0;
10951 #define _(a) u8 a=0;
10952 foreach_ip4_proto_field;
10958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10960 if (unformat (input, "version"))
10962 else if (unformat (input, "hdr_length"))
10964 else if (unformat (input, "src"))
10966 else if (unformat (input, "dst"))
10968 else if (unformat (input, "proto"))
10971 #define _(a) else if (unformat (input, #a)) a=1;
10972 foreach_ip4_proto_field
10978 #define _(a) found_something += a;
10979 foreach_ip4_proto_field;
10982 if (found_something == 0)
10985 vec_validate (mask, sizeof (*ip) - 1);
10987 ip = (ip4_header_t *) mask;
10989 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10990 foreach_ip4_proto_field;
10993 ip->ip_version_and_header_length = 0;
10996 ip->ip_version_and_header_length |= 0xF0;
10999 ip->ip_version_and_header_length |= 0x0F;
11005 #define foreach_ip6_proto_field \
11008 _(payload_length) \
11013 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11015 u8 **maskp = va_arg (*args, u8 **);
11017 u8 found_something = 0;
11019 u32 ip_version_traffic_class_and_flow_label;
11021 #define _(a) u8 a=0;
11022 foreach_ip6_proto_field;
11025 u8 traffic_class = 0;
11028 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11030 if (unformat (input, "version"))
11032 else if (unformat (input, "traffic-class"))
11034 else if (unformat (input, "flow-label"))
11036 else if (unformat (input, "src"))
11038 else if (unformat (input, "dst"))
11040 else if (unformat (input, "proto"))
11043 #define _(a) else if (unformat (input, #a)) a=1;
11044 foreach_ip6_proto_field
11050 #define _(a) found_something += a;
11051 foreach_ip6_proto_field;
11054 if (found_something == 0)
11057 vec_validate (mask, sizeof (*ip) - 1);
11059 ip = (ip6_header_t *) mask;
11061 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11062 foreach_ip6_proto_field;
11065 ip_version_traffic_class_and_flow_label = 0;
11068 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11071 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11074 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11076 ip->ip_version_traffic_class_and_flow_label =
11077 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11084 unformat_l3_mask (unformat_input_t * input, va_list * args)
11086 u8 **maskp = va_arg (*args, u8 **);
11088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11090 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11092 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11101 unformat_l2_mask (unformat_input_t * input, va_list * args)
11103 u8 **maskp = va_arg (*args, u8 **);
11110 u8 ignore_tag1 = 0;
11111 u8 ignore_tag2 = 0;
11118 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11120 if (unformat (input, "src"))
11122 else if (unformat (input, "dst"))
11124 else if (unformat (input, "proto"))
11126 else if (unformat (input, "tag1"))
11128 else if (unformat (input, "tag2"))
11130 else if (unformat (input, "ignore-tag1"))
11132 else if (unformat (input, "ignore-tag2"))
11134 else if (unformat (input, "cos1"))
11136 else if (unformat (input, "cos2"))
11138 else if (unformat (input, "dot1q"))
11140 else if (unformat (input, "dot1ad"))
11145 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11146 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11149 if (tag1 || ignore_tag1 || cos1 || dot1q)
11151 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11154 vec_validate (mask, len - 1);
11157 memset (mask, 0xff, 6);
11160 memset (mask + 6, 0xff, 6);
11162 if (tag2 || dot1ad)
11164 /* inner vlan tag */
11173 mask[21] = mask[20] = 0xff;
11194 mask[16] = mask[17] = 0xff;
11204 mask[12] = mask[13] = 0xff;
11211 unformat_classify_mask (unformat_input_t * input, va_list * args)
11213 u8 **maskp = va_arg (*args, u8 **);
11214 u32 *skipp = va_arg (*args, u32 *);
11215 u32 *matchp = va_arg (*args, u32 *);
11223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11225 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11227 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11229 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11231 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11245 if (mask || l2 || l3 || l4)
11247 if (l2 || l3 || l4)
11249 /* "With a free Ethernet header in every package" */
11251 vec_validate (l2, 13);
11255 vec_append (mask, l3);
11260 vec_append (mask, l4);
11265 /* Scan forward looking for the first significant mask octet */
11266 for (i = 0; i < vec_len (mask); i++)
11270 /* compute (skip, match) params */
11271 *skipp = i / sizeof (u32x4);
11272 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11274 /* Pad mask to an even multiple of the vector size */
11275 while (vec_len (mask) % sizeof (u32x4))
11276 vec_add1 (mask, 0);
11278 match = vec_len (mask) / sizeof (u32x4);
11280 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11282 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11283 if (*tmp || *(tmp + 1))
11288 clib_warning ("BUG: match 0");
11290 _vec_len (mask) = match * sizeof (u32x4);
11300 #endif /* VPP_API_TEST_BUILTIN */
11302 #define foreach_l2_next \
11304 _(ethernet, ETHERNET_INPUT) \
11305 _(ip4, IP4_INPUT) \
11309 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11311 u32 *miss_next_indexp = va_arg (*args, u32 *);
11312 u32 next_index = 0;
11316 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11320 if (unformat (input, "%d", &tmp))
11329 *miss_next_indexp = next_index;
11333 #define foreach_ip_next \
11336 _(rewrite, REWRITE)
11339 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11341 u32 *miss_next_indexp = va_arg (*args, u32 *);
11342 u32 next_index = 0;
11346 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11350 if (unformat (input, "%d", &tmp))
11359 *miss_next_indexp = next_index;
11363 #define foreach_acl_next \
11367 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11369 u32 *miss_next_indexp = va_arg (*args, u32 *);
11370 u32 next_index = 0;
11374 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11378 if (unformat (input, "permit"))
11383 else if (unformat (input, "%d", &tmp))
11392 *miss_next_indexp = next_index;
11397 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11399 u32 *r = va_arg (*args, u32 *);
11401 if (unformat (input, "conform-color"))
11402 *r = POLICE_CONFORM;
11403 else if (unformat (input, "exceed-color"))
11404 *r = POLICE_EXCEED;
11412 api_classify_add_del_table (vat_main_t * vam)
11414 unformat_input_t *i = vam->input;
11415 vl_api_classify_add_del_table_t *mp;
11422 u32 table_index = ~0;
11423 u32 next_table_index = ~0;
11424 u32 miss_next_index = ~0;
11425 u32 memory_size = 32 << 20;
11427 u32 current_data_flag = 0;
11428 int current_data_offset = 0;
11431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11433 if (unformat (i, "del"))
11435 else if (unformat (i, "del-chain"))
11440 else if (unformat (i, "buckets %d", &nbuckets))
11442 else if (unformat (i, "memory_size %d", &memory_size))
11444 else if (unformat (i, "skip %d", &skip))
11446 else if (unformat (i, "match %d", &match))
11448 else if (unformat (i, "table %d", &table_index))
11450 else if (unformat (i, "mask %U", unformat_classify_mask,
11451 &mask, &skip, &match))
11453 else if (unformat (i, "next-table %d", &next_table_index))
11455 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11458 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11461 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11464 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11466 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11472 if (is_add && mask == 0)
11474 errmsg ("Mask required");
11478 if (is_add && skip == ~0)
11480 errmsg ("skip count required");
11484 if (is_add && match == ~0)
11486 errmsg ("match count required");
11490 if (!is_add && table_index == ~0)
11492 errmsg ("table index required for delete");
11496 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11498 mp->is_add = is_add;
11499 mp->del_chain = del_chain;
11500 mp->table_index = ntohl (table_index);
11501 mp->nbuckets = ntohl (nbuckets);
11502 mp->memory_size = ntohl (memory_size);
11503 mp->skip_n_vectors = ntohl (skip);
11504 mp->match_n_vectors = ntohl (match);
11505 mp->next_table_index = ntohl (next_table_index);
11506 mp->miss_next_index = ntohl (miss_next_index);
11507 mp->current_data_flag = ntohl (current_data_flag);
11508 mp->current_data_offset = ntohl (current_data_offset);
11509 clib_memcpy (mp->mask, mask, vec_len (mask));
11518 #if VPP_API_TEST_BUILTIN == 0
11520 unformat_l4_match (unformat_input_t * input, va_list * args)
11522 u8 **matchp = va_arg (*args, u8 **);
11524 u8 *proto_header = 0;
11530 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11532 if (unformat (input, "src_port %d", &src_port))
11534 else if (unformat (input, "dst_port %d", &dst_port))
11540 h.src_port = clib_host_to_net_u16 (src_port);
11541 h.dst_port = clib_host_to_net_u16 (dst_port);
11542 vec_validate (proto_header, sizeof (h) - 1);
11543 memcpy (proto_header, &h, sizeof (h));
11545 *matchp = proto_header;
11551 unformat_ip4_match (unformat_input_t * input, va_list * args)
11553 u8 **matchp = va_arg (*args, u8 **);
11558 int hdr_length = 0;
11559 u32 hdr_length_val;
11560 int src = 0, dst = 0;
11561 ip4_address_t src_val, dst_val;
11568 int fragment_id = 0;
11569 u32 fragment_id_val;
11575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11577 if (unformat (input, "version %d", &version_val))
11579 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11581 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11583 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11585 else if (unformat (input, "proto %d", &proto_val))
11587 else if (unformat (input, "tos %d", &tos_val))
11589 else if (unformat (input, "length %d", &length_val))
11591 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11593 else if (unformat (input, "ttl %d", &ttl_val))
11595 else if (unformat (input, "checksum %d", &checksum_val))
11601 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11602 + ttl + checksum == 0)
11606 * Aligned because we use the real comparison functions
11608 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11610 ip = (ip4_header_t *) match;
11612 /* These are realistically matched in practice */
11614 ip->src_address.as_u32 = src_val.as_u32;
11617 ip->dst_address.as_u32 = dst_val.as_u32;
11620 ip->protocol = proto_val;
11623 /* These are not, but they're included for completeness */
11625 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11628 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11634 ip->length = clib_host_to_net_u16 (length_val);
11640 ip->checksum = clib_host_to_net_u16 (checksum_val);
11647 unformat_ip6_match (unformat_input_t * input, va_list * args)
11649 u8 **matchp = va_arg (*args, u8 **);
11654 u8 traffic_class = 0;
11655 u32 traffic_class_val = 0;
11658 int src = 0, dst = 0;
11659 ip6_address_t src_val, dst_val;
11662 int payload_length = 0;
11663 u32 payload_length_val;
11666 u32 ip_version_traffic_class_and_flow_label;
11668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11670 if (unformat (input, "version %d", &version_val))
11672 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11674 else if (unformat (input, "flow_label %d", &flow_label_val))
11676 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11678 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11680 else if (unformat (input, "proto %d", &proto_val))
11682 else if (unformat (input, "payload_length %d", &payload_length_val))
11683 payload_length = 1;
11684 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11690 if (version + traffic_class + flow_label + src + dst + proto +
11691 payload_length + hop_limit == 0)
11695 * Aligned because we use the real comparison functions
11697 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11699 ip = (ip6_header_t *) match;
11702 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11705 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11708 ip->protocol = proto_val;
11710 ip_version_traffic_class_and_flow_label = 0;
11713 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11716 ip_version_traffic_class_and_flow_label |=
11717 (traffic_class_val & 0xFF) << 20;
11720 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11722 ip->ip_version_traffic_class_and_flow_label =
11723 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11725 if (payload_length)
11726 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11729 ip->hop_limit = hop_limit_val;
11736 unformat_l3_match (unformat_input_t * input, va_list * args)
11738 u8 **matchp = va_arg (*args, u8 **);
11740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11742 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11744 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11753 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11755 u8 *tagp = va_arg (*args, u8 *);
11758 if (unformat (input, "%d", &tag))
11760 tagp[0] = (tag >> 8) & 0x0F;
11761 tagp[1] = tag & 0xFF;
11769 unformat_l2_match (unformat_input_t * input, va_list * args)
11771 u8 **matchp = va_arg (*args, u8 **);
11784 u8 ignore_tag1 = 0;
11785 u8 ignore_tag2 = 0;
11791 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11793 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11796 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11798 else if (unformat (input, "proto %U",
11799 unformat_ethernet_type_host_byte_order, &proto_val))
11801 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11803 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11805 else if (unformat (input, "ignore-tag1"))
11807 else if (unformat (input, "ignore-tag2"))
11809 else if (unformat (input, "cos1 %d", &cos1_val))
11811 else if (unformat (input, "cos2 %d", &cos2_val))
11816 if ((src + dst + proto + tag1 + tag2 +
11817 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11820 if (tag1 || ignore_tag1 || cos1)
11822 if (tag2 || ignore_tag2 || cos2)
11825 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11828 clib_memcpy (match, dst_val, 6);
11831 clib_memcpy (match + 6, src_val, 6);
11835 /* inner vlan tag */
11836 match[19] = tag2_val[1];
11837 match[18] = tag2_val[0];
11839 match[18] |= (cos2_val & 0x7) << 5;
11842 match[21] = proto_val & 0xff;
11843 match[20] = proto_val >> 8;
11847 match[15] = tag1_val[1];
11848 match[14] = tag1_val[0];
11851 match[14] |= (cos1_val & 0x7) << 5;
11857 match[15] = tag1_val[1];
11858 match[14] = tag1_val[0];
11861 match[17] = proto_val & 0xff;
11862 match[16] = proto_val >> 8;
11865 match[14] |= (cos1_val & 0x7) << 5;
11871 match[18] |= (cos2_val & 0x7) << 5;
11873 match[14] |= (cos1_val & 0x7) << 5;
11876 match[13] = proto_val & 0xff;
11877 match[12] = proto_val >> 8;
11885 unformat_qos_source (unformat_input_t * input, va_list * args)
11887 int *qs = va_arg (*args, int *);
11889 if (unformat (input, "ip"))
11890 *qs = QOS_SOURCE_IP;
11891 else if (unformat (input, "mpls"))
11892 *qs = QOS_SOURCE_MPLS;
11893 else if (unformat (input, "ext"))
11894 *qs = QOS_SOURCE_EXT;
11895 else if (unformat (input, "vlan"))
11896 *qs = QOS_SOURCE_VLAN;
11905 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11907 u8 **matchp = va_arg (*args, u8 **);
11908 u32 skip_n_vectors = va_arg (*args, u32);
11909 u32 match_n_vectors = va_arg (*args, u32);
11916 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11918 if (unformat (input, "hex %U", unformat_hex_string, &match))
11920 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11922 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11924 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11938 if (match || l2 || l3 || l4)
11940 if (l2 || l3 || l4)
11942 /* "Win a free Ethernet header in every packet" */
11944 vec_validate_aligned (l2, 13, sizeof (u32x4));
11948 vec_append_aligned (match, l3, sizeof (u32x4));
11953 vec_append_aligned (match, l4, sizeof (u32x4));
11958 /* Make sure the vector is big enough even if key is all 0's */
11959 vec_validate_aligned
11960 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11963 /* Set size, include skipped vectors */
11964 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11975 api_classify_add_del_session (vat_main_t * vam)
11977 unformat_input_t *i = vam->input;
11978 vl_api_classify_add_del_session_t *mp;
11980 u32 table_index = ~0;
11981 u32 hit_next_index = ~0;
11982 u32 opaque_index = ~0;
11985 u32 skip_n_vectors = 0;
11986 u32 match_n_vectors = 0;
11992 * Warning: you have to supply skip_n and match_n
11993 * because the API client cant simply look at the classify
11997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11999 if (unformat (i, "del"))
12001 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12004 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12007 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12010 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12012 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12014 else if (unformat (i, "opaque-index %d", &opaque_index))
12016 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12018 else if (unformat (i, "match_n %d", &match_n_vectors))
12020 else if (unformat (i, "match %U", api_unformat_classify_match,
12021 &match, skip_n_vectors, match_n_vectors))
12023 else if (unformat (i, "advance %d", &advance))
12025 else if (unformat (i, "table-index %d", &table_index))
12027 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12029 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12031 else if (unformat (i, "action %d", &action))
12033 else if (unformat (i, "metadata %d", &metadata))
12039 if (table_index == ~0)
12041 errmsg ("Table index required");
12045 if (is_add && match == 0)
12047 errmsg ("Match value required");
12051 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12053 mp->is_add = is_add;
12054 mp->table_index = ntohl (table_index);
12055 mp->hit_next_index = ntohl (hit_next_index);
12056 mp->opaque_index = ntohl (opaque_index);
12057 mp->advance = ntohl (advance);
12058 mp->action = action;
12059 mp->metadata = ntohl (metadata);
12060 clib_memcpy (mp->match, match, vec_len (match));
12069 api_classify_set_interface_ip_table (vat_main_t * vam)
12071 unformat_input_t *i = vam->input;
12072 vl_api_classify_set_interface_ip_table_t *mp;
12074 int sw_if_index_set;
12075 u32 table_index = ~0;
12079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12082 sw_if_index_set = 1;
12083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12084 sw_if_index_set = 1;
12085 else if (unformat (i, "table %d", &table_index))
12089 clib_warning ("parse error '%U'", format_unformat_error, i);
12094 if (sw_if_index_set == 0)
12096 errmsg ("missing interface name or sw_if_index");
12101 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12103 mp->sw_if_index = ntohl (sw_if_index);
12104 mp->table_index = ntohl (table_index);
12105 mp->is_ipv6 = is_ipv6;
12113 api_classify_set_interface_l2_tables (vat_main_t * vam)
12115 unformat_input_t *i = vam->input;
12116 vl_api_classify_set_interface_l2_tables_t *mp;
12118 int sw_if_index_set;
12119 u32 ip4_table_index = ~0;
12120 u32 ip6_table_index = ~0;
12121 u32 other_table_index = ~0;
12125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12127 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12128 sw_if_index_set = 1;
12129 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12130 sw_if_index_set = 1;
12131 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12133 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12135 else if (unformat (i, "other-table %d", &other_table_index))
12137 else if (unformat (i, "is-input %d", &is_input))
12141 clib_warning ("parse error '%U'", format_unformat_error, i);
12146 if (sw_if_index_set == 0)
12148 errmsg ("missing interface name or sw_if_index");
12153 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12155 mp->sw_if_index = ntohl (sw_if_index);
12156 mp->ip4_table_index = ntohl (ip4_table_index);
12157 mp->ip6_table_index = ntohl (ip6_table_index);
12158 mp->other_table_index = ntohl (other_table_index);
12159 mp->is_input = (u8) is_input;
12167 api_set_ipfix_exporter (vat_main_t * vam)
12169 unformat_input_t *i = vam->input;
12170 vl_api_set_ipfix_exporter_t *mp;
12171 ip4_address_t collector_address;
12172 u8 collector_address_set = 0;
12173 u32 collector_port = ~0;
12174 ip4_address_t src_address;
12175 u8 src_address_set = 0;
12178 u32 template_interval = ~0;
12179 u8 udp_checksum = 0;
12182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12184 if (unformat (i, "collector_address %U", unformat_ip4_address,
12185 &collector_address))
12186 collector_address_set = 1;
12187 else if (unformat (i, "collector_port %d", &collector_port))
12189 else if (unformat (i, "src_address %U", unformat_ip4_address,
12191 src_address_set = 1;
12192 else if (unformat (i, "vrf_id %d", &vrf_id))
12194 else if (unformat (i, "path_mtu %d", &path_mtu))
12196 else if (unformat (i, "template_interval %d", &template_interval))
12198 else if (unformat (i, "udp_checksum"))
12204 if (collector_address_set == 0)
12206 errmsg ("collector_address required");
12210 if (src_address_set == 0)
12212 errmsg ("src_address required");
12216 M (SET_IPFIX_EXPORTER, mp);
12218 memcpy (mp->collector_address, collector_address.data,
12219 sizeof (collector_address.data));
12220 mp->collector_port = htons ((u16) collector_port);
12221 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12222 mp->vrf_id = htonl (vrf_id);
12223 mp->path_mtu = htonl (path_mtu);
12224 mp->template_interval = htonl (template_interval);
12225 mp->udp_checksum = udp_checksum;
12233 api_set_ipfix_classify_stream (vat_main_t * vam)
12235 unformat_input_t *i = vam->input;
12236 vl_api_set_ipfix_classify_stream_t *mp;
12238 u32 src_port = UDP_DST_PORT_ipfix;
12241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12243 if (unformat (i, "domain %d", &domain_id))
12245 else if (unformat (i, "src_port %d", &src_port))
12249 errmsg ("unknown input `%U'", format_unformat_error, i);
12254 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12256 mp->domain_id = htonl (domain_id);
12257 mp->src_port = htons ((u16) src_port);
12265 api_ipfix_classify_table_add_del (vat_main_t * vam)
12267 unformat_input_t *i = vam->input;
12268 vl_api_ipfix_classify_table_add_del_t *mp;
12270 u32 classify_table_index = ~0;
12272 u8 transport_protocol = 255;
12275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12277 if (unformat (i, "add"))
12279 else if (unformat (i, "del"))
12281 else if (unformat (i, "table %d", &classify_table_index))
12283 else if (unformat (i, "ip4"))
12285 else if (unformat (i, "ip6"))
12287 else if (unformat (i, "tcp"))
12288 transport_protocol = 6;
12289 else if (unformat (i, "udp"))
12290 transport_protocol = 17;
12293 errmsg ("unknown input `%U'", format_unformat_error, i);
12300 errmsg ("expecting: add|del");
12303 if (classify_table_index == ~0)
12305 errmsg ("classifier table not specified");
12308 if (ip_version == 0)
12310 errmsg ("IP version not specified");
12314 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12316 mp->is_add = is_add;
12317 mp->table_id = htonl (classify_table_index);
12318 mp->ip_version = ip_version;
12319 mp->transport_protocol = transport_protocol;
12327 api_get_node_index (vat_main_t * vam)
12329 unformat_input_t *i = vam->input;
12330 vl_api_get_node_index_t *mp;
12334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12336 if (unformat (i, "node %s", &name))
12343 errmsg ("node name required");
12346 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12348 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12352 M (GET_NODE_INDEX, mp);
12353 clib_memcpy (mp->node_name, name, vec_len (name));
12362 api_get_next_index (vat_main_t * vam)
12364 unformat_input_t *i = vam->input;
12365 vl_api_get_next_index_t *mp;
12366 u8 *node_name = 0, *next_node_name = 0;
12369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12371 if (unformat (i, "node-name %s", &node_name))
12373 else if (unformat (i, "next-node-name %s", &next_node_name))
12377 if (node_name == 0)
12379 errmsg ("node name required");
12382 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12384 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12388 if (next_node_name == 0)
12390 errmsg ("next node name required");
12393 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12395 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12399 M (GET_NEXT_INDEX, mp);
12400 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12401 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12402 vec_free (node_name);
12403 vec_free (next_node_name);
12411 api_add_node_next (vat_main_t * vam)
12413 unformat_input_t *i = vam->input;
12414 vl_api_add_node_next_t *mp;
12419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12421 if (unformat (i, "node %s", &name))
12423 else if (unformat (i, "next %s", &next))
12430 errmsg ("node name required");
12433 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12435 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12440 errmsg ("next node required");
12443 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12445 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12449 M (ADD_NODE_NEXT, mp);
12450 clib_memcpy (mp->node_name, name, vec_len (name));
12451 clib_memcpy (mp->next_name, next, vec_len (next));
12461 api_l2tpv3_create_tunnel (vat_main_t * vam)
12463 unformat_input_t *i = vam->input;
12464 ip6_address_t client_address, our_address;
12465 int client_address_set = 0;
12466 int our_address_set = 0;
12467 u32 local_session_id = 0;
12468 u32 remote_session_id = 0;
12469 u64 local_cookie = 0;
12470 u64 remote_cookie = 0;
12471 u8 l2_sublayer_present = 0;
12472 vl_api_l2tpv3_create_tunnel_t *mp;
12475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12477 if (unformat (i, "client_address %U", unformat_ip6_address,
12479 client_address_set = 1;
12480 else if (unformat (i, "our_address %U", unformat_ip6_address,
12482 our_address_set = 1;
12483 else if (unformat (i, "local_session_id %d", &local_session_id))
12485 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12487 else if (unformat (i, "local_cookie %lld", &local_cookie))
12489 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12491 else if (unformat (i, "l2-sublayer-present"))
12492 l2_sublayer_present = 1;
12497 if (client_address_set == 0)
12499 errmsg ("client_address required");
12503 if (our_address_set == 0)
12505 errmsg ("our_address required");
12509 M (L2TPV3_CREATE_TUNNEL, mp);
12511 clib_memcpy (mp->client_address, client_address.as_u8,
12512 sizeof (mp->client_address));
12514 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12516 mp->local_session_id = ntohl (local_session_id);
12517 mp->remote_session_id = ntohl (remote_session_id);
12518 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12519 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12520 mp->l2_sublayer_present = l2_sublayer_present;
12529 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12531 unformat_input_t *i = vam->input;
12533 u8 sw_if_index_set = 0;
12534 u64 new_local_cookie = 0;
12535 u64 new_remote_cookie = 0;
12536 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12542 sw_if_index_set = 1;
12543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12544 sw_if_index_set = 1;
12545 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12547 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12553 if (sw_if_index_set == 0)
12555 errmsg ("missing interface name or sw_if_index");
12559 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12561 mp->sw_if_index = ntohl (sw_if_index);
12562 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12563 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12571 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12573 unformat_input_t *i = vam->input;
12574 vl_api_l2tpv3_interface_enable_disable_t *mp;
12576 u8 sw_if_index_set = 0;
12577 u8 enable_disable = 1;
12580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12583 sw_if_index_set = 1;
12584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12585 sw_if_index_set = 1;
12586 else if (unformat (i, "enable"))
12587 enable_disable = 1;
12588 else if (unformat (i, "disable"))
12589 enable_disable = 0;
12594 if (sw_if_index_set == 0)
12596 errmsg ("missing interface name or sw_if_index");
12600 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12602 mp->sw_if_index = ntohl (sw_if_index);
12603 mp->enable_disable = enable_disable;
12611 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12613 unformat_input_t *i = vam->input;
12614 vl_api_l2tpv3_set_lookup_key_t *mp;
12618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12620 if (unformat (i, "lookup_v6_src"))
12621 key = L2T_LOOKUP_SRC_ADDRESS;
12622 else if (unformat (i, "lookup_v6_dst"))
12623 key = L2T_LOOKUP_DST_ADDRESS;
12624 else if (unformat (i, "lookup_session_id"))
12625 key = L2T_LOOKUP_SESSION_ID;
12630 if (key == (u8) ~ 0)
12632 errmsg ("l2tp session lookup key unset");
12636 M (L2TPV3_SET_LOOKUP_KEY, mp);
12645 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12646 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12648 vat_main_t *vam = &vat_main;
12650 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12651 format_ip6_address, mp->our_address,
12652 format_ip6_address, mp->client_address,
12653 clib_net_to_host_u32 (mp->sw_if_index));
12656 " local cookies %016llx %016llx remote cookie %016llx",
12657 clib_net_to_host_u64 (mp->local_cookie[0]),
12658 clib_net_to_host_u64 (mp->local_cookie[1]),
12659 clib_net_to_host_u64 (mp->remote_cookie));
12661 print (vam->ofp, " local session-id %d remote session-id %d",
12662 clib_net_to_host_u32 (mp->local_session_id),
12663 clib_net_to_host_u32 (mp->remote_session_id));
12665 print (vam->ofp, " l2 specific sublayer %s\n",
12666 mp->l2_sublayer_present ? "preset" : "absent");
12670 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12671 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12673 vat_main_t *vam = &vat_main;
12674 vat_json_node_t *node = NULL;
12675 struct in6_addr addr;
12677 if (VAT_JSON_ARRAY != vam->json_tree.type)
12679 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12680 vat_json_init_array (&vam->json_tree);
12682 node = vat_json_array_add (&vam->json_tree);
12684 vat_json_init_object (node);
12686 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12687 vat_json_object_add_ip6 (node, "our_address", addr);
12688 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12689 vat_json_object_add_ip6 (node, "client_address", addr);
12691 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12692 vat_json_init_array (lc);
12693 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12694 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12695 vat_json_object_add_uint (node, "remote_cookie",
12696 clib_net_to_host_u64 (mp->remote_cookie));
12698 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12699 vat_json_object_add_uint (node, "local_session_id",
12700 clib_net_to_host_u32 (mp->local_session_id));
12701 vat_json_object_add_uint (node, "remote_session_id",
12702 clib_net_to_host_u32 (mp->remote_session_id));
12703 vat_json_object_add_string_copy (node, "l2_sublayer",
12704 mp->l2_sublayer_present ? (u8 *) "present"
12705 : (u8 *) "absent");
12709 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12711 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12712 vl_api_control_ping_t *mp_ping;
12715 /* Get list of l2tpv3-tunnel interfaces */
12716 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12719 /* Use a control ping for synchronization */
12720 MPING (CONTROL_PING, mp_ping);
12728 static void vl_api_sw_interface_tap_details_t_handler
12729 (vl_api_sw_interface_tap_details_t * mp)
12731 vat_main_t *vam = &vat_main;
12733 print (vam->ofp, "%-16s %d",
12734 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12737 static void vl_api_sw_interface_tap_details_t_handler_json
12738 (vl_api_sw_interface_tap_details_t * mp)
12740 vat_main_t *vam = &vat_main;
12741 vat_json_node_t *node = NULL;
12743 if (VAT_JSON_ARRAY != vam->json_tree.type)
12745 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12746 vat_json_init_array (&vam->json_tree);
12748 node = vat_json_array_add (&vam->json_tree);
12750 vat_json_init_object (node);
12751 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12752 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12756 api_sw_interface_tap_dump (vat_main_t * vam)
12758 vl_api_sw_interface_tap_dump_t *mp;
12759 vl_api_control_ping_t *mp_ping;
12762 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12763 /* Get list of tap interfaces */
12764 M (SW_INTERFACE_TAP_DUMP, mp);
12767 /* Use a control ping for synchronization */
12768 MPING (CONTROL_PING, mp_ping);
12775 static void vl_api_sw_interface_tap_v2_details_t_handler
12776 (vl_api_sw_interface_tap_v2_details_t * mp)
12778 vat_main_t *vam = &vat_main;
12780 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12781 mp->host_ip4_prefix_len);
12782 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12783 mp->host_ip6_prefix_len);
12786 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12787 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12788 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12789 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12790 mp->host_bridge, ip4, ip6);
12796 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12797 (vl_api_sw_interface_tap_v2_details_t * mp)
12799 vat_main_t *vam = &vat_main;
12800 vat_json_node_t *node = NULL;
12802 if (VAT_JSON_ARRAY != vam->json_tree.type)
12804 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12805 vat_json_init_array (&vam->json_tree);
12807 node = vat_json_array_add (&vam->json_tree);
12809 vat_json_init_object (node);
12810 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12811 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12812 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12813 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12814 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12815 vat_json_object_add_string_copy (node, "host_mac_addr",
12816 format (0, "%U", format_ethernet_address,
12817 &mp->host_mac_addr));
12818 vat_json_object_add_string_copy (node, "host_namespace",
12819 mp->host_namespace);
12820 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12821 vat_json_object_add_string_copy (node, "host_ip4_addr",
12822 format (0, "%U/%d", format_ip4_address,
12824 mp->host_ip4_prefix_len));
12825 vat_json_object_add_string_copy (node, "host_ip6_addr",
12826 format (0, "%U/%d", format_ip6_address,
12828 mp->host_ip6_prefix_len));
12833 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12835 vl_api_sw_interface_tap_v2_dump_t *mp;
12836 vl_api_control_ping_t *mp_ping;
12840 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12841 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12842 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12845 /* Get list of tap interfaces */
12846 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12849 /* Use a control ping for synchronization */
12850 MPING (CONTROL_PING, mp_ping);
12857 static uword unformat_vxlan_decap_next
12858 (unformat_input_t * input, va_list * args)
12860 u32 *result = va_arg (*args, u32 *);
12863 if (unformat (input, "l2"))
12864 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12865 else if (unformat (input, "%d", &tmp))
12873 api_vxlan_add_del_tunnel (vat_main_t * vam)
12875 unformat_input_t *line_input = vam->input;
12876 vl_api_vxlan_add_del_tunnel_t *mp;
12877 ip46_address_t src, dst;
12879 u8 ipv4_set = 0, ipv6_set = 0;
12884 u32 mcast_sw_if_index = ~0;
12885 u32 encap_vrf_id = 0;
12886 u32 decap_next_index = ~0;
12890 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12891 memset (&src, 0, sizeof src);
12892 memset (&dst, 0, sizeof dst);
12894 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12896 if (unformat (line_input, "del"))
12898 else if (unformat (line_input, "instance %d", &instance))
12901 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12907 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12913 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12919 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12924 else if (unformat (line_input, "group %U %U",
12925 unformat_ip4_address, &dst.ip4,
12926 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12928 grp_set = dst_set = 1;
12931 else if (unformat (line_input, "group %U",
12932 unformat_ip4_address, &dst.ip4))
12934 grp_set = dst_set = 1;
12937 else if (unformat (line_input, "group %U %U",
12938 unformat_ip6_address, &dst.ip6,
12939 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12941 grp_set = dst_set = 1;
12944 else if (unformat (line_input, "group %U",
12945 unformat_ip6_address, &dst.ip6))
12947 grp_set = dst_set = 1;
12951 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12953 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12955 else if (unformat (line_input, "decap-next %U",
12956 unformat_vxlan_decap_next, &decap_next_index))
12958 else if (unformat (line_input, "vni %d", &vni))
12962 errmsg ("parse error '%U'", format_unformat_error, line_input);
12969 errmsg ("tunnel src address not specified");
12974 errmsg ("tunnel dst address not specified");
12978 if (grp_set && !ip46_address_is_multicast (&dst))
12980 errmsg ("tunnel group address not multicast");
12983 if (grp_set && mcast_sw_if_index == ~0)
12985 errmsg ("tunnel nonexistent multicast device");
12988 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12990 errmsg ("tunnel dst address must be unicast");
12995 if (ipv4_set && ipv6_set)
12997 errmsg ("both IPv4 and IPv6 addresses specified");
13001 if ((vni == 0) || (vni >> 24))
13003 errmsg ("vni not specified or out of range");
13007 M (VXLAN_ADD_DEL_TUNNEL, mp);
13011 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13012 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13016 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13017 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13020 mp->instance = htonl (instance);
13021 mp->encap_vrf_id = ntohl (encap_vrf_id);
13022 mp->decap_next_index = ntohl (decap_next_index);
13023 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13024 mp->vni = ntohl (vni);
13025 mp->is_add = is_add;
13026 mp->is_ipv6 = ipv6_set;
13033 static void vl_api_vxlan_tunnel_details_t_handler
13034 (vl_api_vxlan_tunnel_details_t * mp)
13036 vat_main_t *vam = &vat_main;
13037 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13038 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13040 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13041 ntohl (mp->sw_if_index),
13042 ntohl (mp->instance),
13043 format_ip46_address, &src, IP46_TYPE_ANY,
13044 format_ip46_address, &dst, IP46_TYPE_ANY,
13045 ntohl (mp->encap_vrf_id),
13046 ntohl (mp->decap_next_index), ntohl (mp->vni),
13047 ntohl (mp->mcast_sw_if_index));
13050 static void vl_api_vxlan_tunnel_details_t_handler_json
13051 (vl_api_vxlan_tunnel_details_t * mp)
13053 vat_main_t *vam = &vat_main;
13054 vat_json_node_t *node = NULL;
13056 if (VAT_JSON_ARRAY != vam->json_tree.type)
13058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13059 vat_json_init_array (&vam->json_tree);
13061 node = vat_json_array_add (&vam->json_tree);
13063 vat_json_init_object (node);
13064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13066 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13070 struct in6_addr ip6;
13072 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13073 vat_json_object_add_ip6 (node, "src_address", ip6);
13074 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13075 vat_json_object_add_ip6 (node, "dst_address", ip6);
13079 struct in_addr ip4;
13081 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13082 vat_json_object_add_ip4 (node, "src_address", ip4);
13083 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13084 vat_json_object_add_ip4 (node, "dst_address", ip4);
13086 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13087 vat_json_object_add_uint (node, "decap_next_index",
13088 ntohl (mp->decap_next_index));
13089 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13090 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13091 vat_json_object_add_uint (node, "mcast_sw_if_index",
13092 ntohl (mp->mcast_sw_if_index));
13096 api_vxlan_tunnel_dump (vat_main_t * vam)
13098 unformat_input_t *i = vam->input;
13099 vl_api_vxlan_tunnel_dump_t *mp;
13100 vl_api_control_ping_t *mp_ping;
13102 u8 sw_if_index_set = 0;
13105 /* Parse args required to build the message */
13106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13108 if (unformat (i, "sw_if_index %d", &sw_if_index))
13109 sw_if_index_set = 1;
13114 if (sw_if_index_set == 0)
13119 if (!vam->json_output)
13121 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13122 "sw_if_index", "instance", "src_address", "dst_address",
13123 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13126 /* Get list of vxlan-tunnel interfaces */
13127 M (VXLAN_TUNNEL_DUMP, mp);
13129 mp->sw_if_index = htonl (sw_if_index);
13133 /* Use a control ping for synchronization */
13134 MPING (CONTROL_PING, mp_ping);
13141 static uword unformat_geneve_decap_next
13142 (unformat_input_t * input, va_list * args)
13144 u32 *result = va_arg (*args, u32 *);
13147 if (unformat (input, "l2"))
13148 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13149 else if (unformat (input, "%d", &tmp))
13157 api_geneve_add_del_tunnel (vat_main_t * vam)
13159 unformat_input_t *line_input = vam->input;
13160 vl_api_geneve_add_del_tunnel_t *mp;
13161 ip46_address_t src, dst;
13163 u8 ipv4_set = 0, ipv6_set = 0;
13167 u32 mcast_sw_if_index = ~0;
13168 u32 encap_vrf_id = 0;
13169 u32 decap_next_index = ~0;
13173 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13174 memset (&src, 0, sizeof src);
13175 memset (&dst, 0, sizeof dst);
13177 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13179 if (unformat (line_input, "del"))
13182 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13188 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13194 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13200 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13205 else if (unformat (line_input, "group %U %U",
13206 unformat_ip4_address, &dst.ip4,
13207 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13209 grp_set = dst_set = 1;
13212 else if (unformat (line_input, "group %U",
13213 unformat_ip4_address, &dst.ip4))
13215 grp_set = dst_set = 1;
13218 else if (unformat (line_input, "group %U %U",
13219 unformat_ip6_address, &dst.ip6,
13220 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13222 grp_set = dst_set = 1;
13225 else if (unformat (line_input, "group %U",
13226 unformat_ip6_address, &dst.ip6))
13228 grp_set = dst_set = 1;
13232 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13234 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13236 else if (unformat (line_input, "decap-next %U",
13237 unformat_geneve_decap_next, &decap_next_index))
13239 else if (unformat (line_input, "vni %d", &vni))
13243 errmsg ("parse error '%U'", format_unformat_error, line_input);
13250 errmsg ("tunnel src address not specified");
13255 errmsg ("tunnel dst address not specified");
13259 if (grp_set && !ip46_address_is_multicast (&dst))
13261 errmsg ("tunnel group address not multicast");
13264 if (grp_set && mcast_sw_if_index == ~0)
13266 errmsg ("tunnel nonexistent multicast device");
13269 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13271 errmsg ("tunnel dst address must be unicast");
13276 if (ipv4_set && ipv6_set)
13278 errmsg ("both IPv4 and IPv6 addresses specified");
13282 if ((vni == 0) || (vni >> 24))
13284 errmsg ("vni not specified or out of range");
13288 M (GENEVE_ADD_DEL_TUNNEL, mp);
13292 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13293 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13297 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13298 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13300 mp->encap_vrf_id = ntohl (encap_vrf_id);
13301 mp->decap_next_index = ntohl (decap_next_index);
13302 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13303 mp->vni = ntohl (vni);
13304 mp->is_add = is_add;
13305 mp->is_ipv6 = ipv6_set;
13312 static void vl_api_geneve_tunnel_details_t_handler
13313 (vl_api_geneve_tunnel_details_t * mp)
13315 vat_main_t *vam = &vat_main;
13316 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13317 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13319 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13320 ntohl (mp->sw_if_index),
13321 format_ip46_address, &src, IP46_TYPE_ANY,
13322 format_ip46_address, &dst, IP46_TYPE_ANY,
13323 ntohl (mp->encap_vrf_id),
13324 ntohl (mp->decap_next_index), ntohl (mp->vni),
13325 ntohl (mp->mcast_sw_if_index));
13328 static void vl_api_geneve_tunnel_details_t_handler_json
13329 (vl_api_geneve_tunnel_details_t * mp)
13331 vat_main_t *vam = &vat_main;
13332 vat_json_node_t *node = NULL;
13334 if (VAT_JSON_ARRAY != vam->json_tree.type)
13336 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13337 vat_json_init_array (&vam->json_tree);
13339 node = vat_json_array_add (&vam->json_tree);
13341 vat_json_init_object (node);
13342 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13345 struct in6_addr ip6;
13347 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13348 vat_json_object_add_ip6 (node, "src_address", ip6);
13349 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13350 vat_json_object_add_ip6 (node, "dst_address", ip6);
13354 struct in_addr ip4;
13356 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13357 vat_json_object_add_ip4 (node, "src_address", ip4);
13358 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13359 vat_json_object_add_ip4 (node, "dst_address", ip4);
13361 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13362 vat_json_object_add_uint (node, "decap_next_index",
13363 ntohl (mp->decap_next_index));
13364 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13365 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13366 vat_json_object_add_uint (node, "mcast_sw_if_index",
13367 ntohl (mp->mcast_sw_if_index));
13371 api_geneve_tunnel_dump (vat_main_t * vam)
13373 unformat_input_t *i = vam->input;
13374 vl_api_geneve_tunnel_dump_t *mp;
13375 vl_api_control_ping_t *mp_ping;
13377 u8 sw_if_index_set = 0;
13380 /* Parse args required to build the message */
13381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13383 if (unformat (i, "sw_if_index %d", &sw_if_index))
13384 sw_if_index_set = 1;
13389 if (sw_if_index_set == 0)
13394 if (!vam->json_output)
13396 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13397 "sw_if_index", "local_address", "remote_address",
13398 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13401 /* Get list of geneve-tunnel interfaces */
13402 M (GENEVE_TUNNEL_DUMP, mp);
13404 mp->sw_if_index = htonl (sw_if_index);
13408 /* Use a control ping for synchronization */
13409 M (CONTROL_PING, mp_ping);
13417 api_gre_add_del_tunnel (vat_main_t * vam)
13419 unformat_input_t *line_input = vam->input;
13420 vl_api_gre_add_del_tunnel_t *mp;
13421 ip4_address_t src4, dst4;
13422 ip6_address_t src6, dst6;
13426 u8 t_type = GRE_TUNNEL_TYPE_L3;
13429 u32 outer_fib_id = 0;
13430 u32 session_id = 0;
13434 memset (&src4, 0, sizeof src4);
13435 memset (&dst4, 0, sizeof dst4);
13436 memset (&src6, 0, sizeof src6);
13437 memset (&dst6, 0, sizeof dst6);
13439 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13441 if (unformat (line_input, "del"))
13443 else if (unformat (line_input, "instance %d", &instance))
13445 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13450 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13455 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13460 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13465 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13467 else if (unformat (line_input, "teb"))
13468 t_type = GRE_TUNNEL_TYPE_TEB;
13469 else if (unformat (line_input, "erspan %d", &session_id))
13470 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13473 errmsg ("parse error '%U'", format_unformat_error, line_input);
13480 errmsg ("tunnel src address not specified");
13485 errmsg ("tunnel dst address not specified");
13488 if (ipv4_set && ipv6_set)
13490 errmsg ("both IPv4 and IPv6 addresses specified");
13495 M (GRE_ADD_DEL_TUNNEL, mp);
13499 clib_memcpy (&mp->src_address, &src4, 4);
13500 clib_memcpy (&mp->dst_address, &dst4, 4);
13504 clib_memcpy (&mp->src_address, &src6, 16);
13505 clib_memcpy (&mp->dst_address, &dst6, 16);
13507 mp->instance = htonl (instance);
13508 mp->outer_fib_id = htonl (outer_fib_id);
13509 mp->is_add = is_add;
13510 mp->session_id = htons ((u16) session_id);
13511 mp->tunnel_type = t_type;
13512 mp->is_ipv6 = ipv6_set;
13519 static void vl_api_gre_tunnel_details_t_handler
13520 (vl_api_gre_tunnel_details_t * mp)
13522 vat_main_t *vam = &vat_main;
13523 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13524 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13526 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13527 ntohl (mp->sw_if_index),
13528 ntohl (mp->instance),
13529 format_ip46_address, &src, IP46_TYPE_ANY,
13530 format_ip46_address, &dst, IP46_TYPE_ANY,
13531 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13534 static void vl_api_gre_tunnel_details_t_handler_json
13535 (vl_api_gre_tunnel_details_t * mp)
13537 vat_main_t *vam = &vat_main;
13538 vat_json_node_t *node = NULL;
13539 struct in_addr ip4;
13540 struct in6_addr ip6;
13542 if (VAT_JSON_ARRAY != vam->json_tree.type)
13544 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13545 vat_json_init_array (&vam->json_tree);
13547 node = vat_json_array_add (&vam->json_tree);
13549 vat_json_init_object (node);
13550 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13551 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13554 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13555 vat_json_object_add_ip4 (node, "src_address", ip4);
13556 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13557 vat_json_object_add_ip4 (node, "dst_address", ip4);
13561 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13562 vat_json_object_add_ip6 (node, "src_address", ip6);
13563 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13564 vat_json_object_add_ip6 (node, "dst_address", ip6);
13566 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13567 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13568 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13569 vat_json_object_add_uint (node, "session_id", mp->session_id);
13573 api_gre_tunnel_dump (vat_main_t * vam)
13575 unformat_input_t *i = vam->input;
13576 vl_api_gre_tunnel_dump_t *mp;
13577 vl_api_control_ping_t *mp_ping;
13579 u8 sw_if_index_set = 0;
13582 /* Parse args required to build the message */
13583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13585 if (unformat (i, "sw_if_index %d", &sw_if_index))
13586 sw_if_index_set = 1;
13591 if (sw_if_index_set == 0)
13596 if (!vam->json_output)
13598 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13599 "sw_if_index", "instance", "src_address", "dst_address",
13600 "tunnel_type", "outer_fib_id", "session_id");
13603 /* Get list of gre-tunnel interfaces */
13604 M (GRE_TUNNEL_DUMP, mp);
13606 mp->sw_if_index = htonl (sw_if_index);
13610 /* Use a control ping for synchronization */
13611 MPING (CONTROL_PING, mp_ping);
13619 api_l2_fib_clear_table (vat_main_t * vam)
13621 // unformat_input_t * i = vam->input;
13622 vl_api_l2_fib_clear_table_t *mp;
13625 M (L2_FIB_CLEAR_TABLE, mp);
13633 api_l2_interface_efp_filter (vat_main_t * vam)
13635 unformat_input_t *i = vam->input;
13636 vl_api_l2_interface_efp_filter_t *mp;
13639 u8 sw_if_index_set = 0;
13642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13645 sw_if_index_set = 1;
13646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13647 sw_if_index_set = 1;
13648 else if (unformat (i, "enable"))
13650 else if (unformat (i, "disable"))
13654 clib_warning ("parse error '%U'", format_unformat_error, i);
13659 if (sw_if_index_set == 0)
13661 errmsg ("missing sw_if_index");
13665 M (L2_INTERFACE_EFP_FILTER, mp);
13667 mp->sw_if_index = ntohl (sw_if_index);
13668 mp->enable_disable = enable;
13675 #define foreach_vtr_op \
13676 _("disable", L2_VTR_DISABLED) \
13677 _("push-1", L2_VTR_PUSH_1) \
13678 _("push-2", L2_VTR_PUSH_2) \
13679 _("pop-1", L2_VTR_POP_1) \
13680 _("pop-2", L2_VTR_POP_2) \
13681 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13682 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13683 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13684 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13687 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13689 unformat_input_t *i = vam->input;
13690 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13692 u8 sw_if_index_set = 0;
13695 u32 push_dot1q = 1;
13700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13703 sw_if_index_set = 1;
13704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13705 sw_if_index_set = 1;
13706 else if (unformat (i, "vtr_op %d", &vtr_op))
13708 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13711 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13713 else if (unformat (i, "tag1 %d", &tag1))
13715 else if (unformat (i, "tag2 %d", &tag2))
13719 clib_warning ("parse error '%U'", format_unformat_error, i);
13724 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13726 errmsg ("missing vtr operation or sw_if_index");
13730 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13731 mp->sw_if_index = ntohl (sw_if_index);
13732 mp->vtr_op = ntohl (vtr_op);
13733 mp->push_dot1q = ntohl (push_dot1q);
13734 mp->tag1 = ntohl (tag1);
13735 mp->tag2 = ntohl (tag2);
13743 api_create_vhost_user_if (vat_main_t * vam)
13745 unformat_input_t *i = vam->input;
13746 vl_api_create_vhost_user_if_t *mp;
13749 u8 file_name_set = 0;
13750 u32 custom_dev_instance = ~0;
13752 u8 use_custom_mac = 0;
13756 /* Shut up coverity */
13757 memset (hwaddr, 0, sizeof (hwaddr));
13759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13761 if (unformat (i, "socket %s", &file_name))
13765 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13767 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13768 use_custom_mac = 1;
13769 else if (unformat (i, "server"))
13771 else if (unformat (i, "tag %s", &tag))
13777 if (file_name_set == 0)
13779 errmsg ("missing socket file name");
13783 if (vec_len (file_name) > 255)
13785 errmsg ("socket file name too long");
13788 vec_add1 (file_name, 0);
13790 M (CREATE_VHOST_USER_IF, mp);
13792 mp->is_server = is_server;
13793 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13794 vec_free (file_name);
13795 if (custom_dev_instance != ~0)
13798 mp->custom_dev_instance = ntohl (custom_dev_instance);
13800 mp->use_custom_mac = use_custom_mac;
13801 clib_memcpy (mp->mac_address, hwaddr, 6);
13803 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13812 api_modify_vhost_user_if (vat_main_t * vam)
13814 unformat_input_t *i = vam->input;
13815 vl_api_modify_vhost_user_if_t *mp;
13818 u8 file_name_set = 0;
13819 u32 custom_dev_instance = ~0;
13820 u8 sw_if_index_set = 0;
13821 u32 sw_if_index = (u32) ~ 0;
13824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13826 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13827 sw_if_index_set = 1;
13828 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13829 sw_if_index_set = 1;
13830 else if (unformat (i, "socket %s", &file_name))
13834 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13836 else if (unformat (i, "server"))
13842 if (sw_if_index_set == 0)
13844 errmsg ("missing sw_if_index or interface name");
13848 if (file_name_set == 0)
13850 errmsg ("missing socket file name");
13854 if (vec_len (file_name) > 255)
13856 errmsg ("socket file name too long");
13859 vec_add1 (file_name, 0);
13861 M (MODIFY_VHOST_USER_IF, mp);
13863 mp->sw_if_index = ntohl (sw_if_index);
13864 mp->is_server = is_server;
13865 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13866 vec_free (file_name);
13867 if (custom_dev_instance != ~0)
13870 mp->custom_dev_instance = ntohl (custom_dev_instance);
13879 api_delete_vhost_user_if (vat_main_t * vam)
13881 unformat_input_t *i = vam->input;
13882 vl_api_delete_vhost_user_if_t *mp;
13883 u32 sw_if_index = ~0;
13884 u8 sw_if_index_set = 0;
13887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13889 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13890 sw_if_index_set = 1;
13891 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13892 sw_if_index_set = 1;
13897 if (sw_if_index_set == 0)
13899 errmsg ("missing sw_if_index or interface name");
13904 M (DELETE_VHOST_USER_IF, mp);
13906 mp->sw_if_index = ntohl (sw_if_index);
13913 static void vl_api_sw_interface_vhost_user_details_t_handler
13914 (vl_api_sw_interface_vhost_user_details_t * mp)
13916 vat_main_t *vam = &vat_main;
13918 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13919 (char *) mp->interface_name,
13920 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13921 clib_net_to_host_u64 (mp->features), mp->is_server,
13922 ntohl (mp->num_regions), (char *) mp->sock_filename);
13923 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13926 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13927 (vl_api_sw_interface_vhost_user_details_t * mp)
13929 vat_main_t *vam = &vat_main;
13930 vat_json_node_t *node = NULL;
13932 if (VAT_JSON_ARRAY != vam->json_tree.type)
13934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13935 vat_json_init_array (&vam->json_tree);
13937 node = vat_json_array_add (&vam->json_tree);
13939 vat_json_init_object (node);
13940 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13941 vat_json_object_add_string_copy (node, "interface_name",
13942 mp->interface_name);
13943 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13944 ntohl (mp->virtio_net_hdr_sz));
13945 vat_json_object_add_uint (node, "features",
13946 clib_net_to_host_u64 (mp->features));
13947 vat_json_object_add_uint (node, "is_server", mp->is_server);
13948 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13949 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13950 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13954 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13956 vl_api_sw_interface_vhost_user_dump_t *mp;
13957 vl_api_control_ping_t *mp_ping;
13960 "Interface name idx hdr_sz features server regions filename");
13962 /* Get list of vhost-user interfaces */
13963 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13966 /* Use a control ping for synchronization */
13967 MPING (CONTROL_PING, mp_ping);
13975 api_show_version (vat_main_t * vam)
13977 vl_api_show_version_t *mp;
13980 M (SHOW_VERSION, mp);
13989 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13991 unformat_input_t *line_input = vam->input;
13992 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13993 ip4_address_t local4, remote4;
13994 ip6_address_t local6, remote6;
13996 u8 ipv4_set = 0, ipv6_set = 0;
14000 u32 mcast_sw_if_index = ~0;
14001 u32 encap_vrf_id = 0;
14002 u32 decap_vrf_id = 0;
14008 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14009 memset (&local4, 0, sizeof local4);
14010 memset (&remote4, 0, sizeof remote4);
14011 memset (&local6, 0, sizeof local6);
14012 memset (&remote6, 0, sizeof remote6);
14014 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14016 if (unformat (line_input, "del"))
14018 else if (unformat (line_input, "local %U",
14019 unformat_ip4_address, &local4))
14024 else if (unformat (line_input, "remote %U",
14025 unformat_ip4_address, &remote4))
14030 else if (unformat (line_input, "local %U",
14031 unformat_ip6_address, &local6))
14036 else if (unformat (line_input, "remote %U",
14037 unformat_ip6_address, &remote6))
14042 else if (unformat (line_input, "group %U %U",
14043 unformat_ip4_address, &remote4,
14044 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14046 grp_set = remote_set = 1;
14049 else if (unformat (line_input, "group %U",
14050 unformat_ip4_address, &remote4))
14052 grp_set = remote_set = 1;
14055 else if (unformat (line_input, "group %U %U",
14056 unformat_ip6_address, &remote6,
14057 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14059 grp_set = remote_set = 1;
14062 else if (unformat (line_input, "group %U",
14063 unformat_ip6_address, &remote6))
14065 grp_set = remote_set = 1;
14069 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14071 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14073 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14075 else if (unformat (line_input, "vni %d", &vni))
14077 else if (unformat (line_input, "next-ip4"))
14079 else if (unformat (line_input, "next-ip6"))
14081 else if (unformat (line_input, "next-ethernet"))
14083 else if (unformat (line_input, "next-nsh"))
14087 errmsg ("parse error '%U'", format_unformat_error, line_input);
14092 if (local_set == 0)
14094 errmsg ("tunnel local address not specified");
14097 if (remote_set == 0)
14099 errmsg ("tunnel remote address not specified");
14102 if (grp_set && mcast_sw_if_index == ~0)
14104 errmsg ("tunnel nonexistent multicast device");
14107 if (ipv4_set && ipv6_set)
14109 errmsg ("both IPv4 and IPv6 addresses specified");
14115 errmsg ("vni not specified");
14119 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14124 clib_memcpy (&mp->local, &local6, sizeof (local6));
14125 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14129 clib_memcpy (&mp->local, &local4, sizeof (local4));
14130 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14133 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14134 mp->encap_vrf_id = ntohl (encap_vrf_id);
14135 mp->decap_vrf_id = ntohl (decap_vrf_id);
14136 mp->protocol = protocol;
14137 mp->vni = ntohl (vni);
14138 mp->is_add = is_add;
14139 mp->is_ipv6 = ipv6_set;
14146 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14147 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14149 vat_main_t *vam = &vat_main;
14150 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14151 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14153 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14154 ntohl (mp->sw_if_index),
14155 format_ip46_address, &local, IP46_TYPE_ANY,
14156 format_ip46_address, &remote, IP46_TYPE_ANY,
14157 ntohl (mp->vni), mp->protocol,
14158 ntohl (mp->mcast_sw_if_index),
14159 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14163 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14164 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14166 vat_main_t *vam = &vat_main;
14167 vat_json_node_t *node = NULL;
14168 struct in_addr ip4;
14169 struct in6_addr ip6;
14171 if (VAT_JSON_ARRAY != vam->json_tree.type)
14173 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14174 vat_json_init_array (&vam->json_tree);
14176 node = vat_json_array_add (&vam->json_tree);
14178 vat_json_init_object (node);
14179 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14182 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14183 vat_json_object_add_ip6 (node, "local", ip6);
14184 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14185 vat_json_object_add_ip6 (node, "remote", ip6);
14189 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14190 vat_json_object_add_ip4 (node, "local", ip4);
14191 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14192 vat_json_object_add_ip4 (node, "remote", ip4);
14194 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14195 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14196 vat_json_object_add_uint (node, "mcast_sw_if_index",
14197 ntohl (mp->mcast_sw_if_index));
14198 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14199 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14200 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14204 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14206 unformat_input_t *i = vam->input;
14207 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14208 vl_api_control_ping_t *mp_ping;
14210 u8 sw_if_index_set = 0;
14213 /* Parse args required to build the message */
14214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14216 if (unformat (i, "sw_if_index %d", &sw_if_index))
14217 sw_if_index_set = 1;
14222 if (sw_if_index_set == 0)
14227 if (!vam->json_output)
14229 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14230 "sw_if_index", "local", "remote", "vni",
14231 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14234 /* Get list of vxlan-tunnel interfaces */
14235 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14237 mp->sw_if_index = htonl (sw_if_index);
14241 /* Use a control ping for synchronization */
14242 MPING (CONTROL_PING, mp_ping);
14249 static void vl_api_l2_fib_table_details_t_handler
14250 (vl_api_l2_fib_table_details_t * mp)
14252 vat_main_t *vam = &vat_main;
14254 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14256 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14257 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14261 static void vl_api_l2_fib_table_details_t_handler_json
14262 (vl_api_l2_fib_table_details_t * mp)
14264 vat_main_t *vam = &vat_main;
14265 vat_json_node_t *node = NULL;
14267 if (VAT_JSON_ARRAY != vam->json_tree.type)
14269 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14270 vat_json_init_array (&vam->json_tree);
14272 node = vat_json_array_add (&vam->json_tree);
14274 vat_json_init_object (node);
14275 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14276 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14277 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14278 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14279 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14280 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14284 api_l2_fib_table_dump (vat_main_t * vam)
14286 unformat_input_t *i = vam->input;
14287 vl_api_l2_fib_table_dump_t *mp;
14288 vl_api_control_ping_t *mp_ping;
14293 /* Parse args required to build the message */
14294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14296 if (unformat (i, "bd_id %d", &bd_id))
14302 if (bd_id_set == 0)
14304 errmsg ("missing bridge domain");
14308 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14310 /* Get list of l2 fib entries */
14311 M (L2_FIB_TABLE_DUMP, mp);
14313 mp->bd_id = ntohl (bd_id);
14316 /* Use a control ping for synchronization */
14317 MPING (CONTROL_PING, mp_ping);
14326 api_interface_name_renumber (vat_main_t * vam)
14328 unformat_input_t *line_input = vam->input;
14329 vl_api_interface_name_renumber_t *mp;
14330 u32 sw_if_index = ~0;
14331 u32 new_show_dev_instance = ~0;
14334 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14336 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14339 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14341 else if (unformat (line_input, "new_show_dev_instance %d",
14342 &new_show_dev_instance))
14348 if (sw_if_index == ~0)
14350 errmsg ("missing interface name or sw_if_index");
14354 if (new_show_dev_instance == ~0)
14356 errmsg ("missing new_show_dev_instance");
14360 M (INTERFACE_NAME_RENUMBER, mp);
14362 mp->sw_if_index = ntohl (sw_if_index);
14363 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14371 api_ip_probe_neighbor (vat_main_t * vam)
14373 unformat_input_t *i = vam->input;
14374 vl_api_ip_probe_neighbor_t *mp;
14382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14388 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14390 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14401 errmsg ("missing interface");
14407 errmsg ("missing addresses");
14411 M (IP_PROBE_NEIGHBOR, mp);
14413 mp->sw_if_index = ntohl (sw_if_index);
14414 mp->is_ipv6 = is_ipv6;
14415 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14423 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14425 unformat_input_t *i = vam->input;
14426 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14427 u8 mode = IP_SCAN_V46_NEIGHBORS;
14428 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14433 if (unformat (i, "ip4"))
14434 mode = IP_SCAN_V4_NEIGHBORS;
14435 else if (unformat (i, "ip6"))
14436 mode = IP_SCAN_V6_NEIGHBORS;
14437 if (unformat (i, "both"))
14438 mode = IP_SCAN_V46_NEIGHBORS;
14439 else if (unformat (i, "disable"))
14440 mode = IP_SCAN_DISABLED;
14441 else if (unformat (i, "interval %d", &interval))
14443 else if (unformat (i, "max-time %d", &time))
14445 else if (unformat (i, "max-update %d", &update))
14447 else if (unformat (i, "delay %d", &delay))
14449 else if (unformat (i, "stale %d", &stale))
14455 if (interval > 255)
14457 errmsg ("interval cannot exceed 255 minutes.");
14462 errmsg ("max-time cannot exceed 255 usec.");
14467 errmsg ("max-update cannot exceed 255.");
14472 errmsg ("delay cannot exceed 255 msec.");
14477 errmsg ("stale cannot exceed 255 minutes.");
14481 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14483 mp->scan_interval = interval;
14484 mp->max_proc_time = time;
14485 mp->max_update = update;
14486 mp->scan_int_delay = delay;
14487 mp->stale_threshold = stale;
14495 api_want_ip4_arp_events (vat_main_t * vam)
14497 unformat_input_t *line_input = vam->input;
14498 vl_api_want_ip4_arp_events_t *mp;
14499 ip4_address_t address;
14500 int address_set = 0;
14501 u32 enable_disable = 1;
14504 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14506 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14508 else if (unformat (line_input, "del"))
14509 enable_disable = 0;
14514 if (address_set == 0)
14516 errmsg ("missing addresses");
14520 M (WANT_IP4_ARP_EVENTS, mp);
14521 mp->enable_disable = enable_disable;
14522 mp->pid = htonl (getpid ());
14523 mp->address = address.as_u32;
14531 api_want_ip6_nd_events (vat_main_t * vam)
14533 unformat_input_t *line_input = vam->input;
14534 vl_api_want_ip6_nd_events_t *mp;
14535 ip6_address_t address;
14536 int address_set = 0;
14537 u32 enable_disable = 1;
14540 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14542 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14544 else if (unformat (line_input, "del"))
14545 enable_disable = 0;
14550 if (address_set == 0)
14552 errmsg ("missing addresses");
14556 M (WANT_IP6_ND_EVENTS, mp);
14557 mp->enable_disable = enable_disable;
14558 mp->pid = htonl (getpid ());
14559 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14567 api_want_l2_macs_events (vat_main_t * vam)
14569 unformat_input_t *line_input = vam->input;
14570 vl_api_want_l2_macs_events_t *mp;
14571 u8 enable_disable = 1;
14572 u32 scan_delay = 0;
14573 u32 max_macs_in_event = 0;
14574 u32 learn_limit = 0;
14577 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14579 if (unformat (line_input, "learn-limit %d", &learn_limit))
14581 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14583 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14585 else if (unformat (line_input, "disable"))
14586 enable_disable = 0;
14591 M (WANT_L2_MACS_EVENTS, mp);
14592 mp->enable_disable = enable_disable;
14593 mp->pid = htonl (getpid ());
14594 mp->learn_limit = htonl (learn_limit);
14595 mp->scan_delay = (u8) scan_delay;
14596 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14603 api_input_acl_set_interface (vat_main_t * vam)
14605 unformat_input_t *i = vam->input;
14606 vl_api_input_acl_set_interface_t *mp;
14608 int sw_if_index_set;
14609 u32 ip4_table_index = ~0;
14610 u32 ip6_table_index = ~0;
14611 u32 l2_table_index = ~0;
14615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14617 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14618 sw_if_index_set = 1;
14619 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14620 sw_if_index_set = 1;
14621 else if (unformat (i, "del"))
14623 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14625 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14627 else if (unformat (i, "l2-table %d", &l2_table_index))
14631 clib_warning ("parse error '%U'", format_unformat_error, i);
14636 if (sw_if_index_set == 0)
14638 errmsg ("missing interface name or sw_if_index");
14642 M (INPUT_ACL_SET_INTERFACE, mp);
14644 mp->sw_if_index = ntohl (sw_if_index);
14645 mp->ip4_table_index = ntohl (ip4_table_index);
14646 mp->ip6_table_index = ntohl (ip6_table_index);
14647 mp->l2_table_index = ntohl (l2_table_index);
14648 mp->is_add = is_add;
14656 api_output_acl_set_interface (vat_main_t * vam)
14658 unformat_input_t *i = vam->input;
14659 vl_api_output_acl_set_interface_t *mp;
14661 int sw_if_index_set;
14662 u32 ip4_table_index = ~0;
14663 u32 ip6_table_index = ~0;
14664 u32 l2_table_index = ~0;
14668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14670 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14671 sw_if_index_set = 1;
14672 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14673 sw_if_index_set = 1;
14674 else if (unformat (i, "del"))
14676 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14678 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14680 else if (unformat (i, "l2-table %d", &l2_table_index))
14684 clib_warning ("parse error '%U'", format_unformat_error, i);
14689 if (sw_if_index_set == 0)
14691 errmsg ("missing interface name or sw_if_index");
14695 M (OUTPUT_ACL_SET_INTERFACE, mp);
14697 mp->sw_if_index = ntohl (sw_if_index);
14698 mp->ip4_table_index = ntohl (ip4_table_index);
14699 mp->ip6_table_index = ntohl (ip6_table_index);
14700 mp->l2_table_index = ntohl (l2_table_index);
14701 mp->is_add = is_add;
14709 api_ip_address_dump (vat_main_t * vam)
14711 unformat_input_t *i = vam->input;
14712 vl_api_ip_address_dump_t *mp;
14713 vl_api_control_ping_t *mp_ping;
14714 u32 sw_if_index = ~0;
14715 u8 sw_if_index_set = 0;
14720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14722 if (unformat (i, "sw_if_index %d", &sw_if_index))
14723 sw_if_index_set = 1;
14725 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14726 sw_if_index_set = 1;
14727 else if (unformat (i, "ipv4"))
14729 else if (unformat (i, "ipv6"))
14735 if (ipv4_set && ipv6_set)
14737 errmsg ("ipv4 and ipv6 flags cannot be both set");
14741 if ((!ipv4_set) && (!ipv6_set))
14743 errmsg ("no ipv4 nor ipv6 flag set");
14747 if (sw_if_index_set == 0)
14749 errmsg ("missing interface name or sw_if_index");
14753 vam->current_sw_if_index = sw_if_index;
14754 vam->is_ipv6 = ipv6_set;
14756 M (IP_ADDRESS_DUMP, mp);
14757 mp->sw_if_index = ntohl (sw_if_index);
14758 mp->is_ipv6 = ipv6_set;
14761 /* Use a control ping for synchronization */
14762 MPING (CONTROL_PING, mp_ping);
14770 api_ip_dump (vat_main_t * vam)
14772 vl_api_ip_dump_t *mp;
14773 vl_api_control_ping_t *mp_ping;
14774 unformat_input_t *in = vam->input;
14781 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14783 if (unformat (in, "ipv4"))
14785 else if (unformat (in, "ipv6"))
14791 if (ipv4_set && ipv6_set)
14793 errmsg ("ipv4 and ipv6 flags cannot be both set");
14797 if ((!ipv4_set) && (!ipv6_set))
14799 errmsg ("no ipv4 nor ipv6 flag set");
14803 is_ipv6 = ipv6_set;
14804 vam->is_ipv6 = is_ipv6;
14806 /* free old data */
14807 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14809 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14811 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14814 mp->is_ipv6 = ipv6_set;
14817 /* Use a control ping for synchronization */
14818 MPING (CONTROL_PING, mp_ping);
14826 api_ipsec_spd_add_del (vat_main_t * vam)
14828 unformat_input_t *i = vam->input;
14829 vl_api_ipsec_spd_add_del_t *mp;
14834 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14836 if (unformat (i, "spd_id %d", &spd_id))
14838 else if (unformat (i, "del"))
14842 clib_warning ("parse error '%U'", format_unformat_error, i);
14848 errmsg ("spd_id must be set");
14852 M (IPSEC_SPD_ADD_DEL, mp);
14854 mp->spd_id = ntohl (spd_id);
14855 mp->is_add = is_add;
14863 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14865 unformat_input_t *i = vam->input;
14866 vl_api_ipsec_interface_add_del_spd_t *mp;
14868 u8 sw_if_index_set = 0;
14869 u32 spd_id = (u32) ~ 0;
14873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14875 if (unformat (i, "del"))
14877 else if (unformat (i, "spd_id %d", &spd_id))
14880 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14881 sw_if_index_set = 1;
14882 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14883 sw_if_index_set = 1;
14886 clib_warning ("parse error '%U'", format_unformat_error, i);
14892 if (spd_id == (u32) ~ 0)
14894 errmsg ("spd_id must be set");
14898 if (sw_if_index_set == 0)
14900 errmsg ("missing interface name or sw_if_index");
14904 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14906 mp->spd_id = ntohl (spd_id);
14907 mp->sw_if_index = ntohl (sw_if_index);
14908 mp->is_add = is_add;
14916 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14918 unformat_input_t *i = vam->input;
14919 vl_api_ipsec_spd_add_del_entry_t *mp;
14920 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14921 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14923 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14924 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14925 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14926 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14929 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14930 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14931 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14932 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14933 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14934 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14938 if (unformat (i, "del"))
14940 if (unformat (i, "outbound"))
14942 if (unformat (i, "inbound"))
14944 else if (unformat (i, "spd_id %d", &spd_id))
14946 else if (unformat (i, "sa_id %d", &sa_id))
14948 else if (unformat (i, "priority %d", &priority))
14950 else if (unformat (i, "protocol %d", &protocol))
14952 else if (unformat (i, "lport_start %d", &lport_start))
14954 else if (unformat (i, "lport_stop %d", &lport_stop))
14956 else if (unformat (i, "rport_start %d", &rport_start))
14958 else if (unformat (i, "rport_stop %d", &rport_stop))
14962 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14968 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14975 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14981 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14988 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14994 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15001 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15007 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15013 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15015 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15017 clib_warning ("unsupported action: 'resolve'");
15023 clib_warning ("parse error '%U'", format_unformat_error, i);
15029 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15031 mp->spd_id = ntohl (spd_id);
15032 mp->priority = ntohl (priority);
15033 mp->is_outbound = is_outbound;
15035 mp->is_ipv6 = is_ipv6;
15036 if (is_ipv6 || is_ip_any)
15038 clib_memcpy (mp->remote_address_start, &raddr6_start,
15039 sizeof (ip6_address_t));
15040 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15041 sizeof (ip6_address_t));
15042 clib_memcpy (mp->local_address_start, &laddr6_start,
15043 sizeof (ip6_address_t));
15044 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15045 sizeof (ip6_address_t));
15049 clib_memcpy (mp->remote_address_start, &raddr4_start,
15050 sizeof (ip4_address_t));
15051 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15052 sizeof (ip4_address_t));
15053 clib_memcpy (mp->local_address_start, &laddr4_start,
15054 sizeof (ip4_address_t));
15055 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15056 sizeof (ip4_address_t));
15058 mp->protocol = (u8) protocol;
15059 mp->local_port_start = ntohs ((u16) lport_start);
15060 mp->local_port_stop = ntohs ((u16) lport_stop);
15061 mp->remote_port_start = ntohs ((u16) rport_start);
15062 mp->remote_port_stop = ntohs ((u16) rport_stop);
15063 mp->policy = (u8) policy;
15064 mp->sa_id = ntohl (sa_id);
15065 mp->is_add = is_add;
15066 mp->is_ip_any = is_ip_any;
15073 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15075 unformat_input_t *i = vam->input;
15076 vl_api_ipsec_sad_add_del_entry_t *mp;
15077 u32 sad_id = 0, spi = 0;
15078 u8 *ck = 0, *ik = 0;
15081 u8 protocol = IPSEC_PROTOCOL_AH;
15082 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15083 u32 crypto_alg = 0, integ_alg = 0;
15084 ip4_address_t tun_src4;
15085 ip4_address_t tun_dst4;
15086 ip6_address_t tun_src6;
15087 ip6_address_t tun_dst6;
15090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15092 if (unformat (i, "del"))
15094 else if (unformat (i, "sad_id %d", &sad_id))
15096 else if (unformat (i, "spi %d", &spi))
15098 else if (unformat (i, "esp"))
15099 protocol = IPSEC_PROTOCOL_ESP;
15100 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15103 is_tunnel_ipv6 = 0;
15105 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15108 is_tunnel_ipv6 = 0;
15110 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15113 is_tunnel_ipv6 = 1;
15115 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15118 is_tunnel_ipv6 = 1;
15122 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15124 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15125 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15127 clib_warning ("unsupported crypto-alg: '%U'",
15128 format_ipsec_crypto_alg, crypto_alg);
15132 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15136 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15138 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15139 integ_alg >= IPSEC_INTEG_N_ALG)
15141 clib_warning ("unsupported integ-alg: '%U'",
15142 format_ipsec_integ_alg, integ_alg);
15146 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15150 clib_warning ("parse error '%U'", format_unformat_error, i);
15156 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15158 mp->sad_id = ntohl (sad_id);
15159 mp->is_add = is_add;
15160 mp->protocol = protocol;
15161 mp->spi = ntohl (spi);
15162 mp->is_tunnel = is_tunnel;
15163 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15164 mp->crypto_algorithm = crypto_alg;
15165 mp->integrity_algorithm = integ_alg;
15166 mp->crypto_key_length = vec_len (ck);
15167 mp->integrity_key_length = vec_len (ik);
15169 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15170 mp->crypto_key_length = sizeof (mp->crypto_key);
15172 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15173 mp->integrity_key_length = sizeof (mp->integrity_key);
15176 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15178 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15182 if (is_tunnel_ipv6)
15184 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15185 sizeof (ip6_address_t));
15186 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15187 sizeof (ip6_address_t));
15191 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15192 sizeof (ip4_address_t));
15193 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15194 sizeof (ip4_address_t));
15204 api_ipsec_sa_set_key (vat_main_t * vam)
15206 unformat_input_t *i = vam->input;
15207 vl_api_ipsec_sa_set_key_t *mp;
15209 u8 *ck = 0, *ik = 0;
15212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15214 if (unformat (i, "sa_id %d", &sa_id))
15216 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15218 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15222 clib_warning ("parse error '%U'", format_unformat_error, i);
15227 M (IPSEC_SA_SET_KEY, mp);
15229 mp->sa_id = ntohl (sa_id);
15230 mp->crypto_key_length = vec_len (ck);
15231 mp->integrity_key_length = vec_len (ik);
15233 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15234 mp->crypto_key_length = sizeof (mp->crypto_key);
15236 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15237 mp->integrity_key_length = sizeof (mp->integrity_key);
15240 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15242 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15250 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15252 unformat_input_t *i = vam->input;
15253 vl_api_ipsec_tunnel_if_add_del_t *mp;
15254 u32 local_spi = 0, remote_spi = 0;
15255 u32 crypto_alg = 0, integ_alg = 0;
15256 u8 *lck = NULL, *rck = NULL;
15257 u8 *lik = NULL, *rik = NULL;
15258 ip4_address_t local_ip = { {0} };
15259 ip4_address_t remote_ip = { {0} };
15262 u8 anti_replay = 0;
15267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15269 if (unformat (i, "del"))
15271 else if (unformat (i, "esn"))
15273 else if (unformat (i, "anti_replay"))
15275 else if (unformat (i, "local_spi %d", &local_spi))
15277 else if (unformat (i, "remote_spi %d", &remote_spi))
15279 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15281 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15283 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15286 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15288 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15290 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15294 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15296 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15297 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15299 errmsg ("unsupported crypto-alg: '%U'\n",
15300 format_ipsec_crypto_alg, crypto_alg);
15306 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15308 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15309 integ_alg >= IPSEC_INTEG_N_ALG)
15311 errmsg ("unsupported integ-alg: '%U'\n",
15312 format_ipsec_integ_alg, integ_alg);
15316 else if (unformat (i, "instance %u", &instance))
15320 errmsg ("parse error '%U'\n", format_unformat_error, i);
15325 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15327 mp->is_add = is_add;
15329 mp->anti_replay = anti_replay;
15331 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15332 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15334 mp->local_spi = htonl (local_spi);
15335 mp->remote_spi = htonl (remote_spi);
15336 mp->crypto_alg = (u8) crypto_alg;
15338 mp->local_crypto_key_len = 0;
15341 mp->local_crypto_key_len = vec_len (lck);
15342 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15343 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15344 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15347 mp->remote_crypto_key_len = 0;
15350 mp->remote_crypto_key_len = vec_len (rck);
15351 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15352 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15353 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15356 mp->integ_alg = (u8) integ_alg;
15358 mp->local_integ_key_len = 0;
15361 mp->local_integ_key_len = vec_len (lik);
15362 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15363 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15364 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15367 mp->remote_integ_key_len = 0;
15370 mp->remote_integ_key_len = vec_len (rik);
15371 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15372 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15373 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15378 mp->renumber = renumber;
15379 mp->show_instance = ntohl (instance);
15388 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15390 vat_main_t *vam = &vat_main;
15392 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15393 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15394 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15395 "tunnel_src_addr %U tunnel_dst_addr %U "
15396 "salt %u seq_outbound %lu last_seq_inbound %lu "
15397 "replay_window %lu total_data_size %lu\n",
15398 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15400 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15401 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15402 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15403 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15404 mp->tunnel_src_addr,
15405 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15406 mp->tunnel_dst_addr,
15408 clib_net_to_host_u64 (mp->seq_outbound),
15409 clib_net_to_host_u64 (mp->last_seq_inbound),
15410 clib_net_to_host_u64 (mp->replay_window),
15411 clib_net_to_host_u64 (mp->total_data_size));
15414 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15415 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15417 static void vl_api_ipsec_sa_details_t_handler_json
15418 (vl_api_ipsec_sa_details_t * mp)
15420 vat_main_t *vam = &vat_main;
15421 vat_json_node_t *node = NULL;
15422 struct in_addr src_ip4, dst_ip4;
15423 struct in6_addr src_ip6, dst_ip6;
15425 if (VAT_JSON_ARRAY != vam->json_tree.type)
15427 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15428 vat_json_init_array (&vam->json_tree);
15430 node = vat_json_array_add (&vam->json_tree);
15432 vat_json_init_object (node);
15433 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15434 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15435 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15436 vat_json_object_add_uint (node, "proto", mp->protocol);
15437 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15438 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15439 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15440 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15441 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15442 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15443 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15444 mp->crypto_key_len);
15445 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15446 mp->integ_key_len);
15447 if (mp->is_tunnel_ip6)
15449 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15450 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15451 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15452 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15456 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15457 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15458 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15459 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15461 vat_json_object_add_uint (node, "replay_window",
15462 clib_net_to_host_u64 (mp->replay_window));
15463 vat_json_object_add_uint (node, "total_data_size",
15464 clib_net_to_host_u64 (mp->total_data_size));
15469 api_ipsec_sa_dump (vat_main_t * vam)
15471 unformat_input_t *i = vam->input;
15472 vl_api_ipsec_sa_dump_t *mp;
15473 vl_api_control_ping_t *mp_ping;
15477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15479 if (unformat (i, "sa_id %d", &sa_id))
15483 clib_warning ("parse error '%U'", format_unformat_error, i);
15488 M (IPSEC_SA_DUMP, mp);
15490 mp->sa_id = ntohl (sa_id);
15494 /* Use a control ping for synchronization */
15495 M (CONTROL_PING, mp_ping);
15503 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15505 unformat_input_t *i = vam->input;
15506 vl_api_ipsec_tunnel_if_set_key_t *mp;
15507 u32 sw_if_index = ~0;
15508 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15518 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15519 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15521 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15522 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15523 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15524 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15526 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15527 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15528 else if (unformat (i, "%U", unformat_hex_string, &key))
15532 clib_warning ("parse error '%U'", format_unformat_error, i);
15537 if (sw_if_index == ~0)
15539 errmsg ("interface must be specified");
15543 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15545 errmsg ("key type must be specified");
15551 errmsg ("algorithm must be specified");
15555 if (vec_len (key) == 0)
15557 errmsg ("key must be specified");
15561 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15563 mp->sw_if_index = htonl (sw_if_index);
15565 mp->key_type = key_type;
15566 mp->key_len = vec_len (key);
15567 clib_memcpy (mp->key, key, vec_len (key));
15576 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15578 unformat_input_t *i = vam->input;
15579 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15580 u32 sw_if_index = ~0;
15582 u8 is_outbound = (u8) ~ 0;
15585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15589 else if (unformat (i, "sa_id %d", &sa_id))
15591 else if (unformat (i, "outbound"))
15593 else if (unformat (i, "inbound"))
15597 clib_warning ("parse error '%U'", format_unformat_error, i);
15602 if (sw_if_index == ~0)
15604 errmsg ("interface must be specified");
15610 errmsg ("SA ID must be specified");
15614 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15616 mp->sw_if_index = htonl (sw_if_index);
15617 mp->sa_id = htonl (sa_id);
15618 mp->is_outbound = is_outbound;
15627 api_ikev2_profile_add_del (vat_main_t * vam)
15629 unformat_input_t *i = vam->input;
15630 vl_api_ikev2_profile_add_del_t *mp;
15635 const char *valid_chars = "a-zA-Z0-9_";
15637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15639 if (unformat (i, "del"))
15641 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15642 vec_add1 (name, 0);
15645 errmsg ("parse error '%U'", format_unformat_error, i);
15650 if (!vec_len (name))
15652 errmsg ("profile name must be specified");
15656 if (vec_len (name) > 64)
15658 errmsg ("profile name too long");
15662 M (IKEV2_PROFILE_ADD_DEL, mp);
15664 clib_memcpy (mp->name, name, vec_len (name));
15665 mp->is_add = is_add;
15674 api_ikev2_profile_set_auth (vat_main_t * vam)
15676 unformat_input_t *i = vam->input;
15677 vl_api_ikev2_profile_set_auth_t *mp;
15680 u32 auth_method = 0;
15684 const char *valid_chars = "a-zA-Z0-9_";
15686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15688 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15689 vec_add1 (name, 0);
15690 else if (unformat (i, "auth_method %U",
15691 unformat_ikev2_auth_method, &auth_method))
15693 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15695 else if (unformat (i, "auth_data %v", &data))
15699 errmsg ("parse error '%U'", format_unformat_error, i);
15704 if (!vec_len (name))
15706 errmsg ("profile name must be specified");
15710 if (vec_len (name) > 64)
15712 errmsg ("profile name too long");
15716 if (!vec_len (data))
15718 errmsg ("auth_data must be specified");
15724 errmsg ("auth_method must be specified");
15728 M (IKEV2_PROFILE_SET_AUTH, mp);
15730 mp->is_hex = is_hex;
15731 mp->auth_method = (u8) auth_method;
15732 mp->data_len = vec_len (data);
15733 clib_memcpy (mp->name, name, vec_len (name));
15734 clib_memcpy (mp->data, data, vec_len (data));
15744 api_ikev2_profile_set_id (vat_main_t * vam)
15746 unformat_input_t *i = vam->input;
15747 vl_api_ikev2_profile_set_id_t *mp;
15755 const char *valid_chars = "a-zA-Z0-9_";
15757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15759 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15760 vec_add1 (name, 0);
15761 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15763 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15765 data = vec_new (u8, 4);
15766 clib_memcpy (data, ip4.as_u8, 4);
15768 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15770 else if (unformat (i, "id_data %v", &data))
15772 else if (unformat (i, "local"))
15774 else if (unformat (i, "remote"))
15778 errmsg ("parse error '%U'", format_unformat_error, i);
15783 if (!vec_len (name))
15785 errmsg ("profile name must be specified");
15789 if (vec_len (name) > 64)
15791 errmsg ("profile name too long");
15795 if (!vec_len (data))
15797 errmsg ("id_data must be specified");
15803 errmsg ("id_type must be specified");
15807 M (IKEV2_PROFILE_SET_ID, mp);
15809 mp->is_local = is_local;
15810 mp->id_type = (u8) id_type;
15811 mp->data_len = vec_len (data);
15812 clib_memcpy (mp->name, name, vec_len (name));
15813 clib_memcpy (mp->data, data, vec_len (data));
15823 api_ikev2_profile_set_ts (vat_main_t * vam)
15825 unformat_input_t *i = vam->input;
15826 vl_api_ikev2_profile_set_ts_t *mp;
15829 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15830 ip4_address_t start_addr, end_addr;
15832 const char *valid_chars = "a-zA-Z0-9_";
15835 start_addr.as_u32 = 0;
15836 end_addr.as_u32 = (u32) ~ 0;
15838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15840 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15841 vec_add1 (name, 0);
15842 else if (unformat (i, "protocol %d", &proto))
15844 else if (unformat (i, "start_port %d", &start_port))
15846 else if (unformat (i, "end_port %d", &end_port))
15849 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15851 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15853 else if (unformat (i, "local"))
15855 else if (unformat (i, "remote"))
15859 errmsg ("parse error '%U'", format_unformat_error, i);
15864 if (!vec_len (name))
15866 errmsg ("profile name must be specified");
15870 if (vec_len (name) > 64)
15872 errmsg ("profile name too long");
15876 M (IKEV2_PROFILE_SET_TS, mp);
15878 mp->is_local = is_local;
15879 mp->proto = (u8) proto;
15880 mp->start_port = (u16) start_port;
15881 mp->end_port = (u16) end_port;
15882 mp->start_addr = start_addr.as_u32;
15883 mp->end_addr = end_addr.as_u32;
15884 clib_memcpy (mp->name, name, vec_len (name));
15893 api_ikev2_set_local_key (vat_main_t * vam)
15895 unformat_input_t *i = vam->input;
15896 vl_api_ikev2_set_local_key_t *mp;
15900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15902 if (unformat (i, "file %v", &file))
15903 vec_add1 (file, 0);
15906 errmsg ("parse error '%U'", format_unformat_error, i);
15911 if (!vec_len (file))
15913 errmsg ("RSA key file must be specified");
15917 if (vec_len (file) > 256)
15919 errmsg ("file name too long");
15923 M (IKEV2_SET_LOCAL_KEY, mp);
15925 clib_memcpy (mp->key_file, file, vec_len (file));
15934 api_ikev2_set_responder (vat_main_t * vam)
15936 unformat_input_t *i = vam->input;
15937 vl_api_ikev2_set_responder_t *mp;
15940 u32 sw_if_index = ~0;
15941 ip4_address_t address;
15943 const char *valid_chars = "a-zA-Z0-9_";
15945 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15948 (i, "%U interface %d address %U", unformat_token, valid_chars,
15949 &name, &sw_if_index, unformat_ip4_address, &address))
15950 vec_add1 (name, 0);
15953 errmsg ("parse error '%U'", format_unformat_error, i);
15958 if (!vec_len (name))
15960 errmsg ("profile name must be specified");
15964 if (vec_len (name) > 64)
15966 errmsg ("profile name too long");
15970 M (IKEV2_SET_RESPONDER, mp);
15972 clib_memcpy (mp->name, name, vec_len (name));
15975 mp->sw_if_index = sw_if_index;
15976 clib_memcpy (mp->address, &address, sizeof (address));
15984 api_ikev2_set_ike_transforms (vat_main_t * vam)
15986 unformat_input_t *i = vam->input;
15987 vl_api_ikev2_set_ike_transforms_t *mp;
15990 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15992 const char *valid_chars = "a-zA-Z0-9_";
15994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15996 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15997 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15998 vec_add1 (name, 0);
16001 errmsg ("parse error '%U'", format_unformat_error, i);
16006 if (!vec_len (name))
16008 errmsg ("profile name must be specified");
16012 if (vec_len (name) > 64)
16014 errmsg ("profile name too long");
16018 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16020 clib_memcpy (mp->name, name, vec_len (name));
16022 mp->crypto_alg = crypto_alg;
16023 mp->crypto_key_size = crypto_key_size;
16024 mp->integ_alg = integ_alg;
16025 mp->dh_group = dh_group;
16034 api_ikev2_set_esp_transforms (vat_main_t * vam)
16036 unformat_input_t *i = vam->input;
16037 vl_api_ikev2_set_esp_transforms_t *mp;
16040 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16042 const char *valid_chars = "a-zA-Z0-9_";
16044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16046 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16047 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16048 vec_add1 (name, 0);
16051 errmsg ("parse error '%U'", format_unformat_error, i);
16056 if (!vec_len (name))
16058 errmsg ("profile name must be specified");
16062 if (vec_len (name) > 64)
16064 errmsg ("profile name too long");
16068 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16070 clib_memcpy (mp->name, name, vec_len (name));
16072 mp->crypto_alg = crypto_alg;
16073 mp->crypto_key_size = crypto_key_size;
16074 mp->integ_alg = integ_alg;
16075 mp->dh_group = dh_group;
16083 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16085 unformat_input_t *i = vam->input;
16086 vl_api_ikev2_set_sa_lifetime_t *mp;
16089 u64 lifetime, lifetime_maxdata;
16090 u32 lifetime_jitter, handover;
16092 const char *valid_chars = "a-zA-Z0-9_";
16094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16096 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16097 &lifetime, &lifetime_jitter, &handover,
16098 &lifetime_maxdata))
16099 vec_add1 (name, 0);
16102 errmsg ("parse error '%U'", format_unformat_error, i);
16107 if (!vec_len (name))
16109 errmsg ("profile name must be specified");
16113 if (vec_len (name) > 64)
16115 errmsg ("profile name too long");
16119 M (IKEV2_SET_SA_LIFETIME, mp);
16121 clib_memcpy (mp->name, name, vec_len (name));
16123 mp->lifetime = lifetime;
16124 mp->lifetime_jitter = lifetime_jitter;
16125 mp->handover = handover;
16126 mp->lifetime_maxdata = lifetime_maxdata;
16134 api_ikev2_initiate_sa_init (vat_main_t * vam)
16136 unformat_input_t *i = vam->input;
16137 vl_api_ikev2_initiate_sa_init_t *mp;
16141 const char *valid_chars = "a-zA-Z0-9_";
16143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16145 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16146 vec_add1 (name, 0);
16149 errmsg ("parse error '%U'", format_unformat_error, i);
16154 if (!vec_len (name))
16156 errmsg ("profile name must be specified");
16160 if (vec_len (name) > 64)
16162 errmsg ("profile name too long");
16166 M (IKEV2_INITIATE_SA_INIT, mp);
16168 clib_memcpy (mp->name, name, vec_len (name));
16177 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16179 unformat_input_t *i = vam->input;
16180 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16185 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16187 if (unformat (i, "%lx", &ispi))
16191 errmsg ("parse error '%U'", format_unformat_error, i);
16196 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16206 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16208 unformat_input_t *i = vam->input;
16209 vl_api_ikev2_initiate_del_child_sa_t *mp;
16214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16216 if (unformat (i, "%x", &ispi))
16220 errmsg ("parse error '%U'", format_unformat_error, i);
16225 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16235 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16237 unformat_input_t *i = vam->input;
16238 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16245 if (unformat (i, "%x", &ispi))
16249 errmsg ("parse error '%U'", format_unformat_error, i);
16254 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16267 api_map_add_domain (vat_main_t * vam)
16269 unformat_input_t *i = vam->input;
16270 vl_api_map_add_domain_t *mp;
16272 ip4_address_t ip4_prefix;
16273 ip6_address_t ip6_prefix;
16274 ip6_address_t ip6_src;
16275 u32 num_m_args = 0;
16276 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16277 0, psid_length = 0;
16278 u8 is_translation = 0;
16280 u32 ip6_src_len = 128;
16283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16285 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16286 &ip4_prefix, &ip4_prefix_len))
16288 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16289 &ip6_prefix, &ip6_prefix_len))
16293 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16296 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16298 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16300 else if (unformat (i, "psid-offset %d", &psid_offset))
16302 else if (unformat (i, "psid-len %d", &psid_length))
16304 else if (unformat (i, "mtu %d", &mtu))
16306 else if (unformat (i, "map-t"))
16307 is_translation = 1;
16310 clib_warning ("parse error '%U'", format_unformat_error, i);
16315 if (num_m_args < 3)
16317 errmsg ("mandatory argument(s) missing");
16321 /* Construct the API message */
16322 M (MAP_ADD_DOMAIN, mp);
16324 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16325 mp->ip4_prefix_len = ip4_prefix_len;
16327 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16328 mp->ip6_prefix_len = ip6_prefix_len;
16330 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16331 mp->ip6_src_prefix_len = ip6_src_len;
16333 mp->ea_bits_len = ea_bits_len;
16334 mp->psid_offset = psid_offset;
16335 mp->psid_length = psid_length;
16336 mp->is_translation = is_translation;
16337 mp->mtu = htons (mtu);
16342 /* Wait for a reply, return good/bad news */
16348 api_map_del_domain (vat_main_t * vam)
16350 unformat_input_t *i = vam->input;
16351 vl_api_map_del_domain_t *mp;
16353 u32 num_m_args = 0;
16357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16359 if (unformat (i, "index %d", &index))
16363 clib_warning ("parse error '%U'", format_unformat_error, i);
16368 if (num_m_args != 1)
16370 errmsg ("mandatory argument(s) missing");
16374 /* Construct the API message */
16375 M (MAP_DEL_DOMAIN, mp);
16377 mp->index = ntohl (index);
16382 /* Wait for a reply, return good/bad news */
16388 api_map_add_del_rule (vat_main_t * vam)
16390 unformat_input_t *i = vam->input;
16391 vl_api_map_add_del_rule_t *mp;
16393 ip6_address_t ip6_dst;
16394 u32 num_m_args = 0, index, psid = 0;
16397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16399 if (unformat (i, "index %d", &index))
16401 else if (unformat (i, "psid %d", &psid))
16403 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16405 else if (unformat (i, "del"))
16411 clib_warning ("parse error '%U'", format_unformat_error, i);
16416 /* Construct the API message */
16417 M (MAP_ADD_DEL_RULE, mp);
16419 mp->index = ntohl (index);
16420 mp->is_add = is_add;
16421 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16422 mp->psid = ntohs (psid);
16427 /* Wait for a reply, return good/bad news */
16433 api_map_domain_dump (vat_main_t * vam)
16435 vl_api_map_domain_dump_t *mp;
16436 vl_api_control_ping_t *mp_ping;
16439 /* Construct the API message */
16440 M (MAP_DOMAIN_DUMP, mp);
16445 /* Use a control ping for synchronization */
16446 MPING (CONTROL_PING, mp_ping);
16454 api_map_rule_dump (vat_main_t * vam)
16456 unformat_input_t *i = vam->input;
16457 vl_api_map_rule_dump_t *mp;
16458 vl_api_control_ping_t *mp_ping;
16459 u32 domain_index = ~0;
16462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16464 if (unformat (i, "index %u", &domain_index))
16470 if (domain_index == ~0)
16472 clib_warning ("parse error: domain index expected");
16476 /* Construct the API message */
16477 M (MAP_RULE_DUMP, mp);
16479 mp->domain_index = htonl (domain_index);
16484 /* Use a control ping for synchronization */
16485 MPING (CONTROL_PING, mp_ping);
16492 static void vl_api_map_add_domain_reply_t_handler
16493 (vl_api_map_add_domain_reply_t * mp)
16495 vat_main_t *vam = &vat_main;
16496 i32 retval = ntohl (mp->retval);
16498 if (vam->async_mode)
16500 vam->async_errors += (retval < 0);
16504 vam->retval = retval;
16505 vam->result_ready = 1;
16509 static void vl_api_map_add_domain_reply_t_handler_json
16510 (vl_api_map_add_domain_reply_t * mp)
16512 vat_main_t *vam = &vat_main;
16513 vat_json_node_t node;
16515 vat_json_init_object (&node);
16516 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16517 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16519 vat_json_print (vam->ofp, &node);
16520 vat_json_free (&node);
16522 vam->retval = ntohl (mp->retval);
16523 vam->result_ready = 1;
16527 api_get_first_msg_id (vat_main_t * vam)
16529 vl_api_get_first_msg_id_t *mp;
16530 unformat_input_t *i = vam->input;
16535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16537 if (unformat (i, "client %s", &name))
16545 errmsg ("missing client name");
16548 vec_add1 (name, 0);
16550 if (vec_len (name) > 63)
16552 errmsg ("client name too long");
16556 M (GET_FIRST_MSG_ID, mp);
16557 clib_memcpy (mp->name, name, vec_len (name));
16564 api_cop_interface_enable_disable (vat_main_t * vam)
16566 unformat_input_t *line_input = vam->input;
16567 vl_api_cop_interface_enable_disable_t *mp;
16568 u32 sw_if_index = ~0;
16569 u8 enable_disable = 1;
16572 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16574 if (unformat (line_input, "disable"))
16575 enable_disable = 0;
16576 if (unformat (line_input, "enable"))
16577 enable_disable = 1;
16578 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16579 vam, &sw_if_index))
16581 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16587 if (sw_if_index == ~0)
16589 errmsg ("missing interface name or sw_if_index");
16593 /* Construct the API message */
16594 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16595 mp->sw_if_index = ntohl (sw_if_index);
16596 mp->enable_disable = enable_disable;
16600 /* Wait for the reply */
16606 api_cop_whitelist_enable_disable (vat_main_t * vam)
16608 unformat_input_t *line_input = vam->input;
16609 vl_api_cop_whitelist_enable_disable_t *mp;
16610 u32 sw_if_index = ~0;
16611 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16615 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16617 if (unformat (line_input, "ip4"))
16619 else if (unformat (line_input, "ip6"))
16621 else if (unformat (line_input, "default"))
16623 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16624 vam, &sw_if_index))
16626 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16628 else if (unformat (line_input, "fib-id %d", &fib_id))
16634 if (sw_if_index == ~0)
16636 errmsg ("missing interface name or sw_if_index");
16640 /* Construct the API message */
16641 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16642 mp->sw_if_index = ntohl (sw_if_index);
16643 mp->fib_id = ntohl (fib_id);
16646 mp->default_cop = default_cop;
16650 /* Wait for the reply */
16656 api_get_node_graph (vat_main_t * vam)
16658 vl_api_get_node_graph_t *mp;
16661 M (GET_NODE_GRAPH, mp);
16665 /* Wait for the reply */
16671 /** Used for parsing LISP eids */
16672 typedef CLIB_PACKED(struct{
16673 u8 addr[16]; /**< eid address */
16674 u32 len; /**< prefix length if IP */
16675 u8 type; /**< type of eid */
16680 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16682 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16684 memset (a, 0, sizeof (a[0]));
16686 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16688 a->type = 0; /* ipv4 type */
16690 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16692 a->type = 1; /* ipv6 type */
16694 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16696 a->type = 2; /* mac type */
16698 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16700 a->type = 3; /* NSH type */
16701 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16702 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16709 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16718 lisp_eid_size_vat (u8 type)
16735 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16737 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16741 api_one_add_del_locator_set (vat_main_t * vam)
16743 unformat_input_t *input = vam->input;
16744 vl_api_one_add_del_locator_set_t *mp;
16746 u8 *locator_set_name = NULL;
16747 u8 locator_set_name_set = 0;
16748 vl_api_local_locator_t locator, *locators = 0;
16749 u32 sw_if_index, priority, weight;
16753 /* Parse args required to build the message */
16754 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16756 if (unformat (input, "del"))
16760 else if (unformat (input, "locator-set %s", &locator_set_name))
16762 locator_set_name_set = 1;
16764 else if (unformat (input, "sw_if_index %u p %u w %u",
16765 &sw_if_index, &priority, &weight))
16767 locator.sw_if_index = htonl (sw_if_index);
16768 locator.priority = priority;
16769 locator.weight = weight;
16770 vec_add1 (locators, locator);
16774 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16775 &sw_if_index, &priority, &weight))
16777 locator.sw_if_index = htonl (sw_if_index);
16778 locator.priority = priority;
16779 locator.weight = weight;
16780 vec_add1 (locators, locator);
16786 if (locator_set_name_set == 0)
16788 errmsg ("missing locator-set name");
16789 vec_free (locators);
16793 if (vec_len (locator_set_name) > 64)
16795 errmsg ("locator-set name too long");
16796 vec_free (locator_set_name);
16797 vec_free (locators);
16800 vec_add1 (locator_set_name, 0);
16802 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16804 /* Construct the API message */
16805 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16807 mp->is_add = is_add;
16808 clib_memcpy (mp->locator_set_name, locator_set_name,
16809 vec_len (locator_set_name));
16810 vec_free (locator_set_name);
16812 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16814 clib_memcpy (mp->locators, locators, data_len);
16815 vec_free (locators);
16820 /* Wait for a reply... */
16825 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16828 api_one_add_del_locator (vat_main_t * vam)
16830 unformat_input_t *input = vam->input;
16831 vl_api_one_add_del_locator_t *mp;
16832 u32 tmp_if_index = ~0;
16833 u32 sw_if_index = ~0;
16834 u8 sw_if_index_set = 0;
16835 u8 sw_if_index_if_name_set = 0;
16837 u8 priority_set = 0;
16841 u8 *locator_set_name = NULL;
16842 u8 locator_set_name_set = 0;
16845 /* Parse args required to build the message */
16846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16848 if (unformat (input, "del"))
16852 else if (unformat (input, "locator-set %s", &locator_set_name))
16854 locator_set_name_set = 1;
16856 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16859 sw_if_index_if_name_set = 1;
16860 sw_if_index = tmp_if_index;
16862 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16864 sw_if_index_set = 1;
16865 sw_if_index = tmp_if_index;
16867 else if (unformat (input, "p %d", &priority))
16871 else if (unformat (input, "w %d", &weight))
16879 if (locator_set_name_set == 0)
16881 errmsg ("missing locator-set name");
16885 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16887 errmsg ("missing sw_if_index");
16888 vec_free (locator_set_name);
16892 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16894 errmsg ("cannot use both params interface name and sw_if_index");
16895 vec_free (locator_set_name);
16899 if (priority_set == 0)
16901 errmsg ("missing locator-set priority");
16902 vec_free (locator_set_name);
16906 if (weight_set == 0)
16908 errmsg ("missing locator-set weight");
16909 vec_free (locator_set_name);
16913 if (vec_len (locator_set_name) > 64)
16915 errmsg ("locator-set name too long");
16916 vec_free (locator_set_name);
16919 vec_add1 (locator_set_name, 0);
16921 /* Construct the API message */
16922 M (ONE_ADD_DEL_LOCATOR, mp);
16924 mp->is_add = is_add;
16925 mp->sw_if_index = ntohl (sw_if_index);
16926 mp->priority = priority;
16927 mp->weight = weight;
16928 clib_memcpy (mp->locator_set_name, locator_set_name,
16929 vec_len (locator_set_name));
16930 vec_free (locator_set_name);
16935 /* Wait for a reply... */
16940 #define api_lisp_add_del_locator api_one_add_del_locator
16943 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16945 u32 *key_id = va_arg (*args, u32 *);
16948 if (unformat (input, "%s", &s))
16950 if (!strcmp ((char *) s, "sha1"))
16951 key_id[0] = HMAC_SHA_1_96;
16952 else if (!strcmp ((char *) s, "sha256"))
16953 key_id[0] = HMAC_SHA_256_128;
16956 clib_warning ("invalid key_id: '%s'", s);
16957 key_id[0] = HMAC_NO_KEY;
16968 api_one_add_del_local_eid (vat_main_t * vam)
16970 unformat_input_t *input = vam->input;
16971 vl_api_one_add_del_local_eid_t *mp;
16974 lisp_eid_vat_t _eid, *eid = &_eid;
16975 u8 *locator_set_name = 0;
16976 u8 locator_set_name_set = 0;
16982 /* Parse args required to build the message */
16983 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16985 if (unformat (input, "del"))
16989 else if (unformat (input, "vni %d", &vni))
16993 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16997 else if (unformat (input, "locator-set %s", &locator_set_name))
16999 locator_set_name_set = 1;
17001 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17003 else if (unformat (input, "secret-key %_%v%_", &key))
17009 if (locator_set_name_set == 0)
17011 errmsg ("missing locator-set name");
17017 errmsg ("EID address not set!");
17018 vec_free (locator_set_name);
17022 if (key && (0 == key_id))
17024 errmsg ("invalid key_id!");
17028 if (vec_len (key) > 64)
17030 errmsg ("key too long");
17035 if (vec_len (locator_set_name) > 64)
17037 errmsg ("locator-set name too long");
17038 vec_free (locator_set_name);
17041 vec_add1 (locator_set_name, 0);
17043 /* Construct the API message */
17044 M (ONE_ADD_DEL_LOCAL_EID, mp);
17046 mp->is_add = is_add;
17047 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17048 mp->eid_type = eid->type;
17049 mp->prefix_len = eid->len;
17050 mp->vni = clib_host_to_net_u32 (vni);
17051 mp->key_id = clib_host_to_net_u16 (key_id);
17052 clib_memcpy (mp->locator_set_name, locator_set_name,
17053 vec_len (locator_set_name));
17054 clib_memcpy (mp->key, key, vec_len (key));
17056 vec_free (locator_set_name);
17062 /* Wait for a reply... */
17067 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17070 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17072 u32 dp_table = 0, vni = 0;;
17073 unformat_input_t *input = vam->input;
17074 vl_api_gpe_add_del_fwd_entry_t *mp;
17076 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17077 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17078 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17079 u32 action = ~0, w;
17080 ip4_address_t rmt_rloc4, lcl_rloc4;
17081 ip6_address_t rmt_rloc6, lcl_rloc6;
17082 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17085 memset (&rloc, 0, sizeof (rloc));
17087 /* Parse args required to build the message */
17088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17090 if (unformat (input, "del"))
17092 else if (unformat (input, "add"))
17094 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17098 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17102 else if (unformat (input, "vrf %d", &dp_table))
17104 else if (unformat (input, "bd %d", &dp_table))
17106 else if (unformat (input, "vni %d", &vni))
17108 else if (unformat (input, "w %d", &w))
17112 errmsg ("No RLOC configured for setting priority/weight!");
17115 curr_rloc->weight = w;
17117 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17118 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17122 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17124 vec_add1 (lcl_locs, rloc);
17126 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17127 vec_add1 (rmt_locs, rloc);
17128 /* weight saved in rmt loc */
17129 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17131 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17132 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17135 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17137 vec_add1 (lcl_locs, rloc);
17139 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17140 vec_add1 (rmt_locs, rloc);
17141 /* weight saved in rmt loc */
17142 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17144 else if (unformat (input, "action %d", &action))
17150 clib_warning ("parse error '%U'", format_unformat_error, input);
17157 errmsg ("remote eid addresses not set");
17161 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17163 errmsg ("eid types don't match");
17167 if (0 == rmt_locs && (u32) ~ 0 == action)
17169 errmsg ("action not set for negative mapping");
17173 /* Construct the API message */
17174 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17175 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17177 mp->is_add = is_add;
17178 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17179 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17180 mp->eid_type = rmt_eid->type;
17181 mp->dp_table = clib_host_to_net_u32 (dp_table);
17182 mp->vni = clib_host_to_net_u32 (vni);
17183 mp->rmt_len = rmt_eid->len;
17184 mp->lcl_len = lcl_eid->len;
17185 mp->action = action;
17187 if (0 != rmt_locs && 0 != lcl_locs)
17189 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17190 clib_memcpy (mp->locs, lcl_locs,
17191 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17193 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17194 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17195 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17197 vec_free (lcl_locs);
17198 vec_free (rmt_locs);
17203 /* Wait for a reply... */
17209 api_one_add_del_map_server (vat_main_t * vam)
17211 unformat_input_t *input = vam->input;
17212 vl_api_one_add_del_map_server_t *mp;
17216 ip4_address_t ipv4;
17217 ip6_address_t ipv6;
17220 /* Parse args required to build the message */
17221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17223 if (unformat (input, "del"))
17227 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17231 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17239 if (ipv4_set && ipv6_set)
17241 errmsg ("both eid v4 and v6 addresses set");
17245 if (!ipv4_set && !ipv6_set)
17247 errmsg ("eid addresses not set");
17251 /* Construct the API message */
17252 M (ONE_ADD_DEL_MAP_SERVER, mp);
17254 mp->is_add = is_add;
17258 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17263 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17269 /* Wait for a reply... */
17274 #define api_lisp_add_del_map_server api_one_add_del_map_server
17277 api_one_add_del_map_resolver (vat_main_t * vam)
17279 unformat_input_t *input = vam->input;
17280 vl_api_one_add_del_map_resolver_t *mp;
17284 ip4_address_t ipv4;
17285 ip6_address_t ipv6;
17288 /* Parse args required to build the message */
17289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17291 if (unformat (input, "del"))
17295 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17299 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17307 if (ipv4_set && ipv6_set)
17309 errmsg ("both eid v4 and v6 addresses set");
17313 if (!ipv4_set && !ipv6_set)
17315 errmsg ("eid addresses not set");
17319 /* Construct the API message */
17320 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17322 mp->is_add = is_add;
17326 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17331 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17337 /* Wait for a reply... */
17342 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17345 api_lisp_gpe_enable_disable (vat_main_t * vam)
17347 unformat_input_t *input = vam->input;
17348 vl_api_gpe_enable_disable_t *mp;
17353 /* Parse args required to build the message */
17354 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17356 if (unformat (input, "enable"))
17361 else if (unformat (input, "disable"))
17372 errmsg ("Value not set");
17376 /* Construct the API message */
17377 M (GPE_ENABLE_DISABLE, mp);
17384 /* Wait for a reply... */
17390 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17392 unformat_input_t *input = vam->input;
17393 vl_api_one_rloc_probe_enable_disable_t *mp;
17398 /* Parse args required to build the message */
17399 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17401 if (unformat (input, "enable"))
17406 else if (unformat (input, "disable"))
17414 errmsg ("Value not set");
17418 /* Construct the API message */
17419 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17421 mp->is_enabled = is_en;
17426 /* Wait for a reply... */
17431 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17434 api_one_map_register_enable_disable (vat_main_t * vam)
17436 unformat_input_t *input = vam->input;
17437 vl_api_one_map_register_enable_disable_t *mp;
17442 /* Parse args required to build the message */
17443 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17445 if (unformat (input, "enable"))
17450 else if (unformat (input, "disable"))
17458 errmsg ("Value not set");
17462 /* Construct the API message */
17463 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17465 mp->is_enabled = is_en;
17470 /* Wait for a reply... */
17475 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17478 api_one_enable_disable (vat_main_t * vam)
17480 unformat_input_t *input = vam->input;
17481 vl_api_one_enable_disable_t *mp;
17486 /* Parse args required to build the message */
17487 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17489 if (unformat (input, "enable"))
17494 else if (unformat (input, "disable"))
17504 errmsg ("Value not set");
17508 /* Construct the API message */
17509 M (ONE_ENABLE_DISABLE, mp);
17516 /* Wait for a reply... */
17521 #define api_lisp_enable_disable api_one_enable_disable
17524 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17526 unformat_input_t *input = vam->input;
17527 vl_api_one_enable_disable_xtr_mode_t *mp;
17532 /* Parse args required to build the message */
17533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17535 if (unformat (input, "enable"))
17540 else if (unformat (input, "disable"))
17550 errmsg ("Value not set");
17554 /* Construct the API message */
17555 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17562 /* Wait for a reply... */
17568 api_one_show_xtr_mode (vat_main_t * vam)
17570 vl_api_one_show_xtr_mode_t *mp;
17573 /* Construct the API message */
17574 M (ONE_SHOW_XTR_MODE, mp);
17579 /* Wait for a reply... */
17585 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17587 unformat_input_t *input = vam->input;
17588 vl_api_one_enable_disable_pitr_mode_t *mp;
17593 /* Parse args required to build the message */
17594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17596 if (unformat (input, "enable"))
17601 else if (unformat (input, "disable"))
17611 errmsg ("Value not set");
17615 /* Construct the API message */
17616 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17623 /* Wait for a reply... */
17629 api_one_show_pitr_mode (vat_main_t * vam)
17631 vl_api_one_show_pitr_mode_t *mp;
17634 /* Construct the API message */
17635 M (ONE_SHOW_PITR_MODE, mp);
17640 /* Wait for a reply... */
17646 api_one_enable_disable_petr_mode (vat_main_t * vam)
17648 unformat_input_t *input = vam->input;
17649 vl_api_one_enable_disable_petr_mode_t *mp;
17654 /* Parse args required to build the message */
17655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17657 if (unformat (input, "enable"))
17662 else if (unformat (input, "disable"))
17672 errmsg ("Value not set");
17676 /* Construct the API message */
17677 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17684 /* Wait for a reply... */
17690 api_one_show_petr_mode (vat_main_t * vam)
17692 vl_api_one_show_petr_mode_t *mp;
17695 /* Construct the API message */
17696 M (ONE_SHOW_PETR_MODE, mp);
17701 /* Wait for a reply... */
17707 api_show_one_map_register_state (vat_main_t * vam)
17709 vl_api_show_one_map_register_state_t *mp;
17712 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17717 /* wait for reply */
17722 #define api_show_lisp_map_register_state api_show_one_map_register_state
17725 api_show_one_rloc_probe_state (vat_main_t * vam)
17727 vl_api_show_one_rloc_probe_state_t *mp;
17730 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17735 /* wait for reply */
17740 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17743 api_one_add_del_ndp_entry (vat_main_t * vam)
17745 vl_api_one_add_del_ndp_entry_t *mp;
17746 unformat_input_t *input = vam->input;
17751 u8 mac[6] = { 0, };
17752 u8 ip6[16] = { 0, };
17756 /* Parse args required to build the message */
17757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17759 if (unformat (input, "del"))
17761 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17763 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17765 else if (unformat (input, "bd %d", &bd))
17769 errmsg ("parse error '%U'", format_unformat_error, input);
17774 if (!bd_set || !ip_set || (!mac_set && is_add))
17776 errmsg ("Missing BD, IP or MAC!");
17780 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17781 mp->is_add = is_add;
17782 clib_memcpy (mp->mac, mac, 6);
17783 mp->bd = clib_host_to_net_u32 (bd);
17784 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17789 /* wait for reply */
17795 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17797 vl_api_one_add_del_l2_arp_entry_t *mp;
17798 unformat_input_t *input = vam->input;
17803 u8 mac[6] = { 0, };
17804 u32 ip4 = 0, bd = ~0;
17807 /* Parse args required to build the message */
17808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17810 if (unformat (input, "del"))
17812 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17814 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17816 else if (unformat (input, "bd %d", &bd))
17820 errmsg ("parse error '%U'", format_unformat_error, input);
17825 if (!bd_set || !ip_set || (!mac_set && is_add))
17827 errmsg ("Missing BD, IP or MAC!");
17831 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17832 mp->is_add = is_add;
17833 clib_memcpy (mp->mac, mac, 6);
17834 mp->bd = clib_host_to_net_u32 (bd);
17840 /* wait for reply */
17846 api_one_ndp_bd_get (vat_main_t * vam)
17848 vl_api_one_ndp_bd_get_t *mp;
17851 M (ONE_NDP_BD_GET, mp);
17856 /* wait for reply */
17862 api_one_ndp_entries_get (vat_main_t * vam)
17864 vl_api_one_ndp_entries_get_t *mp;
17865 unformat_input_t *input = vam->input;
17870 /* Parse args required to build the message */
17871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17873 if (unformat (input, "bd %d", &bd))
17877 errmsg ("parse error '%U'", format_unformat_error, input);
17884 errmsg ("Expected bridge domain!");
17888 M (ONE_NDP_ENTRIES_GET, mp);
17889 mp->bd = clib_host_to_net_u32 (bd);
17894 /* wait for reply */
17900 api_one_l2_arp_bd_get (vat_main_t * vam)
17902 vl_api_one_l2_arp_bd_get_t *mp;
17905 M (ONE_L2_ARP_BD_GET, mp);
17910 /* wait for reply */
17916 api_one_l2_arp_entries_get (vat_main_t * vam)
17918 vl_api_one_l2_arp_entries_get_t *mp;
17919 unformat_input_t *input = vam->input;
17924 /* Parse args required to build the message */
17925 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17927 if (unformat (input, "bd %d", &bd))
17931 errmsg ("parse error '%U'", format_unformat_error, input);
17938 errmsg ("Expected bridge domain!");
17942 M (ONE_L2_ARP_ENTRIES_GET, mp);
17943 mp->bd = clib_host_to_net_u32 (bd);
17948 /* wait for reply */
17954 api_one_stats_enable_disable (vat_main_t * vam)
17956 vl_api_one_stats_enable_disable_t *mp;
17957 unformat_input_t *input = vam->input;
17962 /* Parse args required to build the message */
17963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17965 if (unformat (input, "enable"))
17970 else if (unformat (input, "disable"))
17980 errmsg ("Value not set");
17984 M (ONE_STATS_ENABLE_DISABLE, mp);
17990 /* wait for reply */
17996 api_show_one_stats_enable_disable (vat_main_t * vam)
17998 vl_api_show_one_stats_enable_disable_t *mp;
18001 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18006 /* wait for reply */
18012 api_show_one_map_request_mode (vat_main_t * vam)
18014 vl_api_show_one_map_request_mode_t *mp;
18017 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18022 /* wait for reply */
18027 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18030 api_one_map_request_mode (vat_main_t * vam)
18032 unformat_input_t *input = vam->input;
18033 vl_api_one_map_request_mode_t *mp;
18037 /* Parse args required to build the message */
18038 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18040 if (unformat (input, "dst-only"))
18042 else if (unformat (input, "src-dst"))
18046 errmsg ("parse error '%U'", format_unformat_error, input);
18051 M (ONE_MAP_REQUEST_MODE, mp);
18058 /* wait for reply */
18063 #define api_lisp_map_request_mode api_one_map_request_mode
18066 * Enable/disable ONE proxy ITR.
18068 * @param vam vpp API test context
18069 * @return return code
18072 api_one_pitr_set_locator_set (vat_main_t * vam)
18074 u8 ls_name_set = 0;
18075 unformat_input_t *input = vam->input;
18076 vl_api_one_pitr_set_locator_set_t *mp;
18081 /* Parse args required to build the message */
18082 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18084 if (unformat (input, "del"))
18086 else if (unformat (input, "locator-set %s", &ls_name))
18090 errmsg ("parse error '%U'", format_unformat_error, input);
18097 errmsg ("locator-set name not set!");
18101 M (ONE_PITR_SET_LOCATOR_SET, mp);
18103 mp->is_add = is_add;
18104 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18105 vec_free (ls_name);
18110 /* wait for reply */
18115 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18118 api_one_nsh_set_locator_set (vat_main_t * vam)
18120 u8 ls_name_set = 0;
18121 unformat_input_t *input = vam->input;
18122 vl_api_one_nsh_set_locator_set_t *mp;
18127 /* Parse args required to build the message */
18128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18130 if (unformat (input, "del"))
18132 else if (unformat (input, "ls %s", &ls_name))
18136 errmsg ("parse error '%U'", format_unformat_error, input);
18141 if (!ls_name_set && is_add)
18143 errmsg ("locator-set name not set!");
18147 M (ONE_NSH_SET_LOCATOR_SET, mp);
18149 mp->is_add = is_add;
18150 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18151 vec_free (ls_name);
18156 /* wait for reply */
18162 api_show_one_pitr (vat_main_t * vam)
18164 vl_api_show_one_pitr_t *mp;
18167 if (!vam->json_output)
18169 print (vam->ofp, "%=20s", "lisp status:");
18172 M (SHOW_ONE_PITR, mp);
18176 /* Wait for a reply... */
18181 #define api_show_lisp_pitr api_show_one_pitr
18184 api_one_use_petr (vat_main_t * vam)
18186 unformat_input_t *input = vam->input;
18187 vl_api_one_use_petr_t *mp;
18192 memset (&ip, 0, sizeof (ip));
18194 /* Parse args required to build the message */
18195 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18197 if (unformat (input, "disable"))
18200 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18203 ip_addr_version (&ip) = IP4;
18206 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18209 ip_addr_version (&ip) = IP6;
18213 errmsg ("parse error '%U'", format_unformat_error, input);
18218 M (ONE_USE_PETR, mp);
18220 mp->is_add = is_add;
18223 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18225 clib_memcpy (mp->address, &ip, 4);
18227 clib_memcpy (mp->address, &ip, 16);
18233 /* wait for reply */
18238 #define api_lisp_use_petr api_one_use_petr
18241 api_show_one_nsh_mapping (vat_main_t * vam)
18243 vl_api_show_one_use_petr_t *mp;
18246 if (!vam->json_output)
18248 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18251 M (SHOW_ONE_NSH_MAPPING, mp);
18255 /* Wait for a reply... */
18261 api_show_one_use_petr (vat_main_t * vam)
18263 vl_api_show_one_use_petr_t *mp;
18266 if (!vam->json_output)
18268 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18271 M (SHOW_ONE_USE_PETR, mp);
18275 /* Wait for a reply... */
18280 #define api_show_lisp_use_petr api_show_one_use_petr
18283 * Add/delete mapping between vni and vrf
18286 api_one_eid_table_add_del_map (vat_main_t * vam)
18288 unformat_input_t *input = vam->input;
18289 vl_api_one_eid_table_add_del_map_t *mp;
18290 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18291 u32 vni, vrf, bd_index;
18294 /* Parse args required to build the message */
18295 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18297 if (unformat (input, "del"))
18299 else if (unformat (input, "vrf %d", &vrf))
18301 else if (unformat (input, "bd_index %d", &bd_index))
18303 else if (unformat (input, "vni %d", &vni))
18309 if (!vni_set || (!vrf_set && !bd_index_set))
18311 errmsg ("missing arguments!");
18315 if (vrf_set && bd_index_set)
18317 errmsg ("error: both vrf and bd entered!");
18321 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18323 mp->is_add = is_add;
18324 mp->vni = htonl (vni);
18325 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18326 mp->is_l2 = bd_index_set;
18331 /* wait for reply */
18336 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18339 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18341 u32 *action = va_arg (*args, u32 *);
18344 if (unformat (input, "%s", &s))
18346 if (!strcmp ((char *) s, "no-action"))
18348 else if (!strcmp ((char *) s, "natively-forward"))
18350 else if (!strcmp ((char *) s, "send-map-request"))
18352 else if (!strcmp ((char *) s, "drop"))
18356 clib_warning ("invalid action: '%s'", s);
18368 * Add/del remote mapping to/from ONE control plane
18370 * @param vam vpp API test context
18371 * @return return code
18374 api_one_add_del_remote_mapping (vat_main_t * vam)
18376 unformat_input_t *input = vam->input;
18377 vl_api_one_add_del_remote_mapping_t *mp;
18379 lisp_eid_vat_t _eid, *eid = &_eid;
18380 lisp_eid_vat_t _seid, *seid = &_seid;
18381 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18382 u32 action = ~0, p, w, data_len;
18383 ip4_address_t rloc4;
18384 ip6_address_t rloc6;
18385 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18388 memset (&rloc, 0, sizeof (rloc));
18390 /* Parse args required to build the message */
18391 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18393 if (unformat (input, "del-all"))
18397 else if (unformat (input, "del"))
18401 else if (unformat (input, "add"))
18405 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18409 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18413 else if (unformat (input, "vni %d", &vni))
18417 else if (unformat (input, "p %d w %d", &p, &w))
18421 errmsg ("No RLOC configured for setting priority/weight!");
18424 curr_rloc->priority = p;
18425 curr_rloc->weight = w;
18427 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18430 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18431 vec_add1 (rlocs, rloc);
18432 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18434 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18437 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18438 vec_add1 (rlocs, rloc);
18439 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18441 else if (unformat (input, "action %U",
18442 unformat_negative_mapping_action, &action))
18448 clib_warning ("parse error '%U'", format_unformat_error, input);
18455 errmsg ("missing params!");
18459 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18461 errmsg ("no action set for negative map-reply!");
18465 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18467 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18468 mp->is_add = is_add;
18469 mp->vni = htonl (vni);
18470 mp->action = (u8) action;
18471 mp->is_src_dst = seid_set;
18472 mp->eid_len = eid->len;
18473 mp->seid_len = seid->len;
18474 mp->del_all = del_all;
18475 mp->eid_type = eid->type;
18476 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18477 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18479 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18480 clib_memcpy (mp->rlocs, rlocs, data_len);
18486 /* Wait for a reply... */
18491 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18494 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18495 * forwarding entries in data-plane accordingly.
18497 * @param vam vpp API test context
18498 * @return return code
18501 api_one_add_del_adjacency (vat_main_t * vam)
18503 unformat_input_t *input = vam->input;
18504 vl_api_one_add_del_adjacency_t *mp;
18506 ip4_address_t leid4, reid4;
18507 ip6_address_t leid6, reid6;
18508 u8 reid_mac[6] = { 0 };
18509 u8 leid_mac[6] = { 0 };
18510 u8 reid_type, leid_type;
18511 u32 leid_len = 0, reid_len = 0, len;
18515 leid_type = reid_type = (u8) ~ 0;
18517 /* Parse args required to build the message */
18518 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18520 if (unformat (input, "del"))
18524 else if (unformat (input, "add"))
18528 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18531 reid_type = 0; /* ipv4 */
18534 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18537 reid_type = 1; /* ipv6 */
18540 else if (unformat (input, "reid %U", unformat_ethernet_address,
18543 reid_type = 2; /* mac */
18545 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18548 leid_type = 0; /* ipv4 */
18551 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18554 leid_type = 1; /* ipv6 */
18557 else if (unformat (input, "leid %U", unformat_ethernet_address,
18560 leid_type = 2; /* mac */
18562 else if (unformat (input, "vni %d", &vni))
18568 errmsg ("parse error '%U'", format_unformat_error, input);
18573 if ((u8) ~ 0 == reid_type)
18575 errmsg ("missing params!");
18579 if (leid_type != reid_type)
18581 errmsg ("remote and local EIDs are of different types!");
18585 M (ONE_ADD_DEL_ADJACENCY, mp);
18586 mp->is_add = is_add;
18587 mp->vni = htonl (vni);
18588 mp->leid_len = leid_len;
18589 mp->reid_len = reid_len;
18590 mp->eid_type = reid_type;
18592 switch (mp->eid_type)
18595 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18596 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18599 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18600 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18603 clib_memcpy (mp->leid, leid_mac, 6);
18604 clib_memcpy (mp->reid, reid_mac, 6);
18607 errmsg ("unknown EID type %d!", mp->eid_type);
18614 /* Wait for a reply... */
18619 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18622 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18624 u32 *mode = va_arg (*args, u32 *);
18626 if (unformat (input, "lisp"))
18628 else if (unformat (input, "vxlan"))
18637 api_gpe_get_encap_mode (vat_main_t * vam)
18639 vl_api_gpe_get_encap_mode_t *mp;
18642 /* Construct the API message */
18643 M (GPE_GET_ENCAP_MODE, mp);
18648 /* Wait for a reply... */
18654 api_gpe_set_encap_mode (vat_main_t * vam)
18656 unformat_input_t *input = vam->input;
18657 vl_api_gpe_set_encap_mode_t *mp;
18661 /* Parse args required to build the message */
18662 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18664 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18670 /* Construct the API message */
18671 M (GPE_SET_ENCAP_MODE, mp);
18678 /* Wait for a reply... */
18684 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18686 unformat_input_t *input = vam->input;
18687 vl_api_gpe_add_del_iface_t *mp;
18688 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18689 u32 dp_table = 0, vni = 0;
18692 /* Parse args required to build the message */
18693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18695 if (unformat (input, "up"))
18700 else if (unformat (input, "down"))
18705 else if (unformat (input, "table_id %d", &dp_table))
18709 else if (unformat (input, "bd_id %d", &dp_table))
18714 else if (unformat (input, "vni %d", &vni))
18722 if (action_set == 0)
18724 errmsg ("Action not set");
18727 if (dp_table_set == 0 || vni_set == 0)
18729 errmsg ("vni and dp_table must be set");
18733 /* Construct the API message */
18734 M (GPE_ADD_DEL_IFACE, mp);
18736 mp->is_add = is_add;
18737 mp->dp_table = clib_host_to_net_u32 (dp_table);
18739 mp->vni = clib_host_to_net_u32 (vni);
18744 /* Wait for a reply... */
18750 api_one_map_register_fallback_threshold (vat_main_t * vam)
18752 unformat_input_t *input = vam->input;
18753 vl_api_one_map_register_fallback_threshold_t *mp;
18758 /* Parse args required to build the message */
18759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18761 if (unformat (input, "%u", &value))
18765 clib_warning ("parse error '%U'", format_unformat_error, input);
18772 errmsg ("fallback threshold value is missing!");
18776 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18777 mp->value = clib_host_to_net_u32 (value);
18782 /* Wait for a reply... */
18788 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18790 vl_api_show_one_map_register_fallback_threshold_t *mp;
18793 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18798 /* Wait for a reply... */
18804 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18806 u32 *proto = va_arg (*args, u32 *);
18808 if (unformat (input, "udp"))
18810 else if (unformat (input, "api"))
18819 api_one_set_transport_protocol (vat_main_t * vam)
18821 unformat_input_t *input = vam->input;
18822 vl_api_one_set_transport_protocol_t *mp;
18827 /* Parse args required to build the message */
18828 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18830 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18834 clib_warning ("parse error '%U'", format_unformat_error, input);
18841 errmsg ("Transport protocol missing!");
18845 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18846 mp->protocol = (u8) protocol;
18851 /* Wait for a reply... */
18857 api_one_get_transport_protocol (vat_main_t * vam)
18859 vl_api_one_get_transport_protocol_t *mp;
18862 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18867 /* Wait for a reply... */
18873 api_one_map_register_set_ttl (vat_main_t * vam)
18875 unformat_input_t *input = vam->input;
18876 vl_api_one_map_register_set_ttl_t *mp;
18881 /* Parse args required to build the message */
18882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18884 if (unformat (input, "%u", &ttl))
18888 clib_warning ("parse error '%U'", format_unformat_error, input);
18895 errmsg ("TTL value missing!");
18899 M (ONE_MAP_REGISTER_SET_TTL, mp);
18900 mp->ttl = clib_host_to_net_u32 (ttl);
18905 /* Wait for a reply... */
18911 api_show_one_map_register_ttl (vat_main_t * vam)
18913 vl_api_show_one_map_register_ttl_t *mp;
18916 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18921 /* Wait for a reply... */
18927 * Add/del map request itr rlocs from ONE control plane and updates
18929 * @param vam vpp API test context
18930 * @return return code
18933 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18935 unformat_input_t *input = vam->input;
18936 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18937 u8 *locator_set_name = 0;
18938 u8 locator_set_name_set = 0;
18942 /* Parse args required to build the message */
18943 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18945 if (unformat (input, "del"))
18949 else if (unformat (input, "%_%v%_", &locator_set_name))
18951 locator_set_name_set = 1;
18955 clib_warning ("parse error '%U'", format_unformat_error, input);
18960 if (is_add && !locator_set_name_set)
18962 errmsg ("itr-rloc is not set!");
18966 if (is_add && vec_len (locator_set_name) > 64)
18968 errmsg ("itr-rloc locator-set name too long");
18969 vec_free (locator_set_name);
18973 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18974 mp->is_add = is_add;
18977 clib_memcpy (mp->locator_set_name, locator_set_name,
18978 vec_len (locator_set_name));
18982 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18984 vec_free (locator_set_name);
18989 /* Wait for a reply... */
18994 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18997 api_one_locator_dump (vat_main_t * vam)
18999 unformat_input_t *input = vam->input;
19000 vl_api_one_locator_dump_t *mp;
19001 vl_api_control_ping_t *mp_ping;
19002 u8 is_index_set = 0, is_name_set = 0;
19007 /* Parse args required to build the message */
19008 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19010 if (unformat (input, "ls_name %_%v%_", &ls_name))
19014 else if (unformat (input, "ls_index %d", &ls_index))
19020 errmsg ("parse error '%U'", format_unformat_error, input);
19025 if (!is_index_set && !is_name_set)
19027 errmsg ("error: expected one of index or name!");
19031 if (is_index_set && is_name_set)
19033 errmsg ("error: only one param expected!");
19037 if (vec_len (ls_name) > 62)
19039 errmsg ("error: locator set name too long!");
19043 if (!vam->json_output)
19045 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19048 M (ONE_LOCATOR_DUMP, mp);
19049 mp->is_index_set = is_index_set;
19052 mp->ls_index = clib_host_to_net_u32 (ls_index);
19055 vec_add1 (ls_name, 0);
19056 strncpy ((char *) mp->ls_name, (char *) ls_name,
19057 sizeof (mp->ls_name) - 1);
19063 /* Use a control ping for synchronization */
19064 MPING (CONTROL_PING, mp_ping);
19067 /* Wait for a reply... */
19072 #define api_lisp_locator_dump api_one_locator_dump
19075 api_one_locator_set_dump (vat_main_t * vam)
19077 vl_api_one_locator_set_dump_t *mp;
19078 vl_api_control_ping_t *mp_ping;
19079 unformat_input_t *input = vam->input;
19083 /* Parse args required to build the message */
19084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19086 if (unformat (input, "local"))
19090 else if (unformat (input, "remote"))
19096 errmsg ("parse error '%U'", format_unformat_error, input);
19101 if (!vam->json_output)
19103 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19106 M (ONE_LOCATOR_SET_DUMP, mp);
19108 mp->filter = filter;
19113 /* Use a control ping for synchronization */
19114 MPING (CONTROL_PING, mp_ping);
19117 /* Wait for a reply... */
19122 #define api_lisp_locator_set_dump api_one_locator_set_dump
19125 api_one_eid_table_map_dump (vat_main_t * vam)
19129 unformat_input_t *input = vam->input;
19130 vl_api_one_eid_table_map_dump_t *mp;
19131 vl_api_control_ping_t *mp_ping;
19134 /* Parse args required to build the message */
19135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19137 if (unformat (input, "l2"))
19142 else if (unformat (input, "l3"))
19149 errmsg ("parse error '%U'", format_unformat_error, input);
19156 errmsg ("expected one of 'l2' or 'l3' parameter!");
19160 if (!vam->json_output)
19162 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19165 M (ONE_EID_TABLE_MAP_DUMP, mp);
19171 /* Use a control ping for synchronization */
19172 MPING (CONTROL_PING, mp_ping);
19175 /* Wait for a reply... */
19180 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19183 api_one_eid_table_vni_dump (vat_main_t * vam)
19185 vl_api_one_eid_table_vni_dump_t *mp;
19186 vl_api_control_ping_t *mp_ping;
19189 if (!vam->json_output)
19191 print (vam->ofp, "VNI");
19194 M (ONE_EID_TABLE_VNI_DUMP, mp);
19199 /* Use a control ping for synchronization */
19200 MPING (CONTROL_PING, mp_ping);
19203 /* Wait for a reply... */
19208 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19211 api_one_eid_table_dump (vat_main_t * vam)
19213 unformat_input_t *i = vam->input;
19214 vl_api_one_eid_table_dump_t *mp;
19215 vl_api_control_ping_t *mp_ping;
19216 struct in_addr ip4;
19217 struct in6_addr ip6;
19219 u8 eid_type = ~0, eid_set = 0;
19220 u32 prefix_length = ~0, t, vni = 0;
19223 lisp_nsh_api_t nsh;
19225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19227 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19233 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19239 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19244 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19249 else if (unformat (i, "vni %d", &t))
19253 else if (unformat (i, "local"))
19257 else if (unformat (i, "remote"))
19263 errmsg ("parse error '%U'", format_unformat_error, i);
19268 if (!vam->json_output)
19270 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19271 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19274 M (ONE_EID_TABLE_DUMP, mp);
19276 mp->filter = filter;
19280 mp->vni = htonl (vni);
19281 mp->eid_type = eid_type;
19285 mp->prefix_length = prefix_length;
19286 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19289 mp->prefix_length = prefix_length;
19290 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19293 clib_memcpy (mp->eid, mac, sizeof (mac));
19296 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19299 errmsg ("unknown EID type %d!", eid_type);
19307 /* Use a control ping for synchronization */
19308 MPING (CONTROL_PING, mp_ping);
19311 /* Wait for a reply... */
19316 #define api_lisp_eid_table_dump api_one_eid_table_dump
19319 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19321 unformat_input_t *i = vam->input;
19322 vl_api_gpe_fwd_entries_get_t *mp;
19327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19329 if (unformat (i, "vni %d", &vni))
19335 errmsg ("parse error '%U'", format_unformat_error, i);
19342 errmsg ("vni not set!");
19346 if (!vam->json_output)
19348 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19352 M (GPE_FWD_ENTRIES_GET, mp);
19353 mp->vni = clib_host_to_net_u32 (vni);
19358 /* Wait for a reply... */
19363 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19364 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19365 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19366 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19367 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19368 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19369 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19370 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19373 api_one_adjacencies_get (vat_main_t * vam)
19375 unformat_input_t *i = vam->input;
19376 vl_api_one_adjacencies_get_t *mp;
19381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19383 if (unformat (i, "vni %d", &vni))
19389 errmsg ("parse error '%U'", format_unformat_error, i);
19396 errmsg ("vni not set!");
19400 if (!vam->json_output)
19402 print (vam->ofp, "%s %40s", "leid", "reid");
19405 M (ONE_ADJACENCIES_GET, mp);
19406 mp->vni = clib_host_to_net_u32 (vni);
19411 /* Wait for a reply... */
19416 #define api_lisp_adjacencies_get api_one_adjacencies_get
19419 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19421 unformat_input_t *i = vam->input;
19422 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19424 u8 ip_family_set = 0, is_ip4 = 1;
19426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19428 if (unformat (i, "ip4"))
19433 else if (unformat (i, "ip6"))
19440 errmsg ("parse error '%U'", format_unformat_error, i);
19445 if (!ip_family_set)
19447 errmsg ("ip family not set!");
19451 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19452 mp->is_ip4 = is_ip4;
19457 /* Wait for a reply... */
19463 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19465 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19468 if (!vam->json_output)
19470 print (vam->ofp, "VNIs");
19473 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19478 /* Wait for a reply... */
19484 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19486 unformat_input_t *i = vam->input;
19487 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19489 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19490 struct in_addr ip4;
19491 struct in6_addr ip6;
19492 u32 table_id = 0, nh_sw_if_index = ~0;
19494 memset (&ip4, 0, sizeof (ip4));
19495 memset (&ip6, 0, sizeof (ip6));
19497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19499 if (unformat (i, "del"))
19501 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19502 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19507 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19508 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19513 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19517 nh_sw_if_index = ~0;
19519 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19523 nh_sw_if_index = ~0;
19525 else if (unformat (i, "table %d", &table_id))
19529 errmsg ("parse error '%U'", format_unformat_error, i);
19536 errmsg ("nh addr not set!");
19540 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19541 mp->is_add = is_add;
19542 mp->table_id = clib_host_to_net_u32 (table_id);
19543 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19544 mp->is_ip4 = is_ip4;
19546 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19548 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19553 /* Wait for a reply... */
19559 api_one_map_server_dump (vat_main_t * vam)
19561 vl_api_one_map_server_dump_t *mp;
19562 vl_api_control_ping_t *mp_ping;
19565 if (!vam->json_output)
19567 print (vam->ofp, "%=20s", "Map server");
19570 M (ONE_MAP_SERVER_DUMP, mp);
19574 /* Use a control ping for synchronization */
19575 MPING (CONTROL_PING, mp_ping);
19578 /* Wait for a reply... */
19583 #define api_lisp_map_server_dump api_one_map_server_dump
19586 api_one_map_resolver_dump (vat_main_t * vam)
19588 vl_api_one_map_resolver_dump_t *mp;
19589 vl_api_control_ping_t *mp_ping;
19592 if (!vam->json_output)
19594 print (vam->ofp, "%=20s", "Map resolver");
19597 M (ONE_MAP_RESOLVER_DUMP, mp);
19601 /* Use a control ping for synchronization */
19602 MPING (CONTROL_PING, mp_ping);
19605 /* Wait for a reply... */
19610 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19613 api_one_stats_flush (vat_main_t * vam)
19615 vl_api_one_stats_flush_t *mp;
19618 M (ONE_STATS_FLUSH, mp);
19625 api_one_stats_dump (vat_main_t * vam)
19627 vl_api_one_stats_dump_t *mp;
19628 vl_api_control_ping_t *mp_ping;
19631 M (ONE_STATS_DUMP, mp);
19635 /* Use a control ping for synchronization */
19636 MPING (CONTROL_PING, mp_ping);
19639 /* Wait for a reply... */
19645 api_show_one_status (vat_main_t * vam)
19647 vl_api_show_one_status_t *mp;
19650 if (!vam->json_output)
19652 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19655 M (SHOW_ONE_STATUS, mp);
19658 /* Wait for a reply... */
19663 #define api_show_lisp_status api_show_one_status
19666 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19668 vl_api_gpe_fwd_entry_path_dump_t *mp;
19669 vl_api_control_ping_t *mp_ping;
19670 unformat_input_t *i = vam->input;
19671 u32 fwd_entry_index = ~0;
19674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19676 if (unformat (i, "index %d", &fwd_entry_index))
19682 if (~0 == fwd_entry_index)
19684 errmsg ("no index specified!");
19688 if (!vam->json_output)
19690 print (vam->ofp, "first line");
19693 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19697 /* Use a control ping for synchronization */
19698 MPING (CONTROL_PING, mp_ping);
19701 /* Wait for a reply... */
19707 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19709 vl_api_one_get_map_request_itr_rlocs_t *mp;
19712 if (!vam->json_output)
19714 print (vam->ofp, "%=20s", "itr-rlocs:");
19717 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19720 /* Wait for a reply... */
19725 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19728 api_af_packet_create (vat_main_t * vam)
19730 unformat_input_t *i = vam->input;
19731 vl_api_af_packet_create_t *mp;
19732 u8 *host_if_name = 0;
19734 u8 random_hw_addr = 1;
19737 memset (hw_addr, 0, sizeof (hw_addr));
19739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19741 if (unformat (i, "name %s", &host_if_name))
19742 vec_add1 (host_if_name, 0);
19743 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19744 random_hw_addr = 0;
19749 if (!vec_len (host_if_name))
19751 errmsg ("host-interface name must be specified");
19755 if (vec_len (host_if_name) > 64)
19757 errmsg ("host-interface name too long");
19761 M (AF_PACKET_CREATE, mp);
19763 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19764 clib_memcpy (mp->hw_addr, hw_addr, 6);
19765 mp->use_random_hw_addr = random_hw_addr;
19766 vec_free (host_if_name);
19774 fprintf (vam->ofp ? vam->ofp : stderr,
19775 " new sw_if_index = %d\n", vam->sw_if_index);
19782 api_af_packet_delete (vat_main_t * vam)
19784 unformat_input_t *i = vam->input;
19785 vl_api_af_packet_delete_t *mp;
19786 u8 *host_if_name = 0;
19789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19791 if (unformat (i, "name %s", &host_if_name))
19792 vec_add1 (host_if_name, 0);
19797 if (!vec_len (host_if_name))
19799 errmsg ("host-interface name must be specified");
19803 if (vec_len (host_if_name) > 64)
19805 errmsg ("host-interface name too long");
19809 M (AF_PACKET_DELETE, mp);
19811 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19812 vec_free (host_if_name);
19819 static void vl_api_af_packet_details_t_handler
19820 (vl_api_af_packet_details_t * mp)
19822 vat_main_t *vam = &vat_main;
19824 print (vam->ofp, "%-16s %d",
19825 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
19828 static void vl_api_af_packet_details_t_handler_json
19829 (vl_api_af_packet_details_t * mp)
19831 vat_main_t *vam = &vat_main;
19832 vat_json_node_t *node = NULL;
19834 if (VAT_JSON_ARRAY != vam->json_tree.type)
19836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19837 vat_json_init_array (&vam->json_tree);
19839 node = vat_json_array_add (&vam->json_tree);
19841 vat_json_init_object (node);
19842 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19843 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
19847 api_af_packet_dump (vat_main_t * vam)
19849 vl_api_af_packet_dump_t *mp;
19850 vl_api_control_ping_t *mp_ping;
19853 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
19854 /* Get list of tap interfaces */
19855 M (AF_PACKET_DUMP, mp);
19858 /* Use a control ping for synchronization */
19859 MPING (CONTROL_PING, mp_ping);
19867 api_policer_add_del (vat_main_t * vam)
19869 unformat_input_t *i = vam->input;
19870 vl_api_policer_add_del_t *mp;
19880 u8 color_aware = 0;
19881 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19884 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19885 conform_action.dscp = 0;
19886 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19887 exceed_action.dscp = 0;
19888 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19889 violate_action.dscp = 0;
19891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19893 if (unformat (i, "del"))
19895 else if (unformat (i, "name %s", &name))
19896 vec_add1 (name, 0);
19897 else if (unformat (i, "cir %u", &cir))
19899 else if (unformat (i, "eir %u", &eir))
19901 else if (unformat (i, "cb %u", &cb))
19903 else if (unformat (i, "eb %u", &eb))
19905 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19908 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19911 else if (unformat (i, "type %U", unformat_policer_type, &type))
19913 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19916 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19919 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19922 else if (unformat (i, "color-aware"))
19928 if (!vec_len (name))
19930 errmsg ("policer name must be specified");
19934 if (vec_len (name) > 64)
19936 errmsg ("policer name too long");
19940 M (POLICER_ADD_DEL, mp);
19942 clib_memcpy (mp->name, name, vec_len (name));
19944 mp->is_add = is_add;
19945 mp->cir = ntohl (cir);
19946 mp->eir = ntohl (eir);
19947 mp->cb = clib_net_to_host_u64 (cb);
19948 mp->eb = clib_net_to_host_u64 (eb);
19949 mp->rate_type = rate_type;
19950 mp->round_type = round_type;
19952 mp->conform_action_type = conform_action.action_type;
19953 mp->conform_dscp = conform_action.dscp;
19954 mp->exceed_action_type = exceed_action.action_type;
19955 mp->exceed_dscp = exceed_action.dscp;
19956 mp->violate_action_type = violate_action.action_type;
19957 mp->violate_dscp = violate_action.dscp;
19958 mp->color_aware = color_aware;
19966 api_policer_dump (vat_main_t * vam)
19968 unformat_input_t *i = vam->input;
19969 vl_api_policer_dump_t *mp;
19970 vl_api_control_ping_t *mp_ping;
19971 u8 *match_name = 0;
19972 u8 match_name_valid = 0;
19975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19977 if (unformat (i, "name %s", &match_name))
19979 vec_add1 (match_name, 0);
19980 match_name_valid = 1;
19986 M (POLICER_DUMP, mp);
19987 mp->match_name_valid = match_name_valid;
19988 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19989 vec_free (match_name);
19993 /* Use a control ping for synchronization */
19994 MPING (CONTROL_PING, mp_ping);
19997 /* Wait for a reply... */
20003 api_policer_classify_set_interface (vat_main_t * vam)
20005 unformat_input_t *i = vam->input;
20006 vl_api_policer_classify_set_interface_t *mp;
20008 int sw_if_index_set;
20009 u32 ip4_table_index = ~0;
20010 u32 ip6_table_index = ~0;
20011 u32 l2_table_index = ~0;
20015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20018 sw_if_index_set = 1;
20019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20020 sw_if_index_set = 1;
20021 else if (unformat (i, "del"))
20023 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20025 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20027 else if (unformat (i, "l2-table %d", &l2_table_index))
20031 clib_warning ("parse error '%U'", format_unformat_error, i);
20036 if (sw_if_index_set == 0)
20038 errmsg ("missing interface name or sw_if_index");
20042 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
20044 mp->sw_if_index = ntohl (sw_if_index);
20045 mp->ip4_table_index = ntohl (ip4_table_index);
20046 mp->ip6_table_index = ntohl (ip6_table_index);
20047 mp->l2_table_index = ntohl (l2_table_index);
20048 mp->is_add = is_add;
20056 api_policer_classify_dump (vat_main_t * vam)
20058 unformat_input_t *i = vam->input;
20059 vl_api_policer_classify_dump_t *mp;
20060 vl_api_control_ping_t *mp_ping;
20061 u8 type = POLICER_CLASSIFY_N_TABLES;
20064 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20068 errmsg ("classify table type must be specified");
20072 if (!vam->json_output)
20074 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20077 M (POLICER_CLASSIFY_DUMP, mp);
20082 /* Use a control ping for synchronization */
20083 MPING (CONTROL_PING, mp_ping);
20086 /* Wait for a reply... */
20092 api_netmap_create (vat_main_t * vam)
20094 unformat_input_t *i = vam->input;
20095 vl_api_netmap_create_t *mp;
20098 u8 random_hw_addr = 1;
20103 memset (hw_addr, 0, sizeof (hw_addr));
20105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20107 if (unformat (i, "name %s", &if_name))
20108 vec_add1 (if_name, 0);
20109 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20110 random_hw_addr = 0;
20111 else if (unformat (i, "pipe"))
20113 else if (unformat (i, "master"))
20115 else if (unformat (i, "slave"))
20121 if (!vec_len (if_name))
20123 errmsg ("interface name must be specified");
20127 if (vec_len (if_name) > 64)
20129 errmsg ("interface name too long");
20133 M (NETMAP_CREATE, mp);
20135 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20136 clib_memcpy (mp->hw_addr, hw_addr, 6);
20137 mp->use_random_hw_addr = random_hw_addr;
20138 mp->is_pipe = is_pipe;
20139 mp->is_master = is_master;
20140 vec_free (if_name);
20148 api_netmap_delete (vat_main_t * vam)
20150 unformat_input_t *i = vam->input;
20151 vl_api_netmap_delete_t *mp;
20155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20157 if (unformat (i, "name %s", &if_name))
20158 vec_add1 (if_name, 0);
20163 if (!vec_len (if_name))
20165 errmsg ("interface name must be specified");
20169 if (vec_len (if_name) > 64)
20171 errmsg ("interface name too long");
20175 M (NETMAP_DELETE, mp);
20177 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20178 vec_free (if_name);
20186 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20188 if (fp->afi == IP46_TYPE_IP6)
20190 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20191 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20192 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20193 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20194 format_ip6_address, fp->next_hop);
20195 else if (fp->afi == IP46_TYPE_IP4)
20197 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20198 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20199 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20200 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20201 format_ip4_address, fp->next_hop);
20205 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20206 vl_api_fib_path_t * fp)
20208 struct in_addr ip4;
20209 struct in6_addr ip6;
20211 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20212 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20213 vat_json_object_add_uint (node, "is_local", fp->is_local);
20214 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20215 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20216 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20217 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20218 if (fp->afi == IP46_TYPE_IP4)
20220 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20221 vat_json_object_add_ip4 (node, "next_hop", ip4);
20223 else if (fp->afi == IP46_TYPE_IP6)
20225 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20226 vat_json_object_add_ip6 (node, "next_hop", ip6);
20231 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20233 vat_main_t *vam = &vat_main;
20234 int count = ntohl (mp->mt_count);
20235 vl_api_fib_path_t *fp;
20238 print (vam->ofp, "[%d]: sw_if_index %d via:",
20239 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20241 for (i = 0; i < count; i++)
20243 vl_api_mpls_fib_path_print (vam, fp);
20247 print (vam->ofp, "");
20250 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20251 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20254 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20256 vat_main_t *vam = &vat_main;
20257 vat_json_node_t *node = NULL;
20258 int count = ntohl (mp->mt_count);
20259 vl_api_fib_path_t *fp;
20262 if (VAT_JSON_ARRAY != vam->json_tree.type)
20264 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20265 vat_json_init_array (&vam->json_tree);
20267 node = vat_json_array_add (&vam->json_tree);
20269 vat_json_init_object (node);
20270 vat_json_object_add_uint (node, "tunnel_index",
20271 ntohl (mp->mt_tunnel_index));
20272 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20274 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20277 for (i = 0; i < count; i++)
20279 vl_api_mpls_fib_path_json_print (node, fp);
20285 api_mpls_tunnel_dump (vat_main_t * vam)
20287 vl_api_mpls_tunnel_dump_t *mp;
20288 vl_api_control_ping_t *mp_ping;
20292 /* Parse args required to build the message */
20293 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20295 if (!unformat (vam->input, "tunnel_index %d", &index))
20302 print (vam->ofp, " tunnel_index %d", index);
20304 M (MPLS_TUNNEL_DUMP, mp);
20305 mp->tunnel_index = htonl (index);
20308 /* Use a control ping for synchronization */
20309 MPING (CONTROL_PING, mp_ping);
20316 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20317 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20321 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20323 vat_main_t *vam = &vat_main;
20324 int count = ntohl (mp->count);
20325 vl_api_fib_path_t *fp;
20329 "table-id %d, label %u, ess_bit %u",
20330 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20332 for (i = 0; i < count; i++)
20334 vl_api_mpls_fib_path_print (vam, fp);
20339 static void vl_api_mpls_fib_details_t_handler_json
20340 (vl_api_mpls_fib_details_t * mp)
20342 vat_main_t *vam = &vat_main;
20343 int count = ntohl (mp->count);
20344 vat_json_node_t *node = NULL;
20345 vl_api_fib_path_t *fp;
20348 if (VAT_JSON_ARRAY != vam->json_tree.type)
20350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20351 vat_json_init_array (&vam->json_tree);
20353 node = vat_json_array_add (&vam->json_tree);
20355 vat_json_init_object (node);
20356 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20357 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20358 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20359 vat_json_object_add_uint (node, "path_count", count);
20361 for (i = 0; i < count; i++)
20363 vl_api_mpls_fib_path_json_print (node, fp);
20369 api_mpls_fib_dump (vat_main_t * vam)
20371 vl_api_mpls_fib_dump_t *mp;
20372 vl_api_control_ping_t *mp_ping;
20375 M (MPLS_FIB_DUMP, mp);
20378 /* Use a control ping for synchronization */
20379 MPING (CONTROL_PING, mp_ping);
20386 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20387 #define vl_api_ip_fib_details_t_print vl_noop_handler
20390 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20392 vat_main_t *vam = &vat_main;
20393 int count = ntohl (mp->count);
20394 vl_api_fib_path_t *fp;
20398 "table-id %d, prefix %U/%d",
20399 ntohl (mp->table_id), format_ip4_address, mp->address,
20400 mp->address_length);
20402 for (i = 0; i < count; i++)
20404 if (fp->afi == IP46_TYPE_IP6)
20406 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20407 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20408 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20409 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20410 format_ip6_address, fp->next_hop);
20411 else if (fp->afi == IP46_TYPE_IP4)
20413 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20414 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20415 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20416 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20417 format_ip4_address, fp->next_hop);
20422 static void vl_api_ip_fib_details_t_handler_json
20423 (vl_api_ip_fib_details_t * mp)
20425 vat_main_t *vam = &vat_main;
20426 int count = ntohl (mp->count);
20427 vat_json_node_t *node = NULL;
20428 struct in_addr ip4;
20429 struct in6_addr ip6;
20430 vl_api_fib_path_t *fp;
20433 if (VAT_JSON_ARRAY != vam->json_tree.type)
20435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20436 vat_json_init_array (&vam->json_tree);
20438 node = vat_json_array_add (&vam->json_tree);
20440 vat_json_init_object (node);
20441 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20442 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20443 vat_json_object_add_ip4 (node, "prefix", ip4);
20444 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20445 vat_json_object_add_uint (node, "path_count", count);
20447 for (i = 0; i < count; i++)
20449 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20450 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20451 vat_json_object_add_uint (node, "is_local", fp->is_local);
20452 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20453 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20454 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20455 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20456 if (fp->afi == IP46_TYPE_IP4)
20458 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20459 vat_json_object_add_ip4 (node, "next_hop", ip4);
20461 else if (fp->afi == IP46_TYPE_IP6)
20463 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20464 vat_json_object_add_ip6 (node, "next_hop", ip6);
20470 api_ip_fib_dump (vat_main_t * vam)
20472 vl_api_ip_fib_dump_t *mp;
20473 vl_api_control_ping_t *mp_ping;
20476 M (IP_FIB_DUMP, mp);
20479 /* Use a control ping for synchronization */
20480 MPING (CONTROL_PING, mp_ping);
20488 api_ip_mfib_dump (vat_main_t * vam)
20490 vl_api_ip_mfib_dump_t *mp;
20491 vl_api_control_ping_t *mp_ping;
20494 M (IP_MFIB_DUMP, mp);
20497 /* Use a control ping for synchronization */
20498 MPING (CONTROL_PING, mp_ping);
20505 static void vl_api_ip_neighbor_details_t_handler
20506 (vl_api_ip_neighbor_details_t * mp)
20508 vat_main_t *vam = &vat_main;
20510 print (vam->ofp, "%c %U %U",
20511 (mp->is_static) ? 'S' : 'D',
20512 format_ethernet_address, &mp->mac_address,
20513 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20517 static void vl_api_ip_neighbor_details_t_handler_json
20518 (vl_api_ip_neighbor_details_t * mp)
20521 vat_main_t *vam = &vat_main;
20522 vat_json_node_t *node;
20523 struct in_addr ip4;
20524 struct in6_addr ip6;
20526 if (VAT_JSON_ARRAY != vam->json_tree.type)
20528 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20529 vat_json_init_array (&vam->json_tree);
20531 node = vat_json_array_add (&vam->json_tree);
20533 vat_json_init_object (node);
20534 vat_json_object_add_string_copy (node, "flag",
20535 (mp->is_static) ? (u8 *) "static" : (u8 *)
20538 vat_json_object_add_string_copy (node, "link_layer",
20539 format (0, "%U", format_ethernet_address,
20540 &mp->mac_address));
20544 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20545 vat_json_object_add_ip6 (node, "ip_address", ip6);
20549 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20550 vat_json_object_add_ip4 (node, "ip_address", ip4);
20555 api_ip_neighbor_dump (vat_main_t * vam)
20557 unformat_input_t *i = vam->input;
20558 vl_api_ip_neighbor_dump_t *mp;
20559 vl_api_control_ping_t *mp_ping;
20561 u32 sw_if_index = ~0;
20564 /* Parse args required to build the message */
20565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20571 else if (unformat (i, "ip6"))
20577 if (sw_if_index == ~0)
20579 errmsg ("missing interface name or sw_if_index");
20583 M (IP_NEIGHBOR_DUMP, mp);
20584 mp->is_ipv6 = (u8) is_ipv6;
20585 mp->sw_if_index = ntohl (sw_if_index);
20588 /* Use a control ping for synchronization */
20589 MPING (CONTROL_PING, mp_ping);
20596 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20597 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20600 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20602 vat_main_t *vam = &vat_main;
20603 int count = ntohl (mp->count);
20604 vl_api_fib_path_t *fp;
20608 "table-id %d, prefix %U/%d",
20609 ntohl (mp->table_id), format_ip6_address, mp->address,
20610 mp->address_length);
20612 for (i = 0; i < count; i++)
20614 if (fp->afi == IP46_TYPE_IP6)
20616 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20617 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20618 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20619 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20620 format_ip6_address, fp->next_hop);
20621 else if (fp->afi == IP46_TYPE_IP4)
20623 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20624 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20625 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20626 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20627 format_ip4_address, fp->next_hop);
20632 static void vl_api_ip6_fib_details_t_handler_json
20633 (vl_api_ip6_fib_details_t * mp)
20635 vat_main_t *vam = &vat_main;
20636 int count = ntohl (mp->count);
20637 vat_json_node_t *node = NULL;
20638 struct in_addr ip4;
20639 struct in6_addr ip6;
20640 vl_api_fib_path_t *fp;
20643 if (VAT_JSON_ARRAY != vam->json_tree.type)
20645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20646 vat_json_init_array (&vam->json_tree);
20648 node = vat_json_array_add (&vam->json_tree);
20650 vat_json_init_object (node);
20651 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20652 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20653 vat_json_object_add_ip6 (node, "prefix", ip6);
20654 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20655 vat_json_object_add_uint (node, "path_count", count);
20657 for (i = 0; i < count; i++)
20659 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20660 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20661 vat_json_object_add_uint (node, "is_local", fp->is_local);
20662 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20663 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20664 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20665 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20666 if (fp->afi == IP46_TYPE_IP4)
20668 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20669 vat_json_object_add_ip4 (node, "next_hop", ip4);
20671 else if (fp->afi == IP46_TYPE_IP6)
20673 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20674 vat_json_object_add_ip6 (node, "next_hop", ip6);
20680 api_ip6_fib_dump (vat_main_t * vam)
20682 vl_api_ip6_fib_dump_t *mp;
20683 vl_api_control_ping_t *mp_ping;
20686 M (IP6_FIB_DUMP, mp);
20689 /* Use a control ping for synchronization */
20690 MPING (CONTROL_PING, mp_ping);
20698 api_ip6_mfib_dump (vat_main_t * vam)
20700 vl_api_ip6_mfib_dump_t *mp;
20701 vl_api_control_ping_t *mp_ping;
20704 M (IP6_MFIB_DUMP, mp);
20707 /* Use a control ping for synchronization */
20708 MPING (CONTROL_PING, mp_ping);
20716 api_classify_table_ids (vat_main_t * vam)
20718 vl_api_classify_table_ids_t *mp;
20721 /* Construct the API message */
20722 M (CLASSIFY_TABLE_IDS, mp);
20731 api_classify_table_by_interface (vat_main_t * vam)
20733 unformat_input_t *input = vam->input;
20734 vl_api_classify_table_by_interface_t *mp;
20736 u32 sw_if_index = ~0;
20738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20740 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20742 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20747 if (sw_if_index == ~0)
20749 errmsg ("missing interface name or sw_if_index");
20753 /* Construct the API message */
20754 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20756 mp->sw_if_index = ntohl (sw_if_index);
20764 api_classify_table_info (vat_main_t * vam)
20766 unformat_input_t *input = vam->input;
20767 vl_api_classify_table_info_t *mp;
20771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20773 if (unformat (input, "table_id %d", &table_id))
20778 if (table_id == ~0)
20780 errmsg ("missing table id");
20784 /* Construct the API message */
20785 M (CLASSIFY_TABLE_INFO, mp);
20787 mp->table_id = ntohl (table_id);
20795 api_classify_session_dump (vat_main_t * vam)
20797 unformat_input_t *input = vam->input;
20798 vl_api_classify_session_dump_t *mp;
20799 vl_api_control_ping_t *mp_ping;
20803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20805 if (unformat (input, "table_id %d", &table_id))
20810 if (table_id == ~0)
20812 errmsg ("missing table id");
20816 /* Construct the API message */
20817 M (CLASSIFY_SESSION_DUMP, mp);
20819 mp->table_id = ntohl (table_id);
20822 /* Use a control ping for synchronization */
20823 MPING (CONTROL_PING, mp_ping);
20831 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20833 vat_main_t *vam = &vat_main;
20835 print (vam->ofp, "collector_address %U, collector_port %d, "
20836 "src_address %U, vrf_id %d, path_mtu %u, "
20837 "template_interval %u, udp_checksum %d",
20838 format_ip4_address, mp->collector_address,
20839 ntohs (mp->collector_port),
20840 format_ip4_address, mp->src_address,
20841 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20842 ntohl (mp->template_interval), mp->udp_checksum);
20845 vam->result_ready = 1;
20849 vl_api_ipfix_exporter_details_t_handler_json
20850 (vl_api_ipfix_exporter_details_t * mp)
20852 vat_main_t *vam = &vat_main;
20853 vat_json_node_t node;
20854 struct in_addr collector_address;
20855 struct in_addr src_address;
20857 vat_json_init_object (&node);
20858 clib_memcpy (&collector_address, &mp->collector_address,
20859 sizeof (collector_address));
20860 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20861 vat_json_object_add_uint (&node, "collector_port",
20862 ntohs (mp->collector_port));
20863 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20864 vat_json_object_add_ip4 (&node, "src_address", src_address);
20865 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20866 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20867 vat_json_object_add_uint (&node, "template_interval",
20868 ntohl (mp->template_interval));
20869 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20871 vat_json_print (vam->ofp, &node);
20872 vat_json_free (&node);
20874 vam->result_ready = 1;
20878 api_ipfix_exporter_dump (vat_main_t * vam)
20880 vl_api_ipfix_exporter_dump_t *mp;
20883 /* Construct the API message */
20884 M (IPFIX_EXPORTER_DUMP, mp);
20893 api_ipfix_classify_stream_dump (vat_main_t * vam)
20895 vl_api_ipfix_classify_stream_dump_t *mp;
20898 /* Construct the API message */
20899 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20910 vl_api_ipfix_classify_stream_details_t_handler
20911 (vl_api_ipfix_classify_stream_details_t * mp)
20913 vat_main_t *vam = &vat_main;
20914 print (vam->ofp, "domain_id %d, src_port %d",
20915 ntohl (mp->domain_id), ntohs (mp->src_port));
20917 vam->result_ready = 1;
20921 vl_api_ipfix_classify_stream_details_t_handler_json
20922 (vl_api_ipfix_classify_stream_details_t * mp)
20924 vat_main_t *vam = &vat_main;
20925 vat_json_node_t node;
20927 vat_json_init_object (&node);
20928 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20929 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20931 vat_json_print (vam->ofp, &node);
20932 vat_json_free (&node);
20934 vam->result_ready = 1;
20938 api_ipfix_classify_table_dump (vat_main_t * vam)
20940 vl_api_ipfix_classify_table_dump_t *mp;
20941 vl_api_control_ping_t *mp_ping;
20944 if (!vam->json_output)
20946 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20947 "transport_protocol");
20950 /* Construct the API message */
20951 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20956 /* Use a control ping for synchronization */
20957 MPING (CONTROL_PING, mp_ping);
20965 vl_api_ipfix_classify_table_details_t_handler
20966 (vl_api_ipfix_classify_table_details_t * mp)
20968 vat_main_t *vam = &vat_main;
20969 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20970 mp->transport_protocol);
20974 vl_api_ipfix_classify_table_details_t_handler_json
20975 (vl_api_ipfix_classify_table_details_t * mp)
20977 vat_json_node_t *node = NULL;
20978 vat_main_t *vam = &vat_main;
20980 if (VAT_JSON_ARRAY != vam->json_tree.type)
20982 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20983 vat_json_init_array (&vam->json_tree);
20986 node = vat_json_array_add (&vam->json_tree);
20987 vat_json_init_object (node);
20989 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20990 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20991 vat_json_object_add_uint (node, "transport_protocol",
20992 mp->transport_protocol);
20996 api_sw_interface_span_enable_disable (vat_main_t * vam)
20998 unformat_input_t *i = vam->input;
20999 vl_api_sw_interface_span_enable_disable_t *mp;
21000 u32 src_sw_if_index = ~0;
21001 u32 dst_sw_if_index = ~0;
21006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21009 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
21011 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
21015 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
21017 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
21019 else if (unformat (i, "disable"))
21021 else if (unformat (i, "rx"))
21023 else if (unformat (i, "tx"))
21025 else if (unformat (i, "both"))
21027 else if (unformat (i, "l2"))
21033 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
21035 mp->sw_if_index_from = htonl (src_sw_if_index);
21036 mp->sw_if_index_to = htonl (dst_sw_if_index);
21046 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21049 vat_main_t *vam = &vat_main;
21050 u8 *sw_if_from_name = 0;
21051 u8 *sw_if_to_name = 0;
21052 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21053 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21054 char *states[] = { "none", "rx", "tx", "both" };
21058 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21060 if ((u32) p->value[0] == sw_if_index_from)
21062 sw_if_from_name = (u8 *)(p->key);
21066 if ((u32) p->value[0] == sw_if_index_to)
21068 sw_if_to_name = (u8 *)(p->key);
21069 if (sw_if_from_name)
21074 print (vam->ofp, "%20s => %20s (%s) %s",
21075 sw_if_from_name, sw_if_to_name, states[mp->state],
21076 mp->is_l2 ? "l2" : "device");
21080 vl_api_sw_interface_span_details_t_handler_json
21081 (vl_api_sw_interface_span_details_t * mp)
21083 vat_main_t *vam = &vat_main;
21084 vat_json_node_t *node = NULL;
21085 u8 *sw_if_from_name = 0;
21086 u8 *sw_if_to_name = 0;
21087 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21088 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21092 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21094 if ((u32) p->value[0] == sw_if_index_from)
21096 sw_if_from_name = (u8 *)(p->key);
21100 if ((u32) p->value[0] == sw_if_index_to)
21102 sw_if_to_name = (u8 *)(p->key);
21103 if (sw_if_from_name)
21109 if (VAT_JSON_ARRAY != vam->json_tree.type)
21111 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21112 vat_json_init_array (&vam->json_tree);
21114 node = vat_json_array_add (&vam->json_tree);
21116 vat_json_init_object (node);
21117 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21118 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21119 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21120 if (0 != sw_if_to_name)
21122 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21124 vat_json_object_add_uint (node, "state", mp->state);
21125 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21129 api_sw_interface_span_dump (vat_main_t * vam)
21131 unformat_input_t *input = vam->input;
21132 vl_api_sw_interface_span_dump_t *mp;
21133 vl_api_control_ping_t *mp_ping;
21137 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21139 if (unformat (input, "l2"))
21145 M (SW_INTERFACE_SPAN_DUMP, mp);
21149 /* Use a control ping for synchronization */
21150 MPING (CONTROL_PING, mp_ping);
21158 api_pg_create_interface (vat_main_t * vam)
21160 unformat_input_t *input = vam->input;
21161 vl_api_pg_create_interface_t *mp;
21165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21167 if (unformat (input, "if_id %d", &if_id))
21174 errmsg ("missing pg interface index");
21178 /* Construct the API message */
21179 M (PG_CREATE_INTERFACE, mp);
21181 mp->interface_id = ntohl (if_id);
21189 api_pg_capture (vat_main_t * vam)
21191 unformat_input_t *input = vam->input;
21192 vl_api_pg_capture_t *mp;
21197 u8 pcap_file_set = 0;
21200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21202 if (unformat (input, "if_id %d", &if_id))
21204 else if (unformat (input, "pcap %s", &pcap_file))
21206 else if (unformat (input, "count %d", &count))
21208 else if (unformat (input, "disable"))
21215 errmsg ("missing pg interface index");
21218 if (pcap_file_set > 0)
21220 if (vec_len (pcap_file) > 255)
21222 errmsg ("pcap file name is too long");
21227 u32 name_len = vec_len (pcap_file);
21228 /* Construct the API message */
21229 M (PG_CAPTURE, mp);
21231 mp->interface_id = ntohl (if_id);
21232 mp->is_enabled = enable;
21233 mp->count = ntohl (count);
21234 mp->pcap_name_length = ntohl (name_len);
21235 if (pcap_file_set != 0)
21237 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21239 vec_free (pcap_file);
21247 api_pg_enable_disable (vat_main_t * vam)
21249 unformat_input_t *input = vam->input;
21250 vl_api_pg_enable_disable_t *mp;
21253 u8 stream_name_set = 0;
21254 u8 *stream_name = 0;
21256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21258 if (unformat (input, "stream %s", &stream_name))
21259 stream_name_set = 1;
21260 else if (unformat (input, "disable"))
21266 if (stream_name_set > 0)
21268 if (vec_len (stream_name) > 255)
21270 errmsg ("stream name too long");
21275 u32 name_len = vec_len (stream_name);
21276 /* Construct the API message */
21277 M (PG_ENABLE_DISABLE, mp);
21279 mp->is_enabled = enable;
21280 if (stream_name_set != 0)
21282 mp->stream_name_length = ntohl (name_len);
21283 clib_memcpy (mp->stream_name, stream_name, name_len);
21285 vec_free (stream_name);
21293 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21295 unformat_input_t *input = vam->input;
21296 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21298 u16 *low_ports = 0;
21299 u16 *high_ports = 0;
21302 ip4_address_t ip4_addr;
21303 ip6_address_t ip6_addr;
21312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21314 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21320 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21325 else if (unformat (input, "vrf %d", &vrf_id))
21327 else if (unformat (input, "del"))
21329 else if (unformat (input, "port %d", &tmp))
21331 if (tmp == 0 || tmp > 65535)
21333 errmsg ("port %d out of range", tmp);
21337 this_hi = this_low + 1;
21338 vec_add1 (low_ports, this_low);
21339 vec_add1 (high_ports, this_hi);
21341 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21343 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21345 errmsg ("incorrect range parameters");
21349 /* Note: in debug CLI +1 is added to high before
21350 passing to real fn that does "the work"
21351 (ip_source_and_port_range_check_add_del).
21352 This fn is a wrapper around the binary API fn a
21353 control plane will call, which expects this increment
21354 to have occurred. Hence letting the binary API control
21355 plane fn do the increment for consistency between VAT
21356 and other control planes.
21359 vec_add1 (low_ports, this_low);
21360 vec_add1 (high_ports, this_hi);
21366 if (prefix_set == 0)
21368 errmsg ("<address>/<mask> not specified");
21374 errmsg ("VRF ID required, not specified");
21381 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21385 if (vec_len (low_ports) == 0)
21387 errmsg ("At least one port or port range required");
21391 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21393 mp->is_add = is_add;
21398 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21403 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21406 mp->mask_length = length;
21407 mp->number_of_ranges = vec_len (low_ports);
21409 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21410 vec_free (low_ports);
21412 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21413 vec_free (high_ports);
21415 mp->vrf_id = ntohl (vrf_id);
21423 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21425 unformat_input_t *input = vam->input;
21426 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21427 u32 sw_if_index = ~0;
21429 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21430 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21434 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21436 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21438 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21440 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21442 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21444 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21446 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21448 else if (unformat (input, "del"))
21454 if (sw_if_index == ~0)
21456 errmsg ("Interface required but not specified");
21462 errmsg ("VRF ID required but not specified");
21466 if (tcp_out_vrf_id == 0
21467 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21470 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21474 /* Construct the API message */
21475 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21477 mp->sw_if_index = ntohl (sw_if_index);
21478 mp->is_add = is_add;
21479 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21480 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21481 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21482 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21487 /* Wait for a reply... */
21493 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21495 unformat_input_t *i = vam->input;
21496 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21497 u32 local_sa_id = 0;
21498 u32 remote_sa_id = 0;
21499 ip4_address_t src_address;
21500 ip4_address_t dst_address;
21504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21506 if (unformat (i, "local_sa %d", &local_sa_id))
21508 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21510 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21512 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21514 else if (unformat (i, "del"))
21518 clib_warning ("parse error '%U'", format_unformat_error, i);
21523 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21525 mp->local_sa_id = ntohl (local_sa_id);
21526 mp->remote_sa_id = ntohl (remote_sa_id);
21527 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21528 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21529 mp->is_add = is_add;
21537 api_punt (vat_main_t * vam)
21539 unformat_input_t *i = vam->input;
21547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21549 if (unformat (i, "ip %d", &ipv))
21551 else if (unformat (i, "protocol %d", &protocol))
21553 else if (unformat (i, "port %d", &port))
21555 else if (unformat (i, "del"))
21559 clib_warning ("parse error '%U'", format_unformat_error, i);
21566 mp->is_add = (u8) is_add;
21567 mp->ipv = (u8) ipv;
21568 mp->l4_protocol = (u8) protocol;
21569 mp->l4_port = htons ((u16) port);
21576 static void vl_api_ipsec_gre_tunnel_details_t_handler
21577 (vl_api_ipsec_gre_tunnel_details_t * mp)
21579 vat_main_t *vam = &vat_main;
21581 print (vam->ofp, "%11d%15U%15U%14d%14d",
21582 ntohl (mp->sw_if_index),
21583 format_ip4_address, &mp->src_address,
21584 format_ip4_address, &mp->dst_address,
21585 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21588 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21589 (vl_api_ipsec_gre_tunnel_details_t * mp)
21591 vat_main_t *vam = &vat_main;
21592 vat_json_node_t *node = NULL;
21593 struct in_addr ip4;
21595 if (VAT_JSON_ARRAY != vam->json_tree.type)
21597 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21598 vat_json_init_array (&vam->json_tree);
21600 node = vat_json_array_add (&vam->json_tree);
21602 vat_json_init_object (node);
21603 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21604 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21605 vat_json_object_add_ip4 (node, "src_address", ip4);
21606 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21607 vat_json_object_add_ip4 (node, "dst_address", ip4);
21608 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21609 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21613 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21615 unformat_input_t *i = vam->input;
21616 vl_api_ipsec_gre_tunnel_dump_t *mp;
21617 vl_api_control_ping_t *mp_ping;
21619 u8 sw_if_index_set = 0;
21622 /* Parse args required to build the message */
21623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21625 if (unformat (i, "sw_if_index %d", &sw_if_index))
21626 sw_if_index_set = 1;
21631 if (sw_if_index_set == 0)
21636 if (!vam->json_output)
21638 print (vam->ofp, "%11s%15s%15s%14s%14s",
21639 "sw_if_index", "src_address", "dst_address",
21640 "local_sa_id", "remote_sa_id");
21643 /* Get list of gre-tunnel interfaces */
21644 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21646 mp->sw_if_index = htonl (sw_if_index);
21650 /* Use a control ping for synchronization */
21651 MPING (CONTROL_PING, mp_ping);
21659 api_delete_subif (vat_main_t * vam)
21661 unformat_input_t *i = vam->input;
21662 vl_api_delete_subif_t *mp;
21663 u32 sw_if_index = ~0;
21666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21668 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21670 if (unformat (i, "sw_if_index %d", &sw_if_index))
21676 if (sw_if_index == ~0)
21678 errmsg ("missing sw_if_index");
21682 /* Construct the API message */
21683 M (DELETE_SUBIF, mp);
21684 mp->sw_if_index = ntohl (sw_if_index);
21691 #define foreach_pbb_vtr_op \
21692 _("disable", L2_VTR_DISABLED) \
21693 _("pop", L2_VTR_POP_2) \
21694 _("push", L2_VTR_PUSH_2)
21697 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21699 unformat_input_t *i = vam->input;
21700 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21701 u32 sw_if_index = ~0, vtr_op = ~0;
21702 u16 outer_tag = ~0;
21703 u8 dmac[6], smac[6];
21704 u8 dmac_set = 0, smac_set = 0;
21710 /* Shut up coverity */
21711 memset (dmac, 0, sizeof (dmac));
21712 memset (smac, 0, sizeof (smac));
21714 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21716 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21718 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21720 else if (unformat (i, "vtr_op %d", &vtr_op))
21722 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21725 else if (unformat (i, "translate_pbb_stag"))
21727 if (unformat (i, "%d", &tmp))
21729 vtr_op = L2_VTR_TRANSLATE_2_1;
21735 ("translate_pbb_stag operation requires outer tag definition");
21739 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21741 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21743 else if (unformat (i, "sid %d", &sid))
21745 else if (unformat (i, "vlanid %d", &tmp))
21749 clib_warning ("parse error '%U'", format_unformat_error, i);
21754 if ((sw_if_index == ~0) || (vtr_op == ~0))
21756 errmsg ("missing sw_if_index or vtr operation");
21759 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21760 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21763 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21767 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21768 mp->sw_if_index = ntohl (sw_if_index);
21769 mp->vtr_op = ntohl (vtr_op);
21770 mp->outer_tag = ntohs (outer_tag);
21771 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21772 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21773 mp->b_vlanid = ntohs (vlanid);
21774 mp->i_sid = ntohl (sid);
21782 api_flow_classify_set_interface (vat_main_t * vam)
21784 unformat_input_t *i = vam->input;
21785 vl_api_flow_classify_set_interface_t *mp;
21787 int sw_if_index_set;
21788 u32 ip4_table_index = ~0;
21789 u32 ip6_table_index = ~0;
21793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21795 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21796 sw_if_index_set = 1;
21797 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21798 sw_if_index_set = 1;
21799 else if (unformat (i, "del"))
21801 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21803 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21807 clib_warning ("parse error '%U'", format_unformat_error, i);
21812 if (sw_if_index_set == 0)
21814 errmsg ("missing interface name or sw_if_index");
21818 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21820 mp->sw_if_index = ntohl (sw_if_index);
21821 mp->ip4_table_index = ntohl (ip4_table_index);
21822 mp->ip6_table_index = ntohl (ip6_table_index);
21823 mp->is_add = is_add;
21831 api_flow_classify_dump (vat_main_t * vam)
21833 unformat_input_t *i = vam->input;
21834 vl_api_flow_classify_dump_t *mp;
21835 vl_api_control_ping_t *mp_ping;
21836 u8 type = FLOW_CLASSIFY_N_TABLES;
21839 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21843 errmsg ("classify table type must be specified");
21847 if (!vam->json_output)
21849 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21852 M (FLOW_CLASSIFY_DUMP, mp);
21857 /* Use a control ping for synchronization */
21858 MPING (CONTROL_PING, mp_ping);
21861 /* Wait for a reply... */
21867 api_feature_enable_disable (vat_main_t * vam)
21869 unformat_input_t *i = vam->input;
21870 vl_api_feature_enable_disable_t *mp;
21872 u8 *feature_name = 0;
21873 u32 sw_if_index = ~0;
21877 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21879 if (unformat (i, "arc_name %s", &arc_name))
21881 else if (unformat (i, "feature_name %s", &feature_name))
21884 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21886 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21888 else if (unformat (i, "disable"))
21896 errmsg ("missing arc name");
21899 if (vec_len (arc_name) > 63)
21901 errmsg ("arc name too long");
21904 if (feature_name == 0)
21906 errmsg ("missing feature name");
21909 if (vec_len (feature_name) > 63)
21911 errmsg ("feature name too long");
21914 if (sw_if_index == ~0)
21916 errmsg ("missing interface name or sw_if_index");
21920 /* Construct the API message */
21921 M (FEATURE_ENABLE_DISABLE, mp);
21922 mp->sw_if_index = ntohl (sw_if_index);
21923 mp->enable = enable;
21924 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21925 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21926 vec_free (arc_name);
21927 vec_free (feature_name);
21935 api_sw_interface_tag_add_del (vat_main_t * vam)
21937 unformat_input_t *i = vam->input;
21938 vl_api_sw_interface_tag_add_del_t *mp;
21939 u32 sw_if_index = ~0;
21944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21946 if (unformat (i, "tag %s", &tag))
21948 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21950 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21952 else if (unformat (i, "del"))
21958 if (sw_if_index == ~0)
21960 errmsg ("missing interface name or sw_if_index");
21964 if (enable && (tag == 0))
21966 errmsg ("no tag specified");
21970 /* Construct the API message */
21971 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21972 mp->sw_if_index = ntohl (sw_if_index);
21973 mp->is_add = enable;
21975 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21983 static void vl_api_l2_xconnect_details_t_handler
21984 (vl_api_l2_xconnect_details_t * mp)
21986 vat_main_t *vam = &vat_main;
21988 print (vam->ofp, "%15d%15d",
21989 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21992 static void vl_api_l2_xconnect_details_t_handler_json
21993 (vl_api_l2_xconnect_details_t * mp)
21995 vat_main_t *vam = &vat_main;
21996 vat_json_node_t *node = NULL;
21998 if (VAT_JSON_ARRAY != vam->json_tree.type)
22000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22001 vat_json_init_array (&vam->json_tree);
22003 node = vat_json_array_add (&vam->json_tree);
22005 vat_json_init_object (node);
22006 vat_json_object_add_uint (node, "rx_sw_if_index",
22007 ntohl (mp->rx_sw_if_index));
22008 vat_json_object_add_uint (node, "tx_sw_if_index",
22009 ntohl (mp->tx_sw_if_index));
22013 api_l2_xconnect_dump (vat_main_t * vam)
22015 vl_api_l2_xconnect_dump_t *mp;
22016 vl_api_control_ping_t *mp_ping;
22019 if (!vam->json_output)
22021 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
22024 M (L2_XCONNECT_DUMP, mp);
22028 /* Use a control ping for synchronization */
22029 MPING (CONTROL_PING, mp_ping);
22037 api_sw_interface_set_mtu (vat_main_t * vam)
22039 unformat_input_t *i = vam->input;
22040 vl_api_sw_interface_set_mtu_t *mp;
22041 u32 sw_if_index = ~0;
22045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22047 if (unformat (i, "mtu %d", &mtu))
22049 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22051 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22057 if (sw_if_index == ~0)
22059 errmsg ("missing interface name or sw_if_index");
22065 errmsg ("no mtu specified");
22069 /* Construct the API message */
22070 M (SW_INTERFACE_SET_MTU, mp);
22071 mp->sw_if_index = ntohl (sw_if_index);
22072 mp->mtu = ntohs ((u16) mtu);
22080 api_p2p_ethernet_add (vat_main_t * vam)
22082 unformat_input_t *i = vam->input;
22083 vl_api_p2p_ethernet_add_t *mp;
22084 u32 parent_if_index = ~0;
22090 memset (remote_mac, 0, sizeof (remote_mac));
22091 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22093 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22095 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22099 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22101 else if (unformat (i, "sub_id %d", &sub_id))
22105 clib_warning ("parse error '%U'", format_unformat_error, i);
22110 if (parent_if_index == ~0)
22112 errmsg ("missing interface name or sw_if_index");
22117 errmsg ("missing remote mac address");
22122 errmsg ("missing sub-interface id");
22126 M (P2P_ETHERNET_ADD, mp);
22127 mp->parent_if_index = ntohl (parent_if_index);
22128 mp->subif_id = ntohl (sub_id);
22129 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22137 api_p2p_ethernet_del (vat_main_t * vam)
22139 unformat_input_t *i = vam->input;
22140 vl_api_p2p_ethernet_del_t *mp;
22141 u32 parent_if_index = ~0;
22146 memset (remote_mac, 0, sizeof (remote_mac));
22147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22151 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22155 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22159 clib_warning ("parse error '%U'", format_unformat_error, i);
22164 if (parent_if_index == ~0)
22166 errmsg ("missing interface name or sw_if_index");
22171 errmsg ("missing remote mac address");
22175 M (P2P_ETHERNET_DEL, mp);
22176 mp->parent_if_index = ntohl (parent_if_index);
22177 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22185 api_lldp_config (vat_main_t * vam)
22187 unformat_input_t *i = vam->input;
22188 vl_api_lldp_config_t *mp;
22190 int tx_interval = 0;
22191 u8 *sys_name = NULL;
22194 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22196 if (unformat (i, "system-name %s", &sys_name))
22198 else if (unformat (i, "tx-hold %d", &tx_hold))
22200 else if (unformat (i, "tx-interval %d", &tx_interval))
22204 clib_warning ("parse error '%U'", format_unformat_error, i);
22209 vec_add1 (sys_name, 0);
22211 M (LLDP_CONFIG, mp);
22212 mp->tx_hold = htonl (tx_hold);
22213 mp->tx_interval = htonl (tx_interval);
22214 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22215 vec_free (sys_name);
22223 api_sw_interface_set_lldp (vat_main_t * vam)
22225 unformat_input_t *i = vam->input;
22226 vl_api_sw_interface_set_lldp_t *mp;
22227 u32 sw_if_index = ~0;
22229 u8 *port_desc = NULL, *mgmt_oid = NULL;
22230 ip4_address_t ip4_addr;
22231 ip6_address_t ip6_addr;
22234 memset (&ip4_addr, 0, sizeof (ip4_addr));
22235 memset (&ip6_addr, 0, sizeof (ip6_addr));
22237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22239 if (unformat (i, "disable"))
22242 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22244 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22246 else if (unformat (i, "port-desc %s", &port_desc))
22248 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22250 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22252 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22258 if (sw_if_index == ~0)
22260 errmsg ("missing interface name or sw_if_index");
22264 /* Construct the API message */
22265 vec_add1 (port_desc, 0);
22266 vec_add1 (mgmt_oid, 0);
22267 M (SW_INTERFACE_SET_LLDP, mp);
22268 mp->sw_if_index = ntohl (sw_if_index);
22269 mp->enable = enable;
22270 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22271 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22272 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22273 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22274 vec_free (port_desc);
22275 vec_free (mgmt_oid);
22283 api_tcp_configure_src_addresses (vat_main_t * vam)
22285 vl_api_tcp_configure_src_addresses_t *mp;
22286 unformat_input_t *i = vam->input;
22287 ip4_address_t v4first, v4last;
22288 ip6_address_t v6first, v6last;
22293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22295 if (unformat (i, "%U - %U",
22296 unformat_ip4_address, &v4first,
22297 unformat_ip4_address, &v4last))
22301 errmsg ("one range per message (range already set)");
22306 else if (unformat (i, "%U - %U",
22307 unformat_ip6_address, &v6first,
22308 unformat_ip6_address, &v6last))
22312 errmsg ("one range per message (range already set)");
22317 else if (unformat (i, "vrf %d", &vrf_id))
22323 if (range_set == 0)
22325 errmsg ("address range not set");
22329 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22330 mp->vrf_id = ntohl (vrf_id);
22332 if (range_set == 2)
22335 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22336 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22341 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22342 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22349 static void vl_api_app_namespace_add_del_reply_t_handler
22350 (vl_api_app_namespace_add_del_reply_t * mp)
22352 vat_main_t *vam = &vat_main;
22353 i32 retval = ntohl (mp->retval);
22354 if (vam->async_mode)
22356 vam->async_errors += (retval < 0);
22360 vam->retval = retval;
22362 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22363 vam->result_ready = 1;
22367 static void vl_api_app_namespace_add_del_reply_t_handler_json
22368 (vl_api_app_namespace_add_del_reply_t * mp)
22370 vat_main_t *vam = &vat_main;
22371 vat_json_node_t node;
22373 vat_json_init_object (&node);
22374 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22375 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22377 vat_json_print (vam->ofp, &node);
22378 vat_json_free (&node);
22380 vam->retval = ntohl (mp->retval);
22381 vam->result_ready = 1;
22385 api_app_namespace_add_del (vat_main_t * vam)
22387 vl_api_app_namespace_add_del_t *mp;
22388 unformat_input_t *i = vam->input;
22389 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22390 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22396 if (unformat (i, "id %_%v%_", &ns_id))
22398 else if (unformat (i, "secret %lu", &secret))
22400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22401 sw_if_index_set = 1;
22402 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22404 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22409 if (!ns_id || !secret_set || !sw_if_index_set)
22411 errmsg ("namespace id, secret and sw_if_index must be set");
22414 if (vec_len (ns_id) > 64)
22416 errmsg ("namespace id too long");
22419 M (APP_NAMESPACE_ADD_DEL, mp);
22421 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22422 mp->namespace_id_len = vec_len (ns_id);
22423 mp->secret = clib_host_to_net_u64 (secret);
22424 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22425 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22426 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22434 api_sock_init_shm (vat_main_t * vam)
22436 #if VPP_API_TEST_BUILTIN == 0
22437 unformat_input_t *i = vam->input;
22438 vl_api_shm_elem_config_t *config = 0;
22439 u64 size = 64 << 20;
22442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22444 if (unformat (i, "size %U", unformat_memory_size, &size))
22451 * Canned custom ring allocator config.
22452 * Should probably parse all of this
22454 vec_validate (config, 6);
22455 config[0].type = VL_API_VLIB_RING;
22456 config[0].size = 256;
22457 config[0].count = 32;
22459 config[1].type = VL_API_VLIB_RING;
22460 config[1].size = 1024;
22461 config[1].count = 16;
22463 config[2].type = VL_API_VLIB_RING;
22464 config[2].size = 4096;
22465 config[2].count = 2;
22467 config[3].type = VL_API_CLIENT_RING;
22468 config[3].size = 256;
22469 config[3].count = 32;
22471 config[4].type = VL_API_CLIENT_RING;
22472 config[4].size = 1024;
22473 config[4].count = 16;
22475 config[5].type = VL_API_CLIENT_RING;
22476 config[5].size = 4096;
22477 config[5].count = 2;
22479 config[6].type = VL_API_QUEUE;
22480 config[6].count = 128;
22481 config[6].size = sizeof (uword);
22483 rv = vl_socket_client_init_shm (config);
22485 vam->client_index_invalid = 1;
22493 api_dns_enable_disable (vat_main_t * vam)
22495 unformat_input_t *line_input = vam->input;
22496 vl_api_dns_enable_disable_t *mp;
22497 u8 enable_disable = 1;
22500 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22502 if (unformat (line_input, "disable"))
22503 enable_disable = 0;
22504 if (unformat (line_input, "enable"))
22505 enable_disable = 1;
22510 /* Construct the API message */
22511 M (DNS_ENABLE_DISABLE, mp);
22512 mp->enable = enable_disable;
22516 /* Wait for the reply */
22522 api_dns_resolve_name (vat_main_t * vam)
22524 unformat_input_t *line_input = vam->input;
22525 vl_api_dns_resolve_name_t *mp;
22529 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22531 if (unformat (line_input, "%s", &name))
22537 if (vec_len (name) > 127)
22539 errmsg ("name too long");
22543 /* Construct the API message */
22544 M (DNS_RESOLVE_NAME, mp);
22545 memcpy (mp->name, name, vec_len (name));
22550 /* Wait for the reply */
22556 api_dns_resolve_ip (vat_main_t * vam)
22558 unformat_input_t *line_input = vam->input;
22559 vl_api_dns_resolve_ip_t *mp;
22561 ip4_address_t addr4;
22562 ip6_address_t addr6;
22565 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22567 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22569 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22577 errmsg ("missing address");
22581 /* Construct the API message */
22582 M (DNS_RESOLVE_IP, mp);
22583 mp->is_ip6 = is_ip6;
22585 memcpy (mp->address, &addr6, sizeof (addr6));
22587 memcpy (mp->address, &addr4, sizeof (addr4));
22591 /* Wait for the reply */
22597 api_dns_name_server_add_del (vat_main_t * vam)
22599 unformat_input_t *i = vam->input;
22600 vl_api_dns_name_server_add_del_t *mp;
22602 ip6_address_t ip6_server;
22603 ip4_address_t ip4_server;
22608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22610 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22612 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22614 else if (unformat (i, "del"))
22618 clib_warning ("parse error '%U'", format_unformat_error, i);
22623 if (ip4_set && ip6_set)
22625 errmsg ("Only one server address allowed per message");
22628 if ((ip4_set + ip6_set) == 0)
22630 errmsg ("Server address required");
22634 /* Construct the API message */
22635 M (DNS_NAME_SERVER_ADD_DEL, mp);
22639 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22644 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22648 mp->is_add = is_add;
22653 /* Wait for a reply, return good/bad news */
22659 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22661 vat_main_t *vam = &vat_main;
22666 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22667 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22668 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22669 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22670 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22671 clib_net_to_host_u32 (mp->action_index), mp->tag);
22676 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22677 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22678 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22679 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22680 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22681 clib_net_to_host_u32 (mp->action_index), mp->tag);
22686 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22689 vat_main_t *vam = &vat_main;
22690 vat_json_node_t *node = NULL;
22691 struct in6_addr ip6;
22692 struct in_addr ip4;
22694 if (VAT_JSON_ARRAY != vam->json_tree.type)
22696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22697 vat_json_init_array (&vam->json_tree);
22699 node = vat_json_array_add (&vam->json_tree);
22700 vat_json_init_object (node);
22702 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22703 vat_json_object_add_uint (node, "appns_index",
22704 clib_net_to_host_u32 (mp->appns_index));
22705 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22706 vat_json_object_add_uint (node, "scope", mp->scope);
22707 vat_json_object_add_uint (node, "action_index",
22708 clib_net_to_host_u32 (mp->action_index));
22709 vat_json_object_add_uint (node, "lcl_port",
22710 clib_net_to_host_u16 (mp->lcl_port));
22711 vat_json_object_add_uint (node, "rmt_port",
22712 clib_net_to_host_u16 (mp->rmt_port));
22713 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22714 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22715 vat_json_object_add_string_copy (node, "tag", mp->tag);
22718 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22719 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22720 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22721 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22725 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22726 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22727 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22728 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22733 api_session_rule_add_del (vat_main_t * vam)
22735 vl_api_session_rule_add_del_t *mp;
22736 unformat_input_t *i = vam->input;
22737 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22738 u32 appns_index = 0, scope = 0;
22739 ip4_address_t lcl_ip4, rmt_ip4;
22740 ip6_address_t lcl_ip6, rmt_ip6;
22741 u8 is_ip4 = 1, conn_set = 0;
22742 u8 is_add = 1, *tag = 0;
22745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22747 if (unformat (i, "del"))
22749 else if (unformat (i, "add"))
22751 else if (unformat (i, "proto tcp"))
22753 else if (unformat (i, "proto udp"))
22755 else if (unformat (i, "appns %d", &appns_index))
22757 else if (unformat (i, "scope %d", &scope))
22759 else if (unformat (i, "tag %_%v%_", &tag))
22763 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22764 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22772 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22773 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22779 else if (unformat (i, "action %d", &action))
22784 if (proto == ~0 || !conn_set || action == ~0)
22786 errmsg ("transport proto, connection and action must be set");
22792 errmsg ("scope should be 0-3");
22796 M (SESSION_RULE_ADD_DEL, mp);
22798 mp->is_ip4 = is_ip4;
22799 mp->transport_proto = proto;
22800 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22801 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22802 mp->lcl_plen = lcl_plen;
22803 mp->rmt_plen = rmt_plen;
22804 mp->action_index = clib_host_to_net_u32 (action);
22805 mp->appns_index = clib_host_to_net_u32 (appns_index);
22807 mp->is_add = is_add;
22810 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22811 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22815 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22816 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22820 clib_memcpy (mp->tag, tag, vec_len (tag));
22830 api_session_rules_dump (vat_main_t * vam)
22832 vl_api_session_rules_dump_t *mp;
22833 vl_api_control_ping_t *mp_ping;
22836 if (!vam->json_output)
22838 print (vam->ofp, "%=20s", "Session Rules");
22841 M (SESSION_RULES_DUMP, mp);
22845 /* Use a control ping for synchronization */
22846 MPING (CONTROL_PING, mp_ping);
22849 /* Wait for a reply... */
22855 api_ip_container_proxy_add_del (vat_main_t * vam)
22857 vl_api_ip_container_proxy_add_del_t *mp;
22858 unformat_input_t *i = vam->input;
22859 u32 plen = ~0, sw_if_index = ~0;
22866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22868 if (unformat (i, "del"))
22870 else if (unformat (i, "add"))
22872 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22877 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22882 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22887 if (sw_if_index == ~0 || plen == ~0)
22889 errmsg ("address and sw_if_index must be set");
22893 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22895 mp->is_ip4 = is_ip4;
22896 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22898 mp->is_add = is_add;
22900 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22902 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22910 api_qos_record_enable_disable (vat_main_t * vam)
22912 unformat_input_t *i = vam->input;
22913 vl_api_qos_record_enable_disable_t *mp;
22914 u32 sw_if_index, qs = 0xff;
22915 u8 sw_if_index_set = 0;
22919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22921 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22922 sw_if_index_set = 1;
22923 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22924 sw_if_index_set = 1;
22925 else if (unformat (i, "%U", unformat_qos_source, &qs))
22927 else if (unformat (i, "disable"))
22931 clib_warning ("parse error '%U'", format_unformat_error, i);
22936 if (sw_if_index_set == 0)
22938 errmsg ("missing interface name or sw_if_index");
22943 errmsg ("input location must be specified");
22947 M (QOS_RECORD_ENABLE_DISABLE, mp);
22949 mp->sw_if_index = ntohl (sw_if_index);
22950 mp->input_source = qs;
22951 mp->enable = enable;
22959 q_or_quit (vat_main_t * vam)
22961 #if VPP_API_TEST_BUILTIN == 0
22962 longjmp (vam->jump_buf, 1);
22964 return 0; /* not so much */
22968 q (vat_main_t * vam)
22970 return q_or_quit (vam);
22974 quit (vat_main_t * vam)
22976 return q_or_quit (vam);
22980 comment (vat_main_t * vam)
22986 cmd_cmp (void *a1, void *a2)
22991 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22995 help (vat_main_t * vam)
23000 unformat_input_t *i = vam->input;
23003 if (unformat (i, "%s", &name))
23007 vec_add1 (name, 0);
23009 hs = hash_get_mem (vam->help_by_name, name);
23011 print (vam->ofp, "usage: %s %s", name, hs[0]);
23013 print (vam->ofp, "No such msg / command '%s'", name);
23018 print (vam->ofp, "Help is available for the following:");
23021 hash_foreach_pair (p, vam->function_by_name,
23023 vec_add1 (cmds, (u8 *)(p->key));
23027 vec_sort_with_function (cmds, cmd_cmp);
23029 for (j = 0; j < vec_len (cmds); j++)
23030 print (vam->ofp, "%s", cmds[j]);
23037 set (vat_main_t * vam)
23039 u8 *name = 0, *value = 0;
23040 unformat_input_t *i = vam->input;
23042 if (unformat (i, "%s", &name))
23044 /* The input buffer is a vector, not a string. */
23045 value = vec_dup (i->buffer);
23046 vec_delete (value, i->index, 0);
23047 /* Almost certainly has a trailing newline */
23048 if (value[vec_len (value) - 1] == '\n')
23049 value[vec_len (value) - 1] = 0;
23050 /* Make sure it's a proper string, one way or the other */
23051 vec_add1 (value, 0);
23052 (void) clib_macro_set_value (&vam->macro_main,
23053 (char *) name, (char *) value);
23056 errmsg ("usage: set <name> <value>");
23064 unset (vat_main_t * vam)
23068 if (unformat (vam->input, "%s", &name))
23069 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23070 errmsg ("unset: %s wasn't set", name);
23083 macro_sort_cmp (void *a1, void *a2)
23085 macro_sort_t *s1 = a1;
23086 macro_sort_t *s2 = a2;
23088 return strcmp ((char *) (s1->name), (char *) (s2->name));
23092 dump_macro_table (vat_main_t * vam)
23094 macro_sort_t *sort_me = 0, *sm;
23099 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23101 vec_add2 (sort_me, sm, 1);
23102 sm->name = (u8 *)(p->key);
23103 sm->value = (u8 *) (p->value[0]);
23107 vec_sort_with_function (sort_me, macro_sort_cmp);
23109 if (vec_len (sort_me))
23110 print (vam->ofp, "%-15s%s", "Name", "Value");
23112 print (vam->ofp, "The macro table is empty...");
23114 for (i = 0; i < vec_len (sort_me); i++)
23115 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23120 dump_node_table (vat_main_t * vam)
23123 vlib_node_t *node, *next_node;
23125 if (vec_len (vam->graph_nodes) == 0)
23127 print (vam->ofp, "Node table empty, issue get_node_graph...");
23131 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23133 node = vam->graph_nodes[i];
23134 print (vam->ofp, "[%d] %s", i, node->name);
23135 for (j = 0; j < vec_len (node->next_nodes); j++)
23137 if (node->next_nodes[j] != ~0)
23139 next_node = vam->graph_nodes[node->next_nodes[j]];
23140 print (vam->ofp, " [%d] %s", j, next_node->name);
23148 value_sort_cmp (void *a1, void *a2)
23150 name_sort_t *n1 = a1;
23151 name_sort_t *n2 = a2;
23153 if (n1->value < n2->value)
23155 if (n1->value > n2->value)
23162 dump_msg_api_table (vat_main_t * vam)
23164 api_main_t *am = &api_main;
23165 name_sort_t *nses = 0, *ns;
23170 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23172 vec_add2 (nses, ns, 1);
23173 ns->name = (u8 *)(hp->key);
23174 ns->value = (u32) hp->value[0];
23178 vec_sort_with_function (nses, value_sort_cmp);
23180 for (i = 0; i < vec_len (nses); i++)
23181 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23187 get_msg_id (vat_main_t * vam)
23192 if (unformat (vam->input, "%s", &name_and_crc))
23194 message_index = vl_msg_api_get_msg_index (name_and_crc);
23195 if (message_index == ~0)
23197 print (vam->ofp, " '%s' not found", name_and_crc);
23200 print (vam->ofp, " '%s' has message index %d",
23201 name_and_crc, message_index);
23204 errmsg ("name_and_crc required...");
23209 search_node_table (vat_main_t * vam)
23211 unformat_input_t *line_input = vam->input;
23214 vlib_node_t *node, *next_node;
23217 if (vam->graph_node_index_by_name == 0)
23219 print (vam->ofp, "Node table empty, issue get_node_graph...");
23223 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23225 if (unformat (line_input, "%s", &node_to_find))
23227 vec_add1 (node_to_find, 0);
23228 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23231 print (vam->ofp, "%s not found...", node_to_find);
23234 node = vam->graph_nodes[p[0]];
23235 print (vam->ofp, "[%d] %s", p[0], node->name);
23236 for (j = 0; j < vec_len (node->next_nodes); j++)
23238 if (node->next_nodes[j] != ~0)
23240 next_node = vam->graph_nodes[node->next_nodes[j]];
23241 print (vam->ofp, " [%d] %s", j, next_node->name);
23248 clib_warning ("parse error '%U'", format_unformat_error,
23254 vec_free (node_to_find);
23263 script (vat_main_t * vam)
23265 #if (VPP_API_TEST_BUILTIN==0)
23267 char *save_current_file;
23268 unformat_input_t save_input;
23269 jmp_buf save_jump_buf;
23270 u32 save_line_number;
23272 FILE *new_fp, *save_ifp;
23274 if (unformat (vam->input, "%s", &s))
23276 new_fp = fopen ((char *) s, "r");
23279 errmsg ("Couldn't open script file %s", s);
23286 errmsg ("Missing script name");
23290 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23291 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23292 save_ifp = vam->ifp;
23293 save_line_number = vam->input_line_number;
23294 save_current_file = (char *) vam->current_file;
23296 vam->input_line_number = 0;
23298 vam->current_file = s;
23301 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
23302 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23303 vam->ifp = save_ifp;
23304 vam->input_line_number = save_line_number;
23305 vam->current_file = (u8 *) save_current_file;
23310 clib_warning ("use the exec command...");
23316 echo (vat_main_t * vam)
23318 print (vam->ofp, "%v", vam->input->buffer);
23322 /* List of API message constructors, CLI names map to api_xxx */
23323 #define foreach_vpe_api_msg \
23324 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23325 _(sw_interface_dump,"") \
23326 _(sw_interface_set_flags, \
23327 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23328 _(sw_interface_add_del_address, \
23329 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23330 _(sw_interface_set_rx_mode, \
23331 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23332 _(sw_interface_set_table, \
23333 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23334 _(sw_interface_set_mpls_enable, \
23335 "<intfc> | sw_if_index [disable | dis]") \
23336 _(sw_interface_set_vpath, \
23337 "<intfc> | sw_if_index <id> enable | disable") \
23338 _(sw_interface_set_vxlan_bypass, \
23339 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23340 _(sw_interface_set_geneve_bypass, \
23341 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23342 _(sw_interface_set_l2_xconnect, \
23343 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23344 "enable | disable") \
23345 _(sw_interface_set_l2_bridge, \
23346 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23347 "[shg <split-horizon-group>] [bvi]\n" \
23348 "enable | disable") \
23349 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23350 _(bridge_domain_add_del, \
23351 "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") \
23352 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23354 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23355 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23356 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23358 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23360 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23362 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23364 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23366 "<vpp-if-name> | sw_if_index <id>") \
23367 _(sw_interface_tap_dump, "") \
23369 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23371 "<vpp-if-name> | sw_if_index <id>") \
23372 _(sw_interface_tap_v2_dump, "") \
23374 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23375 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23377 "<vpp-if-name> | sw_if_index <id>") \
23379 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23380 _(bond_detach_slave, \
23381 "sw_if_index <n>") \
23382 _(sw_interface_bond_dump, "") \
23383 _(sw_interface_slave_dump, \
23384 "<vpp-if-name> | sw_if_index <id>") \
23385 _(ip_table_add_del, \
23386 "table-id <n> [ipv6]\n") \
23387 _(ip_add_del_route, \
23388 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23389 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23390 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23391 "[multipath] [count <n>]") \
23392 _(ip_mroute_add_del, \
23393 "<src> <grp>/<mask> [table-id <n>]\n" \
23394 "[<intfc> | sw_if_index <id>] [local] [del]") \
23395 _(mpls_table_add_del, \
23396 "table-id <n>\n") \
23397 _(mpls_route_add_del, \
23398 "<label> <eos> via <addr> [table-id <n>]\n" \
23399 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23400 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23401 "[multipath] [count <n>]") \
23402 _(mpls_ip_bind_unbind, \
23403 "<label> <addr/len>") \
23404 _(mpls_tunnel_add_del, \
23405 " via <addr> [table-id <n>]\n" \
23406 "sw_if_index <id>] [l2] [del]") \
23407 _(bier_table_add_del, \
23408 "<label> <sub-domain> <set> <bsl> [del]") \
23409 _(bier_route_add_del, \
23410 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23411 "[<intfc> | sw_if_index <id>]" \
23412 "[weight <n>] [del] [multipath]") \
23413 _(proxy_arp_add_del, \
23414 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23415 _(proxy_arp_intfc_enable_disable, \
23416 "<intfc> | sw_if_index <id> enable | disable") \
23417 _(sw_interface_set_unnumbered, \
23418 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23419 _(ip_neighbor_add_del, \
23420 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23421 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23422 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23423 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23424 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23425 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23426 "[outer_vlan_id_any][inner_vlan_id_any]") \
23427 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23428 _(reset_fib, "vrf <n> [ipv6]") \
23429 _(dhcp_proxy_config, \
23430 "svr <v46-address> src <v46-address>\n" \
23431 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23432 _(dhcp_proxy_set_vss, \
23433 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23434 _(dhcp_proxy_dump, "ip6") \
23435 _(dhcp_client_config, \
23436 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23437 _(set_ip_flow_hash, \
23438 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23439 _(sw_interface_ip6_enable_disable, \
23440 "<intfc> | sw_if_index <id> enable | disable") \
23441 _(sw_interface_ip6_set_link_local_address, \
23442 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23443 _(ip6nd_proxy_add_del, \
23444 "<intfc> | sw_if_index <id> <ip6-address>") \
23445 _(ip6nd_proxy_dump, "") \
23446 _(sw_interface_ip6nd_ra_prefix, \
23447 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23448 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23449 "[nolink] [isno]") \
23450 _(sw_interface_ip6nd_ra_config, \
23451 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23452 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23453 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23454 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23455 _(l2_patch_add_del, \
23456 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23457 "enable | disable") \
23458 _(sr_localsid_add_del, \
23459 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23460 "fib-table <num> (end.psp) sw_if_index <num>") \
23461 _(classify_add_del_table, \
23462 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23463 " [del] [del-chain] mask <mask-value>\n" \
23464 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23465 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23466 _(classify_add_del_session, \
23467 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23468 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23469 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23470 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23471 _(classify_set_interface_ip_table, \
23472 "<intfc> | sw_if_index <nn> table <nn>") \
23473 _(classify_set_interface_l2_tables, \
23474 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23475 " [other-table <nn>]") \
23476 _(get_node_index, "node <node-name") \
23477 _(add_node_next, "node <node-name> next <next-node-name>") \
23478 _(l2tpv3_create_tunnel, \
23479 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23480 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23481 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23482 _(l2tpv3_set_tunnel_cookies, \
23483 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23484 "[new_remote_cookie <nn>]\n") \
23485 _(l2tpv3_interface_enable_disable, \
23486 "<intfc> | sw_if_index <nn> enable | disable") \
23487 _(l2tpv3_set_lookup_key, \
23488 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23489 _(sw_if_l2tpv3_tunnel_dump, "") \
23490 _(vxlan_add_del_tunnel, \
23491 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23492 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23493 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23494 _(geneve_add_del_tunnel, \
23495 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23496 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23497 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23498 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23499 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23500 _(gre_add_del_tunnel, \
23501 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23502 "[teb | erspan <session-id>] [del]") \
23503 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23504 _(l2_fib_clear_table, "") \
23505 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23506 _(l2_interface_vlan_tag_rewrite, \
23507 "<intfc> | sw_if_index <nn> \n" \
23508 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23509 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23510 _(create_vhost_user_if, \
23511 "socket <filename> [server] [renumber <dev_instance>] " \
23512 "[mac <mac_address>]") \
23513 _(modify_vhost_user_if, \
23514 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23515 "[server] [renumber <dev_instance>]") \
23516 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23517 _(sw_interface_vhost_user_dump, "") \
23518 _(show_version, "") \
23519 _(vxlan_gpe_add_del_tunnel, \
23520 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23521 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23522 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23523 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23524 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23525 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23526 _(interface_name_renumber, \
23527 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23528 _(input_acl_set_interface, \
23529 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23530 " [l2-table <nn>] [del]") \
23531 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23532 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23533 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23534 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23535 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23536 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23537 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23538 _(ip_dump, "ipv4 | ipv6") \
23539 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23540 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23542 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23543 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23544 " integ_alg <alg> integ_key <hex>") \
23545 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23546 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23547 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23548 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23549 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23550 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23551 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23552 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23553 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23554 " [instance <n>]") \
23555 _(ipsec_sa_dump, "[sa_id <n>]") \
23556 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23557 " <alg> <hex>\n") \
23558 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23559 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23560 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23561 "(auth_data 0x<data> | auth_data <data>)") \
23562 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23563 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23564 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23565 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23566 "(local|remote)") \
23567 _(ikev2_set_local_key, "file <absolute_file_path>") \
23568 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23569 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23570 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23571 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23572 _(ikev2_initiate_sa_init, "<profile_name>") \
23573 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23574 _(ikev2_initiate_del_child_sa, "<ispi>") \
23575 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23576 _(delete_loopback,"sw_if_index <nn>") \
23577 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23578 _(map_add_domain, \
23579 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23580 "ip6-src <ip6addr> " \
23581 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23582 _(map_del_domain, "index <n>") \
23583 _(map_add_del_rule, \
23584 "index <n> psid <n> dst <ip6addr> [del]") \
23585 _(map_domain_dump, "") \
23586 _(map_rule_dump, "index <map-domain>") \
23587 _(want_interface_events, "enable|disable") \
23588 _(want_stats,"enable|disable") \
23589 _(get_first_msg_id, "client <name>") \
23590 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23591 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23592 "fib-id <nn> [ip4][ip6][default]") \
23593 _(get_node_graph, " ") \
23594 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23595 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23596 _(ioam_disable, "") \
23597 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23598 " sw_if_index <sw_if_index> p <priority> " \
23599 "w <weight>] [del]") \
23600 _(one_add_del_locator, "locator-set <locator_name> " \
23601 "iface <intf> | sw_if_index <sw_if_index> " \
23602 "p <priority> w <weight> [del]") \
23603 _(one_add_del_local_eid,"vni <vni> eid " \
23604 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23605 "locator-set <locator_name> [del]" \
23606 "[key-id sha1|sha256 secret-key <secret-key>]")\
23607 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23608 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23609 _(one_enable_disable, "enable|disable") \
23610 _(one_map_register_enable_disable, "enable|disable") \
23611 _(one_map_register_fallback_threshold, "<value>") \
23612 _(one_rloc_probe_enable_disable, "enable|disable") \
23613 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23615 "rloc <locator> p <prio> " \
23616 "w <weight> [rloc <loc> ... ] " \
23617 "action <action> [del-all]") \
23618 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23620 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23621 _(one_use_petr, "ip-address> | disable") \
23622 _(one_map_request_mode, "src-dst|dst-only") \
23623 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23624 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23625 _(one_locator_set_dump, "[local | remote]") \
23626 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23627 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23628 "[local] | [remote]") \
23629 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23630 _(one_ndp_bd_get, "") \
23631 _(one_ndp_entries_get, "bd <bridge-domain>") \
23632 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23633 _(one_l2_arp_bd_get, "") \
23634 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23635 _(one_stats_enable_disable, "enable|disalbe") \
23636 _(show_one_stats_enable_disable, "") \
23637 _(one_eid_table_vni_dump, "") \
23638 _(one_eid_table_map_dump, "l2|l3") \
23639 _(one_map_resolver_dump, "") \
23640 _(one_map_server_dump, "") \
23641 _(one_adjacencies_get, "vni <vni>") \
23642 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23643 _(show_one_rloc_probe_state, "") \
23644 _(show_one_map_register_state, "") \
23645 _(show_one_status, "") \
23646 _(one_stats_dump, "") \
23647 _(one_stats_flush, "") \
23648 _(one_get_map_request_itr_rlocs, "") \
23649 _(one_map_register_set_ttl, "<ttl>") \
23650 _(one_set_transport_protocol, "udp|api") \
23651 _(one_get_transport_protocol, "") \
23652 _(one_enable_disable_xtr_mode, "enable|disable") \
23653 _(one_show_xtr_mode, "") \
23654 _(one_enable_disable_pitr_mode, "enable|disable") \
23655 _(one_show_pitr_mode, "") \
23656 _(one_enable_disable_petr_mode, "enable|disable") \
23657 _(one_show_petr_mode, "") \
23658 _(show_one_nsh_mapping, "") \
23659 _(show_one_pitr, "") \
23660 _(show_one_use_petr, "") \
23661 _(show_one_map_request_mode, "") \
23662 _(show_one_map_register_ttl, "") \
23663 _(show_one_map_register_fallback_threshold, "") \
23664 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23665 " sw_if_index <sw_if_index> p <priority> " \
23666 "w <weight>] [del]") \
23667 _(lisp_add_del_locator, "locator-set <locator_name> " \
23668 "iface <intf> | sw_if_index <sw_if_index> " \
23669 "p <priority> w <weight> [del]") \
23670 _(lisp_add_del_local_eid,"vni <vni> eid " \
23671 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23672 "locator-set <locator_name> [del]" \
23673 "[key-id sha1|sha256 secret-key <secret-key>]") \
23674 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23675 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23676 _(lisp_enable_disable, "enable|disable") \
23677 _(lisp_map_register_enable_disable, "enable|disable") \
23678 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23679 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23681 "rloc <locator> p <prio> " \
23682 "w <weight> [rloc <loc> ... ] " \
23683 "action <action> [del-all]") \
23684 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23686 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23687 _(lisp_use_petr, "<ip-address> | disable") \
23688 _(lisp_map_request_mode, "src-dst|dst-only") \
23689 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23690 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23691 _(lisp_locator_set_dump, "[local | remote]") \
23692 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23693 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23694 "[local] | [remote]") \
23695 _(lisp_eid_table_vni_dump, "") \
23696 _(lisp_eid_table_map_dump, "l2|l3") \
23697 _(lisp_map_resolver_dump, "") \
23698 _(lisp_map_server_dump, "") \
23699 _(lisp_adjacencies_get, "vni <vni>") \
23700 _(gpe_fwd_entry_vnis_get, "") \
23701 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23702 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23703 "[table <table-id>]") \
23704 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23705 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23706 _(gpe_set_encap_mode, "lisp|vxlan") \
23707 _(gpe_get_encap_mode, "") \
23708 _(lisp_gpe_add_del_iface, "up|down") \
23709 _(lisp_gpe_enable_disable, "enable|disable") \
23710 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23711 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23712 _(show_lisp_rloc_probe_state, "") \
23713 _(show_lisp_map_register_state, "") \
23714 _(show_lisp_status, "") \
23715 _(lisp_get_map_request_itr_rlocs, "") \
23716 _(show_lisp_pitr, "") \
23717 _(show_lisp_use_petr, "") \
23718 _(show_lisp_map_request_mode, "") \
23719 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23720 _(af_packet_delete, "name <host interface name>") \
23721 _(af_packet_dump, "") \
23722 _(policer_add_del, "name <policer name> <params> [del]") \
23723 _(policer_dump, "[name <policer name>]") \
23724 _(policer_classify_set_interface, \
23725 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23726 " [l2-table <nn>] [del]") \
23727 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23728 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23729 "[master|slave]") \
23730 _(netmap_delete, "name <interface name>") \
23731 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23732 _(mpls_fib_dump, "") \
23733 _(classify_table_ids, "") \
23734 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23735 _(classify_table_info, "table_id <nn>") \
23736 _(classify_session_dump, "table_id <nn>") \
23737 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23738 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23739 "[template_interval <nn>] [udp_checksum]") \
23740 _(ipfix_exporter_dump, "") \
23741 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23742 _(ipfix_classify_stream_dump, "") \
23743 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23744 _(ipfix_classify_table_dump, "") \
23745 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23746 _(sw_interface_span_dump, "[l2]") \
23747 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23748 _(pg_create_interface, "if_id <nn>") \
23749 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23750 _(pg_enable_disable, "[stream <id>] disable") \
23751 _(ip_source_and_port_range_check_add_del, \
23752 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23753 _(ip_source_and_port_range_check_interface_add_del, \
23754 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23755 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23756 _(ipsec_gre_add_del_tunnel, \
23757 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23758 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23759 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23760 _(l2_interface_pbb_tag_rewrite, \
23761 "<intfc> | sw_if_index <nn> \n" \
23762 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23763 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23764 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23765 _(flow_classify_set_interface, \
23766 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23767 _(flow_classify_dump, "type [ip4|ip6]") \
23768 _(ip_fib_dump, "") \
23769 _(ip_mfib_dump, "") \
23770 _(ip6_fib_dump, "") \
23771 _(ip6_mfib_dump, "") \
23772 _(feature_enable_disable, "arc_name <arc_name> " \
23773 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23774 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23776 _(l2_xconnect_dump, "") \
23777 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23778 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23779 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23780 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23781 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23782 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23783 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23784 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23785 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23786 _(sock_init_shm, "size <nnn>") \
23787 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23788 _(dns_enable_disable, "[enable][disable]") \
23789 _(dns_name_server_add_del, "<ip-address> [del]") \
23790 _(dns_resolve_name, "<hostname>") \
23791 _(dns_resolve_ip, "<ip4|ip6>") \
23792 _(dns_name_server_add_del, "<ip-address> [del]") \
23793 _(dns_resolve_name, "<hostname>") \
23794 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23795 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23796 _(session_rules_dump, "") \
23797 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23798 _(output_acl_set_interface, \
23799 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23800 " [l2-table <nn>] [del]") \
23801 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23803 /* List of command functions, CLI names map directly to functions */
23804 #define foreach_cli_function \
23805 _(comment, "usage: comment <ignore-rest-of-line>") \
23806 _(dump_interface_table, "usage: dump_interface_table") \
23807 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23808 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23809 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23810 _(dump_stats_table, "usage: dump_stats_table") \
23811 _(dump_macro_table, "usage: dump_macro_table ") \
23812 _(dump_node_table, "usage: dump_node_table") \
23813 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23814 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23815 _(echo, "usage: echo <message>") \
23816 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23817 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23818 _(help, "usage: help") \
23819 _(q, "usage: quit") \
23820 _(quit, "usage: quit") \
23821 _(search_node_table, "usage: search_node_table <name>...") \
23822 _(set, "usage: set <variable-name> <value>") \
23823 _(script, "usage: script <file-name>") \
23824 _(unset, "usage: unset <variable-name>")
23826 static void vl_api_##n##_t_handler_uni \
23827 (vl_api_##n##_t * mp) \
23829 vat_main_t * vam = &vat_main; \
23830 if (vam->json_output) { \
23831 vl_api_##n##_t_handler_json(mp); \
23833 vl_api_##n##_t_handler(mp); \
23836 foreach_vpe_api_reply_msg;
23837 #if VPP_API_TEST_BUILTIN == 0
23838 foreach_standalone_reply_msg;
23843 vat_api_hookup (vat_main_t * vam)
23846 vl_msg_api_set_handlers(VL_API_##N, #n, \
23847 vl_api_##n##_t_handler_uni, \
23849 vl_api_##n##_t_endian, \
23850 vl_api_##n##_t_print, \
23851 sizeof(vl_api_##n##_t), 1);
23852 foreach_vpe_api_reply_msg;
23853 #if VPP_API_TEST_BUILTIN == 0
23854 foreach_standalone_reply_msg;
23858 #if (VPP_API_TEST_BUILTIN==0)
23859 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23861 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23863 vam->function_by_name = hash_create_string (0, sizeof (uword));
23865 vam->help_by_name = hash_create_string (0, sizeof (uword));
23868 /* API messages we can send */
23869 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23870 foreach_vpe_api_msg;
23874 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23875 foreach_vpe_api_msg;
23878 /* CLI functions */
23879 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23880 foreach_cli_function;
23884 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23885 foreach_cli_function;
23889 #if VPP_API_TEST_BUILTIN
23890 static clib_error_t *
23891 vat_api_hookup_shim (vlib_main_t * vm)
23893 vat_api_hookup (&vat_main);
23897 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23901 * fd.io coding-style-patch-verification: ON
23904 * eval: (c-set-style "gnu")