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 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5829 _(POLICER_DETAILS, policer_details) \
5830 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5831 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5832 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5833 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5834 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5835 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5836 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5837 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5838 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5839 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5840 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5841 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5842 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5843 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5844 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5845 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5846 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5847 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5848 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5849 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5850 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5851 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5852 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5853 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5854 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5855 ip_source_and_port_range_check_add_del_reply) \
5856 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5857 ip_source_and_port_range_check_interface_add_del_reply) \
5858 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5859 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5860 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5861 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5862 _(PUNT_REPLY, punt_reply) \
5863 _(IP_FIB_DETAILS, ip_fib_details) \
5864 _(IP6_FIB_DETAILS, ip6_fib_details) \
5865 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5866 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5867 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5868 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5869 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5870 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5871 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5872 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5873 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5874 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5875 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5876 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5877 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5878 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5879 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5880 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5881 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5882 _(SESSION_RULES_DETAILS, session_rules_details) \
5883 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5884 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5885 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5887 #define foreach_standalone_reply_msg \
5888 _(SW_INTERFACE_EVENT, sw_interface_event) \
5889 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5890 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5891 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5892 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5893 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5894 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5902 #define STR_VTR_OP_CASE(op) \
5903 case L2_VTR_ ## op: \
5907 str_vtr_op (u32 vtr_op)
5911 STR_VTR_OP_CASE (DISABLED);
5912 STR_VTR_OP_CASE (PUSH_1);
5913 STR_VTR_OP_CASE (PUSH_2);
5914 STR_VTR_OP_CASE (POP_1);
5915 STR_VTR_OP_CASE (POP_2);
5916 STR_VTR_OP_CASE (TRANSLATE_1_1);
5917 STR_VTR_OP_CASE (TRANSLATE_1_2);
5918 STR_VTR_OP_CASE (TRANSLATE_2_1);
5919 STR_VTR_OP_CASE (TRANSLATE_2_2);
5926 dump_sub_interface_table (vat_main_t * vam)
5928 const sw_interface_subif_t *sub = NULL;
5930 if (vam->json_output)
5933 ("JSON output supported only for VPE API calls and dump_stats_table");
5938 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5939 "Interface", "sw_if_index",
5940 "sub id", "dot1ad", "tags", "outer id",
5941 "inner id", "exact", "default", "outer any", "inner any");
5943 vec_foreach (sub, vam->sw_if_subif_table)
5946 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5947 sub->interface_name,
5949 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5950 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5951 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5952 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5953 if (sub->vtr_op != L2_VTR_DISABLED)
5956 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5957 "tag1: %d tag2: %d ]",
5958 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5959 sub->vtr_tag1, sub->vtr_tag2);
5967 name_sort_cmp (void *a1, void *a2)
5969 name_sort_t *n1 = a1;
5970 name_sort_t *n2 = a2;
5972 return strcmp ((char *) n1->name, (char *) n2->name);
5976 dump_interface_table (vat_main_t * vam)
5979 name_sort_t *nses = 0, *ns;
5981 if (vam->json_output)
5984 ("JSON output supported only for VPE API calls and dump_stats_table");
5989 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5991 vec_add2 (nses, ns, 1);
5992 ns->name = (u8 *)(p->key);
5993 ns->value = (u32) p->value[0];
5997 vec_sort_with_function (nses, name_sort_cmp);
5999 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
6000 vec_foreach (ns, nses)
6002 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
6009 dump_ip_table (vat_main_t * vam, int is_ipv6)
6011 const ip_details_t *det = NULL;
6012 const ip_address_details_t *address = NULL;
6015 print (vam->ofp, "%-12s", "sw_if_index");
6017 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
6024 print (vam->ofp, "%-12d", i);
6025 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
6030 vec_foreach (address, det->addr)
6034 is_ipv6 ? format_ip6_address : format_ip4_address,
6035 address->ip, address->prefix_length);
6043 dump_ipv4_table (vat_main_t * vam)
6045 if (vam->json_output)
6048 ("JSON output supported only for VPE API calls and dump_stats_table");
6052 return dump_ip_table (vam, 0);
6056 dump_ipv6_table (vat_main_t * vam)
6058 if (vam->json_output)
6061 ("JSON output supported only for VPE API calls and dump_stats_table");
6065 return dump_ip_table (vam, 1);
6069 counter_type_to_str (u8 counter_type, u8 is_combined)
6073 switch (counter_type)
6075 case VNET_INTERFACE_COUNTER_DROP:
6077 case VNET_INTERFACE_COUNTER_PUNT:
6079 case VNET_INTERFACE_COUNTER_IP4:
6081 case VNET_INTERFACE_COUNTER_IP6:
6083 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
6085 case VNET_INTERFACE_COUNTER_RX_MISS:
6087 case VNET_INTERFACE_COUNTER_RX_ERROR:
6089 case VNET_INTERFACE_COUNTER_TX_ERROR:
6092 return "INVALID-COUNTER-TYPE";
6097 switch (counter_type)
6099 case VNET_INTERFACE_COUNTER_RX:
6101 case VNET_INTERFACE_COUNTER_TX:
6104 return "INVALID-COUNTER-TYPE";
6110 dump_stats_table (vat_main_t * vam)
6112 vat_json_node_t node;
6113 vat_json_node_t *msg_array;
6114 vat_json_node_t *msg;
6115 vat_json_node_t *counter_array;
6116 vat_json_node_t *counter;
6117 interface_counter_t c;
6119 ip4_fib_counter_t *c4;
6120 ip6_fib_counter_t *c6;
6121 ip4_nbr_counter_t *n4;
6122 ip6_nbr_counter_t *n6;
6125 if (!vam->json_output)
6127 clib_warning ("dump_stats_table supported only in JSON format");
6131 vat_json_init_object (&node);
6133 /* interface counters */
6134 msg_array = vat_json_object_add (&node, "interface_counters");
6135 vat_json_init_array (msg_array);
6136 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
6138 msg = vat_json_array_add (msg_array);
6139 vat_json_init_object (msg);
6140 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6141 (u8 *) counter_type_to_str (i, 0));
6142 vat_json_object_add_int (msg, "is_combined", 0);
6143 counter_array = vat_json_object_add (msg, "data");
6144 vat_json_init_array (counter_array);
6145 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
6147 packets = vam->simple_interface_counters[i][j];
6148 vat_json_array_add_uint (counter_array, packets);
6151 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
6153 msg = vat_json_array_add (msg_array);
6154 vat_json_init_object (msg);
6155 vat_json_object_add_string_copy (msg, "vnet_counter_type",
6156 (u8 *) counter_type_to_str (i, 1));
6157 vat_json_object_add_int (msg, "is_combined", 1);
6158 counter_array = vat_json_object_add (msg, "data");
6159 vat_json_init_array (counter_array);
6160 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
6162 c = vam->combined_interface_counters[i][j];
6163 counter = vat_json_array_add (counter_array);
6164 vat_json_init_object (counter);
6165 vat_json_object_add_uint (counter, "packets", c.packets);
6166 vat_json_object_add_uint (counter, "bytes", c.bytes);
6170 /* ip4 fib counters */
6171 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
6172 vat_json_init_array (msg_array);
6173 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
6175 msg = vat_json_array_add (msg_array);
6176 vat_json_init_object (msg);
6177 vat_json_object_add_uint (msg, "vrf_id",
6178 vam->ip4_fib_counters_vrf_id_by_index[i]);
6179 counter_array = vat_json_object_add (msg, "c");
6180 vat_json_init_array (counter_array);
6181 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
6183 counter = vat_json_array_add (counter_array);
6184 vat_json_init_object (counter);
6185 c4 = &vam->ip4_fib_counters[i][j];
6186 vat_json_object_add_ip4 (counter, "address", c4->address);
6187 vat_json_object_add_uint (counter, "address_length",
6188 c4->address_length);
6189 vat_json_object_add_uint (counter, "packets", c4->packets);
6190 vat_json_object_add_uint (counter, "bytes", c4->bytes);
6194 /* ip6 fib counters */
6195 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
6196 vat_json_init_array (msg_array);
6197 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
6199 msg = vat_json_array_add (msg_array);
6200 vat_json_init_object (msg);
6201 vat_json_object_add_uint (msg, "vrf_id",
6202 vam->ip6_fib_counters_vrf_id_by_index[i]);
6203 counter_array = vat_json_object_add (msg, "c");
6204 vat_json_init_array (counter_array);
6205 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
6207 counter = vat_json_array_add (counter_array);
6208 vat_json_init_object (counter);
6209 c6 = &vam->ip6_fib_counters[i][j];
6210 vat_json_object_add_ip6 (counter, "address", c6->address);
6211 vat_json_object_add_uint (counter, "address_length",
6212 c6->address_length);
6213 vat_json_object_add_uint (counter, "packets", c6->packets);
6214 vat_json_object_add_uint (counter, "bytes", c6->bytes);
6218 /* ip4 nbr counters */
6219 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
6220 vat_json_init_array (msg_array);
6221 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
6223 msg = vat_json_array_add (msg_array);
6224 vat_json_init_object (msg);
6225 vat_json_object_add_uint (msg, "sw_if_index", i);
6226 counter_array = vat_json_object_add (msg, "c");
6227 vat_json_init_array (counter_array);
6228 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
6230 counter = vat_json_array_add (counter_array);
6231 vat_json_init_object (counter);
6232 n4 = &vam->ip4_nbr_counters[i][j];
6233 vat_json_object_add_ip4 (counter, "address", n4->address);
6234 vat_json_object_add_uint (counter, "link-type", n4->linkt);
6235 vat_json_object_add_uint (counter, "packets", n4->packets);
6236 vat_json_object_add_uint (counter, "bytes", n4->bytes);
6240 /* ip6 nbr counters */
6241 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
6242 vat_json_init_array (msg_array);
6243 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
6245 msg = vat_json_array_add (msg_array);
6246 vat_json_init_object (msg);
6247 vat_json_object_add_uint (msg, "sw_if_index", i);
6248 counter_array = vat_json_object_add (msg, "c");
6249 vat_json_init_array (counter_array);
6250 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6252 counter = vat_json_array_add (counter_array);
6253 vat_json_init_object (counter);
6254 n6 = &vam->ip6_nbr_counters[i][j];
6255 vat_json_object_add_ip6 (counter, "address", n6->address);
6256 vat_json_object_add_uint (counter, "packets", n6->packets);
6257 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6261 vat_json_print (vam->ofp, &node);
6262 vat_json_free (&node);
6268 * Pass CLI buffers directly in the CLI_INBAND API message,
6269 * instead of an additional shared memory area.
6272 exec_inband (vat_main_t * vam)
6274 vl_api_cli_inband_t *mp;
6275 unformat_input_t *i = vam->input;
6278 if (vec_len (i->buffer) == 0)
6281 if (vam->exec_mode == 0 && unformat (i, "mode"))
6286 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6293 * In order for the CLI command to work, it
6294 * must be a vector ending in \n, not a C-string ending
6297 u32 len = vec_len (vam->input->buffer);
6298 M2 (CLI_INBAND, mp, len);
6299 clib_memcpy (mp->cmd, vam->input->buffer, len);
6300 mp->length = htonl (len);
6304 /* json responses may or may not include a useful reply... */
6305 if (vec_len (vam->cmd_reply))
6306 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6311 exec (vat_main_t * vam)
6313 return exec_inband (vam);
6317 api_create_loopback (vat_main_t * vam)
6319 unformat_input_t *i = vam->input;
6320 vl_api_create_loopback_t *mp;
6321 vl_api_create_loopback_instance_t *mp_lbi;
6324 u8 is_specified = 0;
6325 u32 user_instance = 0;
6328 memset (mac_address, 0, sizeof (mac_address));
6330 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6332 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6334 if (unformat (i, "instance %d", &user_instance))
6342 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6343 mp_lbi->is_specified = is_specified;
6345 mp_lbi->user_instance = htonl (user_instance);
6347 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6352 /* Construct the API message */
6353 M (CREATE_LOOPBACK, mp);
6355 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6364 api_delete_loopback (vat_main_t * vam)
6366 unformat_input_t *i = vam->input;
6367 vl_api_delete_loopback_t *mp;
6368 u32 sw_if_index = ~0;
6371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6373 if (unformat (i, "sw_if_index %d", &sw_if_index))
6379 if (sw_if_index == ~0)
6381 errmsg ("missing sw_if_index");
6385 /* Construct the API message */
6386 M (DELETE_LOOPBACK, mp);
6387 mp->sw_if_index = ntohl (sw_if_index);
6395 api_want_stats (vat_main_t * vam)
6397 unformat_input_t *i = vam->input;
6398 vl_api_want_stats_t *mp;
6402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6404 if (unformat (i, "enable"))
6406 else if (unformat (i, "disable"))
6414 errmsg ("missing enable|disable");
6419 mp->enable_disable = enable;
6427 api_want_interface_events (vat_main_t * vam)
6429 unformat_input_t *i = vam->input;
6430 vl_api_want_interface_events_t *mp;
6434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6436 if (unformat (i, "enable"))
6438 else if (unformat (i, "disable"))
6446 errmsg ("missing enable|disable");
6450 M (WANT_INTERFACE_EVENTS, mp);
6451 mp->enable_disable = enable;
6453 vam->interface_event_display = enable;
6461 /* Note: non-static, called once to set up the initial intfc table */
6463 api_sw_interface_dump (vat_main_t * vam)
6465 vl_api_sw_interface_dump_t *mp;
6466 vl_api_control_ping_t *mp_ping;
6468 name_sort_t *nses = 0, *ns;
6469 sw_interface_subif_t *sub = NULL;
6472 /* Toss the old name table */
6474 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6476 vec_add2 (nses, ns, 1);
6477 ns->name = (u8 *)(p->key);
6478 ns->value = (u32) p->value[0];
6482 hash_free (vam->sw_if_index_by_interface_name);
6484 vec_foreach (ns, nses) vec_free (ns->name);
6488 vec_foreach (sub, vam->sw_if_subif_table)
6490 vec_free (sub->interface_name);
6492 vec_free (vam->sw_if_subif_table);
6494 /* recreate the interface name hash table */
6495 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6498 * Ask for all interface names. Otherwise, the epic catalog of
6499 * name filters becomes ridiculously long, and vat ends up needing
6500 * to be taught about new interface types.
6502 M (SW_INTERFACE_DUMP, mp);
6505 /* Use a control ping for synchronization */
6506 MPING (CONTROL_PING, mp_ping);
6514 api_sw_interface_set_flags (vat_main_t * vam)
6516 unformat_input_t *i = vam->input;
6517 vl_api_sw_interface_set_flags_t *mp;
6519 u8 sw_if_index_set = 0;
6523 /* Parse args required to build the message */
6524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6526 if (unformat (i, "admin-up"))
6528 else if (unformat (i, "admin-down"))
6531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6534 sw_if_index_set = 1;
6539 if (sw_if_index_set == 0)
6541 errmsg ("missing interface name or sw_if_index");
6545 /* Construct the API message */
6546 M (SW_INTERFACE_SET_FLAGS, mp);
6547 mp->sw_if_index = ntohl (sw_if_index);
6548 mp->admin_up_down = admin_up;
6553 /* Wait for a reply, return the good/bad news... */
6559 api_sw_interface_set_rx_mode (vat_main_t * vam)
6561 unformat_input_t *i = vam->input;
6562 vl_api_sw_interface_set_rx_mode_t *mp;
6564 u8 sw_if_index_set = 0;
6566 u8 queue_id_valid = 0;
6568 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6570 /* Parse args required to build the message */
6571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6573 if (unformat (i, "queue %d", &queue_id))
6575 else if (unformat (i, "polling"))
6576 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6577 else if (unformat (i, "interrupt"))
6578 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6579 else if (unformat (i, "adaptive"))
6580 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6585 sw_if_index_set = 1;
6590 if (sw_if_index_set == 0)
6592 errmsg ("missing interface name or sw_if_index");
6595 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6597 errmsg ("missing rx-mode");
6601 /* Construct the API message */
6602 M (SW_INTERFACE_SET_RX_MODE, mp);
6603 mp->sw_if_index = ntohl (sw_if_index);
6605 mp->queue_id_valid = queue_id_valid;
6606 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6611 /* Wait for a reply, return the good/bad news... */
6617 api_sw_interface_clear_stats (vat_main_t * vam)
6619 unformat_input_t *i = vam->input;
6620 vl_api_sw_interface_clear_stats_t *mp;
6622 u8 sw_if_index_set = 0;
6625 /* Parse args required to build the message */
6626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6629 sw_if_index_set = 1;
6630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6631 sw_if_index_set = 1;
6636 /* Construct the API message */
6637 M (SW_INTERFACE_CLEAR_STATS, mp);
6639 if (sw_if_index_set == 1)
6640 mp->sw_if_index = ntohl (sw_if_index);
6642 mp->sw_if_index = ~0;
6647 /* Wait for a reply, return the good/bad news... */
6653 api_sw_interface_add_del_address (vat_main_t * vam)
6655 unformat_input_t *i = vam->input;
6656 vl_api_sw_interface_add_del_address_t *mp;
6658 u8 sw_if_index_set = 0;
6659 u8 is_add = 1, del_all = 0;
6660 u32 address_length = 0;
6661 u8 v4_address_set = 0;
6662 u8 v6_address_set = 0;
6663 ip4_address_t v4address;
6664 ip6_address_t v6address;
6667 /* Parse args required to build the message */
6668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6670 if (unformat (i, "del-all"))
6672 else if (unformat (i, "del"))
6675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6676 sw_if_index_set = 1;
6677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6678 sw_if_index_set = 1;
6679 else if (unformat (i, "%U/%d",
6680 unformat_ip4_address, &v4address, &address_length))
6682 else if (unformat (i, "%U/%d",
6683 unformat_ip6_address, &v6address, &address_length))
6689 if (sw_if_index_set == 0)
6691 errmsg ("missing interface name or sw_if_index");
6694 if (v4_address_set && v6_address_set)
6696 errmsg ("both v4 and v6 addresses set");
6699 if (!v4_address_set && !v6_address_set && !del_all)
6701 errmsg ("no addresses set");
6705 /* Construct the API message */
6706 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6708 mp->sw_if_index = ntohl (sw_if_index);
6709 mp->is_add = is_add;
6710 mp->del_all = del_all;
6714 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6718 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6720 mp->address_length = address_length;
6725 /* Wait for a reply, return good/bad news */
6731 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6733 unformat_input_t *i = vam->input;
6734 vl_api_sw_interface_set_mpls_enable_t *mp;
6736 u8 sw_if_index_set = 0;
6740 /* Parse args required to build the message */
6741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6743 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6744 sw_if_index_set = 1;
6745 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6746 sw_if_index_set = 1;
6747 else if (unformat (i, "disable"))
6749 else if (unformat (i, "dis"))
6755 if (sw_if_index_set == 0)
6757 errmsg ("missing interface name or sw_if_index");
6761 /* Construct the API message */
6762 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6764 mp->sw_if_index = ntohl (sw_if_index);
6765 mp->enable = enable;
6770 /* Wait for a reply... */
6776 api_sw_interface_set_table (vat_main_t * vam)
6778 unformat_input_t *i = vam->input;
6779 vl_api_sw_interface_set_table_t *mp;
6780 u32 sw_if_index, vrf_id = 0;
6781 u8 sw_if_index_set = 0;
6785 /* Parse args required to build the message */
6786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6789 sw_if_index_set = 1;
6790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6791 sw_if_index_set = 1;
6792 else if (unformat (i, "vrf %d", &vrf_id))
6794 else if (unformat (i, "ipv6"))
6800 if (sw_if_index_set == 0)
6802 errmsg ("missing interface name or sw_if_index");
6806 /* Construct the API message */
6807 M (SW_INTERFACE_SET_TABLE, mp);
6809 mp->sw_if_index = ntohl (sw_if_index);
6810 mp->is_ipv6 = is_ipv6;
6811 mp->vrf_id = ntohl (vrf_id);
6816 /* Wait for a reply... */
6821 static void vl_api_sw_interface_get_table_reply_t_handler
6822 (vl_api_sw_interface_get_table_reply_t * mp)
6824 vat_main_t *vam = &vat_main;
6826 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6828 vam->retval = ntohl (mp->retval);
6829 vam->result_ready = 1;
6833 static void vl_api_sw_interface_get_table_reply_t_handler_json
6834 (vl_api_sw_interface_get_table_reply_t * mp)
6836 vat_main_t *vam = &vat_main;
6837 vat_json_node_t node;
6839 vat_json_init_object (&node);
6840 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6841 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6843 vat_json_print (vam->ofp, &node);
6844 vat_json_free (&node);
6846 vam->retval = ntohl (mp->retval);
6847 vam->result_ready = 1;
6851 api_sw_interface_get_table (vat_main_t * vam)
6853 unformat_input_t *i = vam->input;
6854 vl_api_sw_interface_get_table_t *mp;
6856 u8 sw_if_index_set = 0;
6860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6862 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6863 sw_if_index_set = 1;
6864 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6865 sw_if_index_set = 1;
6866 else if (unformat (i, "ipv6"))
6872 if (sw_if_index_set == 0)
6874 errmsg ("missing interface name or sw_if_index");
6878 M (SW_INTERFACE_GET_TABLE, mp);
6879 mp->sw_if_index = htonl (sw_if_index);
6880 mp->is_ipv6 = is_ipv6;
6888 api_sw_interface_set_vpath (vat_main_t * vam)
6890 unformat_input_t *i = vam->input;
6891 vl_api_sw_interface_set_vpath_t *mp;
6892 u32 sw_if_index = 0;
6893 u8 sw_if_index_set = 0;
6897 /* Parse args required to build the message */
6898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6901 sw_if_index_set = 1;
6902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6903 sw_if_index_set = 1;
6904 else if (unformat (i, "enable"))
6906 else if (unformat (i, "disable"))
6912 if (sw_if_index_set == 0)
6914 errmsg ("missing interface name or sw_if_index");
6918 /* Construct the API message */
6919 M (SW_INTERFACE_SET_VPATH, mp);
6921 mp->sw_if_index = ntohl (sw_if_index);
6922 mp->enable = is_enable;
6927 /* Wait for a reply... */
6933 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6935 unformat_input_t *i = vam->input;
6936 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6937 u32 sw_if_index = 0;
6938 u8 sw_if_index_set = 0;
6943 /* Parse args required to build the message */
6944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6946 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6947 sw_if_index_set = 1;
6948 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6949 sw_if_index_set = 1;
6950 else if (unformat (i, "enable"))
6952 else if (unformat (i, "disable"))
6954 else if (unformat (i, "ip4"))
6956 else if (unformat (i, "ip6"))
6962 if (sw_if_index_set == 0)
6964 errmsg ("missing interface name or sw_if_index");
6968 /* Construct the API message */
6969 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6971 mp->sw_if_index = ntohl (sw_if_index);
6972 mp->enable = is_enable;
6973 mp->is_ipv6 = is_ipv6;
6978 /* Wait for a reply... */
6984 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6986 unformat_input_t *i = vam->input;
6987 vl_api_sw_interface_set_geneve_bypass_t *mp;
6988 u32 sw_if_index = 0;
6989 u8 sw_if_index_set = 0;
6994 /* Parse args required to build the message */
6995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6997 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6998 sw_if_index_set = 1;
6999 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7000 sw_if_index_set = 1;
7001 else if (unformat (i, "enable"))
7003 else if (unformat (i, "disable"))
7005 else if (unformat (i, "ip4"))
7007 else if (unformat (i, "ip6"))
7013 if (sw_if_index_set == 0)
7015 errmsg ("missing interface name or sw_if_index");
7019 /* Construct the API message */
7020 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
7022 mp->sw_if_index = ntohl (sw_if_index);
7023 mp->enable = is_enable;
7024 mp->is_ipv6 = is_ipv6;
7029 /* Wait for a reply... */
7035 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
7037 unformat_input_t *i = vam->input;
7038 vl_api_sw_interface_set_l2_xconnect_t *mp;
7040 u8 rx_sw_if_index_set = 0;
7042 u8 tx_sw_if_index_set = 0;
7046 /* Parse args required to build the message */
7047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7049 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7050 rx_sw_if_index_set = 1;
7051 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7052 tx_sw_if_index_set = 1;
7053 else if (unformat (i, "rx"))
7055 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7057 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7059 rx_sw_if_index_set = 1;
7064 else if (unformat (i, "tx"))
7066 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7068 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7070 tx_sw_if_index_set = 1;
7075 else if (unformat (i, "enable"))
7077 else if (unformat (i, "disable"))
7083 if (rx_sw_if_index_set == 0)
7085 errmsg ("missing rx interface name or rx_sw_if_index");
7089 if (enable && (tx_sw_if_index_set == 0))
7091 errmsg ("missing tx interface name or tx_sw_if_index");
7095 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
7097 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7098 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7099 mp->enable = enable;
7107 api_sw_interface_set_l2_bridge (vat_main_t * vam)
7109 unformat_input_t *i = vam->input;
7110 vl_api_sw_interface_set_l2_bridge_t *mp;
7112 u8 rx_sw_if_index_set = 0;
7120 /* Parse args required to build the message */
7121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7123 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
7124 rx_sw_if_index_set = 1;
7125 else if (unformat (i, "bd_id %d", &bd_id))
7129 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
7130 rx_sw_if_index_set = 1;
7131 else if (unformat (i, "shg %d", &shg))
7133 else if (unformat (i, "bvi"))
7135 else if (unformat (i, "enable"))
7137 else if (unformat (i, "disable"))
7143 if (rx_sw_if_index_set == 0)
7145 errmsg ("missing rx interface name or sw_if_index");
7149 if (enable && (bd_id_set == 0))
7151 errmsg ("missing bridge domain");
7155 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
7157 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7158 mp->bd_id = ntohl (bd_id);
7161 mp->enable = enable;
7169 api_bridge_domain_dump (vat_main_t * vam)
7171 unformat_input_t *i = vam->input;
7172 vl_api_bridge_domain_dump_t *mp;
7173 vl_api_control_ping_t *mp_ping;
7177 /* Parse args required to build the message */
7178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7180 if (unformat (i, "bd_id %d", &bd_id))
7186 M (BRIDGE_DOMAIN_DUMP, mp);
7187 mp->bd_id = ntohl (bd_id);
7190 /* Use a control ping for synchronization */
7191 MPING (CONTROL_PING, mp_ping);
7199 api_bridge_domain_add_del (vat_main_t * vam)
7201 unformat_input_t *i = vam->input;
7202 vl_api_bridge_domain_add_del_t *mp;
7205 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7210 /* Parse args required to build the message */
7211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7213 if (unformat (i, "bd_id %d", &bd_id))
7215 else if (unformat (i, "flood %d", &flood))
7217 else if (unformat (i, "uu-flood %d", &uu_flood))
7219 else if (unformat (i, "forward %d", &forward))
7221 else if (unformat (i, "learn %d", &learn))
7223 else if (unformat (i, "arp-term %d", &arp_term))
7225 else if (unformat (i, "mac-age %d", &mac_age))
7227 else if (unformat (i, "bd-tag %s", &bd_tag))
7229 else if (unformat (i, "del"))
7232 flood = uu_flood = forward = learn = 0;
7240 errmsg ("missing bridge domain");
7247 errmsg ("mac age must be less than 256 ");
7252 if ((bd_tag) && (vec_len (bd_tag) > 63))
7254 errmsg ("bd-tag cannot be longer than 63");
7259 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7261 mp->bd_id = ntohl (bd_id);
7263 mp->uu_flood = uu_flood;
7264 mp->forward = forward;
7266 mp->arp_term = arp_term;
7267 mp->is_add = is_add;
7268 mp->mac_age = (u8) mac_age;
7271 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
7272 mp->bd_tag[vec_len (bd_tag)] = 0;
7283 api_l2fib_flush_bd (vat_main_t * vam)
7285 unformat_input_t *i = vam->input;
7286 vl_api_l2fib_flush_bd_t *mp;
7290 /* Parse args required to build the message */
7291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7293 if (unformat (i, "bd_id %d", &bd_id));
7300 errmsg ("missing bridge domain");
7304 M (L2FIB_FLUSH_BD, mp);
7306 mp->bd_id = htonl (bd_id);
7314 api_l2fib_flush_int (vat_main_t * vam)
7316 unformat_input_t *i = vam->input;
7317 vl_api_l2fib_flush_int_t *mp;
7318 u32 sw_if_index = ~0;
7321 /* Parse args required to build the message */
7322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7324 if (unformat (i, "sw_if_index %d", &sw_if_index));
7326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7331 if (sw_if_index == ~0)
7333 errmsg ("missing interface name or sw_if_index");
7337 M (L2FIB_FLUSH_INT, mp);
7339 mp->sw_if_index = ntohl (sw_if_index);
7347 api_l2fib_add_del (vat_main_t * vam)
7349 unformat_input_t *i = vam->input;
7350 vl_api_l2fib_add_del_t *mp;
7356 u32 sw_if_index = ~0;
7357 u8 sw_if_index_set = 0;
7366 /* Parse args required to build the message */
7367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7369 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7371 else if (unformat (i, "bd_id %d", &bd_id))
7373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7374 sw_if_index_set = 1;
7375 else if (unformat (i, "sw_if"))
7377 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7380 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7381 sw_if_index_set = 1;
7386 else if (unformat (i, "static"))
7388 else if (unformat (i, "filter"))
7393 else if (unformat (i, "bvi"))
7398 else if (unformat (i, "del"))
7400 else if (unformat (i, "count %d", &count))
7408 errmsg ("missing mac address");
7414 errmsg ("missing bridge domain");
7418 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7420 errmsg ("missing interface name or sw_if_index");
7426 /* Turn on async mode */
7427 vam->async_mode = 1;
7428 vam->async_errors = 0;
7429 before = vat_time_now (vam);
7432 for (j = 0; j < count; j++)
7434 M (L2FIB_ADD_DEL, mp);
7436 clib_memcpy (mp->mac, mac, 6);
7437 mp->bd_id = ntohl (bd_id);
7438 mp->is_add = is_add;
7442 mp->sw_if_index = ntohl (sw_if_index);
7443 mp->static_mac = static_mac;
7444 mp->filter_mac = filter_mac;
7445 mp->bvi_mac = bvi_mac;
7447 increment_mac_address (mac);
7454 vl_api_control_ping_t *mp_ping;
7457 /* Shut off async mode */
7458 vam->async_mode = 0;
7460 MPING (CONTROL_PING, mp_ping);
7463 timeout = vat_time_now (vam) + 1.0;
7464 while (vat_time_now (vam) < timeout)
7465 if (vam->result_ready == 1)
7470 if (vam->retval == -99)
7473 if (vam->async_errors > 0)
7475 errmsg ("%d asynchronous errors", vam->async_errors);
7478 vam->async_errors = 0;
7479 after = vat_time_now (vam);
7481 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7482 count, after - before, count / (after - before));
7488 /* Wait for a reply... */
7492 /* Return the good/bad news */
7493 return (vam->retval);
7497 api_bridge_domain_set_mac_age (vat_main_t * vam)
7499 unformat_input_t *i = vam->input;
7500 vl_api_bridge_domain_set_mac_age_t *mp;
7505 /* Parse args required to build the message */
7506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7508 if (unformat (i, "bd_id %d", &bd_id));
7509 else if (unformat (i, "mac-age %d", &mac_age));
7516 errmsg ("missing bridge domain");
7522 errmsg ("mac age must be less than 256 ");
7526 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7528 mp->bd_id = htonl (bd_id);
7529 mp->mac_age = (u8) mac_age;
7537 api_l2_flags (vat_main_t * vam)
7539 unformat_input_t *i = vam->input;
7540 vl_api_l2_flags_t *mp;
7543 u8 sw_if_index_set = 0;
7547 /* Parse args required to build the message */
7548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7550 if (unformat (i, "sw_if_index %d", &sw_if_index))
7551 sw_if_index_set = 1;
7552 else if (unformat (i, "sw_if"))
7554 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7557 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7558 sw_if_index_set = 1;
7563 else if (unformat (i, "learn"))
7565 else if (unformat (i, "forward"))
7567 else if (unformat (i, "flood"))
7569 else if (unformat (i, "uu-flood"))
7570 flags |= L2_UU_FLOOD;
7571 else if (unformat (i, "arp-term"))
7572 flags |= L2_ARP_TERM;
7573 else if (unformat (i, "off"))
7575 else if (unformat (i, "disable"))
7581 if (sw_if_index_set == 0)
7583 errmsg ("missing interface name or sw_if_index");
7589 mp->sw_if_index = ntohl (sw_if_index);
7590 mp->feature_bitmap = ntohl (flags);
7591 mp->is_set = is_set;
7599 api_bridge_flags (vat_main_t * vam)
7601 unformat_input_t *i = vam->input;
7602 vl_api_bridge_flags_t *mp;
7609 /* Parse args required to build the message */
7610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7612 if (unformat (i, "bd_id %d", &bd_id))
7614 else if (unformat (i, "learn"))
7616 else if (unformat (i, "forward"))
7618 else if (unformat (i, "flood"))
7620 else if (unformat (i, "uu-flood"))
7621 flags |= L2_UU_FLOOD;
7622 else if (unformat (i, "arp-term"))
7623 flags |= L2_ARP_TERM;
7624 else if (unformat (i, "off"))
7626 else if (unformat (i, "disable"))
7634 errmsg ("missing bridge domain");
7638 M (BRIDGE_FLAGS, mp);
7640 mp->bd_id = ntohl (bd_id);
7641 mp->feature_bitmap = ntohl (flags);
7642 mp->is_set = is_set;
7650 api_bd_ip_mac_add_del (vat_main_t * vam)
7652 unformat_input_t *i = vam->input;
7653 vl_api_bd_ip_mac_add_del_t *mp;
7660 ip4_address_t v4addr;
7661 ip6_address_t v6addr;
7666 /* Parse args required to build the message */
7667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7669 if (unformat (i, "bd_id %d", &bd_id))
7673 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7677 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7682 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7686 else if (unformat (i, "del"))
7694 errmsg ("missing bridge domain");
7697 else if (ip_set == 0)
7699 errmsg ("missing IP address");
7702 else if (mac_set == 0)
7704 errmsg ("missing MAC address");
7708 M (BD_IP_MAC_ADD_DEL, mp);
7710 mp->bd_id = ntohl (bd_id);
7711 mp->is_ipv6 = is_ipv6;
7712 mp->is_add = is_add;
7714 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7716 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7717 clib_memcpy (mp->mac_address, macaddr, 6);
7724 api_tap_connect (vat_main_t * vam)
7726 unformat_input_t *i = vam->input;
7727 vl_api_tap_connect_t *mp;
7733 ip4_address_t ip4_address;
7735 int ip4_address_set = 0;
7736 ip6_address_t ip6_address;
7738 int ip6_address_set = 0;
7741 memset (mac_address, 0, sizeof (mac_address));
7743 /* Parse args required to build the message */
7744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7746 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7750 else if (unformat (i, "random-mac"))
7752 else if (unformat (i, "tapname %s", &tap_name))
7754 else if (unformat (i, "tag %s", &tag))
7756 else if (unformat (i, "address %U/%d",
7757 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7758 ip4_address_set = 1;
7759 else if (unformat (i, "address %U/%d",
7760 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7761 ip6_address_set = 1;
7768 errmsg ("missing tap name");
7771 if (vec_len (tap_name) > 63)
7773 errmsg ("tap name too long");
7776 vec_add1 (tap_name, 0);
7778 if (vec_len (tag) > 63)
7780 errmsg ("tag too long");
7784 /* Construct the API message */
7785 M (TAP_CONNECT, mp);
7787 mp->use_random_mac = random_mac;
7788 clib_memcpy (mp->mac_address, mac_address, 6);
7789 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7791 clib_memcpy (mp->tag, tag, vec_len (tag));
7793 if (ip4_address_set)
7795 mp->ip4_address_set = 1;
7796 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7797 mp->ip4_mask_width = ip4_mask_width;
7799 if (ip6_address_set)
7801 mp->ip6_address_set = 1;
7802 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7803 mp->ip6_mask_width = ip6_mask_width;
7806 vec_free (tap_name);
7812 /* Wait for a reply... */
7818 api_tap_modify (vat_main_t * vam)
7820 unformat_input_t *i = vam->input;
7821 vl_api_tap_modify_t *mp;
7826 u32 sw_if_index = ~0;
7827 u8 sw_if_index_set = 0;
7830 memset (mac_address, 0, sizeof (mac_address));
7832 /* Parse args required to build the message */
7833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7836 sw_if_index_set = 1;
7837 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7838 sw_if_index_set = 1;
7839 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7843 else if (unformat (i, "random-mac"))
7845 else if (unformat (i, "tapname %s", &tap_name))
7851 if (sw_if_index_set == 0)
7853 errmsg ("missing vpp interface name");
7858 errmsg ("missing tap name");
7861 if (vec_len (tap_name) > 63)
7863 errmsg ("tap name too long");
7865 vec_add1 (tap_name, 0);
7867 /* Construct the API message */
7870 mp->use_random_mac = random_mac;
7871 mp->sw_if_index = ntohl (sw_if_index);
7872 clib_memcpy (mp->mac_address, mac_address, 6);
7873 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7874 vec_free (tap_name);
7879 /* Wait for a reply... */
7885 api_tap_delete (vat_main_t * vam)
7887 unformat_input_t *i = vam->input;
7888 vl_api_tap_delete_t *mp;
7889 u32 sw_if_index = ~0;
7890 u8 sw_if_index_set = 0;
7893 /* Parse args required to build the message */
7894 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7896 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7897 sw_if_index_set = 1;
7898 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7899 sw_if_index_set = 1;
7904 if (sw_if_index_set == 0)
7906 errmsg ("missing vpp interface name");
7910 /* Construct the API message */
7913 mp->sw_if_index = ntohl (sw_if_index);
7918 /* Wait for a reply... */
7924 api_tap_create_v2 (vat_main_t * vam)
7926 unformat_input_t *i = vam->input;
7927 vl_api_tap_create_v2_t *mp;
7931 u8 *host_if_name = 0;
7933 u8 host_mac_addr[6];
7934 u8 host_mac_addr_set = 0;
7935 u8 *host_bridge = 0;
7936 ip4_address_t host_ip4_addr;
7937 ip4_address_t host_ip4_gw;
7938 u8 host_ip4_gw_set = 0;
7939 u32 host_ip4_prefix_len = 0;
7940 ip6_address_t host_ip6_addr;
7941 ip6_address_t host_ip6_gw;
7942 u8 host_ip6_gw_set = 0;
7943 u32 host_ip6_prefix_len = 0;
7945 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7947 memset (mac_address, 0, sizeof (mac_address));
7949 /* Parse args required to build the message */
7950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7952 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7956 else if (unformat (i, "id %u", &id))
7958 else if (unformat (i, "host-if-name %s", &host_if_name))
7960 else if (unformat (i, "host-ns %s", &host_ns))
7962 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7964 host_mac_addr_set = 1;
7965 else if (unformat (i, "host-bridge %s", &host_bridge))
7967 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7968 &host_ip4_addr, &host_ip4_prefix_len))
7970 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7971 &host_ip6_addr, &host_ip6_prefix_len))
7973 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7975 host_ip4_gw_set = 1;
7976 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7978 host_ip6_gw_set = 1;
7979 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7981 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7987 if (vec_len (host_if_name) > 63)
7989 errmsg ("tap name too long. ");
7992 if (vec_len (host_ns) > 63)
7994 errmsg ("host name space too long. ");
7997 if (vec_len (host_bridge) > 63)
7999 errmsg ("host bridge name too long. ");
8002 if (host_ip4_prefix_len > 32)
8004 errmsg ("host ip4 prefix length not valid. ");
8007 if (host_ip6_prefix_len > 128)
8009 errmsg ("host ip6 prefix length not valid. ");
8012 if (!is_pow2 (rx_ring_sz))
8014 errmsg ("rx ring size must be power of 2. ");
8017 if (rx_ring_sz > 32768)
8019 errmsg ("rx ring size must be 32768 or lower. ");
8022 if (!is_pow2 (tx_ring_sz))
8024 errmsg ("tx ring size must be power of 2. ");
8027 if (tx_ring_sz > 32768)
8029 errmsg ("tx ring size must be 32768 or lower. ");
8033 /* Construct the API message */
8034 M (TAP_CREATE_V2, mp);
8036 mp->use_random_mac = random_mac;
8038 mp->id = ntohl (id);
8039 mp->host_namespace_set = host_ns != 0;
8040 mp->host_bridge_set = host_bridge != 0;
8041 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
8042 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
8043 mp->rx_ring_sz = ntohs (rx_ring_sz);
8044 mp->tx_ring_sz = ntohs (tx_ring_sz);
8046 if (random_mac == 0)
8047 clib_memcpy (mp->mac_address, mac_address, 6);
8048 if (host_mac_addr_set)
8049 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
8051 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
8053 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
8055 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
8056 if (host_ip4_prefix_len)
8057 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
8058 if (host_ip4_prefix_len)
8059 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
8060 if (host_ip4_gw_set)
8061 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
8062 if (host_ip6_gw_set)
8063 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
8066 vec_free (host_if_name);
8067 vec_free (host_bridge);
8072 /* Wait for a reply... */
8078 api_tap_delete_v2 (vat_main_t * vam)
8080 unformat_input_t *i = vam->input;
8081 vl_api_tap_delete_v2_t *mp;
8082 u32 sw_if_index = ~0;
8083 u8 sw_if_index_set = 0;
8086 /* Parse args required to build the message */
8087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8090 sw_if_index_set = 1;
8091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8092 sw_if_index_set = 1;
8097 if (sw_if_index_set == 0)
8099 errmsg ("missing vpp interface name. ");
8103 /* Construct the API message */
8104 M (TAP_DELETE_V2, mp);
8106 mp->sw_if_index = ntohl (sw_if_index);
8111 /* Wait for a reply... */
8117 api_bond_create (vat_main_t * vam)
8119 unformat_input_t *i = vam->input;
8120 vl_api_bond_create_t *mp;
8128 memset (mac_address, 0, sizeof (mac_address));
8131 /* Parse args required to build the message */
8132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8134 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
8136 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
8137 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
8139 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
8146 if (mode_is_set == 0)
8148 errmsg ("Missing bond mode. ");
8152 /* Construct the API message */
8153 M (BOND_CREATE, mp);
8155 mp->use_custom_mac = custom_mac;
8161 clib_memcpy (mp->mac_address, mac_address, 6);
8166 /* Wait for a reply... */
8172 api_bond_delete (vat_main_t * vam)
8174 unformat_input_t *i = vam->input;
8175 vl_api_bond_delete_t *mp;
8176 u32 sw_if_index = ~0;
8177 u8 sw_if_index_set = 0;
8180 /* Parse args required to build the message */
8181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8183 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8184 sw_if_index_set = 1;
8185 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8186 sw_if_index_set = 1;
8191 if (sw_if_index_set == 0)
8193 errmsg ("missing vpp interface name. ");
8197 /* Construct the API message */
8198 M (BOND_DELETE, mp);
8200 mp->sw_if_index = ntohl (sw_if_index);
8205 /* Wait for a reply... */
8211 api_bond_enslave (vat_main_t * vam)
8213 unformat_input_t *i = vam->input;
8214 vl_api_bond_enslave_t *mp;
8215 u32 bond_sw_if_index;
8219 u32 bond_sw_if_index_is_set = 0;
8221 u8 sw_if_index_is_set = 0;
8223 /* Parse args required to build the message */
8224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8226 if (unformat (i, "sw_if_index %d", &sw_if_index))
8227 sw_if_index_is_set = 1;
8228 else if (unformat (i, "bond %u", &bond_sw_if_index))
8229 bond_sw_if_index_is_set = 1;
8230 else if (unformat (i, "passive %d", &is_passive))
8232 else if (unformat (i, "long-timeout %d", &is_long_timeout))
8238 if (bond_sw_if_index_is_set == 0)
8240 errmsg ("Missing bond sw_if_index. ");
8243 if (sw_if_index_is_set == 0)
8245 errmsg ("Missing slave sw_if_index. ");
8249 /* Construct the API message */
8250 M (BOND_ENSLAVE, mp);
8252 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
8253 mp->sw_if_index = ntohl (sw_if_index);
8254 mp->is_long_timeout = is_long_timeout;
8255 mp->is_passive = is_passive;
8260 /* Wait for a reply... */
8266 api_bond_detach_slave (vat_main_t * vam)
8268 unformat_input_t *i = vam->input;
8269 vl_api_bond_detach_slave_t *mp;
8270 u32 sw_if_index = ~0;
8271 u8 sw_if_index_set = 0;
8274 /* Parse args required to build the message */
8275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8277 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8278 sw_if_index_set = 1;
8279 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8280 sw_if_index_set = 1;
8285 if (sw_if_index_set == 0)
8287 errmsg ("missing vpp interface name. ");
8291 /* Construct the API message */
8292 M (BOND_DETACH_SLAVE, mp);
8294 mp->sw_if_index = ntohl (sw_if_index);
8299 /* Wait for a reply... */
8305 api_ip_table_add_del (vat_main_t * vam)
8307 unformat_input_t *i = vam->input;
8308 vl_api_ip_table_add_del_t *mp;
8314 /* Parse args required to build the message */
8315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8317 if (unformat (i, "ipv6"))
8319 else if (unformat (i, "del"))
8321 else if (unformat (i, "add"))
8323 else if (unformat (i, "table %d", &table_id))
8327 clib_warning ("parse error '%U'", format_unformat_error, i);
8334 errmsg ("missing table-ID");
8338 /* Construct the API message */
8339 M (IP_TABLE_ADD_DEL, mp);
8341 mp->table_id = ntohl (table_id);
8342 mp->is_ipv6 = is_ipv6;
8343 mp->is_add = is_add;
8348 /* Wait for a reply... */
8355 api_ip_add_del_route (vat_main_t * vam)
8357 unformat_input_t *i = vam->input;
8358 vl_api_ip_add_del_route_t *mp;
8359 u32 sw_if_index = ~0, vrf_id = 0;
8361 u8 is_local = 0, is_drop = 0;
8362 u8 is_unreach = 0, is_prohibit = 0;
8364 u32 next_hop_weight = 1;
8365 u8 is_multipath = 0;
8367 u8 address_length_set = 0;
8368 u32 next_hop_table_id = 0;
8369 u32 resolve_attempts = 0;
8370 u32 dst_address_length = 0;
8371 u8 next_hop_set = 0;
8372 ip4_address_t v4_dst_address, v4_next_hop_address;
8373 ip6_address_t v6_dst_address, v6_next_hop_address;
8377 u32 random_add_del = 0;
8378 u32 *random_vector = 0;
8380 u32 random_seed = 0xdeaddabe;
8381 u32 classify_table_index = ~0;
8383 u8 resolve_host = 0, resolve_attached = 0;
8384 mpls_label_t *next_hop_out_label_stack = NULL;
8385 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8386 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8388 /* Parse args required to build the message */
8389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8391 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8393 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8395 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8400 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8405 else if (unformat (i, "/%d", &dst_address_length))
8407 address_length_set = 1;
8410 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8411 &v4_next_hop_address))
8415 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8416 &v6_next_hop_address))
8420 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8422 else if (unformat (i, "weight %d", &next_hop_weight))
8424 else if (unformat (i, "drop"))
8428 else if (unformat (i, "null-send-unreach"))
8432 else if (unformat (i, "null-send-prohibit"))
8436 else if (unformat (i, "local"))
8440 else if (unformat (i, "classify %d", &classify_table_index))
8444 else if (unformat (i, "del"))
8446 else if (unformat (i, "add"))
8448 else if (unformat (i, "resolve-via-host"))
8450 else if (unformat (i, "resolve-via-attached"))
8451 resolve_attached = 1;
8452 else if (unformat (i, "multipath"))
8454 else if (unformat (i, "vrf %d", &vrf_id))
8456 else if (unformat (i, "count %d", &count))
8458 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8460 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8462 else if (unformat (i, "out-label %d", &next_hop_out_label))
8463 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8464 else if (unformat (i, "via-label %d", &next_hop_via_label))
8466 else if (unformat (i, "random"))
8468 else if (unformat (i, "seed %d", &random_seed))
8472 clib_warning ("parse error '%U'", format_unformat_error, i);
8477 if (!next_hop_set && !is_drop && !is_local &&
8478 !is_classify && !is_unreach && !is_prohibit &&
8479 MPLS_LABEL_INVALID == next_hop_via_label)
8482 ("next hop / local / drop / unreach / prohibit / classify not set");
8486 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8488 errmsg ("next hop and next-hop via label set");
8491 if (address_set == 0)
8493 errmsg ("missing addresses");
8497 if (address_length_set == 0)
8499 errmsg ("missing address length");
8503 /* Generate a pile of unique, random routes */
8506 u32 this_random_address;
8507 random_hash = hash_create (count, sizeof (uword));
8509 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8510 for (j = 0; j <= count; j++)
8514 this_random_address = random_u32 (&random_seed);
8515 this_random_address =
8516 clib_host_to_net_u32 (this_random_address);
8518 while (hash_get (random_hash, this_random_address));
8519 vec_add1 (random_vector, this_random_address);
8520 hash_set (random_hash, this_random_address, 1);
8522 hash_free (random_hash);
8523 v4_dst_address.as_u32 = random_vector[0];
8528 /* Turn on async mode */
8529 vam->async_mode = 1;
8530 vam->async_errors = 0;
8531 before = vat_time_now (vam);
8534 for (j = 0; j < count; j++)
8536 /* Construct the API message */
8537 M2 (IP_ADD_DEL_ROUTE, mp,
8538 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8540 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8541 mp->table_id = ntohl (vrf_id);
8543 mp->is_add = is_add;
8544 mp->is_drop = is_drop;
8545 mp->is_unreach = is_unreach;
8546 mp->is_prohibit = is_prohibit;
8547 mp->is_ipv6 = is_ipv6;
8548 mp->is_local = is_local;
8549 mp->is_classify = is_classify;
8550 mp->is_multipath = is_multipath;
8551 mp->is_resolve_host = resolve_host;
8552 mp->is_resolve_attached = resolve_attached;
8553 mp->next_hop_weight = next_hop_weight;
8554 mp->dst_address_length = dst_address_length;
8555 mp->next_hop_table_id = ntohl (next_hop_table_id);
8556 mp->classify_table_index = ntohl (classify_table_index);
8557 mp->next_hop_via_label = ntohl (next_hop_via_label);
8558 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8559 if (0 != mp->next_hop_n_out_labels)
8561 memcpy (mp->next_hop_out_label_stack,
8562 next_hop_out_label_stack,
8563 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8564 vec_free (next_hop_out_label_stack);
8569 clib_memcpy (mp->dst_address, &v6_dst_address,
8570 sizeof (v6_dst_address));
8572 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8573 sizeof (v6_next_hop_address));
8574 increment_v6_address (&v6_dst_address);
8578 clib_memcpy (mp->dst_address, &v4_dst_address,
8579 sizeof (v4_dst_address));
8581 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8582 sizeof (v4_next_hop_address));
8584 v4_dst_address.as_u32 = random_vector[j + 1];
8586 increment_v4_address (&v4_dst_address);
8590 /* If we receive SIGTERM, stop now... */
8595 /* When testing multiple add/del ops, use a control-ping to sync */
8598 vl_api_control_ping_t *mp_ping;
8602 /* Shut off async mode */
8603 vam->async_mode = 0;
8605 MPING (CONTROL_PING, mp_ping);
8608 timeout = vat_time_now (vam) + 1.0;
8609 while (vat_time_now (vam) < timeout)
8610 if (vam->result_ready == 1)
8615 if (vam->retval == -99)
8618 if (vam->async_errors > 0)
8620 errmsg ("%d asynchronous errors", vam->async_errors);
8623 vam->async_errors = 0;
8624 after = vat_time_now (vam);
8626 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8630 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8631 count, after - before, count / (after - before));
8637 /* Wait for a reply... */
8642 /* Return the good/bad news */
8643 return (vam->retval);
8647 api_ip_mroute_add_del (vat_main_t * vam)
8649 unformat_input_t *i = vam->input;
8650 vl_api_ip_mroute_add_del_t *mp;
8651 u32 sw_if_index = ~0, vrf_id = 0;
8656 u32 grp_address_length = 0;
8657 ip4_address_t v4_grp_address, v4_src_address;
8658 ip6_address_t v6_grp_address, v6_src_address;
8659 mfib_itf_flags_t iflags = 0;
8660 mfib_entry_flags_t eflags = 0;
8663 /* Parse args required to build the message */
8664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8666 if (unformat (i, "sw_if_index %d", &sw_if_index))
8668 else if (unformat (i, "%U %U",
8669 unformat_ip4_address, &v4_src_address,
8670 unformat_ip4_address, &v4_grp_address))
8672 grp_address_length = 64;
8676 else if (unformat (i, "%U %U",
8677 unformat_ip6_address, &v6_src_address,
8678 unformat_ip6_address, &v6_grp_address))
8680 grp_address_length = 256;
8684 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8686 memset (&v4_src_address, 0, sizeof (v4_src_address));
8687 grp_address_length = 32;
8691 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8693 memset (&v6_src_address, 0, sizeof (v6_src_address));
8694 grp_address_length = 128;
8698 else if (unformat (i, "/%d", &grp_address_length))
8700 else if (unformat (i, "local"))
8704 else if (unformat (i, "del"))
8706 else if (unformat (i, "add"))
8708 else if (unformat (i, "vrf %d", &vrf_id))
8710 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8712 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8716 clib_warning ("parse error '%U'", format_unformat_error, i);
8721 if (address_set == 0)
8723 errmsg ("missing addresses\n");
8727 /* Construct the API message */
8728 M (IP_MROUTE_ADD_DEL, mp);
8730 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8731 mp->table_id = ntohl (vrf_id);
8733 mp->is_add = is_add;
8734 mp->is_ipv6 = is_ipv6;
8735 mp->is_local = is_local;
8736 mp->itf_flags = ntohl (iflags);
8737 mp->entry_flags = ntohl (eflags);
8738 mp->grp_address_length = grp_address_length;
8739 mp->grp_address_length = ntohs (mp->grp_address_length);
8743 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8744 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8748 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8749 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8755 /* Wait for a reply... */
8761 api_mpls_table_add_del (vat_main_t * vam)
8763 unformat_input_t *i = vam->input;
8764 vl_api_mpls_table_add_del_t *mp;
8769 /* Parse args required to build the message */
8770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8772 if (unformat (i, "table %d", &table_id))
8774 else if (unformat (i, "del"))
8776 else if (unformat (i, "add"))
8780 clib_warning ("parse error '%U'", format_unformat_error, i);
8787 errmsg ("missing table-ID");
8791 /* Construct the API message */
8792 M (MPLS_TABLE_ADD_DEL, mp);
8794 mp->mt_table_id = ntohl (table_id);
8795 mp->mt_is_add = is_add;
8800 /* Wait for a reply... */
8807 api_mpls_route_add_del (vat_main_t * vam)
8809 unformat_input_t *i = vam->input;
8810 vl_api_mpls_route_add_del_t *mp;
8811 u32 sw_if_index = ~0, table_id = 0;
8813 u32 next_hop_weight = 1;
8814 u8 is_multipath = 0;
8815 u32 next_hop_table_id = 0;
8816 u8 next_hop_set = 0;
8817 ip4_address_t v4_next_hop_address = {
8820 ip6_address_t v6_next_hop_address = { {0} };
8824 u32 classify_table_index = ~0;
8826 u8 resolve_host = 0, resolve_attached = 0;
8827 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8828 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8829 mpls_label_t *next_hop_out_label_stack = NULL;
8830 mpls_label_t local_label = MPLS_LABEL_INVALID;
8832 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8834 /* Parse args required to build the message */
8835 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8841 else if (unformat (i, "%d", &local_label))
8843 else if (unformat (i, "eos"))
8845 else if (unformat (i, "non-eos"))
8847 else if (unformat (i, "via %U", unformat_ip4_address,
8848 &v4_next_hop_address))
8851 next_hop_proto = DPO_PROTO_IP4;
8853 else if (unformat (i, "via %U", unformat_ip6_address,
8854 &v6_next_hop_address))
8857 next_hop_proto = DPO_PROTO_IP6;
8859 else if (unformat (i, "weight %d", &next_hop_weight))
8861 else if (unformat (i, "classify %d", &classify_table_index))
8865 else if (unformat (i, "del"))
8867 else if (unformat (i, "add"))
8869 else if (unformat (i, "resolve-via-host"))
8871 else if (unformat (i, "resolve-via-attached"))
8872 resolve_attached = 1;
8873 else if (unformat (i, "multipath"))
8875 else if (unformat (i, "count %d", &count))
8877 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8880 next_hop_proto = DPO_PROTO_IP4;
8882 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8885 next_hop_proto = DPO_PROTO_IP6;
8887 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8889 else if (unformat (i, "via-label %d", &next_hop_via_label))
8891 else if (unformat (i, "out-label %d", &next_hop_out_label))
8892 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8895 clib_warning ("parse error '%U'", format_unformat_error, i);
8900 if (!next_hop_set && !is_classify)
8902 errmsg ("next hop / classify not set");
8906 if (MPLS_LABEL_INVALID == local_label)
8908 errmsg ("missing label");
8914 /* Turn on async mode */
8915 vam->async_mode = 1;
8916 vam->async_errors = 0;
8917 before = vat_time_now (vam);
8920 for (j = 0; j < count; j++)
8922 /* Construct the API message */
8923 M2 (MPLS_ROUTE_ADD_DEL, mp,
8924 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8926 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8927 mp->mr_table_id = ntohl (table_id);
8929 mp->mr_is_add = is_add;
8930 mp->mr_next_hop_proto = next_hop_proto;
8931 mp->mr_is_classify = is_classify;
8932 mp->mr_is_multipath = is_multipath;
8933 mp->mr_is_resolve_host = resolve_host;
8934 mp->mr_is_resolve_attached = resolve_attached;
8935 mp->mr_next_hop_weight = next_hop_weight;
8936 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8937 mp->mr_classify_table_index = ntohl (classify_table_index);
8938 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8939 mp->mr_label = ntohl (local_label);
8940 mp->mr_eos = is_eos;
8942 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8943 if (0 != mp->mr_next_hop_n_out_labels)
8945 memcpy (mp->mr_next_hop_out_label_stack,
8946 next_hop_out_label_stack,
8947 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8948 vec_free (next_hop_out_label_stack);
8953 if (DPO_PROTO_IP4 == next_hop_proto)
8955 clib_memcpy (mp->mr_next_hop,
8956 &v4_next_hop_address,
8957 sizeof (v4_next_hop_address));
8959 else if (DPO_PROTO_IP6 == next_hop_proto)
8962 clib_memcpy (mp->mr_next_hop,
8963 &v6_next_hop_address,
8964 sizeof (v6_next_hop_address));
8971 /* If we receive SIGTERM, stop now... */
8976 /* When testing multiple add/del ops, use a control-ping to sync */
8979 vl_api_control_ping_t *mp_ping;
8983 /* Shut off async mode */
8984 vam->async_mode = 0;
8986 MPING (CONTROL_PING, mp_ping);
8989 timeout = vat_time_now (vam) + 1.0;
8990 while (vat_time_now (vam) < timeout)
8991 if (vam->result_ready == 1)
8996 if (vam->retval == -99)
8999 if (vam->async_errors > 0)
9001 errmsg ("%d asynchronous errors", vam->async_errors);
9004 vam->async_errors = 0;
9005 after = vat_time_now (vam);
9007 /* slim chance, but we might have eaten SIGTERM on the first iteration */
9011 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
9012 count, after - before, count / (after - before));
9018 /* Wait for a reply... */
9023 /* Return the good/bad news */
9024 return (vam->retval);
9028 api_mpls_ip_bind_unbind (vat_main_t * vam)
9030 unformat_input_t *i = vam->input;
9031 vl_api_mpls_ip_bind_unbind_t *mp;
9032 u32 ip_table_id = 0;
9035 ip4_address_t v4_address;
9036 ip6_address_t v6_address;
9039 mpls_label_t local_label = MPLS_LABEL_INVALID;
9042 /* Parse args required to build the message */
9043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9045 if (unformat (i, "%U/%d", unformat_ip4_address,
9046 &v4_address, &address_length))
9051 else if (unformat (i, "%U/%d", unformat_ip6_address,
9052 &v6_address, &address_length))
9057 else if (unformat (i, "%d", &local_label))
9059 else if (unformat (i, "table-id %d", &ip_table_id))
9061 else if (unformat (i, "unbind"))
9063 else if (unformat (i, "bind"))
9067 clib_warning ("parse error '%U'", format_unformat_error, i);
9074 errmsg ("IP addres not set");
9078 if (MPLS_LABEL_INVALID == local_label)
9080 errmsg ("missing label");
9084 /* Construct the API message */
9085 M (MPLS_IP_BIND_UNBIND, mp);
9087 mp->mb_is_bind = is_bind;
9088 mp->mb_is_ip4 = is_ip4;
9089 mp->mb_ip_table_id = ntohl (ip_table_id);
9090 mp->mb_mpls_table_id = 0;
9091 mp->mb_label = ntohl (local_label);
9092 mp->mb_address_length = address_length;
9095 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
9097 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
9102 /* Wait for a reply... */
9108 api_bier_table_add_del (vat_main_t * vam)
9110 unformat_input_t *i = vam->input;
9111 vl_api_bier_table_add_del_t *mp;
9113 u32 set = 0, sub_domain = 0, hdr_len = 3;
9114 mpls_label_t local_label = MPLS_LABEL_INVALID;
9117 /* Parse args required to build the message */
9118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9120 if (unformat (i, "sub-domain %d", &sub_domain))
9122 else if (unformat (i, "set %d", &set))
9124 else if (unformat (i, "label %d", &local_label))
9126 else if (unformat (i, "hdr-len %d", &hdr_len))
9128 else if (unformat (i, "add"))
9130 else if (unformat (i, "del"))
9134 clib_warning ("parse error '%U'", format_unformat_error, i);
9139 if (MPLS_LABEL_INVALID == local_label)
9141 errmsg ("missing label\n");
9145 /* Construct the API message */
9146 M (BIER_TABLE_ADD_DEL, mp);
9148 mp->bt_is_add = is_add;
9149 mp->bt_label = ntohl (local_label);
9150 mp->bt_tbl_id.bt_set = set;
9151 mp->bt_tbl_id.bt_sub_domain = sub_domain;
9152 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
9157 /* Wait for a reply... */
9164 api_bier_route_add_del (vat_main_t * vam)
9166 unformat_input_t *i = vam->input;
9167 vl_api_bier_route_add_del_t *mp;
9169 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9170 ip4_address_t v4_next_hop_address;
9171 ip6_address_t v6_next_hop_address;
9172 u8 next_hop_set = 0;
9173 u8 next_hop_proto_is_ip4 = 1;
9174 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9177 /* Parse args required to build the message */
9178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9180 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9182 next_hop_proto_is_ip4 = 1;
9185 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9187 next_hop_proto_is_ip4 = 0;
9190 if (unformat (i, "sub-domain %d", &sub_domain))
9192 else if (unformat (i, "set %d", &set))
9194 else if (unformat (i, "hdr-len %d", &hdr_len))
9196 else if (unformat (i, "bp %d", &bp))
9198 else if (unformat (i, "add"))
9200 else if (unformat (i, "del"))
9202 else if (unformat (i, "out-label %d", &next_hop_out_label))
9206 clib_warning ("parse error '%U'", format_unformat_error, i);
9211 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9213 errmsg ("next hop / label set\n");
9218 errmsg ("bit=position not set\n");
9222 /* Construct the API message */
9223 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9225 mp->br_is_add = is_add;
9226 mp->br_tbl_id.bt_set = set;
9227 mp->br_tbl_id.bt_sub_domain = sub_domain;
9228 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9229 mp->br_bp = ntohs (bp);
9231 mp->br_paths[0].n_labels = 1;
9232 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9233 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9235 if (next_hop_proto_is_ip4)
9237 clib_memcpy (mp->br_paths[0].next_hop,
9238 &v4_next_hop_address, sizeof (v4_next_hop_address));
9242 clib_memcpy (mp->br_paths[0].next_hop,
9243 &v6_next_hop_address, sizeof (v6_next_hop_address));
9249 /* Wait for a reply... */
9256 api_proxy_arp_add_del (vat_main_t * vam)
9258 unformat_input_t *i = vam->input;
9259 vl_api_proxy_arp_add_del_t *mp;
9262 ip4_address_t lo, hi;
9266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9268 if (unformat (i, "vrf %d", &vrf_id))
9270 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
9271 unformat_ip4_address, &hi))
9273 else if (unformat (i, "del"))
9277 clib_warning ("parse error '%U'", format_unformat_error, i);
9284 errmsg ("address range not set");
9288 M (PROXY_ARP_ADD_DEL, mp);
9290 mp->proxy.vrf_id = ntohl (vrf_id);
9291 mp->is_add = is_add;
9292 clib_memcpy (mp->proxy.low_address, &lo, sizeof (mp->proxy.low_address));
9293 clib_memcpy (mp->proxy.hi_address, &hi, sizeof (mp->proxy.hi_address));
9301 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9303 unformat_input_t *i = vam->input;
9304 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9307 u8 sw_if_index_set = 0;
9310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9312 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9313 sw_if_index_set = 1;
9314 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9315 sw_if_index_set = 1;
9316 else if (unformat (i, "enable"))
9318 else if (unformat (i, "disable"))
9322 clib_warning ("parse error '%U'", format_unformat_error, i);
9327 if (sw_if_index_set == 0)
9329 errmsg ("missing interface name or sw_if_index");
9333 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9335 mp->sw_if_index = ntohl (sw_if_index);
9336 mp->enable_disable = enable;
9344 api_mpls_tunnel_add_del (vat_main_t * vam)
9346 unformat_input_t *i = vam->input;
9347 vl_api_mpls_tunnel_add_del_t *mp;
9351 u32 sw_if_index = ~0;
9352 u32 next_hop_sw_if_index = ~0;
9353 u32 next_hop_proto_is_ip4 = 1;
9355 u32 next_hop_table_id = 0;
9356 ip4_address_t v4_next_hop_address = {
9359 ip6_address_t v6_next_hop_address = { {0} };
9360 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
9363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9365 if (unformat (i, "add"))
9367 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9369 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9371 else if (unformat (i, "via %U",
9372 unformat_ip4_address, &v4_next_hop_address))
9374 next_hop_proto_is_ip4 = 1;
9376 else if (unformat (i, "via %U",
9377 unformat_ip6_address, &v6_next_hop_address))
9379 next_hop_proto_is_ip4 = 0;
9381 else if (unformat (i, "l2-only"))
9383 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9385 else if (unformat (i, "out-label %d", &next_hop_out_label))
9386 vec_add1 (labels, ntohl (next_hop_out_label));
9389 clib_warning ("parse error '%U'", format_unformat_error, i);
9394 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
9396 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9397 mp->mt_sw_if_index = ntohl (sw_if_index);
9398 mp->mt_is_add = is_add;
9399 mp->mt_l2_only = l2_only;
9400 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9401 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9403 mp->mt_next_hop_n_out_labels = vec_len (labels);
9405 if (0 != mp->mt_next_hop_n_out_labels)
9407 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
9408 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
9412 if (next_hop_proto_is_ip4)
9414 clib_memcpy (mp->mt_next_hop,
9415 &v4_next_hop_address, sizeof (v4_next_hop_address));
9419 clib_memcpy (mp->mt_next_hop,
9420 &v6_next_hop_address, sizeof (v6_next_hop_address));
9429 api_sw_interface_set_unnumbered (vat_main_t * vam)
9431 unformat_input_t *i = vam->input;
9432 vl_api_sw_interface_set_unnumbered_t *mp;
9434 u32 unnum_sw_index = ~0;
9436 u8 sw_if_index_set = 0;
9439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9442 sw_if_index_set = 1;
9443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9444 sw_if_index_set = 1;
9445 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9447 else if (unformat (i, "del"))
9451 clib_warning ("parse error '%U'", format_unformat_error, i);
9456 if (sw_if_index_set == 0)
9458 errmsg ("missing interface name or sw_if_index");
9462 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9464 mp->sw_if_index = ntohl (sw_if_index);
9465 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9466 mp->is_add = is_add;
9474 api_ip_neighbor_add_del (vat_main_t * vam)
9476 unformat_input_t *i = vam->input;
9477 vl_api_ip_neighbor_add_del_t *mp;
9479 u8 sw_if_index_set = 0;
9482 u8 is_no_fib_entry = 0;
9485 u8 v4_address_set = 0;
9486 u8 v6_address_set = 0;
9487 ip4_address_t v4address;
9488 ip6_address_t v6address;
9491 memset (mac_address, 0, sizeof (mac_address));
9493 /* Parse args required to build the message */
9494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9496 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
9500 else if (unformat (i, "del"))
9503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9504 sw_if_index_set = 1;
9505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9506 sw_if_index_set = 1;
9507 else if (unformat (i, "is_static"))
9509 else if (unformat (i, "no-fib-entry"))
9510 is_no_fib_entry = 1;
9511 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
9513 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
9517 clib_warning ("parse error '%U'", format_unformat_error, i);
9522 if (sw_if_index_set == 0)
9524 errmsg ("missing interface name or sw_if_index");
9527 if (v4_address_set && v6_address_set)
9529 errmsg ("both v4 and v6 addresses set");
9532 if (!v4_address_set && !v6_address_set)
9534 errmsg ("no address set");
9538 /* Construct the API message */
9539 M (IP_NEIGHBOR_ADD_DEL, mp);
9541 mp->sw_if_index = ntohl (sw_if_index);
9542 mp->is_add = is_add;
9543 mp->is_static = is_static;
9544 mp->is_no_adj_fib = is_no_fib_entry;
9546 clib_memcpy (mp->mac_address, mac_address, 6);
9550 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9554 /* mp->is_ipv6 = 0; via memset in M macro above */
9555 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9561 /* Wait for a reply, return good/bad news */
9567 api_create_vlan_subif (vat_main_t * vam)
9569 unformat_input_t *i = vam->input;
9570 vl_api_create_vlan_subif_t *mp;
9572 u8 sw_if_index_set = 0;
9577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9579 if (unformat (i, "sw_if_index %d", &sw_if_index))
9580 sw_if_index_set = 1;
9582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9583 sw_if_index_set = 1;
9584 else if (unformat (i, "vlan %d", &vlan_id))
9588 clib_warning ("parse error '%U'", format_unformat_error, i);
9593 if (sw_if_index_set == 0)
9595 errmsg ("missing interface name or sw_if_index");
9599 if (vlan_id_set == 0)
9601 errmsg ("missing vlan_id");
9604 M (CREATE_VLAN_SUBIF, mp);
9606 mp->sw_if_index = ntohl (sw_if_index);
9607 mp->vlan_id = ntohl (vlan_id);
9614 #define foreach_create_subif_bit \
9621 _(outer_vlan_id_any) \
9622 _(inner_vlan_id_any)
9625 api_create_subif (vat_main_t * vam)
9627 unformat_input_t *i = vam->input;
9628 vl_api_create_subif_t *mp;
9630 u8 sw_if_index_set = 0;
9637 u32 exact_match = 0;
9638 u32 default_sub = 0;
9639 u32 outer_vlan_id_any = 0;
9640 u32 inner_vlan_id_any = 0;
9642 u16 outer_vlan_id = 0;
9643 u16 inner_vlan_id = 0;
9646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9648 if (unformat (i, "sw_if_index %d", &sw_if_index))
9649 sw_if_index_set = 1;
9651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9652 sw_if_index_set = 1;
9653 else if (unformat (i, "sub_id %d", &sub_id))
9655 else if (unformat (i, "outer_vlan_id %d", &tmp))
9656 outer_vlan_id = tmp;
9657 else if (unformat (i, "inner_vlan_id %d", &tmp))
9658 inner_vlan_id = tmp;
9660 #define _(a) else if (unformat (i, #a)) a = 1 ;
9661 foreach_create_subif_bit
9665 clib_warning ("parse error '%U'", format_unformat_error, i);
9670 if (sw_if_index_set == 0)
9672 errmsg ("missing interface name or sw_if_index");
9676 if (sub_id_set == 0)
9678 errmsg ("missing sub_id");
9681 M (CREATE_SUBIF, mp);
9683 mp->sw_if_index = ntohl (sw_if_index);
9684 mp->sub_id = ntohl (sub_id);
9686 #define _(a) mp->a = a;
9687 foreach_create_subif_bit;
9690 mp->outer_vlan_id = ntohs (outer_vlan_id);
9691 mp->inner_vlan_id = ntohs (inner_vlan_id);
9699 api_oam_add_del (vat_main_t * vam)
9701 unformat_input_t *i = vam->input;
9702 vl_api_oam_add_del_t *mp;
9705 ip4_address_t src, dst;
9710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9712 if (unformat (i, "vrf %d", &vrf_id))
9714 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9716 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9718 else if (unformat (i, "del"))
9722 clib_warning ("parse error '%U'", format_unformat_error, i);
9729 errmsg ("missing src addr");
9735 errmsg ("missing dst addr");
9739 M (OAM_ADD_DEL, mp);
9741 mp->vrf_id = ntohl (vrf_id);
9742 mp->is_add = is_add;
9743 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9744 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9752 api_reset_fib (vat_main_t * vam)
9754 unformat_input_t *i = vam->input;
9755 vl_api_reset_fib_t *mp;
9761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9763 if (unformat (i, "vrf %d", &vrf_id))
9765 else if (unformat (i, "ipv6"))
9769 clib_warning ("parse error '%U'", format_unformat_error, i);
9774 if (vrf_id_set == 0)
9776 errmsg ("missing vrf id");
9782 mp->vrf_id = ntohl (vrf_id);
9783 mp->is_ipv6 = is_ipv6;
9791 api_dhcp_proxy_config (vat_main_t * vam)
9793 unformat_input_t *i = vam->input;
9794 vl_api_dhcp_proxy_config_t *mp;
9796 u32 server_vrf_id = 0;
9798 u8 v4_address_set = 0;
9799 u8 v6_address_set = 0;
9800 ip4_address_t v4address;
9801 ip6_address_t v6address;
9802 u8 v4_src_address_set = 0;
9803 u8 v6_src_address_set = 0;
9804 ip4_address_t v4srcaddress;
9805 ip6_address_t v6srcaddress;
9808 /* Parse args required to build the message */
9809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9811 if (unformat (i, "del"))
9813 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9815 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9817 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9819 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9821 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9822 v4_src_address_set = 1;
9823 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9824 v6_src_address_set = 1;
9829 if (v4_address_set && v6_address_set)
9831 errmsg ("both v4 and v6 server addresses set");
9834 if (!v4_address_set && !v6_address_set)
9836 errmsg ("no server addresses set");
9840 if (v4_src_address_set && v6_src_address_set)
9842 errmsg ("both v4 and v6 src addresses set");
9845 if (!v4_src_address_set && !v6_src_address_set)
9847 errmsg ("no src addresses set");
9851 if (!(v4_src_address_set && v4_address_set) &&
9852 !(v6_src_address_set && v6_address_set))
9854 errmsg ("no matching server and src addresses set");
9858 /* Construct the API message */
9859 M (DHCP_PROXY_CONFIG, mp);
9861 mp->is_add = is_add;
9862 mp->rx_vrf_id = ntohl (rx_vrf_id);
9863 mp->server_vrf_id = ntohl (server_vrf_id);
9867 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9868 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9872 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9873 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9879 /* Wait for a reply, return good/bad news */
9884 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9885 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9888 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9890 vat_main_t *vam = &vat_main;
9891 u32 i, count = mp->count;
9892 vl_api_dhcp_server_t *s;
9896 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9897 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9898 ntohl (mp->rx_vrf_id),
9899 format_ip6_address, mp->dhcp_src_address,
9900 mp->vss_type, mp->vss_vpn_ascii_id,
9901 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9904 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9905 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9906 ntohl (mp->rx_vrf_id),
9907 format_ip4_address, mp->dhcp_src_address,
9908 mp->vss_type, mp->vss_vpn_ascii_id,
9909 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9911 for (i = 0; i < count; i++)
9913 s = &mp->servers[i];
9917 " Server Table-ID %d, Server Address %U",
9918 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9921 " Server Table-ID %d, Server Address %U",
9922 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9926 static void vl_api_dhcp_proxy_details_t_handler_json
9927 (vl_api_dhcp_proxy_details_t * mp)
9929 vat_main_t *vam = &vat_main;
9930 vat_json_node_t *node = NULL;
9931 u32 i, count = mp->count;
9933 struct in6_addr ip6;
9934 vl_api_dhcp_server_t *s;
9936 if (VAT_JSON_ARRAY != vam->json_tree.type)
9938 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9939 vat_json_init_array (&vam->json_tree);
9941 node = vat_json_array_add (&vam->json_tree);
9943 vat_json_init_object (node);
9944 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9945 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9946 sizeof (mp->vss_type));
9947 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9948 mp->vss_vpn_ascii_id);
9949 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9950 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9954 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9955 vat_json_object_add_ip6 (node, "src_address", ip6);
9959 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9960 vat_json_object_add_ip4 (node, "src_address", ip4);
9963 for (i = 0; i < count; i++)
9965 s = &mp->servers[i];
9967 vat_json_object_add_uint (node, "server-table-id",
9968 ntohl (s->server_vrf_id));
9972 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9973 vat_json_object_add_ip4 (node, "src_address", ip4);
9977 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9978 vat_json_object_add_ip6 (node, "server_address", ip6);
9984 api_dhcp_proxy_dump (vat_main_t * vam)
9986 unformat_input_t *i = vam->input;
9987 vl_api_control_ping_t *mp_ping;
9988 vl_api_dhcp_proxy_dump_t *mp;
9992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9994 if (unformat (i, "ipv6"))
9998 clib_warning ("parse error '%U'", format_unformat_error, i);
10003 M (DHCP_PROXY_DUMP, mp);
10005 mp->is_ip6 = is_ipv6;
10008 /* Use a control ping for synchronization */
10009 MPING (CONTROL_PING, mp_ping);
10017 api_dhcp_proxy_set_vss (vat_main_t * vam)
10019 unformat_input_t *i = vam->input;
10020 vl_api_dhcp_proxy_set_vss_t *mp;
10024 u8 vss_type = VSS_TYPE_DEFAULT;
10025 u8 *vpn_ascii_id = 0;
10030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10032 if (unformat (i, "tbl_id %d", &tbl_id))
10034 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
10035 vss_type = VSS_TYPE_ASCII;
10036 else if (unformat (i, "fib_id %d", &fib_id))
10037 vss_type = VSS_TYPE_VPN_ID;
10038 else if (unformat (i, "oui %d", &oui))
10039 vss_type = VSS_TYPE_VPN_ID;
10040 else if (unformat (i, "ipv6"))
10042 else if (unformat (i, "del"))
10050 errmsg ("missing tbl_id ");
10051 vec_free (vpn_ascii_id);
10055 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
10057 errmsg ("vpn_ascii_id cannot be longer than 128 ");
10058 vec_free (vpn_ascii_id);
10062 M (DHCP_PROXY_SET_VSS, mp);
10063 mp->tbl_id = ntohl (tbl_id);
10064 mp->vss_type = vss_type;
10067 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
10068 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
10070 mp->vpn_index = ntohl (fib_id);
10071 mp->oui = ntohl (oui);
10072 mp->is_ipv6 = is_ipv6;
10073 mp->is_add = is_add;
10078 vec_free (vpn_ascii_id);
10083 api_dhcp_client_config (vat_main_t * vam)
10085 unformat_input_t *i = vam->input;
10086 vl_api_dhcp_client_config_t *mp;
10088 u8 sw_if_index_set = 0;
10091 u8 disable_event = 0;
10094 /* Parse args required to build the message */
10095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10097 if (unformat (i, "del"))
10100 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10101 sw_if_index_set = 1;
10102 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10103 sw_if_index_set = 1;
10104 else if (unformat (i, "hostname %s", &hostname))
10106 else if (unformat (i, "disable_event"))
10112 if (sw_if_index_set == 0)
10114 errmsg ("missing interface name or sw_if_index");
10118 if (vec_len (hostname) > 63)
10120 errmsg ("hostname too long");
10122 vec_add1 (hostname, 0);
10124 /* Construct the API message */
10125 M (DHCP_CLIENT_CONFIG, mp);
10127 mp->sw_if_index = htonl (sw_if_index);
10128 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
10129 vec_free (hostname);
10130 mp->is_add = is_add;
10131 mp->want_dhcp_event = disable_event ? 0 : 1;
10132 mp->pid = htonl (getpid ());
10137 /* Wait for a reply, return good/bad news */
10143 api_set_ip_flow_hash (vat_main_t * vam)
10145 unformat_input_t *i = vam->input;
10146 vl_api_set_ip_flow_hash_t *mp;
10158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10160 if (unformat (i, "vrf %d", &vrf_id))
10162 else if (unformat (i, "ipv6"))
10164 else if (unformat (i, "src"))
10166 else if (unformat (i, "dst"))
10168 else if (unformat (i, "sport"))
10170 else if (unformat (i, "dport"))
10172 else if (unformat (i, "proto"))
10174 else if (unformat (i, "reverse"))
10179 clib_warning ("parse error '%U'", format_unformat_error, i);
10184 if (vrf_id_set == 0)
10186 errmsg ("missing vrf id");
10190 M (SET_IP_FLOW_HASH, mp);
10196 mp->reverse = reverse;
10197 mp->vrf_id = ntohl (vrf_id);
10198 mp->is_ipv6 = is_ipv6;
10206 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10208 unformat_input_t *i = vam->input;
10209 vl_api_sw_interface_ip6_enable_disable_t *mp;
10211 u8 sw_if_index_set = 0;
10215 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10217 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10218 sw_if_index_set = 1;
10219 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10220 sw_if_index_set = 1;
10221 else if (unformat (i, "enable"))
10223 else if (unformat (i, "disable"))
10227 clib_warning ("parse error '%U'", format_unformat_error, i);
10232 if (sw_if_index_set == 0)
10234 errmsg ("missing interface name or sw_if_index");
10238 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10240 mp->sw_if_index = ntohl (sw_if_index);
10241 mp->enable = enable;
10249 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
10251 unformat_input_t *i = vam->input;
10252 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
10254 u8 sw_if_index_set = 0;
10255 u8 v6_address_set = 0;
10256 ip6_address_t v6address;
10259 /* Parse args required to build the message */
10260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10263 sw_if_index_set = 1;
10264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10265 sw_if_index_set = 1;
10266 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10267 v6_address_set = 1;
10272 if (sw_if_index_set == 0)
10274 errmsg ("missing interface name or sw_if_index");
10277 if (!v6_address_set)
10279 errmsg ("no address set");
10283 /* Construct the API message */
10284 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
10286 mp->sw_if_index = ntohl (sw_if_index);
10287 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10292 /* Wait for a reply, return good/bad news */
10298 api_ip6nd_proxy_add_del (vat_main_t * vam)
10300 unformat_input_t *i = vam->input;
10301 vl_api_ip6nd_proxy_add_del_t *mp;
10302 u32 sw_if_index = ~0;
10303 u8 v6_address_set = 0;
10304 ip6_address_t v6address;
10308 /* Parse args required to build the message */
10309 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10315 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
10316 v6_address_set = 1;
10317 if (unformat (i, "del"))
10321 clib_warning ("parse error '%U'", format_unformat_error, i);
10326 if (sw_if_index == ~0)
10328 errmsg ("missing interface name or sw_if_index");
10331 if (!v6_address_set)
10333 errmsg ("no address set");
10337 /* Construct the API message */
10338 M (IP6ND_PROXY_ADD_DEL, mp);
10340 mp->is_del = is_del;
10341 mp->sw_if_index = ntohl (sw_if_index);
10342 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10347 /* Wait for a reply, return good/bad news */
10353 api_ip6nd_proxy_dump (vat_main_t * vam)
10355 vl_api_ip6nd_proxy_dump_t *mp;
10356 vl_api_control_ping_t *mp_ping;
10359 M (IP6ND_PROXY_DUMP, mp);
10363 /* Use a control ping for synchronization */
10364 MPING (CONTROL_PING, mp_ping);
10371 static void vl_api_ip6nd_proxy_details_t_handler
10372 (vl_api_ip6nd_proxy_details_t * mp)
10374 vat_main_t *vam = &vat_main;
10376 print (vam->ofp, "host %U sw_if_index %d",
10377 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
10380 static void vl_api_ip6nd_proxy_details_t_handler_json
10381 (vl_api_ip6nd_proxy_details_t * mp)
10383 vat_main_t *vam = &vat_main;
10384 struct in6_addr ip6;
10385 vat_json_node_t *node = NULL;
10387 if (VAT_JSON_ARRAY != vam->json_tree.type)
10389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10390 vat_json_init_array (&vam->json_tree);
10392 node = vat_json_array_add (&vam->json_tree);
10394 vat_json_init_object (node);
10395 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10397 clib_memcpy (&ip6, mp->address, sizeof (ip6));
10398 vat_json_object_add_ip6 (node, "host", ip6);
10402 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10404 unformat_input_t *i = vam->input;
10405 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10407 u8 sw_if_index_set = 0;
10408 u32 address_length = 0;
10409 u8 v6_address_set = 0;
10410 ip6_address_t v6address;
10411 u8 use_default = 0;
10412 u8 no_advertise = 0;
10414 u8 no_autoconfig = 0;
10417 u32 val_lifetime = 0;
10418 u32 pref_lifetime = 0;
10421 /* Parse args required to build the message */
10422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10424 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10425 sw_if_index_set = 1;
10426 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10427 sw_if_index_set = 1;
10428 else if (unformat (i, "%U/%d",
10429 unformat_ip6_address, &v6address, &address_length))
10430 v6_address_set = 1;
10431 else if (unformat (i, "val_life %d", &val_lifetime))
10433 else if (unformat (i, "pref_life %d", &pref_lifetime))
10435 else if (unformat (i, "def"))
10437 else if (unformat (i, "noadv"))
10439 else if (unformat (i, "offl"))
10441 else if (unformat (i, "noauto"))
10443 else if (unformat (i, "nolink"))
10445 else if (unformat (i, "isno"))
10449 clib_warning ("parse error '%U'", format_unformat_error, i);
10454 if (sw_if_index_set == 0)
10456 errmsg ("missing interface name or sw_if_index");
10459 if (!v6_address_set)
10461 errmsg ("no address set");
10465 /* Construct the API message */
10466 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10468 mp->sw_if_index = ntohl (sw_if_index);
10469 clib_memcpy (mp->address, &v6address, sizeof (v6address));
10470 mp->address_length = address_length;
10471 mp->use_default = use_default;
10472 mp->no_advertise = no_advertise;
10473 mp->off_link = off_link;
10474 mp->no_autoconfig = no_autoconfig;
10475 mp->no_onlink = no_onlink;
10477 mp->val_lifetime = ntohl (val_lifetime);
10478 mp->pref_lifetime = ntohl (pref_lifetime);
10483 /* Wait for a reply, return good/bad news */
10489 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10491 unformat_input_t *i = vam->input;
10492 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10494 u8 sw_if_index_set = 0;
10499 u8 send_unicast = 0;
10502 u8 default_router = 0;
10503 u32 max_interval = 0;
10504 u32 min_interval = 0;
10506 u32 initial_count = 0;
10507 u32 initial_interval = 0;
10511 /* Parse args required to build the message */
10512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10514 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10515 sw_if_index_set = 1;
10516 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10517 sw_if_index_set = 1;
10518 else if (unformat (i, "maxint %d", &max_interval))
10520 else if (unformat (i, "minint %d", &min_interval))
10522 else if (unformat (i, "life %d", &lifetime))
10524 else if (unformat (i, "count %d", &initial_count))
10526 else if (unformat (i, "interval %d", &initial_interval))
10528 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10530 else if (unformat (i, "managed"))
10532 else if (unformat (i, "other"))
10534 else if (unformat (i, "ll"))
10536 else if (unformat (i, "send"))
10538 else if (unformat (i, "cease"))
10540 else if (unformat (i, "isno"))
10542 else if (unformat (i, "def"))
10543 default_router = 1;
10546 clib_warning ("parse error '%U'", format_unformat_error, i);
10551 if (sw_if_index_set == 0)
10553 errmsg ("missing interface name or sw_if_index");
10557 /* Construct the API message */
10558 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10560 mp->sw_if_index = ntohl (sw_if_index);
10561 mp->max_interval = ntohl (max_interval);
10562 mp->min_interval = ntohl (min_interval);
10563 mp->lifetime = ntohl (lifetime);
10564 mp->initial_count = ntohl (initial_count);
10565 mp->initial_interval = ntohl (initial_interval);
10566 mp->suppress = suppress;
10567 mp->managed = managed;
10569 mp->ll_option = ll_option;
10570 mp->send_unicast = send_unicast;
10573 mp->default_router = default_router;
10578 /* Wait for a reply, return good/bad news */
10584 api_set_arp_neighbor_limit (vat_main_t * vam)
10586 unformat_input_t *i = vam->input;
10587 vl_api_set_arp_neighbor_limit_t *mp;
10593 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10595 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10597 else if (unformat (i, "ipv6"))
10601 clib_warning ("parse error '%U'", format_unformat_error, i);
10606 if (limit_set == 0)
10608 errmsg ("missing limit value");
10612 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10614 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10615 mp->is_ipv6 = is_ipv6;
10623 api_l2_patch_add_del (vat_main_t * vam)
10625 unformat_input_t *i = vam->input;
10626 vl_api_l2_patch_add_del_t *mp;
10627 u32 rx_sw_if_index;
10628 u8 rx_sw_if_index_set = 0;
10629 u32 tx_sw_if_index;
10630 u8 tx_sw_if_index_set = 0;
10634 /* Parse args required to build the message */
10635 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10637 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10638 rx_sw_if_index_set = 1;
10639 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10640 tx_sw_if_index_set = 1;
10641 else if (unformat (i, "rx"))
10643 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10645 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10647 rx_sw_if_index_set = 1;
10652 else if (unformat (i, "tx"))
10654 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10656 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10658 tx_sw_if_index_set = 1;
10663 else if (unformat (i, "del"))
10669 if (rx_sw_if_index_set == 0)
10671 errmsg ("missing rx interface name or rx_sw_if_index");
10675 if (tx_sw_if_index_set == 0)
10677 errmsg ("missing tx interface name or tx_sw_if_index");
10681 M (L2_PATCH_ADD_DEL, mp);
10683 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10684 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10685 mp->is_add = is_add;
10693 u8 localsid_addr[16];
10702 api_sr_localsid_add_del (vat_main_t * vam)
10704 unformat_input_t *i = vam->input;
10705 vl_api_sr_localsid_add_del_t *mp;
10708 ip6_address_t localsid;
10712 u32 fib_table = ~(u32) 0;
10713 ip6_address_t next_hop;
10715 bool nexthop_set = 0;
10719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10721 if (unformat (i, "del"))
10723 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10724 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10726 else if (unformat (i, "behavior %u", &behavior));
10727 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10728 else if (unformat (i, "fib-table %u", &fib_table));
10729 else if (unformat (i, "end.psp %u", &behavior));
10734 M (SR_LOCALSID_ADD_DEL, mp);
10736 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10738 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10739 mp->behavior = behavior;
10740 mp->sw_if_index = ntohl (sw_if_index);
10741 mp->fib_table = ntohl (fib_table);
10742 mp->end_psp = end_psp;
10743 mp->is_del = is_del;
10751 api_ioam_enable (vat_main_t * vam)
10753 unformat_input_t *input = vam->input;
10754 vl_api_ioam_enable_t *mp;
10756 int has_trace_option = 0;
10757 int has_pot_option = 0;
10758 int has_seqno_option = 0;
10759 int has_analyse_option = 0;
10762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10764 if (unformat (input, "trace"))
10765 has_trace_option = 1;
10766 else if (unformat (input, "pot"))
10767 has_pot_option = 1;
10768 else if (unformat (input, "seqno"))
10769 has_seqno_option = 1;
10770 else if (unformat (input, "analyse"))
10771 has_analyse_option = 1;
10775 M (IOAM_ENABLE, mp);
10776 mp->id = htons (id);
10777 mp->seqno = has_seqno_option;
10778 mp->analyse = has_analyse_option;
10779 mp->pot_enable = has_pot_option;
10780 mp->trace_enable = has_trace_option;
10789 api_ioam_disable (vat_main_t * vam)
10791 vl_api_ioam_disable_t *mp;
10794 M (IOAM_DISABLE, mp);
10800 #define foreach_tcp_proto_field \
10804 #define foreach_udp_proto_field \
10808 #define foreach_ip4_proto_field \
10820 u16 src_port, dst_port;
10823 #if VPP_API_TEST_BUILTIN == 0
10825 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10827 u8 **maskp = va_arg (*args, u8 **);
10829 u8 found_something = 0;
10832 #define _(a) u8 a=0;
10833 foreach_tcp_proto_field;
10836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10839 #define _(a) else if (unformat (input, #a)) a=1;
10840 foreach_tcp_proto_field
10846 #define _(a) found_something += a;
10847 foreach_tcp_proto_field;
10850 if (found_something == 0)
10853 vec_validate (mask, sizeof (*tcp) - 1);
10855 tcp = (tcp_header_t *) mask;
10857 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10858 foreach_tcp_proto_field;
10866 unformat_udp_mask (unformat_input_t * input, va_list * args)
10868 u8 **maskp = va_arg (*args, u8 **);
10870 u8 found_something = 0;
10873 #define _(a) u8 a=0;
10874 foreach_udp_proto_field;
10877 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10880 #define _(a) else if (unformat (input, #a)) a=1;
10881 foreach_udp_proto_field
10887 #define _(a) found_something += a;
10888 foreach_udp_proto_field;
10891 if (found_something == 0)
10894 vec_validate (mask, sizeof (*udp) - 1);
10896 udp = (udp_header_t *) mask;
10898 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10899 foreach_udp_proto_field;
10907 unformat_l4_mask (unformat_input_t * input, va_list * args)
10909 u8 **maskp = va_arg (*args, u8 **);
10910 u16 src_port = 0, dst_port = 0;
10911 tcpudp_header_t *tcpudp;
10913 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10915 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10917 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10919 else if (unformat (input, "src_port"))
10921 else if (unformat (input, "dst_port"))
10927 if (!src_port && !dst_port)
10931 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10933 tcpudp = (tcpudp_header_t *) mask;
10934 tcpudp->src_port = src_port;
10935 tcpudp->dst_port = dst_port;
10943 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10945 u8 **maskp = va_arg (*args, u8 **);
10947 u8 found_something = 0;
10950 #define _(a) u8 a=0;
10951 foreach_ip4_proto_field;
10957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10959 if (unformat (input, "version"))
10961 else if (unformat (input, "hdr_length"))
10963 else if (unformat (input, "src"))
10965 else if (unformat (input, "dst"))
10967 else if (unformat (input, "proto"))
10970 #define _(a) else if (unformat (input, #a)) a=1;
10971 foreach_ip4_proto_field
10977 #define _(a) found_something += a;
10978 foreach_ip4_proto_field;
10981 if (found_something == 0)
10984 vec_validate (mask, sizeof (*ip) - 1);
10986 ip = (ip4_header_t *) mask;
10988 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10989 foreach_ip4_proto_field;
10992 ip->ip_version_and_header_length = 0;
10995 ip->ip_version_and_header_length |= 0xF0;
10998 ip->ip_version_and_header_length |= 0x0F;
11004 #define foreach_ip6_proto_field \
11007 _(payload_length) \
11012 unformat_ip6_mask (unformat_input_t * input, va_list * args)
11014 u8 **maskp = va_arg (*args, u8 **);
11016 u8 found_something = 0;
11018 u32 ip_version_traffic_class_and_flow_label;
11020 #define _(a) u8 a=0;
11021 foreach_ip6_proto_field;
11024 u8 traffic_class = 0;
11027 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11029 if (unformat (input, "version"))
11031 else if (unformat (input, "traffic-class"))
11033 else if (unformat (input, "flow-label"))
11035 else if (unformat (input, "src"))
11037 else if (unformat (input, "dst"))
11039 else if (unformat (input, "proto"))
11042 #define _(a) else if (unformat (input, #a)) a=1;
11043 foreach_ip6_proto_field
11049 #define _(a) found_something += a;
11050 foreach_ip6_proto_field;
11053 if (found_something == 0)
11056 vec_validate (mask, sizeof (*ip) - 1);
11058 ip = (ip6_header_t *) mask;
11060 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
11061 foreach_ip6_proto_field;
11064 ip_version_traffic_class_and_flow_label = 0;
11067 ip_version_traffic_class_and_flow_label |= 0xF0000000;
11070 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
11073 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
11075 ip->ip_version_traffic_class_and_flow_label =
11076 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11083 unformat_l3_mask (unformat_input_t * input, va_list * args)
11085 u8 **maskp = va_arg (*args, u8 **);
11087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11089 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
11091 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
11100 unformat_l2_mask (unformat_input_t * input, va_list * args)
11102 u8 **maskp = va_arg (*args, u8 **);
11109 u8 ignore_tag1 = 0;
11110 u8 ignore_tag2 = 0;
11117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11119 if (unformat (input, "src"))
11121 else if (unformat (input, "dst"))
11123 else if (unformat (input, "proto"))
11125 else if (unformat (input, "tag1"))
11127 else if (unformat (input, "tag2"))
11129 else if (unformat (input, "ignore-tag1"))
11131 else if (unformat (input, "ignore-tag2"))
11133 else if (unformat (input, "cos1"))
11135 else if (unformat (input, "cos2"))
11137 else if (unformat (input, "dot1q"))
11139 else if (unformat (input, "dot1ad"))
11144 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
11145 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11148 if (tag1 || ignore_tag1 || cos1 || dot1q)
11150 if (tag2 || ignore_tag2 || cos2 || dot1ad)
11153 vec_validate (mask, len - 1);
11156 memset (mask, 0xff, 6);
11159 memset (mask + 6, 0xff, 6);
11161 if (tag2 || dot1ad)
11163 /* inner vlan tag */
11172 mask[21] = mask[20] = 0xff;
11193 mask[16] = mask[17] = 0xff;
11203 mask[12] = mask[13] = 0xff;
11210 unformat_classify_mask (unformat_input_t * input, va_list * args)
11212 u8 **maskp = va_arg (*args, u8 **);
11213 u32 *skipp = va_arg (*args, u32 *);
11214 u32 *matchp = va_arg (*args, u32 *);
11222 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11224 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11226 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11228 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11230 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11244 if (mask || l2 || l3 || l4)
11246 if (l2 || l3 || l4)
11248 /* "With a free Ethernet header in every package" */
11250 vec_validate (l2, 13);
11254 vec_append (mask, l3);
11259 vec_append (mask, l4);
11264 /* Scan forward looking for the first significant mask octet */
11265 for (i = 0; i < vec_len (mask); i++)
11269 /* compute (skip, match) params */
11270 *skipp = i / sizeof (u32x4);
11271 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11273 /* Pad mask to an even multiple of the vector size */
11274 while (vec_len (mask) % sizeof (u32x4))
11275 vec_add1 (mask, 0);
11277 match = vec_len (mask) / sizeof (u32x4);
11279 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11281 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11282 if (*tmp || *(tmp + 1))
11287 clib_warning ("BUG: match 0");
11289 _vec_len (mask) = match * sizeof (u32x4);
11299 #endif /* VPP_API_TEST_BUILTIN */
11301 #define foreach_l2_next \
11303 _(ethernet, ETHERNET_INPUT) \
11304 _(ip4, IP4_INPUT) \
11308 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11310 u32 *miss_next_indexp = va_arg (*args, u32 *);
11311 u32 next_index = 0;
11315 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11319 if (unformat (input, "%d", &tmp))
11328 *miss_next_indexp = next_index;
11332 #define foreach_ip_next \
11335 _(rewrite, REWRITE)
11338 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11340 u32 *miss_next_indexp = va_arg (*args, u32 *);
11341 u32 next_index = 0;
11345 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11349 if (unformat (input, "%d", &tmp))
11358 *miss_next_indexp = next_index;
11362 #define foreach_acl_next \
11366 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11368 u32 *miss_next_indexp = va_arg (*args, u32 *);
11369 u32 next_index = 0;
11373 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11377 if (unformat (input, "permit"))
11382 else if (unformat (input, "%d", &tmp))
11391 *miss_next_indexp = next_index;
11396 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11398 u32 *r = va_arg (*args, u32 *);
11400 if (unformat (input, "conform-color"))
11401 *r = POLICE_CONFORM;
11402 else if (unformat (input, "exceed-color"))
11403 *r = POLICE_EXCEED;
11411 api_classify_add_del_table (vat_main_t * vam)
11413 unformat_input_t *i = vam->input;
11414 vl_api_classify_add_del_table_t *mp;
11421 u32 table_index = ~0;
11422 u32 next_table_index = ~0;
11423 u32 miss_next_index = ~0;
11424 u32 memory_size = 32 << 20;
11426 u32 current_data_flag = 0;
11427 int current_data_offset = 0;
11430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11432 if (unformat (i, "del"))
11434 else if (unformat (i, "del-chain"))
11439 else if (unformat (i, "buckets %d", &nbuckets))
11441 else if (unformat (i, "memory_size %d", &memory_size))
11443 else if (unformat (i, "skip %d", &skip))
11445 else if (unformat (i, "match %d", &match))
11447 else if (unformat (i, "table %d", &table_index))
11449 else if (unformat (i, "mask %U", unformat_classify_mask,
11450 &mask, &skip, &match))
11452 else if (unformat (i, "next-table %d", &next_table_index))
11454 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11457 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11460 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11463 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11465 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11471 if (is_add && mask == 0)
11473 errmsg ("Mask required");
11477 if (is_add && skip == ~0)
11479 errmsg ("skip count required");
11483 if (is_add && match == ~0)
11485 errmsg ("match count required");
11489 if (!is_add && table_index == ~0)
11491 errmsg ("table index required for delete");
11495 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11497 mp->is_add = is_add;
11498 mp->del_chain = del_chain;
11499 mp->table_index = ntohl (table_index);
11500 mp->nbuckets = ntohl (nbuckets);
11501 mp->memory_size = ntohl (memory_size);
11502 mp->skip_n_vectors = ntohl (skip);
11503 mp->match_n_vectors = ntohl (match);
11504 mp->next_table_index = ntohl (next_table_index);
11505 mp->miss_next_index = ntohl (miss_next_index);
11506 mp->current_data_flag = ntohl (current_data_flag);
11507 mp->current_data_offset = ntohl (current_data_offset);
11508 clib_memcpy (mp->mask, mask, vec_len (mask));
11517 #if VPP_API_TEST_BUILTIN == 0
11519 unformat_l4_match (unformat_input_t * input, va_list * args)
11521 u8 **matchp = va_arg (*args, u8 **);
11523 u8 *proto_header = 0;
11529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11531 if (unformat (input, "src_port %d", &src_port))
11533 else if (unformat (input, "dst_port %d", &dst_port))
11539 h.src_port = clib_host_to_net_u16 (src_port);
11540 h.dst_port = clib_host_to_net_u16 (dst_port);
11541 vec_validate (proto_header, sizeof (h) - 1);
11542 memcpy (proto_header, &h, sizeof (h));
11544 *matchp = proto_header;
11550 unformat_ip4_match (unformat_input_t * input, va_list * args)
11552 u8 **matchp = va_arg (*args, u8 **);
11557 int hdr_length = 0;
11558 u32 hdr_length_val;
11559 int src = 0, dst = 0;
11560 ip4_address_t src_val, dst_val;
11567 int fragment_id = 0;
11568 u32 fragment_id_val;
11574 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11576 if (unformat (input, "version %d", &version_val))
11578 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11580 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11582 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11584 else if (unformat (input, "proto %d", &proto_val))
11586 else if (unformat (input, "tos %d", &tos_val))
11588 else if (unformat (input, "length %d", &length_val))
11590 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11592 else if (unformat (input, "ttl %d", &ttl_val))
11594 else if (unformat (input, "checksum %d", &checksum_val))
11600 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11601 + ttl + checksum == 0)
11605 * Aligned because we use the real comparison functions
11607 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11609 ip = (ip4_header_t *) match;
11611 /* These are realistically matched in practice */
11613 ip->src_address.as_u32 = src_val.as_u32;
11616 ip->dst_address.as_u32 = dst_val.as_u32;
11619 ip->protocol = proto_val;
11622 /* These are not, but they're included for completeness */
11624 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11627 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11633 ip->length = clib_host_to_net_u16 (length_val);
11639 ip->checksum = clib_host_to_net_u16 (checksum_val);
11646 unformat_ip6_match (unformat_input_t * input, va_list * args)
11648 u8 **matchp = va_arg (*args, u8 **);
11653 u8 traffic_class = 0;
11654 u32 traffic_class_val = 0;
11657 int src = 0, dst = 0;
11658 ip6_address_t src_val, dst_val;
11661 int payload_length = 0;
11662 u32 payload_length_val;
11665 u32 ip_version_traffic_class_and_flow_label;
11667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11669 if (unformat (input, "version %d", &version_val))
11671 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11673 else if (unformat (input, "flow_label %d", &flow_label_val))
11675 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11677 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11679 else if (unformat (input, "proto %d", &proto_val))
11681 else if (unformat (input, "payload_length %d", &payload_length_val))
11682 payload_length = 1;
11683 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11689 if (version + traffic_class + flow_label + src + dst + proto +
11690 payload_length + hop_limit == 0)
11694 * Aligned because we use the real comparison functions
11696 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11698 ip = (ip6_header_t *) match;
11701 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11704 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11707 ip->protocol = proto_val;
11709 ip_version_traffic_class_and_flow_label = 0;
11712 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11715 ip_version_traffic_class_and_flow_label |=
11716 (traffic_class_val & 0xFF) << 20;
11719 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11721 ip->ip_version_traffic_class_and_flow_label =
11722 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11724 if (payload_length)
11725 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11728 ip->hop_limit = hop_limit_val;
11735 unformat_l3_match (unformat_input_t * input, va_list * args)
11737 u8 **matchp = va_arg (*args, u8 **);
11739 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11741 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11743 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11752 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11754 u8 *tagp = va_arg (*args, u8 *);
11757 if (unformat (input, "%d", &tag))
11759 tagp[0] = (tag >> 8) & 0x0F;
11760 tagp[1] = tag & 0xFF;
11768 unformat_l2_match (unformat_input_t * input, va_list * args)
11770 u8 **matchp = va_arg (*args, u8 **);
11783 u8 ignore_tag1 = 0;
11784 u8 ignore_tag2 = 0;
11790 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11792 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11795 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11797 else if (unformat (input, "proto %U",
11798 unformat_ethernet_type_host_byte_order, &proto_val))
11800 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11802 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11804 else if (unformat (input, "ignore-tag1"))
11806 else if (unformat (input, "ignore-tag2"))
11808 else if (unformat (input, "cos1 %d", &cos1_val))
11810 else if (unformat (input, "cos2 %d", &cos2_val))
11815 if ((src + dst + proto + tag1 + tag2 +
11816 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11819 if (tag1 || ignore_tag1 || cos1)
11821 if (tag2 || ignore_tag2 || cos2)
11824 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11827 clib_memcpy (match, dst_val, 6);
11830 clib_memcpy (match + 6, src_val, 6);
11834 /* inner vlan tag */
11835 match[19] = tag2_val[1];
11836 match[18] = tag2_val[0];
11838 match[18] |= (cos2_val & 0x7) << 5;
11841 match[21] = proto_val & 0xff;
11842 match[20] = proto_val >> 8;
11846 match[15] = tag1_val[1];
11847 match[14] = tag1_val[0];
11850 match[14] |= (cos1_val & 0x7) << 5;
11856 match[15] = tag1_val[1];
11857 match[14] = tag1_val[0];
11860 match[17] = proto_val & 0xff;
11861 match[16] = proto_val >> 8;
11864 match[14] |= (cos1_val & 0x7) << 5;
11870 match[18] |= (cos2_val & 0x7) << 5;
11872 match[14] |= (cos1_val & 0x7) << 5;
11875 match[13] = proto_val & 0xff;
11876 match[12] = proto_val >> 8;
11884 unformat_qos_source (unformat_input_t * input, va_list * args)
11886 int *qs = va_arg (*args, int *);
11888 if (unformat (input, "ip"))
11889 *qs = QOS_SOURCE_IP;
11890 else if (unformat (input, "mpls"))
11891 *qs = QOS_SOURCE_MPLS;
11892 else if (unformat (input, "ext"))
11893 *qs = QOS_SOURCE_EXT;
11894 else if (unformat (input, "vlan"))
11895 *qs = QOS_SOURCE_VLAN;
11904 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11906 u8 **matchp = va_arg (*args, u8 **);
11907 u32 skip_n_vectors = va_arg (*args, u32);
11908 u32 match_n_vectors = va_arg (*args, u32);
11915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11917 if (unformat (input, "hex %U", unformat_hex_string, &match))
11919 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11921 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11923 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11937 if (match || l2 || l3 || l4)
11939 if (l2 || l3 || l4)
11941 /* "Win a free Ethernet header in every packet" */
11943 vec_validate_aligned (l2, 13, sizeof (u32x4));
11947 vec_append_aligned (match, l3, sizeof (u32x4));
11952 vec_append_aligned (match, l4, sizeof (u32x4));
11957 /* Make sure the vector is big enough even if key is all 0's */
11958 vec_validate_aligned
11959 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11962 /* Set size, include skipped vectors */
11963 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11974 api_classify_add_del_session (vat_main_t * vam)
11976 unformat_input_t *i = vam->input;
11977 vl_api_classify_add_del_session_t *mp;
11979 u32 table_index = ~0;
11980 u32 hit_next_index = ~0;
11981 u32 opaque_index = ~0;
11984 u32 skip_n_vectors = 0;
11985 u32 match_n_vectors = 0;
11991 * Warning: you have to supply skip_n and match_n
11992 * because the API client cant simply look at the classify
11996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11998 if (unformat (i, "del"))
12000 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
12003 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
12006 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
12009 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
12011 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
12013 else if (unformat (i, "opaque-index %d", &opaque_index))
12015 else if (unformat (i, "skip_n %d", &skip_n_vectors))
12017 else if (unformat (i, "match_n %d", &match_n_vectors))
12019 else if (unformat (i, "match %U", api_unformat_classify_match,
12020 &match, skip_n_vectors, match_n_vectors))
12022 else if (unformat (i, "advance %d", &advance))
12024 else if (unformat (i, "table-index %d", &table_index))
12026 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
12028 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
12030 else if (unformat (i, "action %d", &action))
12032 else if (unformat (i, "metadata %d", &metadata))
12038 if (table_index == ~0)
12040 errmsg ("Table index required");
12044 if (is_add && match == 0)
12046 errmsg ("Match value required");
12050 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
12052 mp->is_add = is_add;
12053 mp->table_index = ntohl (table_index);
12054 mp->hit_next_index = ntohl (hit_next_index);
12055 mp->opaque_index = ntohl (opaque_index);
12056 mp->advance = ntohl (advance);
12057 mp->action = action;
12058 mp->metadata = ntohl (metadata);
12059 clib_memcpy (mp->match, match, vec_len (match));
12068 api_classify_set_interface_ip_table (vat_main_t * vam)
12070 unformat_input_t *i = vam->input;
12071 vl_api_classify_set_interface_ip_table_t *mp;
12073 int sw_if_index_set;
12074 u32 table_index = ~0;
12078 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12080 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12081 sw_if_index_set = 1;
12082 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12083 sw_if_index_set = 1;
12084 else if (unformat (i, "table %d", &table_index))
12088 clib_warning ("parse error '%U'", format_unformat_error, i);
12093 if (sw_if_index_set == 0)
12095 errmsg ("missing interface name or sw_if_index");
12100 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
12102 mp->sw_if_index = ntohl (sw_if_index);
12103 mp->table_index = ntohl (table_index);
12104 mp->is_ipv6 = is_ipv6;
12112 api_classify_set_interface_l2_tables (vat_main_t * vam)
12114 unformat_input_t *i = vam->input;
12115 vl_api_classify_set_interface_l2_tables_t *mp;
12117 int sw_if_index_set;
12118 u32 ip4_table_index = ~0;
12119 u32 ip6_table_index = ~0;
12120 u32 other_table_index = ~0;
12124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12126 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12127 sw_if_index_set = 1;
12128 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12129 sw_if_index_set = 1;
12130 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12132 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12134 else if (unformat (i, "other-table %d", &other_table_index))
12136 else if (unformat (i, "is-input %d", &is_input))
12140 clib_warning ("parse error '%U'", format_unformat_error, i);
12145 if (sw_if_index_set == 0)
12147 errmsg ("missing interface name or sw_if_index");
12152 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
12154 mp->sw_if_index = ntohl (sw_if_index);
12155 mp->ip4_table_index = ntohl (ip4_table_index);
12156 mp->ip6_table_index = ntohl (ip6_table_index);
12157 mp->other_table_index = ntohl (other_table_index);
12158 mp->is_input = (u8) is_input;
12166 api_set_ipfix_exporter (vat_main_t * vam)
12168 unformat_input_t *i = vam->input;
12169 vl_api_set_ipfix_exporter_t *mp;
12170 ip4_address_t collector_address;
12171 u8 collector_address_set = 0;
12172 u32 collector_port = ~0;
12173 ip4_address_t src_address;
12174 u8 src_address_set = 0;
12177 u32 template_interval = ~0;
12178 u8 udp_checksum = 0;
12181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12183 if (unformat (i, "collector_address %U", unformat_ip4_address,
12184 &collector_address))
12185 collector_address_set = 1;
12186 else if (unformat (i, "collector_port %d", &collector_port))
12188 else if (unformat (i, "src_address %U", unformat_ip4_address,
12190 src_address_set = 1;
12191 else if (unformat (i, "vrf_id %d", &vrf_id))
12193 else if (unformat (i, "path_mtu %d", &path_mtu))
12195 else if (unformat (i, "template_interval %d", &template_interval))
12197 else if (unformat (i, "udp_checksum"))
12203 if (collector_address_set == 0)
12205 errmsg ("collector_address required");
12209 if (src_address_set == 0)
12211 errmsg ("src_address required");
12215 M (SET_IPFIX_EXPORTER, mp);
12217 memcpy (mp->collector_address, collector_address.data,
12218 sizeof (collector_address.data));
12219 mp->collector_port = htons ((u16) collector_port);
12220 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12221 mp->vrf_id = htonl (vrf_id);
12222 mp->path_mtu = htonl (path_mtu);
12223 mp->template_interval = htonl (template_interval);
12224 mp->udp_checksum = udp_checksum;
12232 api_set_ipfix_classify_stream (vat_main_t * vam)
12234 unformat_input_t *i = vam->input;
12235 vl_api_set_ipfix_classify_stream_t *mp;
12237 u32 src_port = UDP_DST_PORT_ipfix;
12240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12242 if (unformat (i, "domain %d", &domain_id))
12244 else if (unformat (i, "src_port %d", &src_port))
12248 errmsg ("unknown input `%U'", format_unformat_error, i);
12253 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12255 mp->domain_id = htonl (domain_id);
12256 mp->src_port = htons ((u16) src_port);
12264 api_ipfix_classify_table_add_del (vat_main_t * vam)
12266 unformat_input_t *i = vam->input;
12267 vl_api_ipfix_classify_table_add_del_t *mp;
12269 u32 classify_table_index = ~0;
12271 u8 transport_protocol = 255;
12274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12276 if (unformat (i, "add"))
12278 else if (unformat (i, "del"))
12280 else if (unformat (i, "table %d", &classify_table_index))
12282 else if (unformat (i, "ip4"))
12284 else if (unformat (i, "ip6"))
12286 else if (unformat (i, "tcp"))
12287 transport_protocol = 6;
12288 else if (unformat (i, "udp"))
12289 transport_protocol = 17;
12292 errmsg ("unknown input `%U'", format_unformat_error, i);
12299 errmsg ("expecting: add|del");
12302 if (classify_table_index == ~0)
12304 errmsg ("classifier table not specified");
12307 if (ip_version == 0)
12309 errmsg ("IP version not specified");
12313 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12315 mp->is_add = is_add;
12316 mp->table_id = htonl (classify_table_index);
12317 mp->ip_version = ip_version;
12318 mp->transport_protocol = transport_protocol;
12326 api_get_node_index (vat_main_t * vam)
12328 unformat_input_t *i = vam->input;
12329 vl_api_get_node_index_t *mp;
12333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12335 if (unformat (i, "node %s", &name))
12342 errmsg ("node name required");
12345 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12347 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12351 M (GET_NODE_INDEX, mp);
12352 clib_memcpy (mp->node_name, name, vec_len (name));
12361 api_get_next_index (vat_main_t * vam)
12363 unformat_input_t *i = vam->input;
12364 vl_api_get_next_index_t *mp;
12365 u8 *node_name = 0, *next_node_name = 0;
12368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12370 if (unformat (i, "node-name %s", &node_name))
12372 else if (unformat (i, "next-node-name %s", &next_node_name))
12376 if (node_name == 0)
12378 errmsg ("node name required");
12381 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12383 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12387 if (next_node_name == 0)
12389 errmsg ("next node name required");
12392 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12394 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12398 M (GET_NEXT_INDEX, mp);
12399 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12400 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12401 vec_free (node_name);
12402 vec_free (next_node_name);
12410 api_add_node_next (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_add_node_next_t *mp;
12418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12420 if (unformat (i, "node %s", &name))
12422 else if (unformat (i, "next %s", &next))
12429 errmsg ("node name required");
12432 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12434 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12439 errmsg ("next node required");
12442 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12444 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12448 M (ADD_NODE_NEXT, mp);
12449 clib_memcpy (mp->node_name, name, vec_len (name));
12450 clib_memcpy (mp->next_name, next, vec_len (next));
12460 api_l2tpv3_create_tunnel (vat_main_t * vam)
12462 unformat_input_t *i = vam->input;
12463 ip6_address_t client_address, our_address;
12464 int client_address_set = 0;
12465 int our_address_set = 0;
12466 u32 local_session_id = 0;
12467 u32 remote_session_id = 0;
12468 u64 local_cookie = 0;
12469 u64 remote_cookie = 0;
12470 u8 l2_sublayer_present = 0;
12471 vl_api_l2tpv3_create_tunnel_t *mp;
12474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12476 if (unformat (i, "client_address %U", unformat_ip6_address,
12478 client_address_set = 1;
12479 else if (unformat (i, "our_address %U", unformat_ip6_address,
12481 our_address_set = 1;
12482 else if (unformat (i, "local_session_id %d", &local_session_id))
12484 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12486 else if (unformat (i, "local_cookie %lld", &local_cookie))
12488 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12490 else if (unformat (i, "l2-sublayer-present"))
12491 l2_sublayer_present = 1;
12496 if (client_address_set == 0)
12498 errmsg ("client_address required");
12502 if (our_address_set == 0)
12504 errmsg ("our_address required");
12508 M (L2TPV3_CREATE_TUNNEL, mp);
12510 clib_memcpy (mp->client_address, client_address.as_u8,
12511 sizeof (mp->client_address));
12513 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12515 mp->local_session_id = ntohl (local_session_id);
12516 mp->remote_session_id = ntohl (remote_session_id);
12517 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12518 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12519 mp->l2_sublayer_present = l2_sublayer_present;
12528 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12530 unformat_input_t *i = vam->input;
12532 u8 sw_if_index_set = 0;
12533 u64 new_local_cookie = 0;
12534 u64 new_remote_cookie = 0;
12535 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12540 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12541 sw_if_index_set = 1;
12542 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12543 sw_if_index_set = 1;
12544 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12546 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12552 if (sw_if_index_set == 0)
12554 errmsg ("missing interface name or sw_if_index");
12558 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12560 mp->sw_if_index = ntohl (sw_if_index);
12561 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12562 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12570 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12572 unformat_input_t *i = vam->input;
12573 vl_api_l2tpv3_interface_enable_disable_t *mp;
12575 u8 sw_if_index_set = 0;
12576 u8 enable_disable = 1;
12579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12582 sw_if_index_set = 1;
12583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12584 sw_if_index_set = 1;
12585 else if (unformat (i, "enable"))
12586 enable_disable = 1;
12587 else if (unformat (i, "disable"))
12588 enable_disable = 0;
12593 if (sw_if_index_set == 0)
12595 errmsg ("missing interface name or sw_if_index");
12599 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12601 mp->sw_if_index = ntohl (sw_if_index);
12602 mp->enable_disable = enable_disable;
12610 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12612 unformat_input_t *i = vam->input;
12613 vl_api_l2tpv3_set_lookup_key_t *mp;
12617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12619 if (unformat (i, "lookup_v6_src"))
12620 key = L2T_LOOKUP_SRC_ADDRESS;
12621 else if (unformat (i, "lookup_v6_dst"))
12622 key = L2T_LOOKUP_DST_ADDRESS;
12623 else if (unformat (i, "lookup_session_id"))
12624 key = L2T_LOOKUP_SESSION_ID;
12629 if (key == (u8) ~ 0)
12631 errmsg ("l2tp session lookup key unset");
12635 M (L2TPV3_SET_LOOKUP_KEY, mp);
12644 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12645 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12647 vat_main_t *vam = &vat_main;
12649 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12650 format_ip6_address, mp->our_address,
12651 format_ip6_address, mp->client_address,
12652 clib_net_to_host_u32 (mp->sw_if_index));
12655 " local cookies %016llx %016llx remote cookie %016llx",
12656 clib_net_to_host_u64 (mp->local_cookie[0]),
12657 clib_net_to_host_u64 (mp->local_cookie[1]),
12658 clib_net_to_host_u64 (mp->remote_cookie));
12660 print (vam->ofp, " local session-id %d remote session-id %d",
12661 clib_net_to_host_u32 (mp->local_session_id),
12662 clib_net_to_host_u32 (mp->remote_session_id));
12664 print (vam->ofp, " l2 specific sublayer %s\n",
12665 mp->l2_sublayer_present ? "preset" : "absent");
12669 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12670 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12672 vat_main_t *vam = &vat_main;
12673 vat_json_node_t *node = NULL;
12674 struct in6_addr addr;
12676 if (VAT_JSON_ARRAY != vam->json_tree.type)
12678 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12679 vat_json_init_array (&vam->json_tree);
12681 node = vat_json_array_add (&vam->json_tree);
12683 vat_json_init_object (node);
12685 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12686 vat_json_object_add_ip6 (node, "our_address", addr);
12687 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12688 vat_json_object_add_ip6 (node, "client_address", addr);
12690 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12691 vat_json_init_array (lc);
12692 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12693 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12694 vat_json_object_add_uint (node, "remote_cookie",
12695 clib_net_to_host_u64 (mp->remote_cookie));
12697 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12698 vat_json_object_add_uint (node, "local_session_id",
12699 clib_net_to_host_u32 (mp->local_session_id));
12700 vat_json_object_add_uint (node, "remote_session_id",
12701 clib_net_to_host_u32 (mp->remote_session_id));
12702 vat_json_object_add_string_copy (node, "l2_sublayer",
12703 mp->l2_sublayer_present ? (u8 *) "present"
12704 : (u8 *) "absent");
12708 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12710 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12711 vl_api_control_ping_t *mp_ping;
12714 /* Get list of l2tpv3-tunnel interfaces */
12715 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12718 /* Use a control ping for synchronization */
12719 MPING (CONTROL_PING, mp_ping);
12727 static void vl_api_sw_interface_tap_details_t_handler
12728 (vl_api_sw_interface_tap_details_t * mp)
12730 vat_main_t *vam = &vat_main;
12732 print (vam->ofp, "%-16s %d",
12733 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12736 static void vl_api_sw_interface_tap_details_t_handler_json
12737 (vl_api_sw_interface_tap_details_t * mp)
12739 vat_main_t *vam = &vat_main;
12740 vat_json_node_t *node = NULL;
12742 if (VAT_JSON_ARRAY != vam->json_tree.type)
12744 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12745 vat_json_init_array (&vam->json_tree);
12747 node = vat_json_array_add (&vam->json_tree);
12749 vat_json_init_object (node);
12750 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12751 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12755 api_sw_interface_tap_dump (vat_main_t * vam)
12757 vl_api_sw_interface_tap_dump_t *mp;
12758 vl_api_control_ping_t *mp_ping;
12761 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12762 /* Get list of tap interfaces */
12763 M (SW_INTERFACE_TAP_DUMP, mp);
12766 /* Use a control ping for synchronization */
12767 MPING (CONTROL_PING, mp_ping);
12774 static void vl_api_sw_interface_tap_v2_details_t_handler
12775 (vl_api_sw_interface_tap_v2_details_t * mp)
12777 vat_main_t *vam = &vat_main;
12779 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12780 mp->host_ip4_prefix_len);
12781 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12782 mp->host_ip6_prefix_len);
12785 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s",
12786 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12787 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12788 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12789 mp->host_bridge, ip4, ip6);
12795 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12796 (vl_api_sw_interface_tap_v2_details_t * mp)
12798 vat_main_t *vam = &vat_main;
12799 vat_json_node_t *node = NULL;
12801 if (VAT_JSON_ARRAY != vam->json_tree.type)
12803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12804 vat_json_init_array (&vam->json_tree);
12806 node = vat_json_array_add (&vam->json_tree);
12808 vat_json_init_object (node);
12809 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12810 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12811 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12812 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12813 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12814 vat_json_object_add_string_copy (node, "host_mac_addr",
12815 format (0, "%U", format_ethernet_address,
12816 &mp->host_mac_addr));
12817 vat_json_object_add_string_copy (node, "host_namespace",
12818 mp->host_namespace);
12819 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12820 vat_json_object_add_string_copy (node, "host_ip4_addr",
12821 format (0, "%U/%d", format_ip4_address,
12823 mp->host_ip4_prefix_len));
12824 vat_json_object_add_string_copy (node, "host_ip6_addr",
12825 format (0, "%U/%d", format_ip6_address,
12827 mp->host_ip6_prefix_len));
12832 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12834 vl_api_sw_interface_tap_v2_dump_t *mp;
12835 vl_api_control_ping_t *mp_ping;
12839 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12840 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12841 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12844 /* Get list of tap interfaces */
12845 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12848 /* Use a control ping for synchronization */
12849 MPING (CONTROL_PING, mp_ping);
12856 static uword unformat_vxlan_decap_next
12857 (unformat_input_t * input, va_list * args)
12859 u32 *result = va_arg (*args, u32 *);
12862 if (unformat (input, "l2"))
12863 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12864 else if (unformat (input, "%d", &tmp))
12872 api_vxlan_add_del_tunnel (vat_main_t * vam)
12874 unformat_input_t *line_input = vam->input;
12875 vl_api_vxlan_add_del_tunnel_t *mp;
12876 ip46_address_t src, dst;
12878 u8 ipv4_set = 0, ipv6_set = 0;
12883 u32 mcast_sw_if_index = ~0;
12884 u32 encap_vrf_id = 0;
12885 u32 decap_next_index = ~0;
12889 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12890 memset (&src, 0, sizeof src);
12891 memset (&dst, 0, sizeof dst);
12893 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12895 if (unformat (line_input, "del"))
12897 else if (unformat (line_input, "instance %d", &instance))
12900 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12906 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12912 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12918 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12923 else if (unformat (line_input, "group %U %U",
12924 unformat_ip4_address, &dst.ip4,
12925 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12927 grp_set = dst_set = 1;
12930 else if (unformat (line_input, "group %U",
12931 unformat_ip4_address, &dst.ip4))
12933 grp_set = dst_set = 1;
12936 else if (unformat (line_input, "group %U %U",
12937 unformat_ip6_address, &dst.ip6,
12938 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12940 grp_set = dst_set = 1;
12943 else if (unformat (line_input, "group %U",
12944 unformat_ip6_address, &dst.ip6))
12946 grp_set = dst_set = 1;
12950 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12952 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12954 else if (unformat (line_input, "decap-next %U",
12955 unformat_vxlan_decap_next, &decap_next_index))
12957 else if (unformat (line_input, "vni %d", &vni))
12961 errmsg ("parse error '%U'", format_unformat_error, line_input);
12968 errmsg ("tunnel src address not specified");
12973 errmsg ("tunnel dst address not specified");
12977 if (grp_set && !ip46_address_is_multicast (&dst))
12979 errmsg ("tunnel group address not multicast");
12982 if (grp_set && mcast_sw_if_index == ~0)
12984 errmsg ("tunnel nonexistent multicast device");
12987 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12989 errmsg ("tunnel dst address must be unicast");
12994 if (ipv4_set && ipv6_set)
12996 errmsg ("both IPv4 and IPv6 addresses specified");
13000 if ((vni == 0) || (vni >> 24))
13002 errmsg ("vni not specified or out of range");
13006 M (VXLAN_ADD_DEL_TUNNEL, mp);
13010 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
13011 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
13015 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
13016 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
13019 mp->instance = htonl (instance);
13020 mp->encap_vrf_id = ntohl (encap_vrf_id);
13021 mp->decap_next_index = ntohl (decap_next_index);
13022 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13023 mp->vni = ntohl (vni);
13024 mp->is_add = is_add;
13025 mp->is_ipv6 = ipv6_set;
13032 static void vl_api_vxlan_tunnel_details_t_handler
13033 (vl_api_vxlan_tunnel_details_t * mp)
13035 vat_main_t *vam = &vat_main;
13036 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13037 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13039 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
13040 ntohl (mp->sw_if_index),
13041 ntohl (mp->instance),
13042 format_ip46_address, &src, IP46_TYPE_ANY,
13043 format_ip46_address, &dst, IP46_TYPE_ANY,
13044 ntohl (mp->encap_vrf_id),
13045 ntohl (mp->decap_next_index), ntohl (mp->vni),
13046 ntohl (mp->mcast_sw_if_index));
13049 static void vl_api_vxlan_tunnel_details_t_handler_json
13050 (vl_api_vxlan_tunnel_details_t * mp)
13052 vat_main_t *vam = &vat_main;
13053 vat_json_node_t *node = NULL;
13055 if (VAT_JSON_ARRAY != vam->json_tree.type)
13057 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13058 vat_json_init_array (&vam->json_tree);
13060 node = vat_json_array_add (&vam->json_tree);
13062 vat_json_init_object (node);
13063 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13065 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13069 struct in6_addr ip6;
13071 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13072 vat_json_object_add_ip6 (node, "src_address", ip6);
13073 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13074 vat_json_object_add_ip6 (node, "dst_address", ip6);
13078 struct in_addr ip4;
13080 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13081 vat_json_object_add_ip4 (node, "src_address", ip4);
13082 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13083 vat_json_object_add_ip4 (node, "dst_address", ip4);
13085 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13086 vat_json_object_add_uint (node, "decap_next_index",
13087 ntohl (mp->decap_next_index));
13088 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13089 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13090 vat_json_object_add_uint (node, "mcast_sw_if_index",
13091 ntohl (mp->mcast_sw_if_index));
13095 api_vxlan_tunnel_dump (vat_main_t * vam)
13097 unformat_input_t *i = vam->input;
13098 vl_api_vxlan_tunnel_dump_t *mp;
13099 vl_api_control_ping_t *mp_ping;
13101 u8 sw_if_index_set = 0;
13104 /* Parse args required to build the message */
13105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13107 if (unformat (i, "sw_if_index %d", &sw_if_index))
13108 sw_if_index_set = 1;
13113 if (sw_if_index_set == 0)
13118 if (!vam->json_output)
13120 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13121 "sw_if_index", "instance", "src_address", "dst_address",
13122 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13125 /* Get list of vxlan-tunnel interfaces */
13126 M (VXLAN_TUNNEL_DUMP, mp);
13128 mp->sw_if_index = htonl (sw_if_index);
13132 /* Use a control ping for synchronization */
13133 MPING (CONTROL_PING, mp_ping);
13140 static uword unformat_geneve_decap_next
13141 (unformat_input_t * input, va_list * args)
13143 u32 *result = va_arg (*args, u32 *);
13146 if (unformat (input, "l2"))
13147 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13148 else if (unformat (input, "%d", &tmp))
13156 api_geneve_add_del_tunnel (vat_main_t * vam)
13158 unformat_input_t *line_input = vam->input;
13159 vl_api_geneve_add_del_tunnel_t *mp;
13160 ip46_address_t src, dst;
13162 u8 ipv4_set = 0, ipv6_set = 0;
13166 u32 mcast_sw_if_index = ~0;
13167 u32 encap_vrf_id = 0;
13168 u32 decap_next_index = ~0;
13172 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13173 memset (&src, 0, sizeof src);
13174 memset (&dst, 0, sizeof dst);
13176 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13178 if (unformat (line_input, "del"))
13181 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13187 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13193 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13199 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13204 else if (unformat (line_input, "group %U %U",
13205 unformat_ip4_address, &dst.ip4,
13206 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13208 grp_set = dst_set = 1;
13211 else if (unformat (line_input, "group %U",
13212 unformat_ip4_address, &dst.ip4))
13214 grp_set = dst_set = 1;
13217 else if (unformat (line_input, "group %U %U",
13218 unformat_ip6_address, &dst.ip6,
13219 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13221 grp_set = dst_set = 1;
13224 else if (unformat (line_input, "group %U",
13225 unformat_ip6_address, &dst.ip6))
13227 grp_set = dst_set = 1;
13231 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13233 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13235 else if (unformat (line_input, "decap-next %U",
13236 unformat_geneve_decap_next, &decap_next_index))
13238 else if (unformat (line_input, "vni %d", &vni))
13242 errmsg ("parse error '%U'", format_unformat_error, line_input);
13249 errmsg ("tunnel src address not specified");
13254 errmsg ("tunnel dst address not specified");
13258 if (grp_set && !ip46_address_is_multicast (&dst))
13260 errmsg ("tunnel group address not multicast");
13263 if (grp_set && mcast_sw_if_index == ~0)
13265 errmsg ("tunnel nonexistent multicast device");
13268 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13270 errmsg ("tunnel dst address must be unicast");
13275 if (ipv4_set && ipv6_set)
13277 errmsg ("both IPv4 and IPv6 addresses specified");
13281 if ((vni == 0) || (vni >> 24))
13283 errmsg ("vni not specified or out of range");
13287 M (GENEVE_ADD_DEL_TUNNEL, mp);
13291 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13292 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13296 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13297 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13299 mp->encap_vrf_id = ntohl (encap_vrf_id);
13300 mp->decap_next_index = ntohl (decap_next_index);
13301 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13302 mp->vni = ntohl (vni);
13303 mp->is_add = is_add;
13304 mp->is_ipv6 = ipv6_set;
13311 static void vl_api_geneve_tunnel_details_t_handler
13312 (vl_api_geneve_tunnel_details_t * mp)
13314 vat_main_t *vam = &vat_main;
13315 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13316 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13318 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13319 ntohl (mp->sw_if_index),
13320 format_ip46_address, &src, IP46_TYPE_ANY,
13321 format_ip46_address, &dst, IP46_TYPE_ANY,
13322 ntohl (mp->encap_vrf_id),
13323 ntohl (mp->decap_next_index), ntohl (mp->vni),
13324 ntohl (mp->mcast_sw_if_index));
13327 static void vl_api_geneve_tunnel_details_t_handler_json
13328 (vl_api_geneve_tunnel_details_t * mp)
13330 vat_main_t *vam = &vat_main;
13331 vat_json_node_t *node = NULL;
13333 if (VAT_JSON_ARRAY != vam->json_tree.type)
13335 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13336 vat_json_init_array (&vam->json_tree);
13338 node = vat_json_array_add (&vam->json_tree);
13340 vat_json_init_object (node);
13341 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13344 struct in6_addr ip6;
13346 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13347 vat_json_object_add_ip6 (node, "src_address", ip6);
13348 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13349 vat_json_object_add_ip6 (node, "dst_address", ip6);
13353 struct in_addr ip4;
13355 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13356 vat_json_object_add_ip4 (node, "src_address", ip4);
13357 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13358 vat_json_object_add_ip4 (node, "dst_address", ip4);
13360 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13361 vat_json_object_add_uint (node, "decap_next_index",
13362 ntohl (mp->decap_next_index));
13363 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13364 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13365 vat_json_object_add_uint (node, "mcast_sw_if_index",
13366 ntohl (mp->mcast_sw_if_index));
13370 api_geneve_tunnel_dump (vat_main_t * vam)
13372 unformat_input_t *i = vam->input;
13373 vl_api_geneve_tunnel_dump_t *mp;
13374 vl_api_control_ping_t *mp_ping;
13376 u8 sw_if_index_set = 0;
13379 /* Parse args required to build the message */
13380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13382 if (unformat (i, "sw_if_index %d", &sw_if_index))
13383 sw_if_index_set = 1;
13388 if (sw_if_index_set == 0)
13393 if (!vam->json_output)
13395 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13396 "sw_if_index", "local_address", "remote_address",
13397 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13400 /* Get list of geneve-tunnel interfaces */
13401 M (GENEVE_TUNNEL_DUMP, mp);
13403 mp->sw_if_index = htonl (sw_if_index);
13407 /* Use a control ping for synchronization */
13408 M (CONTROL_PING, mp_ping);
13416 api_gre_add_del_tunnel (vat_main_t * vam)
13418 unformat_input_t *line_input = vam->input;
13419 vl_api_gre_add_del_tunnel_t *mp;
13420 ip4_address_t src4, dst4;
13421 ip6_address_t src6, dst6;
13425 u8 t_type = GRE_TUNNEL_TYPE_L3;
13428 u32 outer_fib_id = 0;
13429 u32 session_id = 0;
13433 memset (&src4, 0, sizeof src4);
13434 memset (&dst4, 0, sizeof dst4);
13435 memset (&src6, 0, sizeof src6);
13436 memset (&dst6, 0, sizeof dst6);
13438 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13440 if (unformat (line_input, "del"))
13442 else if (unformat (line_input, "instance %d", &instance))
13444 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13449 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13454 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13459 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13464 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13466 else if (unformat (line_input, "teb"))
13467 t_type = GRE_TUNNEL_TYPE_TEB;
13468 else if (unformat (line_input, "erspan %d", &session_id))
13469 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13472 errmsg ("parse error '%U'", format_unformat_error, line_input);
13479 errmsg ("tunnel src address not specified");
13484 errmsg ("tunnel dst address not specified");
13487 if (ipv4_set && ipv6_set)
13489 errmsg ("both IPv4 and IPv6 addresses specified");
13494 M (GRE_ADD_DEL_TUNNEL, mp);
13498 clib_memcpy (&mp->src_address, &src4, 4);
13499 clib_memcpy (&mp->dst_address, &dst4, 4);
13503 clib_memcpy (&mp->src_address, &src6, 16);
13504 clib_memcpy (&mp->dst_address, &dst6, 16);
13506 mp->instance = htonl (instance);
13507 mp->outer_fib_id = htonl (outer_fib_id);
13508 mp->is_add = is_add;
13509 mp->session_id = htons ((u16) session_id);
13510 mp->tunnel_type = t_type;
13511 mp->is_ipv6 = ipv6_set;
13518 static void vl_api_gre_tunnel_details_t_handler
13519 (vl_api_gre_tunnel_details_t * mp)
13521 vat_main_t *vam = &vat_main;
13522 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13523 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13525 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13526 ntohl (mp->sw_if_index),
13527 ntohl (mp->instance),
13528 format_ip46_address, &src, IP46_TYPE_ANY,
13529 format_ip46_address, &dst, IP46_TYPE_ANY,
13530 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13533 static void vl_api_gre_tunnel_details_t_handler_json
13534 (vl_api_gre_tunnel_details_t * mp)
13536 vat_main_t *vam = &vat_main;
13537 vat_json_node_t *node = NULL;
13538 struct in_addr ip4;
13539 struct in6_addr ip6;
13541 if (VAT_JSON_ARRAY != vam->json_tree.type)
13543 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13544 vat_json_init_array (&vam->json_tree);
13546 node = vat_json_array_add (&vam->json_tree);
13548 vat_json_init_object (node);
13549 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13550 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13553 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13554 vat_json_object_add_ip4 (node, "src_address", ip4);
13555 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13556 vat_json_object_add_ip4 (node, "dst_address", ip4);
13560 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13561 vat_json_object_add_ip6 (node, "src_address", ip6);
13562 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13563 vat_json_object_add_ip6 (node, "dst_address", ip6);
13565 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13566 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13567 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13568 vat_json_object_add_uint (node, "session_id", mp->session_id);
13572 api_gre_tunnel_dump (vat_main_t * vam)
13574 unformat_input_t *i = vam->input;
13575 vl_api_gre_tunnel_dump_t *mp;
13576 vl_api_control_ping_t *mp_ping;
13578 u8 sw_if_index_set = 0;
13581 /* Parse args required to build the message */
13582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13584 if (unformat (i, "sw_if_index %d", &sw_if_index))
13585 sw_if_index_set = 1;
13590 if (sw_if_index_set == 0)
13595 if (!vam->json_output)
13597 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13598 "sw_if_index", "instance", "src_address", "dst_address",
13599 "tunnel_type", "outer_fib_id", "session_id");
13602 /* Get list of gre-tunnel interfaces */
13603 M (GRE_TUNNEL_DUMP, mp);
13605 mp->sw_if_index = htonl (sw_if_index);
13609 /* Use a control ping for synchronization */
13610 MPING (CONTROL_PING, mp_ping);
13618 api_l2_fib_clear_table (vat_main_t * vam)
13620 // unformat_input_t * i = vam->input;
13621 vl_api_l2_fib_clear_table_t *mp;
13624 M (L2_FIB_CLEAR_TABLE, mp);
13632 api_l2_interface_efp_filter (vat_main_t * vam)
13634 unformat_input_t *i = vam->input;
13635 vl_api_l2_interface_efp_filter_t *mp;
13638 u8 sw_if_index_set = 0;
13641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13643 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13644 sw_if_index_set = 1;
13645 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13646 sw_if_index_set = 1;
13647 else if (unformat (i, "enable"))
13649 else if (unformat (i, "disable"))
13653 clib_warning ("parse error '%U'", format_unformat_error, i);
13658 if (sw_if_index_set == 0)
13660 errmsg ("missing sw_if_index");
13664 M (L2_INTERFACE_EFP_FILTER, mp);
13666 mp->sw_if_index = ntohl (sw_if_index);
13667 mp->enable_disable = enable;
13674 #define foreach_vtr_op \
13675 _("disable", L2_VTR_DISABLED) \
13676 _("push-1", L2_VTR_PUSH_1) \
13677 _("push-2", L2_VTR_PUSH_2) \
13678 _("pop-1", L2_VTR_POP_1) \
13679 _("pop-2", L2_VTR_POP_2) \
13680 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13681 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13682 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13683 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13686 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13688 unformat_input_t *i = vam->input;
13689 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13691 u8 sw_if_index_set = 0;
13694 u32 push_dot1q = 1;
13699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13701 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13702 sw_if_index_set = 1;
13703 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13704 sw_if_index_set = 1;
13705 else if (unformat (i, "vtr_op %d", &vtr_op))
13707 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13710 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13712 else if (unformat (i, "tag1 %d", &tag1))
13714 else if (unformat (i, "tag2 %d", &tag2))
13718 clib_warning ("parse error '%U'", format_unformat_error, i);
13723 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13725 errmsg ("missing vtr operation or sw_if_index");
13729 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13730 mp->sw_if_index = ntohl (sw_if_index);
13731 mp->vtr_op = ntohl (vtr_op);
13732 mp->push_dot1q = ntohl (push_dot1q);
13733 mp->tag1 = ntohl (tag1);
13734 mp->tag2 = ntohl (tag2);
13742 api_create_vhost_user_if (vat_main_t * vam)
13744 unformat_input_t *i = vam->input;
13745 vl_api_create_vhost_user_if_t *mp;
13748 u8 file_name_set = 0;
13749 u32 custom_dev_instance = ~0;
13751 u8 use_custom_mac = 0;
13755 /* Shut up coverity */
13756 memset (hwaddr, 0, sizeof (hwaddr));
13758 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13760 if (unformat (i, "socket %s", &file_name))
13764 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13766 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13767 use_custom_mac = 1;
13768 else if (unformat (i, "server"))
13770 else if (unformat (i, "tag %s", &tag))
13776 if (file_name_set == 0)
13778 errmsg ("missing socket file name");
13782 if (vec_len (file_name) > 255)
13784 errmsg ("socket file name too long");
13787 vec_add1 (file_name, 0);
13789 M (CREATE_VHOST_USER_IF, mp);
13791 mp->is_server = is_server;
13792 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13793 vec_free (file_name);
13794 if (custom_dev_instance != ~0)
13797 mp->custom_dev_instance = ntohl (custom_dev_instance);
13799 mp->use_custom_mac = use_custom_mac;
13800 clib_memcpy (mp->mac_address, hwaddr, 6);
13802 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13811 api_modify_vhost_user_if (vat_main_t * vam)
13813 unformat_input_t *i = vam->input;
13814 vl_api_modify_vhost_user_if_t *mp;
13817 u8 file_name_set = 0;
13818 u32 custom_dev_instance = ~0;
13819 u8 sw_if_index_set = 0;
13820 u32 sw_if_index = (u32) ~ 0;
13823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13825 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13826 sw_if_index_set = 1;
13827 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13828 sw_if_index_set = 1;
13829 else if (unformat (i, "socket %s", &file_name))
13833 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13835 else if (unformat (i, "server"))
13841 if (sw_if_index_set == 0)
13843 errmsg ("missing sw_if_index or interface name");
13847 if (file_name_set == 0)
13849 errmsg ("missing socket file name");
13853 if (vec_len (file_name) > 255)
13855 errmsg ("socket file name too long");
13858 vec_add1 (file_name, 0);
13860 M (MODIFY_VHOST_USER_IF, mp);
13862 mp->sw_if_index = ntohl (sw_if_index);
13863 mp->is_server = is_server;
13864 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13865 vec_free (file_name);
13866 if (custom_dev_instance != ~0)
13869 mp->custom_dev_instance = ntohl (custom_dev_instance);
13878 api_delete_vhost_user_if (vat_main_t * vam)
13880 unformat_input_t *i = vam->input;
13881 vl_api_delete_vhost_user_if_t *mp;
13882 u32 sw_if_index = ~0;
13883 u8 sw_if_index_set = 0;
13886 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13888 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13889 sw_if_index_set = 1;
13890 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13891 sw_if_index_set = 1;
13896 if (sw_if_index_set == 0)
13898 errmsg ("missing sw_if_index or interface name");
13903 M (DELETE_VHOST_USER_IF, mp);
13905 mp->sw_if_index = ntohl (sw_if_index);
13912 static void vl_api_sw_interface_vhost_user_details_t_handler
13913 (vl_api_sw_interface_vhost_user_details_t * mp)
13915 vat_main_t *vam = &vat_main;
13917 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13918 (char *) mp->interface_name,
13919 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13920 clib_net_to_host_u64 (mp->features), mp->is_server,
13921 ntohl (mp->num_regions), (char *) mp->sock_filename);
13922 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13925 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13926 (vl_api_sw_interface_vhost_user_details_t * mp)
13928 vat_main_t *vam = &vat_main;
13929 vat_json_node_t *node = NULL;
13931 if (VAT_JSON_ARRAY != vam->json_tree.type)
13933 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13934 vat_json_init_array (&vam->json_tree);
13936 node = vat_json_array_add (&vam->json_tree);
13938 vat_json_init_object (node);
13939 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13940 vat_json_object_add_string_copy (node, "interface_name",
13941 mp->interface_name);
13942 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13943 ntohl (mp->virtio_net_hdr_sz));
13944 vat_json_object_add_uint (node, "features",
13945 clib_net_to_host_u64 (mp->features));
13946 vat_json_object_add_uint (node, "is_server", mp->is_server);
13947 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13948 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13949 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13953 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13955 vl_api_sw_interface_vhost_user_dump_t *mp;
13956 vl_api_control_ping_t *mp_ping;
13959 "Interface name idx hdr_sz features server regions filename");
13961 /* Get list of vhost-user interfaces */
13962 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13965 /* Use a control ping for synchronization */
13966 MPING (CONTROL_PING, mp_ping);
13974 api_show_version (vat_main_t * vam)
13976 vl_api_show_version_t *mp;
13979 M (SHOW_VERSION, mp);
13988 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13990 unformat_input_t *line_input = vam->input;
13991 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13992 ip4_address_t local4, remote4;
13993 ip6_address_t local6, remote6;
13995 u8 ipv4_set = 0, ipv6_set = 0;
13999 u32 mcast_sw_if_index = ~0;
14000 u32 encap_vrf_id = 0;
14001 u32 decap_vrf_id = 0;
14007 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
14008 memset (&local4, 0, sizeof local4);
14009 memset (&remote4, 0, sizeof remote4);
14010 memset (&local6, 0, sizeof local6);
14011 memset (&remote6, 0, sizeof remote6);
14013 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14015 if (unformat (line_input, "del"))
14017 else if (unformat (line_input, "local %U",
14018 unformat_ip4_address, &local4))
14023 else if (unformat (line_input, "remote %U",
14024 unformat_ip4_address, &remote4))
14029 else if (unformat (line_input, "local %U",
14030 unformat_ip6_address, &local6))
14035 else if (unformat (line_input, "remote %U",
14036 unformat_ip6_address, &remote6))
14041 else if (unformat (line_input, "group %U %U",
14042 unformat_ip4_address, &remote4,
14043 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14045 grp_set = remote_set = 1;
14048 else if (unformat (line_input, "group %U",
14049 unformat_ip4_address, &remote4))
14051 grp_set = remote_set = 1;
14054 else if (unformat (line_input, "group %U %U",
14055 unformat_ip6_address, &remote6,
14056 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
14058 grp_set = remote_set = 1;
14061 else if (unformat (line_input, "group %U",
14062 unformat_ip6_address, &remote6))
14064 grp_set = remote_set = 1;
14068 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
14070 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
14072 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
14074 else if (unformat (line_input, "vni %d", &vni))
14076 else if (unformat (line_input, "next-ip4"))
14078 else if (unformat (line_input, "next-ip6"))
14080 else if (unformat (line_input, "next-ethernet"))
14082 else if (unformat (line_input, "next-nsh"))
14086 errmsg ("parse error '%U'", format_unformat_error, line_input);
14091 if (local_set == 0)
14093 errmsg ("tunnel local address not specified");
14096 if (remote_set == 0)
14098 errmsg ("tunnel remote address not specified");
14101 if (grp_set && mcast_sw_if_index == ~0)
14103 errmsg ("tunnel nonexistent multicast device");
14106 if (ipv4_set && ipv6_set)
14108 errmsg ("both IPv4 and IPv6 addresses specified");
14114 errmsg ("vni not specified");
14118 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
14123 clib_memcpy (&mp->local, &local6, sizeof (local6));
14124 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14128 clib_memcpy (&mp->local, &local4, sizeof (local4));
14129 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14132 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14133 mp->encap_vrf_id = ntohl (encap_vrf_id);
14134 mp->decap_vrf_id = ntohl (decap_vrf_id);
14135 mp->protocol = protocol;
14136 mp->vni = ntohl (vni);
14137 mp->is_add = is_add;
14138 mp->is_ipv6 = ipv6_set;
14145 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14146 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14148 vat_main_t *vam = &vat_main;
14149 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14150 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14152 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14153 ntohl (mp->sw_if_index),
14154 format_ip46_address, &local, IP46_TYPE_ANY,
14155 format_ip46_address, &remote, IP46_TYPE_ANY,
14156 ntohl (mp->vni), mp->protocol,
14157 ntohl (mp->mcast_sw_if_index),
14158 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14162 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14163 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14165 vat_main_t *vam = &vat_main;
14166 vat_json_node_t *node = NULL;
14167 struct in_addr ip4;
14168 struct in6_addr ip6;
14170 if (VAT_JSON_ARRAY != vam->json_tree.type)
14172 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14173 vat_json_init_array (&vam->json_tree);
14175 node = vat_json_array_add (&vam->json_tree);
14177 vat_json_init_object (node);
14178 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14181 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14182 vat_json_object_add_ip6 (node, "local", ip6);
14183 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14184 vat_json_object_add_ip6 (node, "remote", ip6);
14188 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14189 vat_json_object_add_ip4 (node, "local", ip4);
14190 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14191 vat_json_object_add_ip4 (node, "remote", ip4);
14193 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14194 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14195 vat_json_object_add_uint (node, "mcast_sw_if_index",
14196 ntohl (mp->mcast_sw_if_index));
14197 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14198 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14199 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14203 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14205 unformat_input_t *i = vam->input;
14206 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14207 vl_api_control_ping_t *mp_ping;
14209 u8 sw_if_index_set = 0;
14212 /* Parse args required to build the message */
14213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14215 if (unformat (i, "sw_if_index %d", &sw_if_index))
14216 sw_if_index_set = 1;
14221 if (sw_if_index_set == 0)
14226 if (!vam->json_output)
14228 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14229 "sw_if_index", "local", "remote", "vni",
14230 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14233 /* Get list of vxlan-tunnel interfaces */
14234 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14236 mp->sw_if_index = htonl (sw_if_index);
14240 /* Use a control ping for synchronization */
14241 MPING (CONTROL_PING, mp_ping);
14248 static void vl_api_l2_fib_table_details_t_handler
14249 (vl_api_l2_fib_table_details_t * mp)
14251 vat_main_t *vam = &vat_main;
14253 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14255 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14256 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14260 static void vl_api_l2_fib_table_details_t_handler_json
14261 (vl_api_l2_fib_table_details_t * mp)
14263 vat_main_t *vam = &vat_main;
14264 vat_json_node_t *node = NULL;
14266 if (VAT_JSON_ARRAY != vam->json_tree.type)
14268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14269 vat_json_init_array (&vam->json_tree);
14271 node = vat_json_array_add (&vam->json_tree);
14273 vat_json_init_object (node);
14274 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14275 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14276 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14277 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14278 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14279 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14283 api_l2_fib_table_dump (vat_main_t * vam)
14285 unformat_input_t *i = vam->input;
14286 vl_api_l2_fib_table_dump_t *mp;
14287 vl_api_control_ping_t *mp_ping;
14292 /* Parse args required to build the message */
14293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14295 if (unformat (i, "bd_id %d", &bd_id))
14301 if (bd_id_set == 0)
14303 errmsg ("missing bridge domain");
14307 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14309 /* Get list of l2 fib entries */
14310 M (L2_FIB_TABLE_DUMP, mp);
14312 mp->bd_id = ntohl (bd_id);
14315 /* Use a control ping for synchronization */
14316 MPING (CONTROL_PING, mp_ping);
14325 api_interface_name_renumber (vat_main_t * vam)
14327 unformat_input_t *line_input = vam->input;
14328 vl_api_interface_name_renumber_t *mp;
14329 u32 sw_if_index = ~0;
14330 u32 new_show_dev_instance = ~0;
14333 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14335 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14338 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14340 else if (unformat (line_input, "new_show_dev_instance %d",
14341 &new_show_dev_instance))
14347 if (sw_if_index == ~0)
14349 errmsg ("missing interface name or sw_if_index");
14353 if (new_show_dev_instance == ~0)
14355 errmsg ("missing new_show_dev_instance");
14359 M (INTERFACE_NAME_RENUMBER, mp);
14361 mp->sw_if_index = ntohl (sw_if_index);
14362 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14370 api_ip_probe_neighbor (vat_main_t * vam)
14372 unformat_input_t *i = vam->input;
14373 vl_api_ip_probe_neighbor_t *mp;
14381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14383 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14385 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14387 else if (unformat (i, "address %U", unformat_ip4_address, dst_adr))
14389 else if (unformat (i, "address %U", unformat_ip6_address, dst_adr))
14400 errmsg ("missing interface");
14406 errmsg ("missing addresses");
14410 M (IP_PROBE_NEIGHBOR, mp);
14412 mp->sw_if_index = ntohl (sw_if_index);
14413 mp->is_ipv6 = is_ipv6;
14414 clib_memcpy (mp->dst_address, dst_adr, sizeof (dst_adr));
14422 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14424 unformat_input_t *i = vam->input;
14425 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14426 u8 mode = IP_SCAN_V46_NEIGHBORS;
14427 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14432 if (unformat (i, "ip4"))
14433 mode = IP_SCAN_V4_NEIGHBORS;
14434 else if (unformat (i, "ip6"))
14435 mode = IP_SCAN_V6_NEIGHBORS;
14436 if (unformat (i, "both"))
14437 mode = IP_SCAN_V46_NEIGHBORS;
14438 else if (unformat (i, "disable"))
14439 mode = IP_SCAN_DISABLED;
14440 else if (unformat (i, "interval %d", &interval))
14442 else if (unformat (i, "max-time %d", &time))
14444 else if (unformat (i, "max-update %d", &update))
14446 else if (unformat (i, "delay %d", &delay))
14448 else if (unformat (i, "stale %d", &stale))
14454 if (interval > 255)
14456 errmsg ("interval cannot exceed 255 minutes.");
14461 errmsg ("max-time cannot exceed 255 usec.");
14466 errmsg ("max-update cannot exceed 255.");
14471 errmsg ("delay cannot exceed 255 msec.");
14476 errmsg ("stale cannot exceed 255 minutes.");
14480 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14482 mp->scan_interval = interval;
14483 mp->max_proc_time = time;
14484 mp->max_update = update;
14485 mp->scan_int_delay = delay;
14486 mp->stale_threshold = stale;
14494 api_want_ip4_arp_events (vat_main_t * vam)
14496 unformat_input_t *line_input = vam->input;
14497 vl_api_want_ip4_arp_events_t *mp;
14498 ip4_address_t address;
14499 int address_set = 0;
14500 u32 enable_disable = 1;
14503 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14505 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14507 else if (unformat (line_input, "del"))
14508 enable_disable = 0;
14513 if (address_set == 0)
14515 errmsg ("missing addresses");
14519 M (WANT_IP4_ARP_EVENTS, mp);
14520 mp->enable_disable = enable_disable;
14521 mp->pid = htonl (getpid ());
14522 mp->address = address.as_u32;
14530 api_want_ip6_nd_events (vat_main_t * vam)
14532 unformat_input_t *line_input = vam->input;
14533 vl_api_want_ip6_nd_events_t *mp;
14534 ip6_address_t address;
14535 int address_set = 0;
14536 u32 enable_disable = 1;
14539 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14541 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
14543 else if (unformat (line_input, "del"))
14544 enable_disable = 0;
14549 if (address_set == 0)
14551 errmsg ("missing addresses");
14555 M (WANT_IP6_ND_EVENTS, mp);
14556 mp->enable_disable = enable_disable;
14557 mp->pid = htonl (getpid ());
14558 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
14566 api_want_l2_macs_events (vat_main_t * vam)
14568 unformat_input_t *line_input = vam->input;
14569 vl_api_want_l2_macs_events_t *mp;
14570 u8 enable_disable = 1;
14571 u32 scan_delay = 0;
14572 u32 max_macs_in_event = 0;
14573 u32 learn_limit = 0;
14576 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14578 if (unformat (line_input, "learn-limit %d", &learn_limit))
14580 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14582 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14584 else if (unformat (line_input, "disable"))
14585 enable_disable = 0;
14590 M (WANT_L2_MACS_EVENTS, mp);
14591 mp->enable_disable = enable_disable;
14592 mp->pid = htonl (getpid ());
14593 mp->learn_limit = htonl (learn_limit);
14594 mp->scan_delay = (u8) scan_delay;
14595 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14602 api_input_acl_set_interface (vat_main_t * vam)
14604 unformat_input_t *i = vam->input;
14605 vl_api_input_acl_set_interface_t *mp;
14607 int sw_if_index_set;
14608 u32 ip4_table_index = ~0;
14609 u32 ip6_table_index = ~0;
14610 u32 l2_table_index = ~0;
14614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14616 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14617 sw_if_index_set = 1;
14618 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14619 sw_if_index_set = 1;
14620 else if (unformat (i, "del"))
14622 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14624 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14626 else if (unformat (i, "l2-table %d", &l2_table_index))
14630 clib_warning ("parse error '%U'", format_unformat_error, i);
14635 if (sw_if_index_set == 0)
14637 errmsg ("missing interface name or sw_if_index");
14641 M (INPUT_ACL_SET_INTERFACE, mp);
14643 mp->sw_if_index = ntohl (sw_if_index);
14644 mp->ip4_table_index = ntohl (ip4_table_index);
14645 mp->ip6_table_index = ntohl (ip6_table_index);
14646 mp->l2_table_index = ntohl (l2_table_index);
14647 mp->is_add = is_add;
14655 api_output_acl_set_interface (vat_main_t * vam)
14657 unformat_input_t *i = vam->input;
14658 vl_api_output_acl_set_interface_t *mp;
14660 int sw_if_index_set;
14661 u32 ip4_table_index = ~0;
14662 u32 ip6_table_index = ~0;
14663 u32 l2_table_index = ~0;
14667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14669 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14670 sw_if_index_set = 1;
14671 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14672 sw_if_index_set = 1;
14673 else if (unformat (i, "del"))
14675 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14677 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14679 else if (unformat (i, "l2-table %d", &l2_table_index))
14683 clib_warning ("parse error '%U'", format_unformat_error, i);
14688 if (sw_if_index_set == 0)
14690 errmsg ("missing interface name or sw_if_index");
14694 M (OUTPUT_ACL_SET_INTERFACE, mp);
14696 mp->sw_if_index = ntohl (sw_if_index);
14697 mp->ip4_table_index = ntohl (ip4_table_index);
14698 mp->ip6_table_index = ntohl (ip6_table_index);
14699 mp->l2_table_index = ntohl (l2_table_index);
14700 mp->is_add = is_add;
14708 api_ip_address_dump (vat_main_t * vam)
14710 unformat_input_t *i = vam->input;
14711 vl_api_ip_address_dump_t *mp;
14712 vl_api_control_ping_t *mp_ping;
14713 u32 sw_if_index = ~0;
14714 u8 sw_if_index_set = 0;
14719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14721 if (unformat (i, "sw_if_index %d", &sw_if_index))
14722 sw_if_index_set = 1;
14724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14725 sw_if_index_set = 1;
14726 else if (unformat (i, "ipv4"))
14728 else if (unformat (i, "ipv6"))
14734 if (ipv4_set && ipv6_set)
14736 errmsg ("ipv4 and ipv6 flags cannot be both set");
14740 if ((!ipv4_set) && (!ipv6_set))
14742 errmsg ("no ipv4 nor ipv6 flag set");
14746 if (sw_if_index_set == 0)
14748 errmsg ("missing interface name or sw_if_index");
14752 vam->current_sw_if_index = sw_if_index;
14753 vam->is_ipv6 = ipv6_set;
14755 M (IP_ADDRESS_DUMP, mp);
14756 mp->sw_if_index = ntohl (sw_if_index);
14757 mp->is_ipv6 = ipv6_set;
14760 /* Use a control ping for synchronization */
14761 MPING (CONTROL_PING, mp_ping);
14769 api_ip_dump (vat_main_t * vam)
14771 vl_api_ip_dump_t *mp;
14772 vl_api_control_ping_t *mp_ping;
14773 unformat_input_t *in = vam->input;
14780 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14782 if (unformat (in, "ipv4"))
14784 else if (unformat (in, "ipv6"))
14790 if (ipv4_set && ipv6_set)
14792 errmsg ("ipv4 and ipv6 flags cannot be both set");
14796 if ((!ipv4_set) && (!ipv6_set))
14798 errmsg ("no ipv4 nor ipv6 flag set");
14802 is_ipv6 = ipv6_set;
14803 vam->is_ipv6 = is_ipv6;
14805 /* free old data */
14806 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14808 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14810 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14813 mp->is_ipv6 = ipv6_set;
14816 /* Use a control ping for synchronization */
14817 MPING (CONTROL_PING, mp_ping);
14825 api_ipsec_spd_add_del (vat_main_t * vam)
14827 unformat_input_t *i = vam->input;
14828 vl_api_ipsec_spd_add_del_t *mp;
14833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14835 if (unformat (i, "spd_id %d", &spd_id))
14837 else if (unformat (i, "del"))
14841 clib_warning ("parse error '%U'", format_unformat_error, i);
14847 errmsg ("spd_id must be set");
14851 M (IPSEC_SPD_ADD_DEL, mp);
14853 mp->spd_id = ntohl (spd_id);
14854 mp->is_add = is_add;
14862 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14864 unformat_input_t *i = vam->input;
14865 vl_api_ipsec_interface_add_del_spd_t *mp;
14867 u8 sw_if_index_set = 0;
14868 u32 spd_id = (u32) ~ 0;
14872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14874 if (unformat (i, "del"))
14876 else if (unformat (i, "spd_id %d", &spd_id))
14879 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14880 sw_if_index_set = 1;
14881 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14882 sw_if_index_set = 1;
14885 clib_warning ("parse error '%U'", format_unformat_error, i);
14891 if (spd_id == (u32) ~ 0)
14893 errmsg ("spd_id must be set");
14897 if (sw_if_index_set == 0)
14899 errmsg ("missing interface name or sw_if_index");
14903 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14905 mp->spd_id = ntohl (spd_id);
14906 mp->sw_if_index = ntohl (sw_if_index);
14907 mp->is_add = is_add;
14915 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14917 unformat_input_t *i = vam->input;
14918 vl_api_ipsec_spd_add_del_entry_t *mp;
14919 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14920 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14922 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14923 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14924 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14925 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14928 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14929 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14930 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14931 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14932 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14933 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14937 if (unformat (i, "del"))
14939 if (unformat (i, "outbound"))
14941 if (unformat (i, "inbound"))
14943 else if (unformat (i, "spd_id %d", &spd_id))
14945 else if (unformat (i, "sa_id %d", &sa_id))
14947 else if (unformat (i, "priority %d", &priority))
14949 else if (unformat (i, "protocol %d", &protocol))
14951 else if (unformat (i, "lport_start %d", &lport_start))
14953 else if (unformat (i, "lport_stop %d", &lport_stop))
14955 else if (unformat (i, "rport_start %d", &rport_start))
14957 else if (unformat (i, "rport_stop %d", &rport_stop))
14961 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14967 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14974 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14980 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14987 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14993 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
15000 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
15006 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
15012 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
15014 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
15016 clib_warning ("unsupported action: 'resolve'");
15022 clib_warning ("parse error '%U'", format_unformat_error, i);
15028 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
15030 mp->spd_id = ntohl (spd_id);
15031 mp->priority = ntohl (priority);
15032 mp->is_outbound = is_outbound;
15034 mp->is_ipv6 = is_ipv6;
15035 if (is_ipv6 || is_ip_any)
15037 clib_memcpy (mp->remote_address_start, &raddr6_start,
15038 sizeof (ip6_address_t));
15039 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
15040 sizeof (ip6_address_t));
15041 clib_memcpy (mp->local_address_start, &laddr6_start,
15042 sizeof (ip6_address_t));
15043 clib_memcpy (mp->local_address_stop, &laddr6_stop,
15044 sizeof (ip6_address_t));
15048 clib_memcpy (mp->remote_address_start, &raddr4_start,
15049 sizeof (ip4_address_t));
15050 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
15051 sizeof (ip4_address_t));
15052 clib_memcpy (mp->local_address_start, &laddr4_start,
15053 sizeof (ip4_address_t));
15054 clib_memcpy (mp->local_address_stop, &laddr4_stop,
15055 sizeof (ip4_address_t));
15057 mp->protocol = (u8) protocol;
15058 mp->local_port_start = ntohs ((u16) lport_start);
15059 mp->local_port_stop = ntohs ((u16) lport_stop);
15060 mp->remote_port_start = ntohs ((u16) rport_start);
15061 mp->remote_port_stop = ntohs ((u16) rport_stop);
15062 mp->policy = (u8) policy;
15063 mp->sa_id = ntohl (sa_id);
15064 mp->is_add = is_add;
15065 mp->is_ip_any = is_ip_any;
15072 api_ipsec_sad_add_del_entry (vat_main_t * vam)
15074 unformat_input_t *i = vam->input;
15075 vl_api_ipsec_sad_add_del_entry_t *mp;
15076 u32 sad_id = 0, spi = 0;
15077 u8 *ck = 0, *ik = 0;
15080 u8 protocol = IPSEC_PROTOCOL_AH;
15081 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
15082 u32 crypto_alg = 0, integ_alg = 0;
15083 ip4_address_t tun_src4;
15084 ip4_address_t tun_dst4;
15085 ip6_address_t tun_src6;
15086 ip6_address_t tun_dst6;
15089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15091 if (unformat (i, "del"))
15093 else if (unformat (i, "sad_id %d", &sad_id))
15095 else if (unformat (i, "spi %d", &spi))
15097 else if (unformat (i, "esp"))
15098 protocol = IPSEC_PROTOCOL_ESP;
15099 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
15102 is_tunnel_ipv6 = 0;
15104 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
15107 is_tunnel_ipv6 = 0;
15109 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
15112 is_tunnel_ipv6 = 1;
15114 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
15117 is_tunnel_ipv6 = 1;
15121 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15123 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15124 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15126 clib_warning ("unsupported crypto-alg: '%U'",
15127 format_ipsec_crypto_alg, crypto_alg);
15131 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15135 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15137 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15138 integ_alg >= IPSEC_INTEG_N_ALG)
15140 clib_warning ("unsupported integ-alg: '%U'",
15141 format_ipsec_integ_alg, integ_alg);
15145 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15149 clib_warning ("parse error '%U'", format_unformat_error, i);
15155 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
15157 mp->sad_id = ntohl (sad_id);
15158 mp->is_add = is_add;
15159 mp->protocol = protocol;
15160 mp->spi = ntohl (spi);
15161 mp->is_tunnel = is_tunnel;
15162 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
15163 mp->crypto_algorithm = crypto_alg;
15164 mp->integrity_algorithm = integ_alg;
15165 mp->crypto_key_length = vec_len (ck);
15166 mp->integrity_key_length = vec_len (ik);
15168 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15169 mp->crypto_key_length = sizeof (mp->crypto_key);
15171 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15172 mp->integrity_key_length = sizeof (mp->integrity_key);
15175 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15177 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15181 if (is_tunnel_ipv6)
15183 clib_memcpy (mp->tunnel_src_address, &tun_src6,
15184 sizeof (ip6_address_t));
15185 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
15186 sizeof (ip6_address_t));
15190 clib_memcpy (mp->tunnel_src_address, &tun_src4,
15191 sizeof (ip4_address_t));
15192 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
15193 sizeof (ip4_address_t));
15203 api_ipsec_sa_set_key (vat_main_t * vam)
15205 unformat_input_t *i = vam->input;
15206 vl_api_ipsec_sa_set_key_t *mp;
15208 u8 *ck = 0, *ik = 0;
15211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15213 if (unformat (i, "sa_id %d", &sa_id))
15215 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
15217 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15221 clib_warning ("parse error '%U'", format_unformat_error, i);
15226 M (IPSEC_SA_SET_KEY, mp);
15228 mp->sa_id = ntohl (sa_id);
15229 mp->crypto_key_length = vec_len (ck);
15230 mp->integrity_key_length = vec_len (ik);
15232 if (mp->crypto_key_length > sizeof (mp->crypto_key))
15233 mp->crypto_key_length = sizeof (mp->crypto_key);
15235 if (mp->integrity_key_length > sizeof (mp->integrity_key))
15236 mp->integrity_key_length = sizeof (mp->integrity_key);
15239 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
15241 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
15249 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15251 unformat_input_t *i = vam->input;
15252 vl_api_ipsec_tunnel_if_add_del_t *mp;
15253 u32 local_spi = 0, remote_spi = 0;
15254 u32 crypto_alg = 0, integ_alg = 0;
15255 u8 *lck = NULL, *rck = NULL;
15256 u8 *lik = NULL, *rik = NULL;
15257 ip4_address_t local_ip = { {0} };
15258 ip4_address_t remote_ip = { {0} };
15261 u8 anti_replay = 0;
15266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15268 if (unformat (i, "del"))
15270 else if (unformat (i, "esn"))
15272 else if (unformat (i, "anti_replay"))
15274 else if (unformat (i, "local_spi %d", &local_spi))
15276 else if (unformat (i, "remote_spi %d", &remote_spi))
15278 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15280 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15282 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15285 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15287 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15289 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15293 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
15295 if (crypto_alg < IPSEC_CRYPTO_ALG_NONE ||
15296 crypto_alg >= IPSEC_CRYPTO_N_ALG)
15298 errmsg ("unsupported crypto-alg: '%U'\n",
15299 format_ipsec_crypto_alg, crypto_alg);
15305 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
15307 if (integ_alg < IPSEC_INTEG_ALG_NONE ||
15308 integ_alg >= IPSEC_INTEG_N_ALG)
15310 errmsg ("unsupported integ-alg: '%U'\n",
15311 format_ipsec_integ_alg, integ_alg);
15315 else if (unformat (i, "instance %u", &instance))
15319 errmsg ("parse error '%U'\n", format_unformat_error, i);
15324 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15326 mp->is_add = is_add;
15328 mp->anti_replay = anti_replay;
15330 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15331 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15333 mp->local_spi = htonl (local_spi);
15334 mp->remote_spi = htonl (remote_spi);
15335 mp->crypto_alg = (u8) crypto_alg;
15337 mp->local_crypto_key_len = 0;
15340 mp->local_crypto_key_len = vec_len (lck);
15341 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15342 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15343 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15346 mp->remote_crypto_key_len = 0;
15349 mp->remote_crypto_key_len = vec_len (rck);
15350 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15351 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15352 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15355 mp->integ_alg = (u8) integ_alg;
15357 mp->local_integ_key_len = 0;
15360 mp->local_integ_key_len = vec_len (lik);
15361 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15362 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15363 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15366 mp->remote_integ_key_len = 0;
15369 mp->remote_integ_key_len = vec_len (rik);
15370 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15371 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15372 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15377 mp->renumber = renumber;
15378 mp->show_instance = ntohl (instance);
15387 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15389 vat_main_t *vam = &vat_main;
15391 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15392 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
15393 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
15394 "tunnel_src_addr %U tunnel_dst_addr %U "
15395 "salt %u seq_outbound %lu last_seq_inbound %lu "
15396 "replay_window %lu total_data_size %lu\n",
15397 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
15399 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
15400 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
15401 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
15402 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15403 mp->tunnel_src_addr,
15404 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
15405 mp->tunnel_dst_addr,
15407 clib_net_to_host_u64 (mp->seq_outbound),
15408 clib_net_to_host_u64 (mp->last_seq_inbound),
15409 clib_net_to_host_u64 (mp->replay_window),
15410 clib_net_to_host_u64 (mp->total_data_size));
15413 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15414 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15416 static void vl_api_ipsec_sa_details_t_handler_json
15417 (vl_api_ipsec_sa_details_t * mp)
15419 vat_main_t *vam = &vat_main;
15420 vat_json_node_t *node = NULL;
15421 struct in_addr src_ip4, dst_ip4;
15422 struct in6_addr src_ip6, dst_ip6;
15424 if (VAT_JSON_ARRAY != vam->json_tree.type)
15426 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15427 vat_json_init_array (&vam->json_tree);
15429 node = vat_json_array_add (&vam->json_tree);
15431 vat_json_init_object (node);
15432 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
15433 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15434 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
15435 vat_json_object_add_uint (node, "proto", mp->protocol);
15436 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
15437 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
15438 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
15439 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
15440 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
15441 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
15442 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
15443 mp->crypto_key_len);
15444 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
15445 mp->integ_key_len);
15446 if (mp->is_tunnel_ip6)
15448 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
15449 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
15450 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
15451 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
15455 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
15456 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
15457 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
15458 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
15460 vat_json_object_add_uint (node, "replay_window",
15461 clib_net_to_host_u64 (mp->replay_window));
15462 vat_json_object_add_uint (node, "total_data_size",
15463 clib_net_to_host_u64 (mp->total_data_size));
15468 api_ipsec_sa_dump (vat_main_t * vam)
15470 unformat_input_t *i = vam->input;
15471 vl_api_ipsec_sa_dump_t *mp;
15472 vl_api_control_ping_t *mp_ping;
15476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15478 if (unformat (i, "sa_id %d", &sa_id))
15482 clib_warning ("parse error '%U'", format_unformat_error, i);
15487 M (IPSEC_SA_DUMP, mp);
15489 mp->sa_id = ntohl (sa_id);
15493 /* Use a control ping for synchronization */
15494 M (CONTROL_PING, mp_ping);
15502 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15504 unformat_input_t *i = vam->input;
15505 vl_api_ipsec_tunnel_if_set_key_t *mp;
15506 u32 sw_if_index = ~0;
15507 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15514 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15517 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
15518 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15520 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
15521 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15522 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
15523 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15525 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
15526 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15527 else if (unformat (i, "%U", unformat_hex_string, &key))
15531 clib_warning ("parse error '%U'", format_unformat_error, i);
15536 if (sw_if_index == ~0)
15538 errmsg ("interface must be specified");
15542 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15544 errmsg ("key type must be specified");
15550 errmsg ("algorithm must be specified");
15554 if (vec_len (key) == 0)
15556 errmsg ("key must be specified");
15560 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15562 mp->sw_if_index = htonl (sw_if_index);
15564 mp->key_type = key_type;
15565 mp->key_len = vec_len (key);
15566 clib_memcpy (mp->key, key, vec_len (key));
15575 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15577 unformat_input_t *i = vam->input;
15578 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15579 u32 sw_if_index = ~0;
15581 u8 is_outbound = (u8) ~ 0;
15584 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15586 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15588 else if (unformat (i, "sa_id %d", &sa_id))
15590 else if (unformat (i, "outbound"))
15592 else if (unformat (i, "inbound"))
15596 clib_warning ("parse error '%U'", format_unformat_error, i);
15601 if (sw_if_index == ~0)
15603 errmsg ("interface must be specified");
15609 errmsg ("SA ID must be specified");
15613 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15615 mp->sw_if_index = htonl (sw_if_index);
15616 mp->sa_id = htonl (sa_id);
15617 mp->is_outbound = is_outbound;
15626 api_ikev2_profile_add_del (vat_main_t * vam)
15628 unformat_input_t *i = vam->input;
15629 vl_api_ikev2_profile_add_del_t *mp;
15634 const char *valid_chars = "a-zA-Z0-9_";
15636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15638 if (unformat (i, "del"))
15640 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15641 vec_add1 (name, 0);
15644 errmsg ("parse error '%U'", format_unformat_error, i);
15649 if (!vec_len (name))
15651 errmsg ("profile name must be specified");
15655 if (vec_len (name) > 64)
15657 errmsg ("profile name too long");
15661 M (IKEV2_PROFILE_ADD_DEL, mp);
15663 clib_memcpy (mp->name, name, vec_len (name));
15664 mp->is_add = is_add;
15673 api_ikev2_profile_set_auth (vat_main_t * vam)
15675 unformat_input_t *i = vam->input;
15676 vl_api_ikev2_profile_set_auth_t *mp;
15679 u32 auth_method = 0;
15683 const char *valid_chars = "a-zA-Z0-9_";
15685 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15687 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15688 vec_add1 (name, 0);
15689 else if (unformat (i, "auth_method %U",
15690 unformat_ikev2_auth_method, &auth_method))
15692 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
15694 else if (unformat (i, "auth_data %v", &data))
15698 errmsg ("parse error '%U'", format_unformat_error, i);
15703 if (!vec_len (name))
15705 errmsg ("profile name must be specified");
15709 if (vec_len (name) > 64)
15711 errmsg ("profile name too long");
15715 if (!vec_len (data))
15717 errmsg ("auth_data must be specified");
15723 errmsg ("auth_method must be specified");
15727 M (IKEV2_PROFILE_SET_AUTH, mp);
15729 mp->is_hex = is_hex;
15730 mp->auth_method = (u8) auth_method;
15731 mp->data_len = vec_len (data);
15732 clib_memcpy (mp->name, name, vec_len (name));
15733 clib_memcpy (mp->data, data, vec_len (data));
15743 api_ikev2_profile_set_id (vat_main_t * vam)
15745 unformat_input_t *i = vam->input;
15746 vl_api_ikev2_profile_set_id_t *mp;
15754 const char *valid_chars = "a-zA-Z0-9_";
15756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15758 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15759 vec_add1 (name, 0);
15760 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
15762 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
15764 data = vec_new (u8, 4);
15765 clib_memcpy (data, ip4.as_u8, 4);
15767 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
15769 else if (unformat (i, "id_data %v", &data))
15771 else if (unformat (i, "local"))
15773 else if (unformat (i, "remote"))
15777 errmsg ("parse error '%U'", format_unformat_error, i);
15782 if (!vec_len (name))
15784 errmsg ("profile name must be specified");
15788 if (vec_len (name) > 64)
15790 errmsg ("profile name too long");
15794 if (!vec_len (data))
15796 errmsg ("id_data must be specified");
15802 errmsg ("id_type must be specified");
15806 M (IKEV2_PROFILE_SET_ID, mp);
15808 mp->is_local = is_local;
15809 mp->id_type = (u8) id_type;
15810 mp->data_len = vec_len (data);
15811 clib_memcpy (mp->name, name, vec_len (name));
15812 clib_memcpy (mp->data, data, vec_len (data));
15822 api_ikev2_profile_set_ts (vat_main_t * vam)
15824 unformat_input_t *i = vam->input;
15825 vl_api_ikev2_profile_set_ts_t *mp;
15828 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
15829 ip4_address_t start_addr, end_addr;
15831 const char *valid_chars = "a-zA-Z0-9_";
15834 start_addr.as_u32 = 0;
15835 end_addr.as_u32 = (u32) ~ 0;
15837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15839 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15840 vec_add1 (name, 0);
15841 else if (unformat (i, "protocol %d", &proto))
15843 else if (unformat (i, "start_port %d", &start_port))
15845 else if (unformat (i, "end_port %d", &end_port))
15848 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15850 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15852 else if (unformat (i, "local"))
15854 else if (unformat (i, "remote"))
15858 errmsg ("parse error '%U'", format_unformat_error, i);
15863 if (!vec_len (name))
15865 errmsg ("profile name must be specified");
15869 if (vec_len (name) > 64)
15871 errmsg ("profile name too long");
15875 M (IKEV2_PROFILE_SET_TS, mp);
15877 mp->is_local = is_local;
15878 mp->proto = (u8) proto;
15879 mp->start_port = (u16) start_port;
15880 mp->end_port = (u16) end_port;
15881 mp->start_addr = start_addr.as_u32;
15882 mp->end_addr = end_addr.as_u32;
15883 clib_memcpy (mp->name, name, vec_len (name));
15892 api_ikev2_set_local_key (vat_main_t * vam)
15894 unformat_input_t *i = vam->input;
15895 vl_api_ikev2_set_local_key_t *mp;
15899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15901 if (unformat (i, "file %v", &file))
15902 vec_add1 (file, 0);
15905 errmsg ("parse error '%U'", format_unformat_error, i);
15910 if (!vec_len (file))
15912 errmsg ("RSA key file must be specified");
15916 if (vec_len (file) > 256)
15918 errmsg ("file name too long");
15922 M (IKEV2_SET_LOCAL_KEY, mp);
15924 clib_memcpy (mp->key_file, file, vec_len (file));
15933 api_ikev2_set_responder (vat_main_t * vam)
15935 unformat_input_t *i = vam->input;
15936 vl_api_ikev2_set_responder_t *mp;
15939 u32 sw_if_index = ~0;
15940 ip4_address_t address;
15942 const char *valid_chars = "a-zA-Z0-9_";
15944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15947 (i, "%U interface %d address %U", unformat_token, valid_chars,
15948 &name, &sw_if_index, unformat_ip4_address, &address))
15949 vec_add1 (name, 0);
15952 errmsg ("parse error '%U'", format_unformat_error, i);
15957 if (!vec_len (name))
15959 errmsg ("profile name must be specified");
15963 if (vec_len (name) > 64)
15965 errmsg ("profile name too long");
15969 M (IKEV2_SET_RESPONDER, mp);
15971 clib_memcpy (mp->name, name, vec_len (name));
15974 mp->sw_if_index = sw_if_index;
15975 clib_memcpy (mp->address, &address, sizeof (address));
15983 api_ikev2_set_ike_transforms (vat_main_t * vam)
15985 unformat_input_t *i = vam->input;
15986 vl_api_ikev2_set_ike_transforms_t *mp;
15989 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15991 const char *valid_chars = "a-zA-Z0-9_";
15993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15995 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15996 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15997 vec_add1 (name, 0);
16000 errmsg ("parse error '%U'", format_unformat_error, i);
16005 if (!vec_len (name))
16007 errmsg ("profile name must be specified");
16011 if (vec_len (name) > 64)
16013 errmsg ("profile name too long");
16017 M (IKEV2_SET_IKE_TRANSFORMS, mp);
16019 clib_memcpy (mp->name, name, vec_len (name));
16021 mp->crypto_alg = crypto_alg;
16022 mp->crypto_key_size = crypto_key_size;
16023 mp->integ_alg = integ_alg;
16024 mp->dh_group = dh_group;
16033 api_ikev2_set_esp_transforms (vat_main_t * vam)
16035 unformat_input_t *i = vam->input;
16036 vl_api_ikev2_set_esp_transforms_t *mp;
16039 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
16041 const char *valid_chars = "a-zA-Z0-9_";
16043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16045 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
16046 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
16047 vec_add1 (name, 0);
16050 errmsg ("parse error '%U'", format_unformat_error, i);
16055 if (!vec_len (name))
16057 errmsg ("profile name must be specified");
16061 if (vec_len (name) > 64)
16063 errmsg ("profile name too long");
16067 M (IKEV2_SET_ESP_TRANSFORMS, mp);
16069 clib_memcpy (mp->name, name, vec_len (name));
16071 mp->crypto_alg = crypto_alg;
16072 mp->crypto_key_size = crypto_key_size;
16073 mp->integ_alg = integ_alg;
16074 mp->dh_group = dh_group;
16082 api_ikev2_set_sa_lifetime (vat_main_t * vam)
16084 unformat_input_t *i = vam->input;
16085 vl_api_ikev2_set_sa_lifetime_t *mp;
16088 u64 lifetime, lifetime_maxdata;
16089 u32 lifetime_jitter, handover;
16091 const char *valid_chars = "a-zA-Z0-9_";
16093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16095 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
16096 &lifetime, &lifetime_jitter, &handover,
16097 &lifetime_maxdata))
16098 vec_add1 (name, 0);
16101 errmsg ("parse error '%U'", format_unformat_error, i);
16106 if (!vec_len (name))
16108 errmsg ("profile name must be specified");
16112 if (vec_len (name) > 64)
16114 errmsg ("profile name too long");
16118 M (IKEV2_SET_SA_LIFETIME, mp);
16120 clib_memcpy (mp->name, name, vec_len (name));
16122 mp->lifetime = lifetime;
16123 mp->lifetime_jitter = lifetime_jitter;
16124 mp->handover = handover;
16125 mp->lifetime_maxdata = lifetime_maxdata;
16133 api_ikev2_initiate_sa_init (vat_main_t * vam)
16135 unformat_input_t *i = vam->input;
16136 vl_api_ikev2_initiate_sa_init_t *mp;
16140 const char *valid_chars = "a-zA-Z0-9_";
16142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16144 if (unformat (i, "%U", unformat_token, valid_chars, &name))
16145 vec_add1 (name, 0);
16148 errmsg ("parse error '%U'", format_unformat_error, i);
16153 if (!vec_len (name))
16155 errmsg ("profile name must be specified");
16159 if (vec_len (name) > 64)
16161 errmsg ("profile name too long");
16165 M (IKEV2_INITIATE_SA_INIT, mp);
16167 clib_memcpy (mp->name, name, vec_len (name));
16176 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
16178 unformat_input_t *i = vam->input;
16179 vl_api_ikev2_initiate_del_ike_sa_t *mp;
16184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16186 if (unformat (i, "%lx", &ispi))
16190 errmsg ("parse error '%U'", format_unformat_error, i);
16195 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
16205 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
16207 unformat_input_t *i = vam->input;
16208 vl_api_ikev2_initiate_del_child_sa_t *mp;
16213 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16215 if (unformat (i, "%x", &ispi))
16219 errmsg ("parse error '%U'", format_unformat_error, i);
16224 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
16234 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
16236 unformat_input_t *i = vam->input;
16237 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
16242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16244 if (unformat (i, "%x", &ispi))
16248 errmsg ("parse error '%U'", format_unformat_error, i);
16253 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
16266 api_map_add_domain (vat_main_t * vam)
16268 unformat_input_t *i = vam->input;
16269 vl_api_map_add_domain_t *mp;
16271 ip4_address_t ip4_prefix;
16272 ip6_address_t ip6_prefix;
16273 ip6_address_t ip6_src;
16274 u32 num_m_args = 0;
16275 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
16276 0, psid_length = 0;
16277 u8 is_translation = 0;
16279 u32 ip6_src_len = 128;
16282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16284 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
16285 &ip4_prefix, &ip4_prefix_len))
16287 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
16288 &ip6_prefix, &ip6_prefix_len))
16292 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
16295 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
16297 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
16299 else if (unformat (i, "psid-offset %d", &psid_offset))
16301 else if (unformat (i, "psid-len %d", &psid_length))
16303 else if (unformat (i, "mtu %d", &mtu))
16305 else if (unformat (i, "map-t"))
16306 is_translation = 1;
16309 clib_warning ("parse error '%U'", format_unformat_error, i);
16314 if (num_m_args < 3)
16316 errmsg ("mandatory argument(s) missing");
16320 /* Construct the API message */
16321 M (MAP_ADD_DOMAIN, mp);
16323 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
16324 mp->ip4_prefix_len = ip4_prefix_len;
16326 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
16327 mp->ip6_prefix_len = ip6_prefix_len;
16329 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
16330 mp->ip6_src_prefix_len = ip6_src_len;
16332 mp->ea_bits_len = ea_bits_len;
16333 mp->psid_offset = psid_offset;
16334 mp->psid_length = psid_length;
16335 mp->is_translation = is_translation;
16336 mp->mtu = htons (mtu);
16341 /* Wait for a reply, return good/bad news */
16347 api_map_del_domain (vat_main_t * vam)
16349 unformat_input_t *i = vam->input;
16350 vl_api_map_del_domain_t *mp;
16352 u32 num_m_args = 0;
16356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16358 if (unformat (i, "index %d", &index))
16362 clib_warning ("parse error '%U'", format_unformat_error, i);
16367 if (num_m_args != 1)
16369 errmsg ("mandatory argument(s) missing");
16373 /* Construct the API message */
16374 M (MAP_DEL_DOMAIN, mp);
16376 mp->index = ntohl (index);
16381 /* Wait for a reply, return good/bad news */
16387 api_map_add_del_rule (vat_main_t * vam)
16389 unformat_input_t *i = vam->input;
16390 vl_api_map_add_del_rule_t *mp;
16392 ip6_address_t ip6_dst;
16393 u32 num_m_args = 0, index, psid = 0;
16396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16398 if (unformat (i, "index %d", &index))
16400 else if (unformat (i, "psid %d", &psid))
16402 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
16404 else if (unformat (i, "del"))
16410 clib_warning ("parse error '%U'", format_unformat_error, i);
16415 /* Construct the API message */
16416 M (MAP_ADD_DEL_RULE, mp);
16418 mp->index = ntohl (index);
16419 mp->is_add = is_add;
16420 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
16421 mp->psid = ntohs (psid);
16426 /* Wait for a reply, return good/bad news */
16432 api_map_domain_dump (vat_main_t * vam)
16434 vl_api_map_domain_dump_t *mp;
16435 vl_api_control_ping_t *mp_ping;
16438 /* Construct the API message */
16439 M (MAP_DOMAIN_DUMP, mp);
16444 /* Use a control ping for synchronization */
16445 MPING (CONTROL_PING, mp_ping);
16453 api_map_rule_dump (vat_main_t * vam)
16455 unformat_input_t *i = vam->input;
16456 vl_api_map_rule_dump_t *mp;
16457 vl_api_control_ping_t *mp_ping;
16458 u32 domain_index = ~0;
16461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16463 if (unformat (i, "index %u", &domain_index))
16469 if (domain_index == ~0)
16471 clib_warning ("parse error: domain index expected");
16475 /* Construct the API message */
16476 M (MAP_RULE_DUMP, mp);
16478 mp->domain_index = htonl (domain_index);
16483 /* Use a control ping for synchronization */
16484 MPING (CONTROL_PING, mp_ping);
16491 static void vl_api_map_add_domain_reply_t_handler
16492 (vl_api_map_add_domain_reply_t * mp)
16494 vat_main_t *vam = &vat_main;
16495 i32 retval = ntohl (mp->retval);
16497 if (vam->async_mode)
16499 vam->async_errors += (retval < 0);
16503 vam->retval = retval;
16504 vam->result_ready = 1;
16508 static void vl_api_map_add_domain_reply_t_handler_json
16509 (vl_api_map_add_domain_reply_t * mp)
16511 vat_main_t *vam = &vat_main;
16512 vat_json_node_t node;
16514 vat_json_init_object (&node);
16515 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
16516 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
16518 vat_json_print (vam->ofp, &node);
16519 vat_json_free (&node);
16521 vam->retval = ntohl (mp->retval);
16522 vam->result_ready = 1;
16526 api_get_first_msg_id (vat_main_t * vam)
16528 vl_api_get_first_msg_id_t *mp;
16529 unformat_input_t *i = vam->input;
16534 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16536 if (unformat (i, "client %s", &name))
16544 errmsg ("missing client name");
16547 vec_add1 (name, 0);
16549 if (vec_len (name) > 63)
16551 errmsg ("client name too long");
16555 M (GET_FIRST_MSG_ID, mp);
16556 clib_memcpy (mp->name, name, vec_len (name));
16563 api_cop_interface_enable_disable (vat_main_t * vam)
16565 unformat_input_t *line_input = vam->input;
16566 vl_api_cop_interface_enable_disable_t *mp;
16567 u32 sw_if_index = ~0;
16568 u8 enable_disable = 1;
16571 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16573 if (unformat (line_input, "disable"))
16574 enable_disable = 0;
16575 if (unformat (line_input, "enable"))
16576 enable_disable = 1;
16577 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16578 vam, &sw_if_index))
16580 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16586 if (sw_if_index == ~0)
16588 errmsg ("missing interface name or sw_if_index");
16592 /* Construct the API message */
16593 M (COP_INTERFACE_ENABLE_DISABLE, mp);
16594 mp->sw_if_index = ntohl (sw_if_index);
16595 mp->enable_disable = enable_disable;
16599 /* Wait for the reply */
16605 api_cop_whitelist_enable_disable (vat_main_t * vam)
16607 unformat_input_t *line_input = vam->input;
16608 vl_api_cop_whitelist_enable_disable_t *mp;
16609 u32 sw_if_index = ~0;
16610 u8 ip4 = 0, ip6 = 0, default_cop = 0;
16614 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
16616 if (unformat (line_input, "ip4"))
16618 else if (unformat (line_input, "ip6"))
16620 else if (unformat (line_input, "default"))
16622 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
16623 vam, &sw_if_index))
16625 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
16627 else if (unformat (line_input, "fib-id %d", &fib_id))
16633 if (sw_if_index == ~0)
16635 errmsg ("missing interface name or sw_if_index");
16639 /* Construct the API message */
16640 M (COP_WHITELIST_ENABLE_DISABLE, mp);
16641 mp->sw_if_index = ntohl (sw_if_index);
16642 mp->fib_id = ntohl (fib_id);
16645 mp->default_cop = default_cop;
16649 /* Wait for the reply */
16655 api_get_node_graph (vat_main_t * vam)
16657 vl_api_get_node_graph_t *mp;
16660 M (GET_NODE_GRAPH, mp);
16664 /* Wait for the reply */
16670 /** Used for parsing LISP eids */
16671 typedef CLIB_PACKED(struct{
16672 u8 addr[16]; /**< eid address */
16673 u32 len; /**< prefix length if IP */
16674 u8 type; /**< type of eid */
16679 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
16681 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
16683 memset (a, 0, sizeof (a[0]));
16685 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
16687 a->type = 0; /* ipv4 type */
16689 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
16691 a->type = 1; /* ipv6 type */
16693 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
16695 a->type = 2; /* mac type */
16697 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
16699 a->type = 3; /* NSH type */
16700 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
16701 nsh->spi = clib_host_to_net_u32 (nsh->spi);
16708 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
16717 lisp_eid_size_vat (u8 type)
16734 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
16736 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
16740 api_one_add_del_locator_set (vat_main_t * vam)
16742 unformat_input_t *input = vam->input;
16743 vl_api_one_add_del_locator_set_t *mp;
16745 u8 *locator_set_name = NULL;
16746 u8 locator_set_name_set = 0;
16747 vl_api_local_locator_t locator, *locators = 0;
16748 u32 sw_if_index, priority, weight;
16752 /* Parse args required to build the message */
16753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16755 if (unformat (input, "del"))
16759 else if (unformat (input, "locator-set %s", &locator_set_name))
16761 locator_set_name_set = 1;
16763 else if (unformat (input, "sw_if_index %u p %u w %u",
16764 &sw_if_index, &priority, &weight))
16766 locator.sw_if_index = htonl (sw_if_index);
16767 locator.priority = priority;
16768 locator.weight = weight;
16769 vec_add1 (locators, locator);
16773 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
16774 &sw_if_index, &priority, &weight))
16776 locator.sw_if_index = htonl (sw_if_index);
16777 locator.priority = priority;
16778 locator.weight = weight;
16779 vec_add1 (locators, locator);
16785 if (locator_set_name_set == 0)
16787 errmsg ("missing locator-set name");
16788 vec_free (locators);
16792 if (vec_len (locator_set_name) > 64)
16794 errmsg ("locator-set name too long");
16795 vec_free (locator_set_name);
16796 vec_free (locators);
16799 vec_add1 (locator_set_name, 0);
16801 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
16803 /* Construct the API message */
16804 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
16806 mp->is_add = is_add;
16807 clib_memcpy (mp->locator_set_name, locator_set_name,
16808 vec_len (locator_set_name));
16809 vec_free (locator_set_name);
16811 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
16813 clib_memcpy (mp->locators, locators, data_len);
16814 vec_free (locators);
16819 /* Wait for a reply... */
16824 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
16827 api_one_add_del_locator (vat_main_t * vam)
16829 unformat_input_t *input = vam->input;
16830 vl_api_one_add_del_locator_t *mp;
16831 u32 tmp_if_index = ~0;
16832 u32 sw_if_index = ~0;
16833 u8 sw_if_index_set = 0;
16834 u8 sw_if_index_if_name_set = 0;
16836 u8 priority_set = 0;
16840 u8 *locator_set_name = NULL;
16841 u8 locator_set_name_set = 0;
16844 /* Parse args required to build the message */
16845 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16847 if (unformat (input, "del"))
16851 else if (unformat (input, "locator-set %s", &locator_set_name))
16853 locator_set_name_set = 1;
16855 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16858 sw_if_index_if_name_set = 1;
16859 sw_if_index = tmp_if_index;
16861 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16863 sw_if_index_set = 1;
16864 sw_if_index = tmp_if_index;
16866 else if (unformat (input, "p %d", &priority))
16870 else if (unformat (input, "w %d", &weight))
16878 if (locator_set_name_set == 0)
16880 errmsg ("missing locator-set name");
16884 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16886 errmsg ("missing sw_if_index");
16887 vec_free (locator_set_name);
16891 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16893 errmsg ("cannot use both params interface name and sw_if_index");
16894 vec_free (locator_set_name);
16898 if (priority_set == 0)
16900 errmsg ("missing locator-set priority");
16901 vec_free (locator_set_name);
16905 if (weight_set == 0)
16907 errmsg ("missing locator-set weight");
16908 vec_free (locator_set_name);
16912 if (vec_len (locator_set_name) > 64)
16914 errmsg ("locator-set name too long");
16915 vec_free (locator_set_name);
16918 vec_add1 (locator_set_name, 0);
16920 /* Construct the API message */
16921 M (ONE_ADD_DEL_LOCATOR, mp);
16923 mp->is_add = is_add;
16924 mp->sw_if_index = ntohl (sw_if_index);
16925 mp->priority = priority;
16926 mp->weight = weight;
16927 clib_memcpy (mp->locator_set_name, locator_set_name,
16928 vec_len (locator_set_name));
16929 vec_free (locator_set_name);
16934 /* Wait for a reply... */
16939 #define api_lisp_add_del_locator api_one_add_del_locator
16942 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16944 u32 *key_id = va_arg (*args, u32 *);
16947 if (unformat (input, "%s", &s))
16949 if (!strcmp ((char *) s, "sha1"))
16950 key_id[0] = HMAC_SHA_1_96;
16951 else if (!strcmp ((char *) s, "sha256"))
16952 key_id[0] = HMAC_SHA_256_128;
16955 clib_warning ("invalid key_id: '%s'", s);
16956 key_id[0] = HMAC_NO_KEY;
16967 api_one_add_del_local_eid (vat_main_t * vam)
16969 unformat_input_t *input = vam->input;
16970 vl_api_one_add_del_local_eid_t *mp;
16973 lisp_eid_vat_t _eid, *eid = &_eid;
16974 u8 *locator_set_name = 0;
16975 u8 locator_set_name_set = 0;
16981 /* Parse args required to build the message */
16982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16984 if (unformat (input, "del"))
16988 else if (unformat (input, "vni %d", &vni))
16992 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16996 else if (unformat (input, "locator-set %s", &locator_set_name))
16998 locator_set_name_set = 1;
17000 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
17002 else if (unformat (input, "secret-key %_%v%_", &key))
17008 if (locator_set_name_set == 0)
17010 errmsg ("missing locator-set name");
17016 errmsg ("EID address not set!");
17017 vec_free (locator_set_name);
17021 if (key && (0 == key_id))
17023 errmsg ("invalid key_id!");
17027 if (vec_len (key) > 64)
17029 errmsg ("key too long");
17034 if (vec_len (locator_set_name) > 64)
17036 errmsg ("locator-set name too long");
17037 vec_free (locator_set_name);
17040 vec_add1 (locator_set_name, 0);
17042 /* Construct the API message */
17043 M (ONE_ADD_DEL_LOCAL_EID, mp);
17045 mp->is_add = is_add;
17046 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17047 mp->eid_type = eid->type;
17048 mp->prefix_len = eid->len;
17049 mp->vni = clib_host_to_net_u32 (vni);
17050 mp->key_id = clib_host_to_net_u16 (key_id);
17051 clib_memcpy (mp->locator_set_name, locator_set_name,
17052 vec_len (locator_set_name));
17053 clib_memcpy (mp->key, key, vec_len (key));
17055 vec_free (locator_set_name);
17061 /* Wait for a reply... */
17066 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
17069 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
17071 u32 dp_table = 0, vni = 0;;
17072 unformat_input_t *input = vam->input;
17073 vl_api_gpe_add_del_fwd_entry_t *mp;
17075 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
17076 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
17077 u8 rmt_eid_set = 0, lcl_eid_set = 0;
17078 u32 action = ~0, w;
17079 ip4_address_t rmt_rloc4, lcl_rloc4;
17080 ip6_address_t rmt_rloc6, lcl_rloc6;
17081 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
17084 memset (&rloc, 0, sizeof (rloc));
17086 /* Parse args required to build the message */
17087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17089 if (unformat (input, "del"))
17091 else if (unformat (input, "add"))
17093 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
17097 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
17101 else if (unformat (input, "vrf %d", &dp_table))
17103 else if (unformat (input, "bd %d", &dp_table))
17105 else if (unformat (input, "vni %d", &vni))
17107 else if (unformat (input, "w %d", &w))
17111 errmsg ("No RLOC configured for setting priority/weight!");
17114 curr_rloc->weight = w;
17116 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
17117 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
17121 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
17123 vec_add1 (lcl_locs, rloc);
17125 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
17126 vec_add1 (rmt_locs, rloc);
17127 /* weight saved in rmt loc */
17128 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17130 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
17131 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
17134 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
17136 vec_add1 (lcl_locs, rloc);
17138 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
17139 vec_add1 (rmt_locs, rloc);
17140 /* weight saved in rmt loc */
17141 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
17143 else if (unformat (input, "action %d", &action))
17149 clib_warning ("parse error '%U'", format_unformat_error, input);
17156 errmsg ("remote eid addresses not set");
17160 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
17162 errmsg ("eid types don't match");
17166 if (0 == rmt_locs && (u32) ~ 0 == action)
17168 errmsg ("action not set for negative mapping");
17172 /* Construct the API message */
17173 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
17174 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
17176 mp->is_add = is_add;
17177 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
17178 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
17179 mp->eid_type = rmt_eid->type;
17180 mp->dp_table = clib_host_to_net_u32 (dp_table);
17181 mp->vni = clib_host_to_net_u32 (vni);
17182 mp->rmt_len = rmt_eid->len;
17183 mp->lcl_len = lcl_eid->len;
17184 mp->action = action;
17186 if (0 != rmt_locs && 0 != lcl_locs)
17188 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
17189 clib_memcpy (mp->locs, lcl_locs,
17190 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
17192 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
17193 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
17194 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
17196 vec_free (lcl_locs);
17197 vec_free (rmt_locs);
17202 /* Wait for a reply... */
17208 api_one_add_del_map_server (vat_main_t * vam)
17210 unformat_input_t *input = vam->input;
17211 vl_api_one_add_del_map_server_t *mp;
17215 ip4_address_t ipv4;
17216 ip6_address_t ipv6;
17219 /* Parse args required to build the message */
17220 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17222 if (unformat (input, "del"))
17226 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17230 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17238 if (ipv4_set && ipv6_set)
17240 errmsg ("both eid v4 and v6 addresses set");
17244 if (!ipv4_set && !ipv6_set)
17246 errmsg ("eid addresses not set");
17250 /* Construct the API message */
17251 M (ONE_ADD_DEL_MAP_SERVER, mp);
17253 mp->is_add = is_add;
17257 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17262 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17268 /* Wait for a reply... */
17273 #define api_lisp_add_del_map_server api_one_add_del_map_server
17276 api_one_add_del_map_resolver (vat_main_t * vam)
17278 unformat_input_t *input = vam->input;
17279 vl_api_one_add_del_map_resolver_t *mp;
17283 ip4_address_t ipv4;
17284 ip6_address_t ipv6;
17287 /* Parse args required to build the message */
17288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17290 if (unformat (input, "del"))
17294 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
17298 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
17306 if (ipv4_set && ipv6_set)
17308 errmsg ("both eid v4 and v6 addresses set");
17312 if (!ipv4_set && !ipv6_set)
17314 errmsg ("eid addresses not set");
17318 /* Construct the API message */
17319 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
17321 mp->is_add = is_add;
17325 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
17330 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
17336 /* Wait for a reply... */
17341 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
17344 api_lisp_gpe_enable_disable (vat_main_t * vam)
17346 unformat_input_t *input = vam->input;
17347 vl_api_gpe_enable_disable_t *mp;
17352 /* Parse args required to build the message */
17353 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17355 if (unformat (input, "enable"))
17360 else if (unformat (input, "disable"))
17371 errmsg ("Value not set");
17375 /* Construct the API message */
17376 M (GPE_ENABLE_DISABLE, mp);
17383 /* Wait for a reply... */
17389 api_one_rloc_probe_enable_disable (vat_main_t * vam)
17391 unformat_input_t *input = vam->input;
17392 vl_api_one_rloc_probe_enable_disable_t *mp;
17397 /* Parse args required to build the message */
17398 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17400 if (unformat (input, "enable"))
17405 else if (unformat (input, "disable"))
17413 errmsg ("Value not set");
17417 /* Construct the API message */
17418 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
17420 mp->is_enabled = is_en;
17425 /* Wait for a reply... */
17430 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
17433 api_one_map_register_enable_disable (vat_main_t * vam)
17435 unformat_input_t *input = vam->input;
17436 vl_api_one_map_register_enable_disable_t *mp;
17441 /* Parse args required to build the message */
17442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17444 if (unformat (input, "enable"))
17449 else if (unformat (input, "disable"))
17457 errmsg ("Value not set");
17461 /* Construct the API message */
17462 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
17464 mp->is_enabled = is_en;
17469 /* Wait for a reply... */
17474 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
17477 api_one_enable_disable (vat_main_t * vam)
17479 unformat_input_t *input = vam->input;
17480 vl_api_one_enable_disable_t *mp;
17485 /* Parse args required to build the message */
17486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17488 if (unformat (input, "enable"))
17493 else if (unformat (input, "disable"))
17503 errmsg ("Value not set");
17507 /* Construct the API message */
17508 M (ONE_ENABLE_DISABLE, mp);
17515 /* Wait for a reply... */
17520 #define api_lisp_enable_disable api_one_enable_disable
17523 api_one_enable_disable_xtr_mode (vat_main_t * vam)
17525 unformat_input_t *input = vam->input;
17526 vl_api_one_enable_disable_xtr_mode_t *mp;
17531 /* Parse args required to build the message */
17532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17534 if (unformat (input, "enable"))
17539 else if (unformat (input, "disable"))
17549 errmsg ("Value not set");
17553 /* Construct the API message */
17554 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
17561 /* Wait for a reply... */
17567 api_one_show_xtr_mode (vat_main_t * vam)
17569 vl_api_one_show_xtr_mode_t *mp;
17572 /* Construct the API message */
17573 M (ONE_SHOW_XTR_MODE, mp);
17578 /* Wait for a reply... */
17584 api_one_enable_disable_pitr_mode (vat_main_t * vam)
17586 unformat_input_t *input = vam->input;
17587 vl_api_one_enable_disable_pitr_mode_t *mp;
17592 /* Parse args required to build the message */
17593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17595 if (unformat (input, "enable"))
17600 else if (unformat (input, "disable"))
17610 errmsg ("Value not set");
17614 /* Construct the API message */
17615 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
17622 /* Wait for a reply... */
17628 api_one_show_pitr_mode (vat_main_t * vam)
17630 vl_api_one_show_pitr_mode_t *mp;
17633 /* Construct the API message */
17634 M (ONE_SHOW_PITR_MODE, mp);
17639 /* Wait for a reply... */
17645 api_one_enable_disable_petr_mode (vat_main_t * vam)
17647 unformat_input_t *input = vam->input;
17648 vl_api_one_enable_disable_petr_mode_t *mp;
17653 /* Parse args required to build the message */
17654 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17656 if (unformat (input, "enable"))
17661 else if (unformat (input, "disable"))
17671 errmsg ("Value not set");
17675 /* Construct the API message */
17676 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
17683 /* Wait for a reply... */
17689 api_one_show_petr_mode (vat_main_t * vam)
17691 vl_api_one_show_petr_mode_t *mp;
17694 /* Construct the API message */
17695 M (ONE_SHOW_PETR_MODE, mp);
17700 /* Wait for a reply... */
17706 api_show_one_map_register_state (vat_main_t * vam)
17708 vl_api_show_one_map_register_state_t *mp;
17711 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
17716 /* wait for reply */
17721 #define api_show_lisp_map_register_state api_show_one_map_register_state
17724 api_show_one_rloc_probe_state (vat_main_t * vam)
17726 vl_api_show_one_rloc_probe_state_t *mp;
17729 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
17734 /* wait for reply */
17739 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
17742 api_one_add_del_ndp_entry (vat_main_t * vam)
17744 vl_api_one_add_del_ndp_entry_t *mp;
17745 unformat_input_t *input = vam->input;
17750 u8 mac[6] = { 0, };
17751 u8 ip6[16] = { 0, };
17755 /* Parse args required to build the message */
17756 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17758 if (unformat (input, "del"))
17760 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17762 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
17764 else if (unformat (input, "bd %d", &bd))
17768 errmsg ("parse error '%U'", format_unformat_error, input);
17773 if (!bd_set || !ip_set || (!mac_set && is_add))
17775 errmsg ("Missing BD, IP or MAC!");
17779 M (ONE_ADD_DEL_NDP_ENTRY, mp);
17780 mp->is_add = is_add;
17781 clib_memcpy (mp->mac, mac, 6);
17782 mp->bd = clib_host_to_net_u32 (bd);
17783 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
17788 /* wait for reply */
17794 api_one_add_del_l2_arp_entry (vat_main_t * vam)
17796 vl_api_one_add_del_l2_arp_entry_t *mp;
17797 unformat_input_t *input = vam->input;
17802 u8 mac[6] = { 0, };
17803 u32 ip4 = 0, bd = ~0;
17806 /* Parse args required to build the message */
17807 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17809 if (unformat (input, "del"))
17811 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
17813 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
17815 else if (unformat (input, "bd %d", &bd))
17819 errmsg ("parse error '%U'", format_unformat_error, input);
17824 if (!bd_set || !ip_set || (!mac_set && is_add))
17826 errmsg ("Missing BD, IP or MAC!");
17830 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
17831 mp->is_add = is_add;
17832 clib_memcpy (mp->mac, mac, 6);
17833 mp->bd = clib_host_to_net_u32 (bd);
17839 /* wait for reply */
17845 api_one_ndp_bd_get (vat_main_t * vam)
17847 vl_api_one_ndp_bd_get_t *mp;
17850 M (ONE_NDP_BD_GET, mp);
17855 /* wait for reply */
17861 api_one_ndp_entries_get (vat_main_t * vam)
17863 vl_api_one_ndp_entries_get_t *mp;
17864 unformat_input_t *input = vam->input;
17869 /* Parse args required to build the message */
17870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17872 if (unformat (input, "bd %d", &bd))
17876 errmsg ("parse error '%U'", format_unformat_error, input);
17883 errmsg ("Expected bridge domain!");
17887 M (ONE_NDP_ENTRIES_GET, mp);
17888 mp->bd = clib_host_to_net_u32 (bd);
17893 /* wait for reply */
17899 api_one_l2_arp_bd_get (vat_main_t * vam)
17901 vl_api_one_l2_arp_bd_get_t *mp;
17904 M (ONE_L2_ARP_BD_GET, mp);
17909 /* wait for reply */
17915 api_one_l2_arp_entries_get (vat_main_t * vam)
17917 vl_api_one_l2_arp_entries_get_t *mp;
17918 unformat_input_t *input = vam->input;
17923 /* Parse args required to build the message */
17924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17926 if (unformat (input, "bd %d", &bd))
17930 errmsg ("parse error '%U'", format_unformat_error, input);
17937 errmsg ("Expected bridge domain!");
17941 M (ONE_L2_ARP_ENTRIES_GET, mp);
17942 mp->bd = clib_host_to_net_u32 (bd);
17947 /* wait for reply */
17953 api_one_stats_enable_disable (vat_main_t * vam)
17955 vl_api_one_stats_enable_disable_t *mp;
17956 unformat_input_t *input = vam->input;
17961 /* Parse args required to build the message */
17962 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17964 if (unformat (input, "enable"))
17969 else if (unformat (input, "disable"))
17979 errmsg ("Value not set");
17983 M (ONE_STATS_ENABLE_DISABLE, mp);
17989 /* wait for reply */
17995 api_show_one_stats_enable_disable (vat_main_t * vam)
17997 vl_api_show_one_stats_enable_disable_t *mp;
18000 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
18005 /* wait for reply */
18011 api_show_one_map_request_mode (vat_main_t * vam)
18013 vl_api_show_one_map_request_mode_t *mp;
18016 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
18021 /* wait for reply */
18026 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
18029 api_one_map_request_mode (vat_main_t * vam)
18031 unformat_input_t *input = vam->input;
18032 vl_api_one_map_request_mode_t *mp;
18036 /* Parse args required to build the message */
18037 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18039 if (unformat (input, "dst-only"))
18041 else if (unformat (input, "src-dst"))
18045 errmsg ("parse error '%U'", format_unformat_error, input);
18050 M (ONE_MAP_REQUEST_MODE, mp);
18057 /* wait for reply */
18062 #define api_lisp_map_request_mode api_one_map_request_mode
18065 * Enable/disable ONE proxy ITR.
18067 * @param vam vpp API test context
18068 * @return return code
18071 api_one_pitr_set_locator_set (vat_main_t * vam)
18073 u8 ls_name_set = 0;
18074 unformat_input_t *input = vam->input;
18075 vl_api_one_pitr_set_locator_set_t *mp;
18080 /* Parse args required to build the message */
18081 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18083 if (unformat (input, "del"))
18085 else if (unformat (input, "locator-set %s", &ls_name))
18089 errmsg ("parse error '%U'", format_unformat_error, input);
18096 errmsg ("locator-set name not set!");
18100 M (ONE_PITR_SET_LOCATOR_SET, mp);
18102 mp->is_add = is_add;
18103 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18104 vec_free (ls_name);
18109 /* wait for reply */
18114 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
18117 api_one_nsh_set_locator_set (vat_main_t * vam)
18119 u8 ls_name_set = 0;
18120 unformat_input_t *input = vam->input;
18121 vl_api_one_nsh_set_locator_set_t *mp;
18126 /* Parse args required to build the message */
18127 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18129 if (unformat (input, "del"))
18131 else if (unformat (input, "ls %s", &ls_name))
18135 errmsg ("parse error '%U'", format_unformat_error, input);
18140 if (!ls_name_set && is_add)
18142 errmsg ("locator-set name not set!");
18146 M (ONE_NSH_SET_LOCATOR_SET, mp);
18148 mp->is_add = is_add;
18149 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
18150 vec_free (ls_name);
18155 /* wait for reply */
18161 api_show_one_pitr (vat_main_t * vam)
18163 vl_api_show_one_pitr_t *mp;
18166 if (!vam->json_output)
18168 print (vam->ofp, "%=20s", "lisp status:");
18171 M (SHOW_ONE_PITR, mp);
18175 /* Wait for a reply... */
18180 #define api_show_lisp_pitr api_show_one_pitr
18183 api_one_use_petr (vat_main_t * vam)
18185 unformat_input_t *input = vam->input;
18186 vl_api_one_use_petr_t *mp;
18191 memset (&ip, 0, sizeof (ip));
18193 /* Parse args required to build the message */
18194 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18196 if (unformat (input, "disable"))
18199 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
18202 ip_addr_version (&ip) = IP4;
18205 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
18208 ip_addr_version (&ip) = IP6;
18212 errmsg ("parse error '%U'", format_unformat_error, input);
18217 M (ONE_USE_PETR, mp);
18219 mp->is_add = is_add;
18222 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
18224 clib_memcpy (mp->address, &ip, 4);
18226 clib_memcpy (mp->address, &ip, 16);
18232 /* wait for reply */
18237 #define api_lisp_use_petr api_one_use_petr
18240 api_show_one_nsh_mapping (vat_main_t * vam)
18242 vl_api_show_one_use_petr_t *mp;
18245 if (!vam->json_output)
18247 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
18250 M (SHOW_ONE_NSH_MAPPING, mp);
18254 /* Wait for a reply... */
18260 api_show_one_use_petr (vat_main_t * vam)
18262 vl_api_show_one_use_petr_t *mp;
18265 if (!vam->json_output)
18267 print (vam->ofp, "%=20s", "Proxy-ETR status:");
18270 M (SHOW_ONE_USE_PETR, mp);
18274 /* Wait for a reply... */
18279 #define api_show_lisp_use_petr api_show_one_use_petr
18282 * Add/delete mapping between vni and vrf
18285 api_one_eid_table_add_del_map (vat_main_t * vam)
18287 unformat_input_t *input = vam->input;
18288 vl_api_one_eid_table_add_del_map_t *mp;
18289 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
18290 u32 vni, vrf, bd_index;
18293 /* Parse args required to build the message */
18294 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18296 if (unformat (input, "del"))
18298 else if (unformat (input, "vrf %d", &vrf))
18300 else if (unformat (input, "bd_index %d", &bd_index))
18302 else if (unformat (input, "vni %d", &vni))
18308 if (!vni_set || (!vrf_set && !bd_index_set))
18310 errmsg ("missing arguments!");
18314 if (vrf_set && bd_index_set)
18316 errmsg ("error: both vrf and bd entered!");
18320 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
18322 mp->is_add = is_add;
18323 mp->vni = htonl (vni);
18324 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
18325 mp->is_l2 = bd_index_set;
18330 /* wait for reply */
18335 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
18338 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
18340 u32 *action = va_arg (*args, u32 *);
18343 if (unformat (input, "%s", &s))
18345 if (!strcmp ((char *) s, "no-action"))
18347 else if (!strcmp ((char *) s, "natively-forward"))
18349 else if (!strcmp ((char *) s, "send-map-request"))
18351 else if (!strcmp ((char *) s, "drop"))
18355 clib_warning ("invalid action: '%s'", s);
18367 * Add/del remote mapping to/from ONE control plane
18369 * @param vam vpp API test context
18370 * @return return code
18373 api_one_add_del_remote_mapping (vat_main_t * vam)
18375 unformat_input_t *input = vam->input;
18376 vl_api_one_add_del_remote_mapping_t *mp;
18378 lisp_eid_vat_t _eid, *eid = &_eid;
18379 lisp_eid_vat_t _seid, *seid = &_seid;
18380 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
18381 u32 action = ~0, p, w, data_len;
18382 ip4_address_t rloc4;
18383 ip6_address_t rloc6;
18384 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
18387 memset (&rloc, 0, sizeof (rloc));
18389 /* Parse args required to build the message */
18390 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18392 if (unformat (input, "del-all"))
18396 else if (unformat (input, "del"))
18400 else if (unformat (input, "add"))
18404 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
18408 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
18412 else if (unformat (input, "vni %d", &vni))
18416 else if (unformat (input, "p %d w %d", &p, &w))
18420 errmsg ("No RLOC configured for setting priority/weight!");
18423 curr_rloc->priority = p;
18424 curr_rloc->weight = w;
18426 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
18429 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
18430 vec_add1 (rlocs, rloc);
18431 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18433 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
18436 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
18437 vec_add1 (rlocs, rloc);
18438 curr_rloc = &rlocs[vec_len (rlocs) - 1];
18440 else if (unformat (input, "action %U",
18441 unformat_negative_mapping_action, &action))
18447 clib_warning ("parse error '%U'", format_unformat_error, input);
18454 errmsg ("missing params!");
18458 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
18460 errmsg ("no action set for negative map-reply!");
18464 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
18466 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
18467 mp->is_add = is_add;
18468 mp->vni = htonl (vni);
18469 mp->action = (u8) action;
18470 mp->is_src_dst = seid_set;
18471 mp->eid_len = eid->len;
18472 mp->seid_len = seid->len;
18473 mp->del_all = del_all;
18474 mp->eid_type = eid->type;
18475 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
18476 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
18478 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
18479 clib_memcpy (mp->rlocs, rlocs, data_len);
18485 /* Wait for a reply... */
18490 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
18493 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
18494 * forwarding entries in data-plane accordingly.
18496 * @param vam vpp API test context
18497 * @return return code
18500 api_one_add_del_adjacency (vat_main_t * vam)
18502 unformat_input_t *input = vam->input;
18503 vl_api_one_add_del_adjacency_t *mp;
18505 ip4_address_t leid4, reid4;
18506 ip6_address_t leid6, reid6;
18507 u8 reid_mac[6] = { 0 };
18508 u8 leid_mac[6] = { 0 };
18509 u8 reid_type, leid_type;
18510 u32 leid_len = 0, reid_len = 0, len;
18514 leid_type = reid_type = (u8) ~ 0;
18516 /* Parse args required to build the message */
18517 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18519 if (unformat (input, "del"))
18523 else if (unformat (input, "add"))
18527 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
18530 reid_type = 0; /* ipv4 */
18533 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
18536 reid_type = 1; /* ipv6 */
18539 else if (unformat (input, "reid %U", unformat_ethernet_address,
18542 reid_type = 2; /* mac */
18544 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
18547 leid_type = 0; /* ipv4 */
18550 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
18553 leid_type = 1; /* ipv6 */
18556 else if (unformat (input, "leid %U", unformat_ethernet_address,
18559 leid_type = 2; /* mac */
18561 else if (unformat (input, "vni %d", &vni))
18567 errmsg ("parse error '%U'", format_unformat_error, input);
18572 if ((u8) ~ 0 == reid_type)
18574 errmsg ("missing params!");
18578 if (leid_type != reid_type)
18580 errmsg ("remote and local EIDs are of different types!");
18584 M (ONE_ADD_DEL_ADJACENCY, mp);
18585 mp->is_add = is_add;
18586 mp->vni = htonl (vni);
18587 mp->leid_len = leid_len;
18588 mp->reid_len = reid_len;
18589 mp->eid_type = reid_type;
18591 switch (mp->eid_type)
18594 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
18595 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
18598 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
18599 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
18602 clib_memcpy (mp->leid, leid_mac, 6);
18603 clib_memcpy (mp->reid, reid_mac, 6);
18606 errmsg ("unknown EID type %d!", mp->eid_type);
18613 /* Wait for a reply... */
18618 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
18621 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
18623 u32 *mode = va_arg (*args, u32 *);
18625 if (unformat (input, "lisp"))
18627 else if (unformat (input, "vxlan"))
18636 api_gpe_get_encap_mode (vat_main_t * vam)
18638 vl_api_gpe_get_encap_mode_t *mp;
18641 /* Construct the API message */
18642 M (GPE_GET_ENCAP_MODE, mp);
18647 /* Wait for a reply... */
18653 api_gpe_set_encap_mode (vat_main_t * vam)
18655 unformat_input_t *input = vam->input;
18656 vl_api_gpe_set_encap_mode_t *mp;
18660 /* Parse args required to build the message */
18661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18663 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
18669 /* Construct the API message */
18670 M (GPE_SET_ENCAP_MODE, mp);
18677 /* Wait for a reply... */
18683 api_lisp_gpe_add_del_iface (vat_main_t * vam)
18685 unformat_input_t *input = vam->input;
18686 vl_api_gpe_add_del_iface_t *mp;
18687 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
18688 u32 dp_table = 0, vni = 0;
18691 /* Parse args required to build the message */
18692 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18694 if (unformat (input, "up"))
18699 else if (unformat (input, "down"))
18704 else if (unformat (input, "table_id %d", &dp_table))
18708 else if (unformat (input, "bd_id %d", &dp_table))
18713 else if (unformat (input, "vni %d", &vni))
18721 if (action_set == 0)
18723 errmsg ("Action not set");
18726 if (dp_table_set == 0 || vni_set == 0)
18728 errmsg ("vni and dp_table must be set");
18732 /* Construct the API message */
18733 M (GPE_ADD_DEL_IFACE, mp);
18735 mp->is_add = is_add;
18736 mp->dp_table = clib_host_to_net_u32 (dp_table);
18738 mp->vni = clib_host_to_net_u32 (vni);
18743 /* Wait for a reply... */
18749 api_one_map_register_fallback_threshold (vat_main_t * vam)
18751 unformat_input_t *input = vam->input;
18752 vl_api_one_map_register_fallback_threshold_t *mp;
18757 /* Parse args required to build the message */
18758 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18760 if (unformat (input, "%u", &value))
18764 clib_warning ("parse error '%U'", format_unformat_error, input);
18771 errmsg ("fallback threshold value is missing!");
18775 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18776 mp->value = clib_host_to_net_u32 (value);
18781 /* Wait for a reply... */
18787 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
18789 vl_api_show_one_map_register_fallback_threshold_t *mp;
18792 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
18797 /* Wait for a reply... */
18803 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
18805 u32 *proto = va_arg (*args, u32 *);
18807 if (unformat (input, "udp"))
18809 else if (unformat (input, "api"))
18818 api_one_set_transport_protocol (vat_main_t * vam)
18820 unformat_input_t *input = vam->input;
18821 vl_api_one_set_transport_protocol_t *mp;
18826 /* Parse args required to build the message */
18827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18829 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
18833 clib_warning ("parse error '%U'", format_unformat_error, input);
18840 errmsg ("Transport protocol missing!");
18844 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18845 mp->protocol = (u8) protocol;
18850 /* Wait for a reply... */
18856 api_one_get_transport_protocol (vat_main_t * vam)
18858 vl_api_one_get_transport_protocol_t *mp;
18861 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18866 /* Wait for a reply... */
18872 api_one_map_register_set_ttl (vat_main_t * vam)
18874 unformat_input_t *input = vam->input;
18875 vl_api_one_map_register_set_ttl_t *mp;
18880 /* Parse args required to build the message */
18881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18883 if (unformat (input, "%u", &ttl))
18887 clib_warning ("parse error '%U'", format_unformat_error, input);
18894 errmsg ("TTL value missing!");
18898 M (ONE_MAP_REGISTER_SET_TTL, mp);
18899 mp->ttl = clib_host_to_net_u32 (ttl);
18904 /* Wait for a reply... */
18910 api_show_one_map_register_ttl (vat_main_t * vam)
18912 vl_api_show_one_map_register_ttl_t *mp;
18915 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18920 /* Wait for a reply... */
18926 * Add/del map request itr rlocs from ONE control plane and updates
18928 * @param vam vpp API test context
18929 * @return return code
18932 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18934 unformat_input_t *input = vam->input;
18935 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18936 u8 *locator_set_name = 0;
18937 u8 locator_set_name_set = 0;
18941 /* Parse args required to build the message */
18942 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18944 if (unformat (input, "del"))
18948 else if (unformat (input, "%_%v%_", &locator_set_name))
18950 locator_set_name_set = 1;
18954 clib_warning ("parse error '%U'", format_unformat_error, input);
18959 if (is_add && !locator_set_name_set)
18961 errmsg ("itr-rloc is not set!");
18965 if (is_add && vec_len (locator_set_name) > 64)
18967 errmsg ("itr-rloc locator-set name too long");
18968 vec_free (locator_set_name);
18972 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18973 mp->is_add = is_add;
18976 clib_memcpy (mp->locator_set_name, locator_set_name,
18977 vec_len (locator_set_name));
18981 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18983 vec_free (locator_set_name);
18988 /* Wait for a reply... */
18993 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18996 api_one_locator_dump (vat_main_t * vam)
18998 unformat_input_t *input = vam->input;
18999 vl_api_one_locator_dump_t *mp;
19000 vl_api_control_ping_t *mp_ping;
19001 u8 is_index_set = 0, is_name_set = 0;
19006 /* Parse args required to build the message */
19007 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19009 if (unformat (input, "ls_name %_%v%_", &ls_name))
19013 else if (unformat (input, "ls_index %d", &ls_index))
19019 errmsg ("parse error '%U'", format_unformat_error, input);
19024 if (!is_index_set && !is_name_set)
19026 errmsg ("error: expected one of index or name!");
19030 if (is_index_set && is_name_set)
19032 errmsg ("error: only one param expected!");
19036 if (vec_len (ls_name) > 62)
19038 errmsg ("error: locator set name too long!");
19042 if (!vam->json_output)
19044 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
19047 M (ONE_LOCATOR_DUMP, mp);
19048 mp->is_index_set = is_index_set;
19051 mp->ls_index = clib_host_to_net_u32 (ls_index);
19054 vec_add1 (ls_name, 0);
19055 strncpy ((char *) mp->ls_name, (char *) ls_name,
19056 sizeof (mp->ls_name) - 1);
19062 /* Use a control ping for synchronization */
19063 MPING (CONTROL_PING, mp_ping);
19066 /* Wait for a reply... */
19071 #define api_lisp_locator_dump api_one_locator_dump
19074 api_one_locator_set_dump (vat_main_t * vam)
19076 vl_api_one_locator_set_dump_t *mp;
19077 vl_api_control_ping_t *mp_ping;
19078 unformat_input_t *input = vam->input;
19082 /* Parse args required to build the message */
19083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19085 if (unformat (input, "local"))
19089 else if (unformat (input, "remote"))
19095 errmsg ("parse error '%U'", format_unformat_error, input);
19100 if (!vam->json_output)
19102 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
19105 M (ONE_LOCATOR_SET_DUMP, mp);
19107 mp->filter = filter;
19112 /* Use a control ping for synchronization */
19113 MPING (CONTROL_PING, mp_ping);
19116 /* Wait for a reply... */
19121 #define api_lisp_locator_set_dump api_one_locator_set_dump
19124 api_one_eid_table_map_dump (vat_main_t * vam)
19128 unformat_input_t *input = vam->input;
19129 vl_api_one_eid_table_map_dump_t *mp;
19130 vl_api_control_ping_t *mp_ping;
19133 /* Parse args required to build the message */
19134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19136 if (unformat (input, "l2"))
19141 else if (unformat (input, "l3"))
19148 errmsg ("parse error '%U'", format_unformat_error, input);
19155 errmsg ("expected one of 'l2' or 'l3' parameter!");
19159 if (!vam->json_output)
19161 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
19164 M (ONE_EID_TABLE_MAP_DUMP, mp);
19170 /* Use a control ping for synchronization */
19171 MPING (CONTROL_PING, mp_ping);
19174 /* Wait for a reply... */
19179 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
19182 api_one_eid_table_vni_dump (vat_main_t * vam)
19184 vl_api_one_eid_table_vni_dump_t *mp;
19185 vl_api_control_ping_t *mp_ping;
19188 if (!vam->json_output)
19190 print (vam->ofp, "VNI");
19193 M (ONE_EID_TABLE_VNI_DUMP, mp);
19198 /* Use a control ping for synchronization */
19199 MPING (CONTROL_PING, mp_ping);
19202 /* Wait for a reply... */
19207 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
19210 api_one_eid_table_dump (vat_main_t * vam)
19212 unformat_input_t *i = vam->input;
19213 vl_api_one_eid_table_dump_t *mp;
19214 vl_api_control_ping_t *mp_ping;
19215 struct in_addr ip4;
19216 struct in6_addr ip6;
19218 u8 eid_type = ~0, eid_set = 0;
19219 u32 prefix_length = ~0, t, vni = 0;
19222 lisp_nsh_api_t nsh;
19224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19226 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
19232 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
19238 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
19243 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
19248 else if (unformat (i, "vni %d", &t))
19252 else if (unformat (i, "local"))
19256 else if (unformat (i, "remote"))
19262 errmsg ("parse error '%U'", format_unformat_error, i);
19267 if (!vam->json_output)
19269 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
19270 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
19273 M (ONE_EID_TABLE_DUMP, mp);
19275 mp->filter = filter;
19279 mp->vni = htonl (vni);
19280 mp->eid_type = eid_type;
19284 mp->prefix_length = prefix_length;
19285 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
19288 mp->prefix_length = prefix_length;
19289 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
19292 clib_memcpy (mp->eid, mac, sizeof (mac));
19295 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
19298 errmsg ("unknown EID type %d!", eid_type);
19306 /* Use a control ping for synchronization */
19307 MPING (CONTROL_PING, mp_ping);
19310 /* Wait for a reply... */
19315 #define api_lisp_eid_table_dump api_one_eid_table_dump
19318 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
19320 unformat_input_t *i = vam->input;
19321 vl_api_gpe_fwd_entries_get_t *mp;
19326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19328 if (unformat (i, "vni %d", &vni))
19334 errmsg ("parse error '%U'", format_unformat_error, i);
19341 errmsg ("vni not set!");
19345 if (!vam->json_output)
19347 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
19351 M (GPE_FWD_ENTRIES_GET, mp);
19352 mp->vni = clib_host_to_net_u32 (vni);
19357 /* Wait for a reply... */
19362 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
19363 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
19364 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
19365 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
19366 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
19367 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
19368 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
19369 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
19372 api_one_adjacencies_get (vat_main_t * vam)
19374 unformat_input_t *i = vam->input;
19375 vl_api_one_adjacencies_get_t *mp;
19380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19382 if (unformat (i, "vni %d", &vni))
19388 errmsg ("parse error '%U'", format_unformat_error, i);
19395 errmsg ("vni not set!");
19399 if (!vam->json_output)
19401 print (vam->ofp, "%s %40s", "leid", "reid");
19404 M (ONE_ADJACENCIES_GET, mp);
19405 mp->vni = clib_host_to_net_u32 (vni);
19410 /* Wait for a reply... */
19415 #define api_lisp_adjacencies_get api_one_adjacencies_get
19418 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
19420 unformat_input_t *i = vam->input;
19421 vl_api_gpe_native_fwd_rpaths_get_t *mp;
19423 u8 ip_family_set = 0, is_ip4 = 1;
19425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19427 if (unformat (i, "ip4"))
19432 else if (unformat (i, "ip6"))
19439 errmsg ("parse error '%U'", format_unformat_error, i);
19444 if (!ip_family_set)
19446 errmsg ("ip family not set!");
19450 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
19451 mp->is_ip4 = is_ip4;
19456 /* Wait for a reply... */
19462 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
19464 vl_api_gpe_fwd_entry_vnis_get_t *mp;
19467 if (!vam->json_output)
19469 print (vam->ofp, "VNIs");
19472 M (GPE_FWD_ENTRY_VNIS_GET, mp);
19477 /* Wait for a reply... */
19483 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
19485 unformat_input_t *i = vam->input;
19486 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
19488 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
19489 struct in_addr ip4;
19490 struct in6_addr ip6;
19491 u32 table_id = 0, nh_sw_if_index = ~0;
19493 memset (&ip4, 0, sizeof (ip4));
19494 memset (&ip6, 0, sizeof (ip6));
19496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19498 if (unformat (i, "del"))
19500 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
19501 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19506 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
19507 api_unformat_sw_if_index, vam, &nh_sw_if_index))
19512 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
19516 nh_sw_if_index = ~0;
19518 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
19522 nh_sw_if_index = ~0;
19524 else if (unformat (i, "table %d", &table_id))
19528 errmsg ("parse error '%U'", format_unformat_error, i);
19535 errmsg ("nh addr not set!");
19539 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
19540 mp->is_add = is_add;
19541 mp->table_id = clib_host_to_net_u32 (table_id);
19542 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
19543 mp->is_ip4 = is_ip4;
19545 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
19547 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
19552 /* Wait for a reply... */
19558 api_one_map_server_dump (vat_main_t * vam)
19560 vl_api_one_map_server_dump_t *mp;
19561 vl_api_control_ping_t *mp_ping;
19564 if (!vam->json_output)
19566 print (vam->ofp, "%=20s", "Map server");
19569 M (ONE_MAP_SERVER_DUMP, mp);
19573 /* Use a control ping for synchronization */
19574 MPING (CONTROL_PING, mp_ping);
19577 /* Wait for a reply... */
19582 #define api_lisp_map_server_dump api_one_map_server_dump
19585 api_one_map_resolver_dump (vat_main_t * vam)
19587 vl_api_one_map_resolver_dump_t *mp;
19588 vl_api_control_ping_t *mp_ping;
19591 if (!vam->json_output)
19593 print (vam->ofp, "%=20s", "Map resolver");
19596 M (ONE_MAP_RESOLVER_DUMP, mp);
19600 /* Use a control ping for synchronization */
19601 MPING (CONTROL_PING, mp_ping);
19604 /* Wait for a reply... */
19609 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
19612 api_one_stats_flush (vat_main_t * vam)
19614 vl_api_one_stats_flush_t *mp;
19617 M (ONE_STATS_FLUSH, mp);
19624 api_one_stats_dump (vat_main_t * vam)
19626 vl_api_one_stats_dump_t *mp;
19627 vl_api_control_ping_t *mp_ping;
19630 M (ONE_STATS_DUMP, mp);
19634 /* Use a control ping for synchronization */
19635 MPING (CONTROL_PING, mp_ping);
19638 /* Wait for a reply... */
19644 api_show_one_status (vat_main_t * vam)
19646 vl_api_show_one_status_t *mp;
19649 if (!vam->json_output)
19651 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
19654 M (SHOW_ONE_STATUS, mp);
19657 /* Wait for a reply... */
19662 #define api_show_lisp_status api_show_one_status
19665 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
19667 vl_api_gpe_fwd_entry_path_dump_t *mp;
19668 vl_api_control_ping_t *mp_ping;
19669 unformat_input_t *i = vam->input;
19670 u32 fwd_entry_index = ~0;
19673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19675 if (unformat (i, "index %d", &fwd_entry_index))
19681 if (~0 == fwd_entry_index)
19683 errmsg ("no index specified!");
19687 if (!vam->json_output)
19689 print (vam->ofp, "first line");
19692 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
19696 /* Use a control ping for synchronization */
19697 MPING (CONTROL_PING, mp_ping);
19700 /* Wait for a reply... */
19706 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
19708 vl_api_one_get_map_request_itr_rlocs_t *mp;
19711 if (!vam->json_output)
19713 print (vam->ofp, "%=20s", "itr-rlocs:");
19716 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
19719 /* Wait for a reply... */
19724 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
19727 api_af_packet_create (vat_main_t * vam)
19729 unformat_input_t *i = vam->input;
19730 vl_api_af_packet_create_t *mp;
19731 u8 *host_if_name = 0;
19733 u8 random_hw_addr = 1;
19736 memset (hw_addr, 0, sizeof (hw_addr));
19738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19740 if (unformat (i, "name %s", &host_if_name))
19741 vec_add1 (host_if_name, 0);
19742 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19743 random_hw_addr = 0;
19748 if (!vec_len (host_if_name))
19750 errmsg ("host-interface name must be specified");
19754 if (vec_len (host_if_name) > 64)
19756 errmsg ("host-interface name too long");
19760 M (AF_PACKET_CREATE, mp);
19762 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19763 clib_memcpy (mp->hw_addr, hw_addr, 6);
19764 mp->use_random_hw_addr = random_hw_addr;
19765 vec_free (host_if_name);
19773 fprintf (vam->ofp ? vam->ofp : stderr,
19774 " new sw_if_index = %d\n", vam->sw_if_index);
19781 api_af_packet_delete (vat_main_t * vam)
19783 unformat_input_t *i = vam->input;
19784 vl_api_af_packet_delete_t *mp;
19785 u8 *host_if_name = 0;
19788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19790 if (unformat (i, "name %s", &host_if_name))
19791 vec_add1 (host_if_name, 0);
19796 if (!vec_len (host_if_name))
19798 errmsg ("host-interface name must be specified");
19802 if (vec_len (host_if_name) > 64)
19804 errmsg ("host-interface name too long");
19808 M (AF_PACKET_DELETE, mp);
19810 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
19811 vec_free (host_if_name);
19819 api_policer_add_del (vat_main_t * vam)
19821 unformat_input_t *i = vam->input;
19822 vl_api_policer_add_del_t *mp;
19832 u8 color_aware = 0;
19833 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19836 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19837 conform_action.dscp = 0;
19838 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19839 exceed_action.dscp = 0;
19840 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19841 violate_action.dscp = 0;
19843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19845 if (unformat (i, "del"))
19847 else if (unformat (i, "name %s", &name))
19848 vec_add1 (name, 0);
19849 else if (unformat (i, "cir %u", &cir))
19851 else if (unformat (i, "eir %u", &eir))
19853 else if (unformat (i, "cb %u", &cb))
19855 else if (unformat (i, "eb %u", &eb))
19857 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19860 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19863 else if (unformat (i, "type %U", unformat_policer_type, &type))
19865 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19868 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19871 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19874 else if (unformat (i, "color-aware"))
19880 if (!vec_len (name))
19882 errmsg ("policer name must be specified");
19886 if (vec_len (name) > 64)
19888 errmsg ("policer name too long");
19892 M (POLICER_ADD_DEL, mp);
19894 clib_memcpy (mp->name, name, vec_len (name));
19896 mp->is_add = is_add;
19897 mp->cir = ntohl (cir);
19898 mp->eir = ntohl (eir);
19899 mp->cb = clib_net_to_host_u64 (cb);
19900 mp->eb = clib_net_to_host_u64 (eb);
19901 mp->rate_type = rate_type;
19902 mp->round_type = round_type;
19904 mp->conform_action_type = conform_action.action_type;
19905 mp->conform_dscp = conform_action.dscp;
19906 mp->exceed_action_type = exceed_action.action_type;
19907 mp->exceed_dscp = exceed_action.dscp;
19908 mp->violate_action_type = violate_action.action_type;
19909 mp->violate_dscp = violate_action.dscp;
19910 mp->color_aware = color_aware;
19918 api_policer_dump (vat_main_t * vam)
19920 unformat_input_t *i = vam->input;
19921 vl_api_policer_dump_t *mp;
19922 vl_api_control_ping_t *mp_ping;
19923 u8 *match_name = 0;
19924 u8 match_name_valid = 0;
19927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19929 if (unformat (i, "name %s", &match_name))
19931 vec_add1 (match_name, 0);
19932 match_name_valid = 1;
19938 M (POLICER_DUMP, mp);
19939 mp->match_name_valid = match_name_valid;
19940 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19941 vec_free (match_name);
19945 /* Use a control ping for synchronization */
19946 MPING (CONTROL_PING, mp_ping);
19949 /* Wait for a reply... */
19955 api_policer_classify_set_interface (vat_main_t * vam)
19957 unformat_input_t *i = vam->input;
19958 vl_api_policer_classify_set_interface_t *mp;
19960 int sw_if_index_set;
19961 u32 ip4_table_index = ~0;
19962 u32 ip6_table_index = ~0;
19963 u32 l2_table_index = ~0;
19967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19970 sw_if_index_set = 1;
19971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19972 sw_if_index_set = 1;
19973 else if (unformat (i, "del"))
19975 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19977 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19979 else if (unformat (i, "l2-table %d", &l2_table_index))
19983 clib_warning ("parse error '%U'", format_unformat_error, i);
19988 if (sw_if_index_set == 0)
19990 errmsg ("missing interface name or sw_if_index");
19994 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19996 mp->sw_if_index = ntohl (sw_if_index);
19997 mp->ip4_table_index = ntohl (ip4_table_index);
19998 mp->ip6_table_index = ntohl (ip6_table_index);
19999 mp->l2_table_index = ntohl (l2_table_index);
20000 mp->is_add = is_add;
20008 api_policer_classify_dump (vat_main_t * vam)
20010 unformat_input_t *i = vam->input;
20011 vl_api_policer_classify_dump_t *mp;
20012 vl_api_control_ping_t *mp_ping;
20013 u8 type = POLICER_CLASSIFY_N_TABLES;
20016 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
20020 errmsg ("classify table type must be specified");
20024 if (!vam->json_output)
20026 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20029 M (POLICER_CLASSIFY_DUMP, mp);
20034 /* Use a control ping for synchronization */
20035 MPING (CONTROL_PING, mp_ping);
20038 /* Wait for a reply... */
20044 api_netmap_create (vat_main_t * vam)
20046 unformat_input_t *i = vam->input;
20047 vl_api_netmap_create_t *mp;
20050 u8 random_hw_addr = 1;
20055 memset (hw_addr, 0, sizeof (hw_addr));
20057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20059 if (unformat (i, "name %s", &if_name))
20060 vec_add1 (if_name, 0);
20061 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
20062 random_hw_addr = 0;
20063 else if (unformat (i, "pipe"))
20065 else if (unformat (i, "master"))
20067 else if (unformat (i, "slave"))
20073 if (!vec_len (if_name))
20075 errmsg ("interface name must be specified");
20079 if (vec_len (if_name) > 64)
20081 errmsg ("interface name too long");
20085 M (NETMAP_CREATE, mp);
20087 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20088 clib_memcpy (mp->hw_addr, hw_addr, 6);
20089 mp->use_random_hw_addr = random_hw_addr;
20090 mp->is_pipe = is_pipe;
20091 mp->is_master = is_master;
20092 vec_free (if_name);
20100 api_netmap_delete (vat_main_t * vam)
20102 unformat_input_t *i = vam->input;
20103 vl_api_netmap_delete_t *mp;
20107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20109 if (unformat (i, "name %s", &if_name))
20110 vec_add1 (if_name, 0);
20115 if (!vec_len (if_name))
20117 errmsg ("interface name must be specified");
20121 if (vec_len (if_name) > 64)
20123 errmsg ("interface name too long");
20127 M (NETMAP_DELETE, mp);
20129 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
20130 vec_free (if_name);
20138 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
20140 if (fp->afi == IP46_TYPE_IP6)
20142 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20143 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20144 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20145 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20146 format_ip6_address, fp->next_hop);
20147 else if (fp->afi == IP46_TYPE_IP4)
20149 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20150 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20151 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20152 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20153 format_ip4_address, fp->next_hop);
20157 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
20158 vl_api_fib_path_t * fp)
20160 struct in_addr ip4;
20161 struct in6_addr ip6;
20163 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20164 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20165 vat_json_object_add_uint (node, "is_local", fp->is_local);
20166 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20167 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20168 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20169 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20170 if (fp->afi == IP46_TYPE_IP4)
20172 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20173 vat_json_object_add_ip4 (node, "next_hop", ip4);
20175 else if (fp->afi == IP46_TYPE_IP6)
20177 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20178 vat_json_object_add_ip6 (node, "next_hop", ip6);
20183 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
20185 vat_main_t *vam = &vat_main;
20186 int count = ntohl (mp->mt_count);
20187 vl_api_fib_path_t *fp;
20190 print (vam->ofp, "[%d]: sw_if_index %d via:",
20191 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
20193 for (i = 0; i < count; i++)
20195 vl_api_mpls_fib_path_print (vam, fp);
20199 print (vam->ofp, "");
20202 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
20203 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
20206 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
20208 vat_main_t *vam = &vat_main;
20209 vat_json_node_t *node = NULL;
20210 int count = ntohl (mp->mt_count);
20211 vl_api_fib_path_t *fp;
20214 if (VAT_JSON_ARRAY != vam->json_tree.type)
20216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20217 vat_json_init_array (&vam->json_tree);
20219 node = vat_json_array_add (&vam->json_tree);
20221 vat_json_init_object (node);
20222 vat_json_object_add_uint (node, "tunnel_index",
20223 ntohl (mp->mt_tunnel_index));
20224 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
20226 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
20229 for (i = 0; i < count; i++)
20231 vl_api_mpls_fib_path_json_print (node, fp);
20237 api_mpls_tunnel_dump (vat_main_t * vam)
20239 vl_api_mpls_tunnel_dump_t *mp;
20240 vl_api_control_ping_t *mp_ping;
20244 /* Parse args required to build the message */
20245 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
20247 if (!unformat (vam->input, "tunnel_index %d", &index))
20254 print (vam->ofp, " tunnel_index %d", index);
20256 M (MPLS_TUNNEL_DUMP, mp);
20257 mp->tunnel_index = htonl (index);
20260 /* Use a control ping for synchronization */
20261 MPING (CONTROL_PING, mp_ping);
20268 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
20269 #define vl_api_mpls_fib_details_t_print vl_noop_handler
20273 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
20275 vat_main_t *vam = &vat_main;
20276 int count = ntohl (mp->count);
20277 vl_api_fib_path_t *fp;
20281 "table-id %d, label %u, ess_bit %u",
20282 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
20284 for (i = 0; i < count; i++)
20286 vl_api_mpls_fib_path_print (vam, fp);
20291 static void vl_api_mpls_fib_details_t_handler_json
20292 (vl_api_mpls_fib_details_t * mp)
20294 vat_main_t *vam = &vat_main;
20295 int count = ntohl (mp->count);
20296 vat_json_node_t *node = NULL;
20297 vl_api_fib_path_t *fp;
20300 if (VAT_JSON_ARRAY != vam->json_tree.type)
20302 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20303 vat_json_init_array (&vam->json_tree);
20305 node = vat_json_array_add (&vam->json_tree);
20307 vat_json_init_object (node);
20308 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20309 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
20310 vat_json_object_add_uint (node, "label", ntohl (mp->label));
20311 vat_json_object_add_uint (node, "path_count", count);
20313 for (i = 0; i < count; i++)
20315 vl_api_mpls_fib_path_json_print (node, fp);
20321 api_mpls_fib_dump (vat_main_t * vam)
20323 vl_api_mpls_fib_dump_t *mp;
20324 vl_api_control_ping_t *mp_ping;
20327 M (MPLS_FIB_DUMP, mp);
20330 /* Use a control ping for synchronization */
20331 MPING (CONTROL_PING, mp_ping);
20338 #define vl_api_ip_fib_details_t_endian vl_noop_handler
20339 #define vl_api_ip_fib_details_t_print vl_noop_handler
20342 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
20344 vat_main_t *vam = &vat_main;
20345 int count = ntohl (mp->count);
20346 vl_api_fib_path_t *fp;
20350 "table-id %d, prefix %U/%d",
20351 ntohl (mp->table_id), format_ip4_address, mp->address,
20352 mp->address_length);
20354 for (i = 0; i < count; i++)
20356 if (fp->afi == IP46_TYPE_IP6)
20358 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20359 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20360 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20361 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20362 format_ip6_address, fp->next_hop);
20363 else if (fp->afi == IP46_TYPE_IP4)
20365 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20366 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20367 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20368 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20369 format_ip4_address, fp->next_hop);
20374 static void vl_api_ip_fib_details_t_handler_json
20375 (vl_api_ip_fib_details_t * mp)
20377 vat_main_t *vam = &vat_main;
20378 int count = ntohl (mp->count);
20379 vat_json_node_t *node = NULL;
20380 struct in_addr ip4;
20381 struct in6_addr ip6;
20382 vl_api_fib_path_t *fp;
20385 if (VAT_JSON_ARRAY != vam->json_tree.type)
20387 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20388 vat_json_init_array (&vam->json_tree);
20390 node = vat_json_array_add (&vam->json_tree);
20392 vat_json_init_object (node);
20393 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20394 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
20395 vat_json_object_add_ip4 (node, "prefix", ip4);
20396 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20397 vat_json_object_add_uint (node, "path_count", count);
20399 for (i = 0; i < count; i++)
20401 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20402 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20403 vat_json_object_add_uint (node, "is_local", fp->is_local);
20404 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20405 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20406 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20407 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20408 if (fp->afi == IP46_TYPE_IP4)
20410 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20411 vat_json_object_add_ip4 (node, "next_hop", ip4);
20413 else if (fp->afi == IP46_TYPE_IP6)
20415 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20416 vat_json_object_add_ip6 (node, "next_hop", ip6);
20422 api_ip_fib_dump (vat_main_t * vam)
20424 vl_api_ip_fib_dump_t *mp;
20425 vl_api_control_ping_t *mp_ping;
20428 M (IP_FIB_DUMP, mp);
20431 /* Use a control ping for synchronization */
20432 MPING (CONTROL_PING, mp_ping);
20440 api_ip_mfib_dump (vat_main_t * vam)
20442 vl_api_ip_mfib_dump_t *mp;
20443 vl_api_control_ping_t *mp_ping;
20446 M (IP_MFIB_DUMP, mp);
20449 /* Use a control ping for synchronization */
20450 MPING (CONTROL_PING, mp_ping);
20457 static void vl_api_ip_neighbor_details_t_handler
20458 (vl_api_ip_neighbor_details_t * mp)
20460 vat_main_t *vam = &vat_main;
20462 print (vam->ofp, "%c %U %U",
20463 (mp->is_static) ? 'S' : 'D',
20464 format_ethernet_address, &mp->mac_address,
20465 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
20469 static void vl_api_ip_neighbor_details_t_handler_json
20470 (vl_api_ip_neighbor_details_t * mp)
20473 vat_main_t *vam = &vat_main;
20474 vat_json_node_t *node;
20475 struct in_addr ip4;
20476 struct in6_addr ip6;
20478 if (VAT_JSON_ARRAY != vam->json_tree.type)
20480 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20481 vat_json_init_array (&vam->json_tree);
20483 node = vat_json_array_add (&vam->json_tree);
20485 vat_json_init_object (node);
20486 vat_json_object_add_string_copy (node, "flag",
20487 (mp->is_static) ? (u8 *) "static" : (u8 *)
20490 vat_json_object_add_string_copy (node, "link_layer",
20491 format (0, "%U", format_ethernet_address,
20492 &mp->mac_address));
20496 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
20497 vat_json_object_add_ip6 (node, "ip_address", ip6);
20501 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
20502 vat_json_object_add_ip4 (node, "ip_address", ip4);
20507 api_ip_neighbor_dump (vat_main_t * vam)
20509 unformat_input_t *i = vam->input;
20510 vl_api_ip_neighbor_dump_t *mp;
20511 vl_api_control_ping_t *mp_ping;
20513 u32 sw_if_index = ~0;
20516 /* Parse args required to build the message */
20517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20519 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20521 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20523 else if (unformat (i, "ip6"))
20529 if (sw_if_index == ~0)
20531 errmsg ("missing interface name or sw_if_index");
20535 M (IP_NEIGHBOR_DUMP, mp);
20536 mp->is_ipv6 = (u8) is_ipv6;
20537 mp->sw_if_index = ntohl (sw_if_index);
20540 /* Use a control ping for synchronization */
20541 MPING (CONTROL_PING, mp_ping);
20548 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
20549 #define vl_api_ip6_fib_details_t_print vl_noop_handler
20552 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
20554 vat_main_t *vam = &vat_main;
20555 int count = ntohl (mp->count);
20556 vl_api_fib_path_t *fp;
20560 "table-id %d, prefix %U/%d",
20561 ntohl (mp->table_id), format_ip6_address, mp->address,
20562 mp->address_length);
20564 for (i = 0; i < count; i++)
20566 if (fp->afi == IP46_TYPE_IP6)
20568 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20569 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20570 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20571 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20572 format_ip6_address, fp->next_hop);
20573 else if (fp->afi == IP46_TYPE_IP4)
20575 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
20576 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
20577 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
20578 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
20579 format_ip4_address, fp->next_hop);
20584 static void vl_api_ip6_fib_details_t_handler_json
20585 (vl_api_ip6_fib_details_t * mp)
20587 vat_main_t *vam = &vat_main;
20588 int count = ntohl (mp->count);
20589 vat_json_node_t *node = NULL;
20590 struct in_addr ip4;
20591 struct in6_addr ip6;
20592 vl_api_fib_path_t *fp;
20595 if (VAT_JSON_ARRAY != vam->json_tree.type)
20597 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20598 vat_json_init_array (&vam->json_tree);
20600 node = vat_json_array_add (&vam->json_tree);
20602 vat_json_init_object (node);
20603 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
20604 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
20605 vat_json_object_add_ip6 (node, "prefix", ip6);
20606 vat_json_object_add_uint (node, "mask_length", mp->address_length);
20607 vat_json_object_add_uint (node, "path_count", count);
20609 for (i = 0; i < count; i++)
20611 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
20612 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
20613 vat_json_object_add_uint (node, "is_local", fp->is_local);
20614 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
20615 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
20616 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
20617 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
20618 if (fp->afi == IP46_TYPE_IP4)
20620 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
20621 vat_json_object_add_ip4 (node, "next_hop", ip4);
20623 else if (fp->afi == IP46_TYPE_IP6)
20625 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
20626 vat_json_object_add_ip6 (node, "next_hop", ip6);
20632 api_ip6_fib_dump (vat_main_t * vam)
20634 vl_api_ip6_fib_dump_t *mp;
20635 vl_api_control_ping_t *mp_ping;
20638 M (IP6_FIB_DUMP, mp);
20641 /* Use a control ping for synchronization */
20642 MPING (CONTROL_PING, mp_ping);
20650 api_ip6_mfib_dump (vat_main_t * vam)
20652 vl_api_ip6_mfib_dump_t *mp;
20653 vl_api_control_ping_t *mp_ping;
20656 M (IP6_MFIB_DUMP, mp);
20659 /* Use a control ping for synchronization */
20660 MPING (CONTROL_PING, mp_ping);
20668 api_classify_table_ids (vat_main_t * vam)
20670 vl_api_classify_table_ids_t *mp;
20673 /* Construct the API message */
20674 M (CLASSIFY_TABLE_IDS, mp);
20683 api_classify_table_by_interface (vat_main_t * vam)
20685 unformat_input_t *input = vam->input;
20686 vl_api_classify_table_by_interface_t *mp;
20688 u32 sw_if_index = ~0;
20690 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20692 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20694 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20699 if (sw_if_index == ~0)
20701 errmsg ("missing interface name or sw_if_index");
20705 /* Construct the API message */
20706 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
20708 mp->sw_if_index = ntohl (sw_if_index);
20716 api_classify_table_info (vat_main_t * vam)
20718 unformat_input_t *input = vam->input;
20719 vl_api_classify_table_info_t *mp;
20723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20725 if (unformat (input, "table_id %d", &table_id))
20730 if (table_id == ~0)
20732 errmsg ("missing table id");
20736 /* Construct the API message */
20737 M (CLASSIFY_TABLE_INFO, mp);
20739 mp->table_id = ntohl (table_id);
20747 api_classify_session_dump (vat_main_t * vam)
20749 unformat_input_t *input = vam->input;
20750 vl_api_classify_session_dump_t *mp;
20751 vl_api_control_ping_t *mp_ping;
20755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20757 if (unformat (input, "table_id %d", &table_id))
20762 if (table_id == ~0)
20764 errmsg ("missing table id");
20768 /* Construct the API message */
20769 M (CLASSIFY_SESSION_DUMP, mp);
20771 mp->table_id = ntohl (table_id);
20774 /* Use a control ping for synchronization */
20775 MPING (CONTROL_PING, mp_ping);
20783 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
20785 vat_main_t *vam = &vat_main;
20787 print (vam->ofp, "collector_address %U, collector_port %d, "
20788 "src_address %U, vrf_id %d, path_mtu %u, "
20789 "template_interval %u, udp_checksum %d",
20790 format_ip4_address, mp->collector_address,
20791 ntohs (mp->collector_port),
20792 format_ip4_address, mp->src_address,
20793 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
20794 ntohl (mp->template_interval), mp->udp_checksum);
20797 vam->result_ready = 1;
20801 vl_api_ipfix_exporter_details_t_handler_json
20802 (vl_api_ipfix_exporter_details_t * mp)
20804 vat_main_t *vam = &vat_main;
20805 vat_json_node_t node;
20806 struct in_addr collector_address;
20807 struct in_addr src_address;
20809 vat_json_init_object (&node);
20810 clib_memcpy (&collector_address, &mp->collector_address,
20811 sizeof (collector_address));
20812 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
20813 vat_json_object_add_uint (&node, "collector_port",
20814 ntohs (mp->collector_port));
20815 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
20816 vat_json_object_add_ip4 (&node, "src_address", src_address);
20817 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
20818 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
20819 vat_json_object_add_uint (&node, "template_interval",
20820 ntohl (mp->template_interval));
20821 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
20823 vat_json_print (vam->ofp, &node);
20824 vat_json_free (&node);
20826 vam->result_ready = 1;
20830 api_ipfix_exporter_dump (vat_main_t * vam)
20832 vl_api_ipfix_exporter_dump_t *mp;
20835 /* Construct the API message */
20836 M (IPFIX_EXPORTER_DUMP, mp);
20845 api_ipfix_classify_stream_dump (vat_main_t * vam)
20847 vl_api_ipfix_classify_stream_dump_t *mp;
20850 /* Construct the API message */
20851 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20862 vl_api_ipfix_classify_stream_details_t_handler
20863 (vl_api_ipfix_classify_stream_details_t * mp)
20865 vat_main_t *vam = &vat_main;
20866 print (vam->ofp, "domain_id %d, src_port %d",
20867 ntohl (mp->domain_id), ntohs (mp->src_port));
20869 vam->result_ready = 1;
20873 vl_api_ipfix_classify_stream_details_t_handler_json
20874 (vl_api_ipfix_classify_stream_details_t * mp)
20876 vat_main_t *vam = &vat_main;
20877 vat_json_node_t node;
20879 vat_json_init_object (&node);
20880 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20881 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20883 vat_json_print (vam->ofp, &node);
20884 vat_json_free (&node);
20886 vam->result_ready = 1;
20890 api_ipfix_classify_table_dump (vat_main_t * vam)
20892 vl_api_ipfix_classify_table_dump_t *mp;
20893 vl_api_control_ping_t *mp_ping;
20896 if (!vam->json_output)
20898 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20899 "transport_protocol");
20902 /* Construct the API message */
20903 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20908 /* Use a control ping for synchronization */
20909 MPING (CONTROL_PING, mp_ping);
20917 vl_api_ipfix_classify_table_details_t_handler
20918 (vl_api_ipfix_classify_table_details_t * mp)
20920 vat_main_t *vam = &vat_main;
20921 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20922 mp->transport_protocol);
20926 vl_api_ipfix_classify_table_details_t_handler_json
20927 (vl_api_ipfix_classify_table_details_t * mp)
20929 vat_json_node_t *node = NULL;
20930 vat_main_t *vam = &vat_main;
20932 if (VAT_JSON_ARRAY != vam->json_tree.type)
20934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20935 vat_json_init_array (&vam->json_tree);
20938 node = vat_json_array_add (&vam->json_tree);
20939 vat_json_init_object (node);
20941 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20942 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20943 vat_json_object_add_uint (node, "transport_protocol",
20944 mp->transport_protocol);
20948 api_sw_interface_span_enable_disable (vat_main_t * vam)
20950 unformat_input_t *i = vam->input;
20951 vl_api_sw_interface_span_enable_disable_t *mp;
20952 u32 src_sw_if_index = ~0;
20953 u32 dst_sw_if_index = ~0;
20958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20961 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20963 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20967 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20969 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20971 else if (unformat (i, "disable"))
20973 else if (unformat (i, "rx"))
20975 else if (unformat (i, "tx"))
20977 else if (unformat (i, "both"))
20979 else if (unformat (i, "l2"))
20985 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20987 mp->sw_if_index_from = htonl (src_sw_if_index);
20988 mp->sw_if_index_to = htonl (dst_sw_if_index);
20998 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
21001 vat_main_t *vam = &vat_main;
21002 u8 *sw_if_from_name = 0;
21003 u8 *sw_if_to_name = 0;
21004 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21005 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21006 char *states[] = { "none", "rx", "tx", "both" };
21010 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21012 if ((u32) p->value[0] == sw_if_index_from)
21014 sw_if_from_name = (u8 *)(p->key);
21018 if ((u32) p->value[0] == sw_if_index_to)
21020 sw_if_to_name = (u8 *)(p->key);
21021 if (sw_if_from_name)
21026 print (vam->ofp, "%20s => %20s (%s) %s",
21027 sw_if_from_name, sw_if_to_name, states[mp->state],
21028 mp->is_l2 ? "l2" : "device");
21032 vl_api_sw_interface_span_details_t_handler_json
21033 (vl_api_sw_interface_span_details_t * mp)
21035 vat_main_t *vam = &vat_main;
21036 vat_json_node_t *node = NULL;
21037 u8 *sw_if_from_name = 0;
21038 u8 *sw_if_to_name = 0;
21039 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
21040 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
21044 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
21046 if ((u32) p->value[0] == sw_if_index_from)
21048 sw_if_from_name = (u8 *)(p->key);
21052 if ((u32) p->value[0] == sw_if_index_to)
21054 sw_if_to_name = (u8 *)(p->key);
21055 if (sw_if_from_name)
21061 if (VAT_JSON_ARRAY != vam->json_tree.type)
21063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21064 vat_json_init_array (&vam->json_tree);
21066 node = vat_json_array_add (&vam->json_tree);
21068 vat_json_init_object (node);
21069 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
21070 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
21071 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
21072 if (0 != sw_if_to_name)
21074 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
21076 vat_json_object_add_uint (node, "state", mp->state);
21077 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
21081 api_sw_interface_span_dump (vat_main_t * vam)
21083 unformat_input_t *input = vam->input;
21084 vl_api_sw_interface_span_dump_t *mp;
21085 vl_api_control_ping_t *mp_ping;
21089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21091 if (unformat (input, "l2"))
21097 M (SW_INTERFACE_SPAN_DUMP, mp);
21101 /* Use a control ping for synchronization */
21102 MPING (CONTROL_PING, mp_ping);
21110 api_pg_create_interface (vat_main_t * vam)
21112 unformat_input_t *input = vam->input;
21113 vl_api_pg_create_interface_t *mp;
21117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21119 if (unformat (input, "if_id %d", &if_id))
21126 errmsg ("missing pg interface index");
21130 /* Construct the API message */
21131 M (PG_CREATE_INTERFACE, mp);
21133 mp->interface_id = ntohl (if_id);
21141 api_pg_capture (vat_main_t * vam)
21143 unformat_input_t *input = vam->input;
21144 vl_api_pg_capture_t *mp;
21149 u8 pcap_file_set = 0;
21152 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21154 if (unformat (input, "if_id %d", &if_id))
21156 else if (unformat (input, "pcap %s", &pcap_file))
21158 else if (unformat (input, "count %d", &count))
21160 else if (unformat (input, "disable"))
21167 errmsg ("missing pg interface index");
21170 if (pcap_file_set > 0)
21172 if (vec_len (pcap_file) > 255)
21174 errmsg ("pcap file name is too long");
21179 u32 name_len = vec_len (pcap_file);
21180 /* Construct the API message */
21181 M (PG_CAPTURE, mp);
21183 mp->interface_id = ntohl (if_id);
21184 mp->is_enabled = enable;
21185 mp->count = ntohl (count);
21186 mp->pcap_name_length = ntohl (name_len);
21187 if (pcap_file_set != 0)
21189 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
21191 vec_free (pcap_file);
21199 api_pg_enable_disable (vat_main_t * vam)
21201 unformat_input_t *input = vam->input;
21202 vl_api_pg_enable_disable_t *mp;
21205 u8 stream_name_set = 0;
21206 u8 *stream_name = 0;
21208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21210 if (unformat (input, "stream %s", &stream_name))
21211 stream_name_set = 1;
21212 else if (unformat (input, "disable"))
21218 if (stream_name_set > 0)
21220 if (vec_len (stream_name) > 255)
21222 errmsg ("stream name too long");
21227 u32 name_len = vec_len (stream_name);
21228 /* Construct the API message */
21229 M (PG_ENABLE_DISABLE, mp);
21231 mp->is_enabled = enable;
21232 if (stream_name_set != 0)
21234 mp->stream_name_length = ntohl (name_len);
21235 clib_memcpy (mp->stream_name, stream_name, name_len);
21237 vec_free (stream_name);
21245 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
21247 unformat_input_t *input = vam->input;
21248 vl_api_ip_source_and_port_range_check_add_del_t *mp;
21250 u16 *low_ports = 0;
21251 u16 *high_ports = 0;
21254 ip4_address_t ip4_addr;
21255 ip6_address_t ip6_addr;
21264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21266 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
21272 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
21277 else if (unformat (input, "vrf %d", &vrf_id))
21279 else if (unformat (input, "del"))
21281 else if (unformat (input, "port %d", &tmp))
21283 if (tmp == 0 || tmp > 65535)
21285 errmsg ("port %d out of range", tmp);
21289 this_hi = this_low + 1;
21290 vec_add1 (low_ports, this_low);
21291 vec_add1 (high_ports, this_hi);
21293 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
21295 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
21297 errmsg ("incorrect range parameters");
21301 /* Note: in debug CLI +1 is added to high before
21302 passing to real fn that does "the work"
21303 (ip_source_and_port_range_check_add_del).
21304 This fn is a wrapper around the binary API fn a
21305 control plane will call, which expects this increment
21306 to have occurred. Hence letting the binary API control
21307 plane fn do the increment for consistency between VAT
21308 and other control planes.
21311 vec_add1 (low_ports, this_low);
21312 vec_add1 (high_ports, this_hi);
21318 if (prefix_set == 0)
21320 errmsg ("<address>/<mask> not specified");
21326 errmsg ("VRF ID required, not specified");
21333 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21337 if (vec_len (low_ports) == 0)
21339 errmsg ("At least one port or port range required");
21343 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
21345 mp->is_add = is_add;
21350 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
21355 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
21358 mp->mask_length = length;
21359 mp->number_of_ranges = vec_len (low_ports);
21361 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
21362 vec_free (low_ports);
21364 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
21365 vec_free (high_ports);
21367 mp->vrf_id = ntohl (vrf_id);
21375 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
21377 unformat_input_t *input = vam->input;
21378 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
21379 u32 sw_if_index = ~0;
21381 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
21382 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
21386 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
21388 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21390 else if (unformat (input, "sw_if_index %d", &sw_if_index))
21392 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
21394 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
21396 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
21398 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
21400 else if (unformat (input, "del"))
21406 if (sw_if_index == ~0)
21408 errmsg ("Interface required but not specified");
21414 errmsg ("VRF ID required but not specified");
21418 if (tcp_out_vrf_id == 0
21419 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
21422 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
21426 /* Construct the API message */
21427 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
21429 mp->sw_if_index = ntohl (sw_if_index);
21430 mp->is_add = is_add;
21431 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
21432 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
21433 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
21434 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
21439 /* Wait for a reply... */
21445 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
21447 unformat_input_t *i = vam->input;
21448 vl_api_ipsec_gre_add_del_tunnel_t *mp;
21449 u32 local_sa_id = 0;
21450 u32 remote_sa_id = 0;
21451 ip4_address_t src_address;
21452 ip4_address_t dst_address;
21456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21458 if (unformat (i, "local_sa %d", &local_sa_id))
21460 else if (unformat (i, "remote_sa %d", &remote_sa_id))
21462 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
21464 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
21466 else if (unformat (i, "del"))
21470 clib_warning ("parse error '%U'", format_unformat_error, i);
21475 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
21477 mp->local_sa_id = ntohl (local_sa_id);
21478 mp->remote_sa_id = ntohl (remote_sa_id);
21479 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
21480 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
21481 mp->is_add = is_add;
21489 api_punt (vat_main_t * vam)
21491 unformat_input_t *i = vam->input;
21499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21501 if (unformat (i, "ip %d", &ipv))
21503 else if (unformat (i, "protocol %d", &protocol))
21505 else if (unformat (i, "port %d", &port))
21507 else if (unformat (i, "del"))
21511 clib_warning ("parse error '%U'", format_unformat_error, i);
21518 mp->is_add = (u8) is_add;
21519 mp->ipv = (u8) ipv;
21520 mp->l4_protocol = (u8) protocol;
21521 mp->l4_port = htons ((u16) port);
21528 static void vl_api_ipsec_gre_tunnel_details_t_handler
21529 (vl_api_ipsec_gre_tunnel_details_t * mp)
21531 vat_main_t *vam = &vat_main;
21533 print (vam->ofp, "%11d%15U%15U%14d%14d",
21534 ntohl (mp->sw_if_index),
21535 format_ip4_address, &mp->src_address,
21536 format_ip4_address, &mp->dst_address,
21537 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
21540 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
21541 (vl_api_ipsec_gre_tunnel_details_t * mp)
21543 vat_main_t *vam = &vat_main;
21544 vat_json_node_t *node = NULL;
21545 struct in_addr ip4;
21547 if (VAT_JSON_ARRAY != vam->json_tree.type)
21549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21550 vat_json_init_array (&vam->json_tree);
21552 node = vat_json_array_add (&vam->json_tree);
21554 vat_json_init_object (node);
21555 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
21556 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
21557 vat_json_object_add_ip4 (node, "src_address", ip4);
21558 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
21559 vat_json_object_add_ip4 (node, "dst_address", ip4);
21560 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
21561 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
21565 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
21567 unformat_input_t *i = vam->input;
21568 vl_api_ipsec_gre_tunnel_dump_t *mp;
21569 vl_api_control_ping_t *mp_ping;
21571 u8 sw_if_index_set = 0;
21574 /* Parse args required to build the message */
21575 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21577 if (unformat (i, "sw_if_index %d", &sw_if_index))
21578 sw_if_index_set = 1;
21583 if (sw_if_index_set == 0)
21588 if (!vam->json_output)
21590 print (vam->ofp, "%11s%15s%15s%14s%14s",
21591 "sw_if_index", "src_address", "dst_address",
21592 "local_sa_id", "remote_sa_id");
21595 /* Get list of gre-tunnel interfaces */
21596 M (IPSEC_GRE_TUNNEL_DUMP, mp);
21598 mp->sw_if_index = htonl (sw_if_index);
21602 /* Use a control ping for synchronization */
21603 MPING (CONTROL_PING, mp_ping);
21611 api_delete_subif (vat_main_t * vam)
21613 unformat_input_t *i = vam->input;
21614 vl_api_delete_subif_t *mp;
21615 u32 sw_if_index = ~0;
21618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21622 if (unformat (i, "sw_if_index %d", &sw_if_index))
21628 if (sw_if_index == ~0)
21630 errmsg ("missing sw_if_index");
21634 /* Construct the API message */
21635 M (DELETE_SUBIF, mp);
21636 mp->sw_if_index = ntohl (sw_if_index);
21643 #define foreach_pbb_vtr_op \
21644 _("disable", L2_VTR_DISABLED) \
21645 _("pop", L2_VTR_POP_2) \
21646 _("push", L2_VTR_PUSH_2)
21649 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
21651 unformat_input_t *i = vam->input;
21652 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
21653 u32 sw_if_index = ~0, vtr_op = ~0;
21654 u16 outer_tag = ~0;
21655 u8 dmac[6], smac[6];
21656 u8 dmac_set = 0, smac_set = 0;
21662 /* Shut up coverity */
21663 memset (dmac, 0, sizeof (dmac));
21664 memset (smac, 0, sizeof (smac));
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 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21672 else if (unformat (i, "vtr_op %d", &vtr_op))
21674 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
21677 else if (unformat (i, "translate_pbb_stag"))
21679 if (unformat (i, "%d", &tmp))
21681 vtr_op = L2_VTR_TRANSLATE_2_1;
21687 ("translate_pbb_stag operation requires outer tag definition");
21691 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
21693 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
21695 else if (unformat (i, "sid %d", &sid))
21697 else if (unformat (i, "vlanid %d", &tmp))
21701 clib_warning ("parse error '%U'", format_unformat_error, i);
21706 if ((sw_if_index == ~0) || (vtr_op == ~0))
21708 errmsg ("missing sw_if_index or vtr operation");
21711 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
21712 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
21715 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
21719 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
21720 mp->sw_if_index = ntohl (sw_if_index);
21721 mp->vtr_op = ntohl (vtr_op);
21722 mp->outer_tag = ntohs (outer_tag);
21723 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
21724 clib_memcpy (mp->b_smac, smac, sizeof (smac));
21725 mp->b_vlanid = ntohs (vlanid);
21726 mp->i_sid = ntohl (sid);
21734 api_flow_classify_set_interface (vat_main_t * vam)
21736 unformat_input_t *i = vam->input;
21737 vl_api_flow_classify_set_interface_t *mp;
21739 int sw_if_index_set;
21740 u32 ip4_table_index = ~0;
21741 u32 ip6_table_index = ~0;
21745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21747 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21748 sw_if_index_set = 1;
21749 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21750 sw_if_index_set = 1;
21751 else if (unformat (i, "del"))
21753 else if (unformat (i, "ip4-table %d", &ip4_table_index))
21755 else if (unformat (i, "ip6-table %d", &ip6_table_index))
21759 clib_warning ("parse error '%U'", format_unformat_error, i);
21764 if (sw_if_index_set == 0)
21766 errmsg ("missing interface name or sw_if_index");
21770 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
21772 mp->sw_if_index = ntohl (sw_if_index);
21773 mp->ip4_table_index = ntohl (ip4_table_index);
21774 mp->ip6_table_index = ntohl (ip6_table_index);
21775 mp->is_add = is_add;
21783 api_flow_classify_dump (vat_main_t * vam)
21785 unformat_input_t *i = vam->input;
21786 vl_api_flow_classify_dump_t *mp;
21787 vl_api_control_ping_t *mp_ping;
21788 u8 type = FLOW_CLASSIFY_N_TABLES;
21791 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
21795 errmsg ("classify table type must be specified");
21799 if (!vam->json_output)
21801 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
21804 M (FLOW_CLASSIFY_DUMP, mp);
21809 /* Use a control ping for synchronization */
21810 MPING (CONTROL_PING, mp_ping);
21813 /* Wait for a reply... */
21819 api_feature_enable_disable (vat_main_t * vam)
21821 unformat_input_t *i = vam->input;
21822 vl_api_feature_enable_disable_t *mp;
21824 u8 *feature_name = 0;
21825 u32 sw_if_index = ~0;
21829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21831 if (unformat (i, "arc_name %s", &arc_name))
21833 else if (unformat (i, "feature_name %s", &feature_name))
21836 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21838 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21840 else if (unformat (i, "disable"))
21848 errmsg ("missing arc name");
21851 if (vec_len (arc_name) > 63)
21853 errmsg ("arc name too long");
21856 if (feature_name == 0)
21858 errmsg ("missing feature name");
21861 if (vec_len (feature_name) > 63)
21863 errmsg ("feature name too long");
21866 if (sw_if_index == ~0)
21868 errmsg ("missing interface name or sw_if_index");
21872 /* Construct the API message */
21873 M (FEATURE_ENABLE_DISABLE, mp);
21874 mp->sw_if_index = ntohl (sw_if_index);
21875 mp->enable = enable;
21876 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21877 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21878 vec_free (arc_name);
21879 vec_free (feature_name);
21887 api_sw_interface_tag_add_del (vat_main_t * vam)
21889 unformat_input_t *i = vam->input;
21890 vl_api_sw_interface_tag_add_del_t *mp;
21891 u32 sw_if_index = ~0;
21896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21898 if (unformat (i, "tag %s", &tag))
21900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21904 else if (unformat (i, "del"))
21910 if (sw_if_index == ~0)
21912 errmsg ("missing interface name or sw_if_index");
21916 if (enable && (tag == 0))
21918 errmsg ("no tag specified");
21922 /* Construct the API message */
21923 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21924 mp->sw_if_index = ntohl (sw_if_index);
21925 mp->is_add = enable;
21927 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21935 static void vl_api_l2_xconnect_details_t_handler
21936 (vl_api_l2_xconnect_details_t * mp)
21938 vat_main_t *vam = &vat_main;
21940 print (vam->ofp, "%15d%15d",
21941 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21944 static void vl_api_l2_xconnect_details_t_handler_json
21945 (vl_api_l2_xconnect_details_t * mp)
21947 vat_main_t *vam = &vat_main;
21948 vat_json_node_t *node = NULL;
21950 if (VAT_JSON_ARRAY != vam->json_tree.type)
21952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21953 vat_json_init_array (&vam->json_tree);
21955 node = vat_json_array_add (&vam->json_tree);
21957 vat_json_init_object (node);
21958 vat_json_object_add_uint (node, "rx_sw_if_index",
21959 ntohl (mp->rx_sw_if_index));
21960 vat_json_object_add_uint (node, "tx_sw_if_index",
21961 ntohl (mp->tx_sw_if_index));
21965 api_l2_xconnect_dump (vat_main_t * vam)
21967 vl_api_l2_xconnect_dump_t *mp;
21968 vl_api_control_ping_t *mp_ping;
21971 if (!vam->json_output)
21973 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21976 M (L2_XCONNECT_DUMP, mp);
21980 /* Use a control ping for synchronization */
21981 MPING (CONTROL_PING, mp_ping);
21989 api_sw_interface_set_mtu (vat_main_t * vam)
21991 unformat_input_t *i = vam->input;
21992 vl_api_sw_interface_set_mtu_t *mp;
21993 u32 sw_if_index = ~0;
21997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21999 if (unformat (i, "mtu %d", &mtu))
22001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22009 if (sw_if_index == ~0)
22011 errmsg ("missing interface name or sw_if_index");
22017 errmsg ("no mtu specified");
22021 /* Construct the API message */
22022 M (SW_INTERFACE_SET_MTU, mp);
22023 mp->sw_if_index = ntohl (sw_if_index);
22024 mp->mtu = ntohs ((u16) mtu);
22032 api_p2p_ethernet_add (vat_main_t * vam)
22034 unformat_input_t *i = vam->input;
22035 vl_api_p2p_ethernet_add_t *mp;
22036 u32 parent_if_index = ~0;
22042 memset (remote_mac, 0, sizeof (remote_mac));
22043 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22045 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22047 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22051 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22053 else if (unformat (i, "sub_id %d", &sub_id))
22057 clib_warning ("parse error '%U'", format_unformat_error, i);
22062 if (parent_if_index == ~0)
22064 errmsg ("missing interface name or sw_if_index");
22069 errmsg ("missing remote mac address");
22074 errmsg ("missing sub-interface id");
22078 M (P2P_ETHERNET_ADD, mp);
22079 mp->parent_if_index = ntohl (parent_if_index);
22080 mp->subif_id = ntohl (sub_id);
22081 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22089 api_p2p_ethernet_del (vat_main_t * vam)
22091 unformat_input_t *i = vam->input;
22092 vl_api_p2p_ethernet_del_t *mp;
22093 u32 parent_if_index = ~0;
22098 memset (remote_mac, 0, sizeof (remote_mac));
22099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
22103 else if (unformat (i, "sw_if_index %d", &parent_if_index))
22107 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
22111 clib_warning ("parse error '%U'", format_unformat_error, i);
22116 if (parent_if_index == ~0)
22118 errmsg ("missing interface name or sw_if_index");
22123 errmsg ("missing remote mac address");
22127 M (P2P_ETHERNET_DEL, mp);
22128 mp->parent_if_index = ntohl (parent_if_index);
22129 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
22137 api_lldp_config (vat_main_t * vam)
22139 unformat_input_t *i = vam->input;
22140 vl_api_lldp_config_t *mp;
22142 int tx_interval = 0;
22143 u8 *sys_name = NULL;
22146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22148 if (unformat (i, "system-name %s", &sys_name))
22150 else if (unformat (i, "tx-hold %d", &tx_hold))
22152 else if (unformat (i, "tx-interval %d", &tx_interval))
22156 clib_warning ("parse error '%U'", format_unformat_error, i);
22161 vec_add1 (sys_name, 0);
22163 M (LLDP_CONFIG, mp);
22164 mp->tx_hold = htonl (tx_hold);
22165 mp->tx_interval = htonl (tx_interval);
22166 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
22167 vec_free (sys_name);
22175 api_sw_interface_set_lldp (vat_main_t * vam)
22177 unformat_input_t *i = vam->input;
22178 vl_api_sw_interface_set_lldp_t *mp;
22179 u32 sw_if_index = ~0;
22181 u8 *port_desc = NULL, *mgmt_oid = NULL;
22182 ip4_address_t ip4_addr;
22183 ip6_address_t ip6_addr;
22186 memset (&ip4_addr, 0, sizeof (ip4_addr));
22187 memset (&ip6_addr, 0, sizeof (ip6_addr));
22189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22191 if (unformat (i, "disable"))
22194 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22196 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22198 else if (unformat (i, "port-desc %s", &port_desc))
22200 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
22202 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
22204 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
22210 if (sw_if_index == ~0)
22212 errmsg ("missing interface name or sw_if_index");
22216 /* Construct the API message */
22217 vec_add1 (port_desc, 0);
22218 vec_add1 (mgmt_oid, 0);
22219 M (SW_INTERFACE_SET_LLDP, mp);
22220 mp->sw_if_index = ntohl (sw_if_index);
22221 mp->enable = enable;
22222 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
22223 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
22224 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
22225 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
22226 vec_free (port_desc);
22227 vec_free (mgmt_oid);
22235 api_tcp_configure_src_addresses (vat_main_t * vam)
22237 vl_api_tcp_configure_src_addresses_t *mp;
22238 unformat_input_t *i = vam->input;
22239 ip4_address_t v4first, v4last;
22240 ip6_address_t v6first, v6last;
22245 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22247 if (unformat (i, "%U - %U",
22248 unformat_ip4_address, &v4first,
22249 unformat_ip4_address, &v4last))
22253 errmsg ("one range per message (range already set)");
22258 else if (unformat (i, "%U - %U",
22259 unformat_ip6_address, &v6first,
22260 unformat_ip6_address, &v6last))
22264 errmsg ("one range per message (range already set)");
22269 else if (unformat (i, "vrf %d", &vrf_id))
22275 if (range_set == 0)
22277 errmsg ("address range not set");
22281 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
22282 mp->vrf_id = ntohl (vrf_id);
22284 if (range_set == 2)
22287 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
22288 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
22293 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
22294 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
22301 static void vl_api_app_namespace_add_del_reply_t_handler
22302 (vl_api_app_namespace_add_del_reply_t * mp)
22304 vat_main_t *vam = &vat_main;
22305 i32 retval = ntohl (mp->retval);
22306 if (vam->async_mode)
22308 vam->async_errors += (retval < 0);
22312 vam->retval = retval;
22314 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
22315 vam->result_ready = 1;
22319 static void vl_api_app_namespace_add_del_reply_t_handler_json
22320 (vl_api_app_namespace_add_del_reply_t * mp)
22322 vat_main_t *vam = &vat_main;
22323 vat_json_node_t node;
22325 vat_json_init_object (&node);
22326 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
22327 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
22329 vat_json_print (vam->ofp, &node);
22330 vat_json_free (&node);
22332 vam->retval = ntohl (mp->retval);
22333 vam->result_ready = 1;
22337 api_app_namespace_add_del (vat_main_t * vam)
22339 vl_api_app_namespace_add_del_t *mp;
22340 unformat_input_t *i = vam->input;
22341 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
22342 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
22346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22348 if (unformat (i, "id %_%v%_", &ns_id))
22350 else if (unformat (i, "secret %lu", &secret))
22352 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22353 sw_if_index_set = 1;
22354 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
22356 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
22361 if (!ns_id || !secret_set || !sw_if_index_set)
22363 errmsg ("namespace id, secret and sw_if_index must be set");
22366 if (vec_len (ns_id) > 64)
22368 errmsg ("namespace id too long");
22371 M (APP_NAMESPACE_ADD_DEL, mp);
22373 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
22374 mp->namespace_id_len = vec_len (ns_id);
22375 mp->secret = clib_host_to_net_u64 (secret);
22376 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22377 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
22378 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
22386 api_sock_init_shm (vat_main_t * vam)
22388 #if VPP_API_TEST_BUILTIN == 0
22389 unformat_input_t *i = vam->input;
22390 vl_api_shm_elem_config_t *config = 0;
22391 u64 size = 64 << 20;
22394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22396 if (unformat (i, "size %U", unformat_memory_size, &size))
22403 * Canned custom ring allocator config.
22404 * Should probably parse all of this
22406 vec_validate (config, 6);
22407 config[0].type = VL_API_VLIB_RING;
22408 config[0].size = 256;
22409 config[0].count = 32;
22411 config[1].type = VL_API_VLIB_RING;
22412 config[1].size = 1024;
22413 config[1].count = 16;
22415 config[2].type = VL_API_VLIB_RING;
22416 config[2].size = 4096;
22417 config[2].count = 2;
22419 config[3].type = VL_API_CLIENT_RING;
22420 config[3].size = 256;
22421 config[3].count = 32;
22423 config[4].type = VL_API_CLIENT_RING;
22424 config[4].size = 1024;
22425 config[4].count = 16;
22427 config[5].type = VL_API_CLIENT_RING;
22428 config[5].size = 4096;
22429 config[5].count = 2;
22431 config[6].type = VL_API_QUEUE;
22432 config[6].count = 128;
22433 config[6].size = sizeof (uword);
22435 rv = vl_socket_client_init_shm (config);
22437 vam->client_index_invalid = 1;
22445 api_dns_enable_disable (vat_main_t * vam)
22447 unformat_input_t *line_input = vam->input;
22448 vl_api_dns_enable_disable_t *mp;
22449 u8 enable_disable = 1;
22452 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22454 if (unformat (line_input, "disable"))
22455 enable_disable = 0;
22456 if (unformat (line_input, "enable"))
22457 enable_disable = 1;
22462 /* Construct the API message */
22463 M (DNS_ENABLE_DISABLE, mp);
22464 mp->enable = enable_disable;
22468 /* Wait for the reply */
22474 api_dns_resolve_name (vat_main_t * vam)
22476 unformat_input_t *line_input = vam->input;
22477 vl_api_dns_resolve_name_t *mp;
22481 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22483 if (unformat (line_input, "%s", &name))
22489 if (vec_len (name) > 127)
22491 errmsg ("name too long");
22495 /* Construct the API message */
22496 M (DNS_RESOLVE_NAME, mp);
22497 memcpy (mp->name, name, vec_len (name));
22502 /* Wait for the reply */
22508 api_dns_resolve_ip (vat_main_t * vam)
22510 unformat_input_t *line_input = vam->input;
22511 vl_api_dns_resolve_ip_t *mp;
22513 ip4_address_t addr4;
22514 ip6_address_t addr6;
22517 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22519 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
22521 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
22529 errmsg ("missing address");
22533 /* Construct the API message */
22534 M (DNS_RESOLVE_IP, mp);
22535 mp->is_ip6 = is_ip6;
22537 memcpy (mp->address, &addr6, sizeof (addr6));
22539 memcpy (mp->address, &addr4, sizeof (addr4));
22543 /* Wait for the reply */
22549 api_dns_name_server_add_del (vat_main_t * vam)
22551 unformat_input_t *i = vam->input;
22552 vl_api_dns_name_server_add_del_t *mp;
22554 ip6_address_t ip6_server;
22555 ip4_address_t ip4_server;
22560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22562 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
22564 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
22566 else if (unformat (i, "del"))
22570 clib_warning ("parse error '%U'", format_unformat_error, i);
22575 if (ip4_set && ip6_set)
22577 errmsg ("Only one server address allowed per message");
22580 if ((ip4_set + ip6_set) == 0)
22582 errmsg ("Server address required");
22586 /* Construct the API message */
22587 M (DNS_NAME_SERVER_ADD_DEL, mp);
22591 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
22596 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
22600 mp->is_add = is_add;
22605 /* Wait for a reply, return good/bad news */
22611 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
22613 vat_main_t *vam = &vat_main;
22618 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22619 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22620 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
22621 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
22622 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22623 clib_net_to_host_u32 (mp->action_index), mp->tag);
22628 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
22629 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
22630 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
22631 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
22632 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
22633 clib_net_to_host_u32 (mp->action_index), mp->tag);
22638 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
22641 vat_main_t *vam = &vat_main;
22642 vat_json_node_t *node = NULL;
22643 struct in6_addr ip6;
22644 struct in_addr ip4;
22646 if (VAT_JSON_ARRAY != vam->json_tree.type)
22648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
22649 vat_json_init_array (&vam->json_tree);
22651 node = vat_json_array_add (&vam->json_tree);
22652 vat_json_init_object (node);
22654 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
22655 vat_json_object_add_uint (node, "appns_index",
22656 clib_net_to_host_u32 (mp->appns_index));
22657 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
22658 vat_json_object_add_uint (node, "scope", mp->scope);
22659 vat_json_object_add_uint (node, "action_index",
22660 clib_net_to_host_u32 (mp->action_index));
22661 vat_json_object_add_uint (node, "lcl_port",
22662 clib_net_to_host_u16 (mp->lcl_port));
22663 vat_json_object_add_uint (node, "rmt_port",
22664 clib_net_to_host_u16 (mp->rmt_port));
22665 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
22666 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
22667 vat_json_object_add_string_copy (node, "tag", mp->tag);
22670 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
22671 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
22672 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
22673 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
22677 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
22678 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
22679 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
22680 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
22685 api_session_rule_add_del (vat_main_t * vam)
22687 vl_api_session_rule_add_del_t *mp;
22688 unformat_input_t *i = vam->input;
22689 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
22690 u32 appns_index = 0, scope = 0;
22691 ip4_address_t lcl_ip4, rmt_ip4;
22692 ip6_address_t lcl_ip6, rmt_ip6;
22693 u8 is_ip4 = 1, conn_set = 0;
22694 u8 is_add = 1, *tag = 0;
22697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22699 if (unformat (i, "del"))
22701 else if (unformat (i, "add"))
22703 else if (unformat (i, "proto tcp"))
22705 else if (unformat (i, "proto udp"))
22707 else if (unformat (i, "appns %d", &appns_index))
22709 else if (unformat (i, "scope %d", &scope))
22711 else if (unformat (i, "tag %_%v%_", &tag))
22715 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
22716 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
22724 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
22725 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
22731 else if (unformat (i, "action %d", &action))
22736 if (proto == ~0 || !conn_set || action == ~0)
22738 errmsg ("transport proto, connection and action must be set");
22744 errmsg ("scope should be 0-3");
22748 M (SESSION_RULE_ADD_DEL, mp);
22750 mp->is_ip4 = is_ip4;
22751 mp->transport_proto = proto;
22752 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
22753 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
22754 mp->lcl_plen = lcl_plen;
22755 mp->rmt_plen = rmt_plen;
22756 mp->action_index = clib_host_to_net_u32 (action);
22757 mp->appns_index = clib_host_to_net_u32 (appns_index);
22759 mp->is_add = is_add;
22762 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
22763 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
22767 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
22768 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
22772 clib_memcpy (mp->tag, tag, vec_len (tag));
22782 api_session_rules_dump (vat_main_t * vam)
22784 vl_api_session_rules_dump_t *mp;
22785 vl_api_control_ping_t *mp_ping;
22788 if (!vam->json_output)
22790 print (vam->ofp, "%=20s", "Session Rules");
22793 M (SESSION_RULES_DUMP, mp);
22797 /* Use a control ping for synchronization */
22798 MPING (CONTROL_PING, mp_ping);
22801 /* Wait for a reply... */
22807 api_ip_container_proxy_add_del (vat_main_t * vam)
22809 vl_api_ip_container_proxy_add_del_t *mp;
22810 unformat_input_t *i = vam->input;
22811 u32 plen = ~0, sw_if_index = ~0;
22818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22820 if (unformat (i, "del"))
22822 else if (unformat (i, "add"))
22824 if (unformat (i, "%U", unformat_ip4_address, &ip4))
22829 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
22834 else if (unformat (i, "sw_if_index %u", &sw_if_index))
22839 if (sw_if_index == ~0 || plen == ~0)
22841 errmsg ("address and sw_if_index must be set");
22845 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
22847 mp->is_ip4 = is_ip4;
22848 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
22850 mp->is_add = is_add;
22852 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
22854 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
22862 api_qos_record_enable_disable (vat_main_t * vam)
22864 unformat_input_t *i = vam->input;
22865 vl_api_qos_record_enable_disable_t *mp;
22866 u32 sw_if_index, qs = 0xff;
22867 u8 sw_if_index_set = 0;
22871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
22873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
22874 sw_if_index_set = 1;
22875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
22876 sw_if_index_set = 1;
22877 else if (unformat (i, "%U", unformat_qos_source, &qs))
22879 else if (unformat (i, "disable"))
22883 clib_warning ("parse error '%U'", format_unformat_error, i);
22888 if (sw_if_index_set == 0)
22890 errmsg ("missing interface name or sw_if_index");
22895 errmsg ("input location must be specified");
22899 M (QOS_RECORD_ENABLE_DISABLE, mp);
22901 mp->sw_if_index = ntohl (sw_if_index);
22902 mp->input_source = qs;
22903 mp->enable = enable;
22911 q_or_quit (vat_main_t * vam)
22913 #if VPP_API_TEST_BUILTIN == 0
22914 longjmp (vam->jump_buf, 1);
22916 return 0; /* not so much */
22920 q (vat_main_t * vam)
22922 return q_or_quit (vam);
22926 quit (vat_main_t * vam)
22928 return q_or_quit (vam);
22932 comment (vat_main_t * vam)
22938 cmd_cmp (void *a1, void *a2)
22943 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22947 help (vat_main_t * vam)
22952 unformat_input_t *i = vam->input;
22955 if (unformat (i, "%s", &name))
22959 vec_add1 (name, 0);
22961 hs = hash_get_mem (vam->help_by_name, name);
22963 print (vam->ofp, "usage: %s %s", name, hs[0]);
22965 print (vam->ofp, "No such msg / command '%s'", name);
22970 print (vam->ofp, "Help is available for the following:");
22973 hash_foreach_pair (p, vam->function_by_name,
22975 vec_add1 (cmds, (u8 *)(p->key));
22979 vec_sort_with_function (cmds, cmd_cmp);
22981 for (j = 0; j < vec_len (cmds); j++)
22982 print (vam->ofp, "%s", cmds[j]);
22989 set (vat_main_t * vam)
22991 u8 *name = 0, *value = 0;
22992 unformat_input_t *i = vam->input;
22994 if (unformat (i, "%s", &name))
22996 /* The input buffer is a vector, not a string. */
22997 value = vec_dup (i->buffer);
22998 vec_delete (value, i->index, 0);
22999 /* Almost certainly has a trailing newline */
23000 if (value[vec_len (value) - 1] == '\n')
23001 value[vec_len (value) - 1] = 0;
23002 /* Make sure it's a proper string, one way or the other */
23003 vec_add1 (value, 0);
23004 (void) clib_macro_set_value (&vam->macro_main,
23005 (char *) name, (char *) value);
23008 errmsg ("usage: set <name> <value>");
23016 unset (vat_main_t * vam)
23020 if (unformat (vam->input, "%s", &name))
23021 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
23022 errmsg ("unset: %s wasn't set", name);
23035 macro_sort_cmp (void *a1, void *a2)
23037 macro_sort_t *s1 = a1;
23038 macro_sort_t *s2 = a2;
23040 return strcmp ((char *) (s1->name), (char *) (s2->name));
23044 dump_macro_table (vat_main_t * vam)
23046 macro_sort_t *sort_me = 0, *sm;
23051 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
23053 vec_add2 (sort_me, sm, 1);
23054 sm->name = (u8 *)(p->key);
23055 sm->value = (u8 *) (p->value[0]);
23059 vec_sort_with_function (sort_me, macro_sort_cmp);
23061 if (vec_len (sort_me))
23062 print (vam->ofp, "%-15s%s", "Name", "Value");
23064 print (vam->ofp, "The macro table is empty...");
23066 for (i = 0; i < vec_len (sort_me); i++)
23067 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
23072 dump_node_table (vat_main_t * vam)
23075 vlib_node_t *node, *next_node;
23077 if (vec_len (vam->graph_nodes) == 0)
23079 print (vam->ofp, "Node table empty, issue get_node_graph...");
23083 for (i = 0; i < vec_len (vam->graph_nodes); i++)
23085 node = vam->graph_nodes[i];
23086 print (vam->ofp, "[%d] %s", i, node->name);
23087 for (j = 0; j < vec_len (node->next_nodes); j++)
23089 if (node->next_nodes[j] != ~0)
23091 next_node = vam->graph_nodes[node->next_nodes[j]];
23092 print (vam->ofp, " [%d] %s", j, next_node->name);
23100 value_sort_cmp (void *a1, void *a2)
23102 name_sort_t *n1 = a1;
23103 name_sort_t *n2 = a2;
23105 if (n1->value < n2->value)
23107 if (n1->value > n2->value)
23114 dump_msg_api_table (vat_main_t * vam)
23116 api_main_t *am = &api_main;
23117 name_sort_t *nses = 0, *ns;
23122 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
23124 vec_add2 (nses, ns, 1);
23125 ns->name = (u8 *)(hp->key);
23126 ns->value = (u32) hp->value[0];
23130 vec_sort_with_function (nses, value_sort_cmp);
23132 for (i = 0; i < vec_len (nses); i++)
23133 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
23139 get_msg_id (vat_main_t * vam)
23144 if (unformat (vam->input, "%s", &name_and_crc))
23146 message_index = vl_msg_api_get_msg_index (name_and_crc);
23147 if (message_index == ~0)
23149 print (vam->ofp, " '%s' not found", name_and_crc);
23152 print (vam->ofp, " '%s' has message index %d",
23153 name_and_crc, message_index);
23156 errmsg ("name_and_crc required...");
23161 search_node_table (vat_main_t * vam)
23163 unformat_input_t *line_input = vam->input;
23166 vlib_node_t *node, *next_node;
23169 if (vam->graph_node_index_by_name == 0)
23171 print (vam->ofp, "Node table empty, issue get_node_graph...");
23175 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
23177 if (unformat (line_input, "%s", &node_to_find))
23179 vec_add1 (node_to_find, 0);
23180 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
23183 print (vam->ofp, "%s not found...", node_to_find);
23186 node = vam->graph_nodes[p[0]];
23187 print (vam->ofp, "[%d] %s", p[0], node->name);
23188 for (j = 0; j < vec_len (node->next_nodes); j++)
23190 if (node->next_nodes[j] != ~0)
23192 next_node = vam->graph_nodes[node->next_nodes[j]];
23193 print (vam->ofp, " [%d] %s", j, next_node->name);
23200 clib_warning ("parse error '%U'", format_unformat_error,
23206 vec_free (node_to_find);
23215 script (vat_main_t * vam)
23217 #if (VPP_API_TEST_BUILTIN==0)
23219 char *save_current_file;
23220 unformat_input_t save_input;
23221 jmp_buf save_jump_buf;
23222 u32 save_line_number;
23224 FILE *new_fp, *save_ifp;
23226 if (unformat (vam->input, "%s", &s))
23228 new_fp = fopen ((char *) s, "r");
23231 errmsg ("Couldn't open script file %s", s);
23238 errmsg ("Missing script name");
23242 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
23243 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
23244 save_ifp = vam->ifp;
23245 save_line_number = vam->input_line_number;
23246 save_current_file = (char *) vam->current_file;
23248 vam->input_line_number = 0;
23250 vam->current_file = s;
23253 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
23254 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
23255 vam->ifp = save_ifp;
23256 vam->input_line_number = save_line_number;
23257 vam->current_file = (u8 *) save_current_file;
23262 clib_warning ("use the exec command...");
23268 echo (vat_main_t * vam)
23270 print (vam->ofp, "%v", vam->input->buffer);
23274 /* List of API message constructors, CLI names map to api_xxx */
23275 #define foreach_vpe_api_msg \
23276 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
23277 _(sw_interface_dump,"") \
23278 _(sw_interface_set_flags, \
23279 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
23280 _(sw_interface_add_del_address, \
23281 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
23282 _(sw_interface_set_rx_mode, \
23283 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
23284 _(sw_interface_set_table, \
23285 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
23286 _(sw_interface_set_mpls_enable, \
23287 "<intfc> | sw_if_index [disable | dis]") \
23288 _(sw_interface_set_vpath, \
23289 "<intfc> | sw_if_index <id> enable | disable") \
23290 _(sw_interface_set_vxlan_bypass, \
23291 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23292 _(sw_interface_set_geneve_bypass, \
23293 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
23294 _(sw_interface_set_l2_xconnect, \
23295 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23296 "enable | disable") \
23297 _(sw_interface_set_l2_bridge, \
23298 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
23299 "[shg <split-horizon-group>] [bvi]\n" \
23300 "enable | disable") \
23301 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
23302 _(bridge_domain_add_del, \
23303 "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") \
23304 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
23306 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
23307 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
23308 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
23310 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23312 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
23314 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
23316 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
23318 "<vpp-if-name> | sw_if_index <id>") \
23319 _(sw_interface_tap_dump, "") \
23321 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
23323 "<vpp-if-name> | sw_if_index <id>") \
23324 _(sw_interface_tap_v2_dump, "") \
23326 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
23327 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]}") \
23329 "<vpp-if-name> | sw_if_index <id>") \
23331 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
23332 _(bond_detach_slave, \
23333 "sw_if_index <n>") \
23334 _(sw_interface_bond_dump, "") \
23335 _(sw_interface_slave_dump, \
23336 "<vpp-if-name> | sw_if_index <id>") \
23337 _(ip_table_add_del, \
23338 "table-id <n> [ipv6]\n") \
23339 _(ip_add_del_route, \
23340 "<addr>/<mask> via <addr> [table-id <n>]\n" \
23341 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23342 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23343 "[multipath] [count <n>]") \
23344 _(ip_mroute_add_del, \
23345 "<src> <grp>/<mask> [table-id <n>]\n" \
23346 "[<intfc> | sw_if_index <id>] [local] [del]") \
23347 _(mpls_table_add_del, \
23348 "table-id <n>\n") \
23349 _(mpls_route_add_del, \
23350 "<label> <eos> via <addr> [table-id <n>]\n" \
23351 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
23352 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
23353 "[multipath] [count <n>]") \
23354 _(mpls_ip_bind_unbind, \
23355 "<label> <addr/len>") \
23356 _(mpls_tunnel_add_del, \
23357 " via <addr> [table-id <n>]\n" \
23358 "sw_if_index <id>] [l2] [del]") \
23359 _(bier_table_add_del, \
23360 "<label> <sub-domain> <set> <bsl> [del]") \
23361 _(bier_route_add_del, \
23362 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
23363 "[<intfc> | sw_if_index <id>]" \
23364 "[weight <n>] [del] [multipath]") \
23365 _(proxy_arp_add_del, \
23366 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
23367 _(proxy_arp_intfc_enable_disable, \
23368 "<intfc> | sw_if_index <id> enable | disable") \
23369 _(sw_interface_set_unnumbered, \
23370 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
23371 _(ip_neighbor_add_del, \
23372 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
23373 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
23374 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
23375 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
23376 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
23377 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
23378 "[outer_vlan_id_any][inner_vlan_id_any]") \
23379 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
23380 _(reset_fib, "vrf <n> [ipv6]") \
23381 _(dhcp_proxy_config, \
23382 "svr <v46-address> src <v46-address>\n" \
23383 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
23384 _(dhcp_proxy_set_vss, \
23385 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
23386 _(dhcp_proxy_dump, "ip6") \
23387 _(dhcp_client_config, \
23388 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
23389 _(set_ip_flow_hash, \
23390 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
23391 _(sw_interface_ip6_enable_disable, \
23392 "<intfc> | sw_if_index <id> enable | disable") \
23393 _(sw_interface_ip6_set_link_local_address, \
23394 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
23395 _(ip6nd_proxy_add_del, \
23396 "<intfc> | sw_if_index <id> <ip6-address>") \
23397 _(ip6nd_proxy_dump, "") \
23398 _(sw_interface_ip6nd_ra_prefix, \
23399 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
23400 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
23401 "[nolink] [isno]") \
23402 _(sw_interface_ip6nd_ra_config, \
23403 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
23404 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
23405 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
23406 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
23407 _(l2_patch_add_del, \
23408 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
23409 "enable | disable") \
23410 _(sr_localsid_add_del, \
23411 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
23412 "fib-table <num> (end.psp) sw_if_index <num>") \
23413 _(classify_add_del_table, \
23414 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
23415 " [del] [del-chain] mask <mask-value>\n" \
23416 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
23417 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
23418 _(classify_add_del_session, \
23419 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
23420 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
23421 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
23422 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
23423 _(classify_set_interface_ip_table, \
23424 "<intfc> | sw_if_index <nn> table <nn>") \
23425 _(classify_set_interface_l2_tables, \
23426 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23427 " [other-table <nn>]") \
23428 _(get_node_index, "node <node-name") \
23429 _(add_node_next, "node <node-name> next <next-node-name>") \
23430 _(l2tpv3_create_tunnel, \
23431 "client_address <ip6-addr> our_address <ip6-addr>\n" \
23432 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
23433 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
23434 _(l2tpv3_set_tunnel_cookies, \
23435 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
23436 "[new_remote_cookie <nn>]\n") \
23437 _(l2tpv3_interface_enable_disable, \
23438 "<intfc> | sw_if_index <nn> enable | disable") \
23439 _(l2tpv3_set_lookup_key, \
23440 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
23441 _(sw_if_l2tpv3_tunnel_dump, "") \
23442 _(vxlan_add_del_tunnel, \
23443 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23444 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
23445 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23446 _(geneve_add_del_tunnel, \
23447 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
23448 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23449 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
23450 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23451 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23452 _(gre_add_del_tunnel, \
23453 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
23454 "[teb | erspan <session-id>] [del]") \
23455 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23456 _(l2_fib_clear_table, "") \
23457 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
23458 _(l2_interface_vlan_tag_rewrite, \
23459 "<intfc> | sw_if_index <nn> \n" \
23460 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
23461 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
23462 _(create_vhost_user_if, \
23463 "socket <filename> [server] [renumber <dev_instance>] " \
23464 "[mac <mac_address>]") \
23465 _(modify_vhost_user_if, \
23466 "<intfc> | sw_if_index <nn> socket <filename>\n" \
23467 "[server] [renumber <dev_instance>]") \
23468 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
23469 _(sw_interface_vhost_user_dump, "") \
23470 _(show_version, "") \
23471 _(vxlan_gpe_add_del_tunnel, \
23472 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
23473 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
23474 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
23475 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
23476 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
23477 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
23478 _(interface_name_renumber, \
23479 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
23480 _(input_acl_set_interface, \
23481 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23482 " [l2-table <nn>] [del]") \
23483 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
23484 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
23485 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
23486 _(want_ip4_arp_events, "address <ip4-address> [del]") \
23487 _(want_ip6_nd_events, "address <ip6-address> [del]") \
23488 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
23489 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
23490 _(ip_dump, "ipv4 | ipv6") \
23491 _(ipsec_spd_add_del, "spd_id <n> [del]") \
23492 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
23494 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
23495 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
23496 " integ_alg <alg> integ_key <hex>") \
23497 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
23498 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
23499 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
23500 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
23501 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
23502 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
23503 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
23504 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
23505 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
23506 " [instance <n>]") \
23507 _(ipsec_sa_dump, "[sa_id <n>]") \
23508 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
23509 " <alg> <hex>\n") \
23510 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
23511 _(ikev2_profile_add_del, "name <profile_name> [del]") \
23512 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
23513 "(auth_data 0x<data> | auth_data <data>)") \
23514 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
23515 "(id_data 0x<data> | id_data <data>) (local|remote)") \
23516 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
23517 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
23518 "(local|remote)") \
23519 _(ikev2_set_local_key, "file <absolute_file_path>") \
23520 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
23521 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23522 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
23523 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
23524 _(ikev2_initiate_sa_init, "<profile_name>") \
23525 _(ikev2_initiate_del_ike_sa, "<ispi>") \
23526 _(ikev2_initiate_del_child_sa, "<ispi>") \
23527 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
23528 _(delete_loopback,"sw_if_index <nn>") \
23529 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
23530 _(map_add_domain, \
23531 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
23532 "ip6-src <ip6addr> " \
23533 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
23534 _(map_del_domain, "index <n>") \
23535 _(map_add_del_rule, \
23536 "index <n> psid <n> dst <ip6addr> [del]") \
23537 _(map_domain_dump, "") \
23538 _(map_rule_dump, "index <map-domain>") \
23539 _(want_interface_events, "enable|disable") \
23540 _(want_stats,"enable|disable") \
23541 _(get_first_msg_id, "client <name>") \
23542 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
23543 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
23544 "fib-id <nn> [ip4][ip6][default]") \
23545 _(get_node_graph, " ") \
23546 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
23547 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
23548 _(ioam_disable, "") \
23549 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
23550 " sw_if_index <sw_if_index> p <priority> " \
23551 "w <weight>] [del]") \
23552 _(one_add_del_locator, "locator-set <locator_name> " \
23553 "iface <intf> | sw_if_index <sw_if_index> " \
23554 "p <priority> w <weight> [del]") \
23555 _(one_add_del_local_eid,"vni <vni> eid " \
23556 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23557 "locator-set <locator_name> [del]" \
23558 "[key-id sha1|sha256 secret-key <secret-key>]")\
23559 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
23560 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
23561 _(one_enable_disable, "enable|disable") \
23562 _(one_map_register_enable_disable, "enable|disable") \
23563 _(one_map_register_fallback_threshold, "<value>") \
23564 _(one_rloc_probe_enable_disable, "enable|disable") \
23565 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23567 "rloc <locator> p <prio> " \
23568 "w <weight> [rloc <loc> ... ] " \
23569 "action <action> [del-all]") \
23570 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23572 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23573 _(one_use_petr, "ip-address> | disable") \
23574 _(one_map_request_mode, "src-dst|dst-only") \
23575 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23576 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23577 _(one_locator_set_dump, "[local | remote]") \
23578 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
23579 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23580 "[local] | [remote]") \
23581 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
23582 _(one_ndp_bd_get, "") \
23583 _(one_ndp_entries_get, "bd <bridge-domain>") \
23584 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
23585 _(one_l2_arp_bd_get, "") \
23586 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
23587 _(one_stats_enable_disable, "enable|disalbe") \
23588 _(show_one_stats_enable_disable, "") \
23589 _(one_eid_table_vni_dump, "") \
23590 _(one_eid_table_map_dump, "l2|l3") \
23591 _(one_map_resolver_dump, "") \
23592 _(one_map_server_dump, "") \
23593 _(one_adjacencies_get, "vni <vni>") \
23594 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
23595 _(show_one_rloc_probe_state, "") \
23596 _(show_one_map_register_state, "") \
23597 _(show_one_status, "") \
23598 _(one_stats_dump, "") \
23599 _(one_stats_flush, "") \
23600 _(one_get_map_request_itr_rlocs, "") \
23601 _(one_map_register_set_ttl, "<ttl>") \
23602 _(one_set_transport_protocol, "udp|api") \
23603 _(one_get_transport_protocol, "") \
23604 _(one_enable_disable_xtr_mode, "enable|disable") \
23605 _(one_show_xtr_mode, "") \
23606 _(one_enable_disable_pitr_mode, "enable|disable") \
23607 _(one_show_pitr_mode, "") \
23608 _(one_enable_disable_petr_mode, "enable|disable") \
23609 _(one_show_petr_mode, "") \
23610 _(show_one_nsh_mapping, "") \
23611 _(show_one_pitr, "") \
23612 _(show_one_use_petr, "") \
23613 _(show_one_map_request_mode, "") \
23614 _(show_one_map_register_ttl, "") \
23615 _(show_one_map_register_fallback_threshold, "") \
23616 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
23617 " sw_if_index <sw_if_index> p <priority> " \
23618 "w <weight>] [del]") \
23619 _(lisp_add_del_locator, "locator-set <locator_name> " \
23620 "iface <intf> | sw_if_index <sw_if_index> " \
23621 "p <priority> w <weight> [del]") \
23622 _(lisp_add_del_local_eid,"vni <vni> eid " \
23623 "<ipv4|ipv6>/<prefix> | <L2 address> " \
23624 "locator-set <locator_name> [del]" \
23625 "[key-id sha1|sha256 secret-key <secret-key>]") \
23626 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
23627 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
23628 _(lisp_enable_disable, "enable|disable") \
23629 _(lisp_map_register_enable_disable, "enable|disable") \
23630 _(lisp_rloc_probe_enable_disable, "enable|disable") \
23631 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
23633 "rloc <locator> p <prio> " \
23634 "w <weight> [rloc <loc> ... ] " \
23635 "action <action> [del-all]") \
23636 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
23638 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
23639 _(lisp_use_petr, "<ip-address> | disable") \
23640 _(lisp_map_request_mode, "src-dst|dst-only") \
23641 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
23642 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
23643 _(lisp_locator_set_dump, "[local | remote]") \
23644 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
23645 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
23646 "[local] | [remote]") \
23647 _(lisp_eid_table_vni_dump, "") \
23648 _(lisp_eid_table_map_dump, "l2|l3") \
23649 _(lisp_map_resolver_dump, "") \
23650 _(lisp_map_server_dump, "") \
23651 _(lisp_adjacencies_get, "vni <vni>") \
23652 _(gpe_fwd_entry_vnis_get, "") \
23653 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
23654 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
23655 "[table <table-id>]") \
23656 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
23657 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
23658 _(gpe_set_encap_mode, "lisp|vxlan") \
23659 _(gpe_get_encap_mode, "") \
23660 _(lisp_gpe_add_del_iface, "up|down") \
23661 _(lisp_gpe_enable_disable, "enable|disable") \
23662 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
23663 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
23664 _(show_lisp_rloc_probe_state, "") \
23665 _(show_lisp_map_register_state, "") \
23666 _(show_lisp_status, "") \
23667 _(lisp_get_map_request_itr_rlocs, "") \
23668 _(show_lisp_pitr, "") \
23669 _(show_lisp_use_petr, "") \
23670 _(show_lisp_map_request_mode, "") \
23671 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
23672 _(af_packet_delete, "name <host interface name>") \
23673 _(policer_add_del, "name <policer name> <params> [del]") \
23674 _(policer_dump, "[name <policer name>]") \
23675 _(policer_classify_set_interface, \
23676 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23677 " [l2-table <nn>] [del]") \
23678 _(policer_classify_dump, "type [ip4|ip6|l2]") \
23679 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
23680 "[master|slave]") \
23681 _(netmap_delete, "name <interface name>") \
23682 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
23683 _(mpls_fib_dump, "") \
23684 _(classify_table_ids, "") \
23685 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
23686 _(classify_table_info, "table_id <nn>") \
23687 _(classify_session_dump, "table_id <nn>") \
23688 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
23689 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
23690 "[template_interval <nn>] [udp_checksum]") \
23691 _(ipfix_exporter_dump, "") \
23692 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
23693 _(ipfix_classify_stream_dump, "") \
23694 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
23695 _(ipfix_classify_table_dump, "") \
23696 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
23697 _(sw_interface_span_dump, "[l2]") \
23698 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
23699 _(pg_create_interface, "if_id <nn>") \
23700 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
23701 _(pg_enable_disable, "[stream <id>] disable") \
23702 _(ip_source_and_port_range_check_add_del, \
23703 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
23704 _(ip_source_and_port_range_check_interface_add_del, \
23705 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
23706 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
23707 _(ipsec_gre_add_del_tunnel, \
23708 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
23709 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
23710 _(delete_subif,"<intfc> | sw_if_index <nn>") \
23711 _(l2_interface_pbb_tag_rewrite, \
23712 "<intfc> | sw_if_index <nn> \n" \
23713 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
23714 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
23715 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
23716 _(flow_classify_set_interface, \
23717 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
23718 _(flow_classify_dump, "type [ip4|ip6]") \
23719 _(ip_fib_dump, "") \
23720 _(ip_mfib_dump, "") \
23721 _(ip6_fib_dump, "") \
23722 _(ip6_mfib_dump, "") \
23723 _(feature_enable_disable, "arc_name <arc_name> " \
23724 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
23725 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
23727 _(l2_xconnect_dump, "") \
23728 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
23729 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
23730 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
23731 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
23732 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
23733 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
23734 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
23735 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
23736 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
23737 _(sock_init_shm, "size <nnn>") \
23738 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
23739 _(dns_enable_disable, "[enable][disable]") \
23740 _(dns_name_server_add_del, "<ip-address> [del]") \
23741 _(dns_resolve_name, "<hostname>") \
23742 _(dns_resolve_ip, "<ip4|ip6>") \
23743 _(dns_name_server_add_del, "<ip-address> [del]") \
23744 _(dns_resolve_name, "<hostname>") \
23745 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
23746 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
23747 _(session_rules_dump, "") \
23748 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
23749 _(output_acl_set_interface, \
23750 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
23751 " [l2-table <nn>] [del]") \
23752 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
23754 /* List of command functions, CLI names map directly to functions */
23755 #define foreach_cli_function \
23756 _(comment, "usage: comment <ignore-rest-of-line>") \
23757 _(dump_interface_table, "usage: dump_interface_table") \
23758 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
23759 _(dump_ipv4_table, "usage: dump_ipv4_table") \
23760 _(dump_ipv6_table, "usage: dump_ipv6_table") \
23761 _(dump_stats_table, "usage: dump_stats_table") \
23762 _(dump_macro_table, "usage: dump_macro_table ") \
23763 _(dump_node_table, "usage: dump_node_table") \
23764 _(dump_msg_api_table, "usage: dump_msg_api_table") \
23765 _(get_msg_id, "usage: get_msg_id name_and_crc") \
23766 _(echo, "usage: echo <message>") \
23767 _(exec, "usage: exec <vpe-debug-CLI-command>") \
23768 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
23769 _(help, "usage: help") \
23770 _(q, "usage: quit") \
23771 _(quit, "usage: quit") \
23772 _(search_node_table, "usage: search_node_table <name>...") \
23773 _(set, "usage: set <variable-name> <value>") \
23774 _(script, "usage: script <file-name>") \
23775 _(unset, "usage: unset <variable-name>")
23777 static void vl_api_##n##_t_handler_uni \
23778 (vl_api_##n##_t * mp) \
23780 vat_main_t * vam = &vat_main; \
23781 if (vam->json_output) { \
23782 vl_api_##n##_t_handler_json(mp); \
23784 vl_api_##n##_t_handler(mp); \
23787 foreach_vpe_api_reply_msg;
23788 #if VPP_API_TEST_BUILTIN == 0
23789 foreach_standalone_reply_msg;
23794 vat_api_hookup (vat_main_t * vam)
23797 vl_msg_api_set_handlers(VL_API_##N, #n, \
23798 vl_api_##n##_t_handler_uni, \
23800 vl_api_##n##_t_endian, \
23801 vl_api_##n##_t_print, \
23802 sizeof(vl_api_##n##_t), 1);
23803 foreach_vpe_api_reply_msg;
23804 #if VPP_API_TEST_BUILTIN == 0
23805 foreach_standalone_reply_msg;
23809 #if (VPP_API_TEST_BUILTIN==0)
23810 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
23812 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
23814 vam->function_by_name = hash_create_string (0, sizeof (uword));
23816 vam->help_by_name = hash_create_string (0, sizeof (uword));
23819 /* API messages we can send */
23820 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
23821 foreach_vpe_api_msg;
23825 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23826 foreach_vpe_api_msg;
23829 /* CLI functions */
23830 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
23831 foreach_cli_function;
23835 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
23836 foreach_cli_function;
23840 #if VPP_API_TEST_BUILTIN
23841 static clib_error_t *
23842 vat_api_hookup_shim (vlib_main_t * vm)
23844 vat_api_hookup (&vat_main);
23848 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
23852 * fd.io coding-style-patch-verification: ON
23855 * eval: (c-set-style "gnu")