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 <svm/memfd.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.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/input_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>
54 #include "vat/json_format.h"
59 #define vl_typedefs /* define message structures */
60 #include <vpp/api/vpe_all_api_h.h>
63 /* declare message handlers for each api */
65 #define vl_endianfun /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...)
72 #include <vpp/api/vpe_all_api_h.h>
75 #define __plugin_msg_base 0
76 #include <vlibapi/vat_helper_macros.h>
78 #if VPP_API_TEST_BUILTIN == 0
88 vat_socket_connect (vat_main_t * vam)
90 return vl_socket_client_connect
91 (&vam->socket_client_main, (char *) vam->socket_name,
92 "vpp_api_test(s)", 0 /* default socket rx, tx buffer */ );
94 #else /* vpp built-in case, we don't do sockets... */
96 vat_socket_connect (vat_main_t * vam)
102 vl_socket_client_read_reply (socket_client_main_t * scm)
109 vat_time_now (vat_main_t * vam)
111 #if VPP_API_TEST_BUILTIN
112 return vlib_time_now (vam->vlib_main);
114 return clib_time_now (&vam->clib_time);
119 errmsg (char *fmt, ...)
121 vat_main_t *vam = &vat_main;
126 s = va_format (0, fmt, &va);
131 #if VPP_API_TEST_BUILTIN
132 vlib_cli_output (vam->vlib_main, (char *) s);
135 if (vam->ifp != stdin)
136 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
137 vam->input_line_number);
138 fformat (vam->ofp, (char *) s);
146 #if VPP_API_TEST_BUILTIN == 0
148 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
150 vat_main_t *vam = va_arg (*args, vat_main_t *);
151 u32 *result = va_arg (*args, u32 *);
155 if (!unformat (input, "%s", &if_name))
158 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
165 /* Parse an IP4 address %d.%d.%d.%d. */
167 unformat_ip4_address (unformat_input_t * input, va_list * args)
169 u8 *result = va_arg (*args, u8 *);
172 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
175 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
187 unformat_ethernet_address (unformat_input_t * input, va_list * args)
189 u8 *result = va_arg (*args, u8 *);
192 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
193 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
197 for (i = 0; i < 6; i++)
198 if (a[i] >= (1 << 8))
201 for (i = 0; i < 6; i++)
207 /* Returns ethernet type as an int in host byte order. */
209 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
212 u16 *result = va_arg (*args, u16 *);
216 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
218 if (type >= (1 << 16))
226 /* Parse an IP6 address. */
228 unformat_ip6_address (unformat_input_t * input, va_list * args)
230 ip6_address_t *result = va_arg (*args, ip6_address_t *);
232 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
233 uword c, n_colon, double_colon_index;
235 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
236 double_colon_index = ARRAY_LEN (hex_quads);
237 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
240 if (c >= '0' && c <= '9')
242 else if (c >= 'a' && c <= 'f')
243 hex_digit = c + 10 - 'a';
244 else if (c >= 'A' && c <= 'F')
245 hex_digit = c + 10 - 'A';
246 else if (c == ':' && n_colon < 2)
250 unformat_put_input (input);
254 /* Too many hex quads. */
255 if (n_hex_quads >= ARRAY_LEN (hex_quads))
260 hex_quad = (hex_quad << 4) | hex_digit;
262 /* Hex quad must fit in 16 bits. */
263 if (n_hex_digits >= 4)
270 /* Save position of :: */
273 /* More than one :: ? */
274 if (double_colon_index < ARRAY_LEN (hex_quads))
276 double_colon_index = n_hex_quads;
279 if (n_colon > 0 && n_hex_digits > 0)
281 hex_quads[n_hex_quads++] = hex_quad;
287 if (n_hex_digits > 0)
288 hex_quads[n_hex_quads++] = hex_quad;
293 /* Expand :: to appropriate number of zero hex quads. */
294 if (double_colon_index < ARRAY_LEN (hex_quads))
296 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
298 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
299 hex_quads[n_zero + i] = hex_quads[i];
301 for (i = 0; i < n_zero; i++)
302 hex_quads[double_colon_index + i] = 0;
304 n_hex_quads = ARRAY_LEN (hex_quads);
307 /* Too few hex quads given. */
308 if (n_hex_quads < ARRAY_LEN (hex_quads))
311 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
312 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
319 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
321 u32 *r = va_arg (*args, u32 *);
324 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
325 foreach_ipsec_policy_action
333 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
335 u32 *r = va_arg (*args, u32 *);
338 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
339 foreach_ipsec_crypto_alg
347 format_ipsec_crypto_alg (u8 * s, va_list * args)
349 u32 i = va_arg (*args, u32);
354 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
355 foreach_ipsec_crypto_alg
358 return format (s, "unknown");
360 return format (s, "%s", t);
364 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
366 u32 *r = va_arg (*args, u32 *);
369 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
370 foreach_ipsec_integ_alg
378 format_ipsec_integ_alg (u8 * s, va_list * args)
380 u32 i = va_arg (*args, u32);
385 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
386 foreach_ipsec_integ_alg
389 return format (s, "unknown");
391 return format (s, "%s", t);
395 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
397 u32 *r = va_arg (*args, u32 *);
400 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
401 foreach_ikev2_auth_method
409 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
411 u32 *r = va_arg (*args, u32 *);
414 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
415 foreach_ikev2_id_type
421 #else /* VPP_API_TEST_BUILTIN == 1 */
423 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
425 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
426 vnet_main_t *vnm = vnet_get_main ();
427 u32 *result = va_arg (*args, u32 *);
430 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
433 *result = sw_if_index;
436 #endif /* VPP_API_TEST_BUILTIN */
439 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
441 u8 *r = va_arg (*args, u8 *);
443 if (unformat (input, "kbps"))
444 *r = SSE2_QOS_RATE_KBPS;
445 else if (unformat (input, "pps"))
446 *r = SSE2_QOS_RATE_PPS;
453 unformat_policer_round_type (unformat_input_t * input, va_list * args)
455 u8 *r = va_arg (*args, u8 *);
457 if (unformat (input, "closest"))
458 *r = SSE2_QOS_ROUND_TO_CLOSEST;
459 else if (unformat (input, "up"))
460 *r = SSE2_QOS_ROUND_TO_UP;
461 else if (unformat (input, "down"))
462 *r = SSE2_QOS_ROUND_TO_DOWN;
469 unformat_policer_type (unformat_input_t * input, va_list * args)
471 u8 *r = va_arg (*args, u8 *);
473 if (unformat (input, "1r2c"))
474 *r = SSE2_QOS_POLICER_TYPE_1R2C;
475 else if (unformat (input, "1r3c"))
476 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
477 else if (unformat (input, "2r3c-2698"))
478 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
479 else if (unformat (input, "2r3c-4115"))
480 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
481 else if (unformat (input, "2r3c-mef5cf1"))
482 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
489 unformat_dscp (unformat_input_t * input, va_list * va)
491 u8 *r = va_arg (*va, u8 *);
494 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
503 unformat_policer_action_type (unformat_input_t * input, va_list * va)
505 sse2_qos_pol_action_params_st *a
506 = va_arg (*va, sse2_qos_pol_action_params_st *);
508 if (unformat (input, "drop"))
509 a->action_type = SSE2_QOS_ACTION_DROP;
510 else if (unformat (input, "transmit"))
511 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
512 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
513 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
520 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
522 u32 *r = va_arg (*va, u32 *);
525 if (unformat (input, "ip4"))
526 tid = POLICER_CLASSIFY_TABLE_IP4;
527 else if (unformat (input, "ip6"))
528 tid = POLICER_CLASSIFY_TABLE_IP6;
529 else if (unformat (input, "l2"))
530 tid = POLICER_CLASSIFY_TABLE_L2;
539 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
541 u32 *r = va_arg (*va, u32 *);
544 if (unformat (input, "ip4"))
545 tid = FLOW_CLASSIFY_TABLE_IP4;
546 else if (unformat (input, "ip6"))
547 tid = FLOW_CLASSIFY_TABLE_IP6;
555 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
556 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
557 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
558 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
560 #if (VPP_API_TEST_BUILTIN==0)
562 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
564 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
565 mfib_itf_attribute_t attr;
568 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
570 if (unformat (input, mfib_itf_flag_long_names[attr]))
571 *iflags |= (1 << attr);
573 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
575 if (unformat (input, mfib_itf_flag_names[attr]))
576 *iflags |= (1 << attr);
579 return (old == *iflags ? 0 : 1);
583 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
585 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
586 mfib_entry_attribute_t attr;
589 FOR_EACH_MFIB_ATTRIBUTE (attr)
591 if (unformat (input, mfib_flag_long_names[attr]))
592 *eflags |= (1 << attr);
594 FOR_EACH_MFIB_ATTRIBUTE (attr)
596 if (unformat (input, mfib_flag_names[attr]))
597 *eflags |= (1 << attr);
600 return (old == *eflags ? 0 : 1);
604 format_ip4_address (u8 * s, va_list * args)
606 u8 *a = va_arg (*args, u8 *);
607 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
611 format_ip6_address (u8 * s, va_list * args)
613 ip6_address_t *a = va_arg (*args, ip6_address_t *);
614 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
616 i_max_n_zero = ARRAY_LEN (a->as_u16);
618 i_first_zero = i_max_n_zero;
620 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
622 u32 is_zero = a->as_u16[i] == 0;
623 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
629 if ((!is_zero && n_zeros > max_n_zeros)
630 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
632 i_max_n_zero = i_first_zero;
633 max_n_zeros = n_zeros;
634 i_first_zero = ARRAY_LEN (a->as_u16);
639 last_double_colon = 0;
640 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
642 if (i == i_max_n_zero && max_n_zeros > 1)
644 s = format (s, "::");
645 i += max_n_zeros - 1;
646 last_double_colon = 1;
650 s = format (s, "%s%x",
651 (last_double_colon || i == 0) ? "" : ":",
652 clib_net_to_host_u16 (a->as_u16[i]));
653 last_double_colon = 0;
660 /* Format an IP46 address. */
662 format_ip46_address (u8 * s, va_list * args)
664 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
665 ip46_type_t type = va_arg (*args, ip46_type_t);
671 is_ip4 = ip46_address_is_ip4 (ip46);
682 format (s, "%U", format_ip4_address, &ip46->ip4) :
683 format (s, "%U", format_ip6_address, &ip46->ip6);
687 format_ethernet_address (u8 * s, va_list * args)
689 u8 *a = va_arg (*args, u8 *);
691 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
692 a[0], a[1], a[2], a[3], a[4], a[5]);
697 increment_v4_address (ip4_address_t * a)
701 v = ntohl (a->as_u32) + 1;
702 a->as_u32 = ntohl (v);
706 increment_v6_address (ip6_address_t * a)
710 v0 = clib_net_to_host_u64 (a->as_u64[0]);
711 v1 = clib_net_to_host_u64 (a->as_u64[1]);
716 a->as_u64[0] = clib_net_to_host_u64 (v0);
717 a->as_u64[1] = clib_net_to_host_u64 (v1);
721 increment_mac_address (u8 * mac)
723 u64 tmp = *((u64 *) mac);
724 tmp = clib_net_to_host_u64 (tmp);
725 tmp += 1 << 16; /* skip unused (least significant) octets */
726 tmp = clib_host_to_net_u64 (tmp);
728 clib_memcpy (mac, &tmp, 6);
731 static void vl_api_create_loopback_reply_t_handler
732 (vl_api_create_loopback_reply_t * mp)
734 vat_main_t *vam = &vat_main;
735 i32 retval = ntohl (mp->retval);
737 vam->retval = retval;
738 vam->regenerate_interface_table = 1;
739 vam->sw_if_index = ntohl (mp->sw_if_index);
740 vam->result_ready = 1;
743 static void vl_api_create_loopback_reply_t_handler_json
744 (vl_api_create_loopback_reply_t * mp)
746 vat_main_t *vam = &vat_main;
747 vat_json_node_t node;
749 vat_json_init_object (&node);
750 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
751 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
753 vat_json_print (vam->ofp, &node);
754 vat_json_free (&node);
755 vam->retval = ntohl (mp->retval);
756 vam->result_ready = 1;
759 static void vl_api_create_loopback_instance_reply_t_handler
760 (vl_api_create_loopback_instance_reply_t * mp)
762 vat_main_t *vam = &vat_main;
763 i32 retval = ntohl (mp->retval);
765 vam->retval = retval;
766 vam->regenerate_interface_table = 1;
767 vam->sw_if_index = ntohl (mp->sw_if_index);
768 vam->result_ready = 1;
771 static void vl_api_create_loopback_instance_reply_t_handler_json
772 (vl_api_create_loopback_instance_reply_t * mp)
774 vat_main_t *vam = &vat_main;
775 vat_json_node_t node;
777 vat_json_init_object (&node);
778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
779 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
781 vat_json_print (vam->ofp, &node);
782 vat_json_free (&node);
783 vam->retval = ntohl (mp->retval);
784 vam->result_ready = 1;
787 static void vl_api_af_packet_create_reply_t_handler
788 (vl_api_af_packet_create_reply_t * mp)
790 vat_main_t *vam = &vat_main;
791 i32 retval = ntohl (mp->retval);
793 vam->retval = retval;
794 vam->regenerate_interface_table = 1;
795 vam->sw_if_index = ntohl (mp->sw_if_index);
796 vam->result_ready = 1;
799 static void vl_api_af_packet_create_reply_t_handler_json
800 (vl_api_af_packet_create_reply_t * mp)
802 vat_main_t *vam = &vat_main;
803 vat_json_node_t node;
805 vat_json_init_object (&node);
806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
809 vat_json_print (vam->ofp, &node);
810 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_create_vlan_subif_reply_t_handler
817 (vl_api_create_vlan_subif_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_create_vlan_subif_reply_t_handler_json
829 (vl_api_create_vlan_subif_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_subif_reply_t_handler
846 (vl_api_create_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_subif_reply_t_handler_json
858 (vl_api_create_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_interface_name_renumber_reply_t_handler
875 (vl_api_interface_name_renumber_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->result_ready = 1;
885 static void vl_api_interface_name_renumber_reply_t_handler_json
886 (vl_api_interface_name_renumber_reply_t * mp)
888 vat_main_t *vam = &vat_main;
889 vat_json_node_t node;
891 vat_json_init_object (&node);
892 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_print (vam->ofp, &node);
895 vat_json_free (&node);
897 vam->retval = ntohl (mp->retval);
898 vam->result_ready = 1;
902 * Special-case: build the interface table, maintain
903 * the next loopback sw_if_index vbl.
905 static void vl_api_sw_interface_details_t_handler
906 (vl_api_sw_interface_details_t * mp)
908 vat_main_t *vam = &vat_main;
909 u8 *s = format (0, "%s%c", mp->interface_name, 0);
911 hash_set_mem (vam->sw_if_index_by_interface_name, s,
912 ntohl (mp->sw_if_index));
914 /* In sub interface case, fill the sub interface table entry */
915 if (mp->sw_if_index != mp->sup_sw_if_index)
917 sw_interface_subif_t *sub = NULL;
919 vec_add2 (vam->sw_if_subif_table, sub, 1);
921 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
922 strncpy ((char *) sub->interface_name, (char *) s,
923 vec_len (sub->interface_name));
924 sub->sw_if_index = ntohl (mp->sw_if_index);
925 sub->sub_id = ntohl (mp->sub_id);
927 sub->sub_dot1ad = mp->sub_dot1ad;
928 sub->sub_number_of_tags = mp->sub_number_of_tags;
929 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
930 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
931 sub->sub_exact_match = mp->sub_exact_match;
932 sub->sub_default = mp->sub_default;
933 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
934 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
936 /* vlan tag rewrite */
937 sub->vtr_op = ntohl (mp->vtr_op);
938 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
939 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
940 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
944 static void vl_api_sw_interface_details_t_handler_json
945 (vl_api_sw_interface_details_t * mp)
947 vat_main_t *vam = &vat_main;
948 vat_json_node_t *node = NULL;
950 if (VAT_JSON_ARRAY != vam->json_tree.type)
952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
953 vat_json_init_array (&vam->json_tree);
955 node = vat_json_array_add (&vam->json_tree);
957 vat_json_init_object (node);
958 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
959 vat_json_object_add_uint (node, "sup_sw_if_index",
960 ntohl (mp->sup_sw_if_index));
961 vat_json_object_add_uint (node, "l2_address_length",
962 ntohl (mp->l2_address_length));
963 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
964 sizeof (mp->l2_address));
965 vat_json_object_add_string_copy (node, "interface_name",
967 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
968 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
969 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
970 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
971 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
972 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
973 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
974 vat_json_object_add_uint (node, "sub_number_of_tags",
975 mp->sub_number_of_tags);
976 vat_json_object_add_uint (node, "sub_outer_vlan_id",
977 ntohs (mp->sub_outer_vlan_id));
978 vat_json_object_add_uint (node, "sub_inner_vlan_id",
979 ntohs (mp->sub_inner_vlan_id));
980 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
981 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
982 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
983 mp->sub_outer_vlan_id_any);
984 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
985 mp->sub_inner_vlan_id_any);
986 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
987 vat_json_object_add_uint (node, "vtr_push_dot1q",
988 ntohl (mp->vtr_push_dot1q));
989 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
990 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
993 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
995 format_ethernet_address,
997 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
999 format_ethernet_address,
1001 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1002 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1006 #if VPP_API_TEST_BUILTIN == 0
1007 static void vl_api_sw_interface_event_t_handler
1008 (vl_api_sw_interface_event_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 if (vam->interface_event_display)
1012 errmsg ("interface flags: sw_if_index %d %s %s",
1013 ntohl (mp->sw_if_index),
1014 mp->admin_up_down ? "admin-up" : "admin-down",
1015 mp->link_up_down ? "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = ntohl (mp->length);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply), mp->reply, length);
1080 vam->cmd_reply[length] = 0;
1082 vam->result_ready = 1;
1086 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 vat_json_node_t node;
1091 vec_reset_length (vam->cmd_reply);
1093 vat_json_init_object (&node);
1094 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1095 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1097 vat_json_print (vam->ofp, &node);
1098 vat_json_free (&node);
1100 vam->retval = ntohl (mp->retval);
1101 vam->result_ready = 1;
1104 static void vl_api_classify_add_del_table_reply_t_handler
1105 (vl_api_classify_add_del_table_reply_t * mp)
1107 vat_main_t *vam = &vat_main;
1108 i32 retval = ntohl (mp->retval);
1109 if (vam->async_mode)
1111 vam->async_errors += (retval < 0);
1115 vam->retval = retval;
1117 ((mp->new_table_index != 0xFFFFFFFF) ||
1118 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1119 (mp->match_n_vectors != 0xFFFFFFFF)))
1121 * Note: this is just barely thread-safe, depends on
1122 * the main thread spinning waiting for an answer...
1124 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1125 ntohl (mp->new_table_index),
1126 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1127 vam->result_ready = 1;
1131 static void vl_api_classify_add_del_table_reply_t_handler_json
1132 (vl_api_classify_add_del_table_reply_t * mp)
1134 vat_main_t *vam = &vat_main;
1135 vat_json_node_t node;
1137 vat_json_init_object (&node);
1138 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1139 vat_json_object_add_uint (&node, "new_table_index",
1140 ntohl (mp->new_table_index));
1141 vat_json_object_add_uint (&node, "skip_n_vectors",
1142 ntohl (mp->skip_n_vectors));
1143 vat_json_object_add_uint (&node, "match_n_vectors",
1144 ntohl (mp->match_n_vectors));
1146 vat_json_print (vam->ofp, &node);
1147 vat_json_free (&node);
1149 vam->retval = ntohl (mp->retval);
1150 vam->result_ready = 1;
1153 static void vl_api_get_node_index_reply_t_handler
1154 (vl_api_get_node_index_reply_t * mp)
1156 vat_main_t *vam = &vat_main;
1157 i32 retval = ntohl (mp->retval);
1158 if (vam->async_mode)
1160 vam->async_errors += (retval < 0);
1164 vam->retval = retval;
1166 errmsg ("node index %d", ntohl (mp->node_index));
1167 vam->result_ready = 1;
1171 static void vl_api_get_node_index_reply_t_handler_json
1172 (vl_api_get_node_index_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1177 vat_json_init_object (&node);
1178 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1179 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1181 vat_json_print (vam->ofp, &node);
1182 vat_json_free (&node);
1184 vam->retval = ntohl (mp->retval);
1185 vam->result_ready = 1;
1188 static void vl_api_get_next_index_reply_t_handler
1189 (vl_api_get_next_index_reply_t * mp)
1191 vat_main_t *vam = &vat_main;
1192 i32 retval = ntohl (mp->retval);
1193 if (vam->async_mode)
1195 vam->async_errors += (retval < 0);
1199 vam->retval = retval;
1201 errmsg ("next node index %d", ntohl (mp->next_index));
1202 vam->result_ready = 1;
1206 static void vl_api_get_next_index_reply_t_handler_json
1207 (vl_api_get_next_index_reply_t * mp)
1209 vat_main_t *vam = &vat_main;
1210 vat_json_node_t node;
1212 vat_json_init_object (&node);
1213 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1214 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1216 vat_json_print (vam->ofp, &node);
1217 vat_json_free (&node);
1219 vam->retval = ntohl (mp->retval);
1220 vam->result_ready = 1;
1223 static void vl_api_add_node_next_reply_t_handler
1224 (vl_api_add_node_next_reply_t * mp)
1226 vat_main_t *vam = &vat_main;
1227 i32 retval = ntohl (mp->retval);
1228 if (vam->async_mode)
1230 vam->async_errors += (retval < 0);
1234 vam->retval = retval;
1236 errmsg ("next index %d", ntohl (mp->next_index));
1237 vam->result_ready = 1;
1241 static void vl_api_add_node_next_reply_t_handler_json
1242 (vl_api_add_node_next_reply_t * mp)
1244 vat_main_t *vam = &vat_main;
1245 vat_json_node_t node;
1247 vat_json_init_object (&node);
1248 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1249 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1251 vat_json_print (vam->ofp, &node);
1252 vat_json_free (&node);
1254 vam->retval = ntohl (mp->retval);
1255 vam->result_ready = 1;
1258 static void vl_api_show_version_reply_t_handler
1259 (vl_api_show_version_reply_t * mp)
1261 vat_main_t *vam = &vat_main;
1262 i32 retval = ntohl (mp->retval);
1266 errmsg (" program: %s", mp->program);
1267 errmsg (" version: %s", mp->version);
1268 errmsg (" build date: %s", mp->build_date);
1269 errmsg ("build directory: %s", mp->build_directory);
1271 vam->retval = retval;
1272 vam->result_ready = 1;
1275 static void vl_api_show_version_reply_t_handler_json
1276 (vl_api_show_version_reply_t * mp)
1278 vat_main_t *vam = &vat_main;
1279 vat_json_node_t node;
1281 vat_json_init_object (&node);
1282 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1283 vat_json_object_add_string_copy (&node, "program", mp->program);
1284 vat_json_object_add_string_copy (&node, "version", mp->version);
1285 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1286 vat_json_object_add_string_copy (&node, "build_directory",
1287 mp->build_directory);
1289 vat_json_print (vam->ofp, &node);
1290 vat_json_free (&node);
1292 vam->retval = ntohl (mp->retval);
1293 vam->result_ready = 1;
1297 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1299 u32 sw_if_index = ntohl (mp->sw_if_index);
1300 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1301 mp->mac_ip ? "mac/ip binding" : "address resolution",
1302 ntohl (mp->pid), format_ip4_address, &mp->address,
1303 format_ethernet_address, mp->new_mac, sw_if_index);
1307 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1309 /* JSON output not supported */
1313 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1315 u32 sw_if_index = ntohl (mp->sw_if_index);
1316 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1317 mp->mac_ip ? "mac/ip binding" : "address resolution",
1318 ntohl (mp->pid), format_ip6_address, mp->address,
1319 format_ethernet_address, mp->new_mac, sw_if_index);
1323 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1325 /* JSON output not supported */
1329 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1331 u32 n_macs = ntohl (mp->n_macs);
1332 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1333 ntohl (mp->pid), mp->client_index, n_macs);
1335 for (i = 0; i < n_macs; i++)
1337 vl_api_mac_entry_t *mac = &mp->mac[i];
1338 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1339 i + 1, ntohl (mac->sw_if_index),
1340 format_ethernet_address, mac->mac_addr, mac->is_del);
1347 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1349 /* JSON output not supported */
1352 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1353 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1356 * Special-case: build the bridge domain table, maintain
1357 * the next bd id vbl.
1359 static void vl_api_bridge_domain_details_t_handler
1360 (vl_api_bridge_domain_details_t * mp)
1362 vat_main_t *vam = &vat_main;
1363 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1366 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1367 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1369 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1370 ntohl (mp->bd_id), mp->learn, mp->forward,
1371 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1375 vl_api_bridge_domain_sw_if_t *sw_ifs;
1376 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1379 sw_ifs = mp->sw_if_details;
1380 for (i = 0; i < n_sw_ifs; i++)
1386 sw_if_index = ntohl (sw_ifs->sw_if_index);
1389 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1391 if ((u32) p->value[0] == sw_if_index)
1393 sw_if_name = (u8 *)(p->key);
1398 print (vam->ofp, "%7d %3d %s", sw_if_index,
1399 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1400 "sw_if_index not found!");
1407 static void vl_api_bridge_domain_details_t_handler_json
1408 (vl_api_bridge_domain_details_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t *node, *array = NULL;
1412 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1414 if (VAT_JSON_ARRAY != vam->json_tree.type)
1416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1417 vat_json_init_array (&vam->json_tree);
1419 node = vat_json_array_add (&vam->json_tree);
1421 vat_json_init_object (node);
1422 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1423 vat_json_object_add_uint (node, "flood", mp->flood);
1424 vat_json_object_add_uint (node, "forward", mp->forward);
1425 vat_json_object_add_uint (node, "learn", mp->learn);
1426 vat_json_object_add_uint (node, "bvi_sw_if_index",
1427 ntohl (mp->bvi_sw_if_index));
1428 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1429 array = vat_json_object_add (node, "sw_if");
1430 vat_json_init_array (array);
1436 vl_api_bridge_domain_sw_if_t *sw_ifs;
1439 sw_ifs = mp->sw_if_details;
1440 for (i = 0; i < n_sw_ifs; i++)
1442 node = vat_json_array_add (array);
1443 vat_json_init_object (node);
1444 vat_json_object_add_uint (node, "sw_if_index",
1445 ntohl (sw_ifs->sw_if_index));
1446 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1452 static void vl_api_control_ping_reply_t_handler
1453 (vl_api_control_ping_reply_t * mp)
1455 vat_main_t *vam = &vat_main;
1456 i32 retval = ntohl (mp->retval);
1457 if (vam->async_mode)
1459 vam->async_errors += (retval < 0);
1463 vam->retval = retval;
1464 vam->result_ready = 1;
1466 vam->socket_client_main.control_pings_outstanding--;
1469 static void vl_api_control_ping_reply_t_handler_json
1470 (vl_api_control_ping_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 i32 retval = ntohl (mp->retval);
1475 if (VAT_JSON_NONE != vam->json_tree.type)
1477 vat_json_print (vam->ofp, &vam->json_tree);
1478 vat_json_free (&vam->json_tree);
1479 vam->json_tree.type = VAT_JSON_NONE;
1484 vat_json_init_array (&vam->json_tree);
1485 vat_json_print (vam->ofp, &vam->json_tree);
1486 vam->json_tree.type = VAT_JSON_NONE;
1489 vam->retval = retval;
1490 vam->result_ready = 1;
1494 vl_api_bridge_domain_set_mac_age_reply_t_handler
1495 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1497 vat_main_t *vam = &vat_main;
1498 i32 retval = ntohl (mp->retval);
1499 if (vam->async_mode)
1501 vam->async_errors += (retval < 0);
1505 vam->retval = retval;
1506 vam->result_ready = 1;
1510 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1511 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1513 vat_main_t *vam = &vat_main;
1514 vat_json_node_t node;
1516 vat_json_init_object (&node);
1517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1519 vat_json_print (vam->ofp, &node);
1520 vat_json_free (&node);
1522 vam->retval = ntohl (mp->retval);
1523 vam->result_ready = 1;
1527 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1529 vat_main_t *vam = &vat_main;
1530 i32 retval = ntohl (mp->retval);
1531 if (vam->async_mode)
1533 vam->async_errors += (retval < 0);
1537 vam->retval = retval;
1538 vam->result_ready = 1;
1542 static void vl_api_l2_flags_reply_t_handler_json
1543 (vl_api_l2_flags_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1551 ntohl (mp->resulting_feature_bitmap));
1553 vat_json_print (vam->ofp, &node);
1554 vat_json_free (&node);
1556 vam->retval = ntohl (mp->retval);
1557 vam->result_ready = 1;
1560 static void vl_api_bridge_flags_reply_t_handler
1561 (vl_api_bridge_flags_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1576 static void vl_api_bridge_flags_reply_t_handler_json
1577 (vl_api_bridge_flags_reply_t * mp)
1579 vat_main_t *vam = &vat_main;
1580 vat_json_node_t node;
1582 vat_json_init_object (&node);
1583 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1585 ntohl (mp->resulting_feature_bitmap));
1587 vat_json_print (vam->ofp, &node);
1588 vat_json_free (&node);
1590 vam->retval = ntohl (mp->retval);
1591 vam->result_ready = 1;
1594 static void vl_api_tap_connect_reply_t_handler
1595 (vl_api_tap_connect_reply_t * mp)
1597 vat_main_t *vam = &vat_main;
1598 i32 retval = ntohl (mp->retval);
1599 if (vam->async_mode)
1601 vam->async_errors += (retval < 0);
1605 vam->retval = retval;
1606 vam->sw_if_index = ntohl (mp->sw_if_index);
1607 vam->result_ready = 1;
1612 static void vl_api_tap_connect_reply_t_handler_json
1613 (vl_api_tap_connect_reply_t * mp)
1615 vat_main_t *vam = &vat_main;
1616 vat_json_node_t node;
1618 vat_json_init_object (&node);
1619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1622 vat_json_print (vam->ofp, &node);
1623 vat_json_free (&node);
1625 vam->retval = ntohl (mp->retval);
1626 vam->result_ready = 1;
1631 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1633 vat_main_t *vam = &vat_main;
1634 i32 retval = ntohl (mp->retval);
1635 if (vam->async_mode)
1637 vam->async_errors += (retval < 0);
1641 vam->retval = retval;
1642 vam->sw_if_index = ntohl (mp->sw_if_index);
1643 vam->result_ready = 1;
1647 static void vl_api_tap_modify_reply_t_handler_json
1648 (vl_api_tap_modify_reply_t * mp)
1650 vat_main_t *vam = &vat_main;
1651 vat_json_node_t node;
1653 vat_json_init_object (&node);
1654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_tap_delete_reply_t_handler_json
1681 (vl_api_tap_delete_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1689 vat_json_print (vam->ofp, &node);
1690 vat_json_free (&node);
1692 vam->retval = ntohl (mp->retval);
1693 vam->result_ready = 1;
1696 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1697 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1699 vat_main_t *vam = &vat_main;
1700 i32 retval = ntohl (mp->retval);
1701 if (vam->async_mode)
1703 vam->async_errors += (retval < 0);
1707 vam->retval = retval;
1708 vam->result_ready = 1;
1712 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1713 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1715 vat_main_t *vam = &vat_main;
1716 vat_json_node_t node;
1718 vat_json_init_object (&node);
1719 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1720 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1721 ntohl (mp->sw_if_index));
1723 vat_json_print (vam->ofp, &node);
1724 vat_json_free (&node);
1726 vam->retval = ntohl (mp->retval);
1727 vam->result_ready = 1;
1730 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1731 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1733 vat_main_t *vam = &vat_main;
1734 i32 retval = ntohl (mp->retval);
1735 if (vam->async_mode)
1737 vam->async_errors += (retval < 0);
1741 vam->retval = retval;
1742 vam->sw_if_index = ntohl (mp->sw_if_index);
1743 vam->result_ready = 1;
1747 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1748 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1750 vat_main_t *vam = &vat_main;
1751 vat_json_node_t node;
1753 vat_json_init_object (&node);
1754 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1755 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1757 vat_json_print (vam->ofp, &node);
1758 vat_json_free (&node);
1760 vam->retval = ntohl (mp->retval);
1761 vam->result_ready = 1;
1764 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1765 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1767 vat_main_t *vam = &vat_main;
1768 i32 retval = ntohl (mp->retval);
1769 if (vam->async_mode)
1771 vam->async_errors += (retval < 0);
1775 vam->retval = retval;
1776 vam->result_ready = 1;
1780 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1781 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1783 vat_main_t *vam = &vat_main;
1784 vat_json_node_t node;
1786 vat_json_init_object (&node);
1787 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_object_add_uint (&node, "fwd_entry_index",
1789 clib_net_to_host_u32 (mp->fwd_entry_index));
1791 vat_json_print (vam->ofp, &node);
1792 vat_json_free (&node);
1794 vam->retval = ntohl (mp->retval);
1795 vam->result_ready = 1;
1799 format_lisp_transport_protocol (u8 * s, va_list * args)
1801 u32 proto = va_arg (*args, u32);
1806 return format (s, "udp");
1808 return format (s, "api");
1815 static void vl_api_one_get_transport_protocol_reply_t_handler
1816 (vl_api_one_get_transport_protocol_reply_t * mp)
1818 vat_main_t *vam = &vat_main;
1819 i32 retval = ntohl (mp->retval);
1820 if (vam->async_mode)
1822 vam->async_errors += (retval < 0);
1826 u32 proto = mp->protocol;
1827 print (vam->ofp, "Transport protocol: %U",
1828 format_lisp_transport_protocol, proto);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_one_get_transport_protocol_reply_t_handler_json
1835 (vl_api_one_get_transport_protocol_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1841 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
1844 vat_json_init_object (&node);
1845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1846 vat_json_object_add_string_copy (&node, "transport-protocol", s);
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_one_add_del_locator_set_reply_t_handler
1857 (vl_api_one_add_del_locator_set_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->result_ready = 1;
1872 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1873 (vl_api_one_add_del_locator_set_reply_t * mp)
1875 vat_main_t *vam = &vat_main;
1876 vat_json_node_t node;
1878 vat_json_init_object (&node);
1879 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1880 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1882 vat_json_print (vam->ofp, &node);
1883 vat_json_free (&node);
1885 vam->retval = ntohl (mp->retval);
1886 vam->result_ready = 1;
1889 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1890 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 i32 retval = ntohl (mp->retval);
1894 if (vam->async_mode)
1896 vam->async_errors += (retval < 0);
1900 vam->retval = retval;
1901 vam->sw_if_index = ntohl (mp->sw_if_index);
1902 vam->result_ready = 1;
1906 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1907 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 vat_json_node_t node;
1912 vat_json_init_object (&node);
1913 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1914 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1916 vat_json_print (vam->ofp, &node);
1917 vat_json_free (&node);
1919 vam->retval = ntohl (mp->retval);
1920 vam->result_ready = 1;
1923 static void vl_api_geneve_add_del_tunnel_reply_t_handler
1924 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 i32 retval = ntohl (mp->retval);
1928 if (vam->async_mode)
1930 vam->async_errors += (retval < 0);
1934 vam->retval = retval;
1935 vam->sw_if_index = ntohl (mp->sw_if_index);
1936 vam->result_ready = 1;
1940 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
1941 (vl_api_geneve_add_del_tunnel_reply_t * mp)
1943 vat_main_t *vam = &vat_main;
1944 vat_json_node_t node;
1946 vat_json_init_object (&node);
1947 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1948 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1950 vat_json_print (vam->ofp, &node);
1951 vat_json_free (&node);
1953 vam->retval = ntohl (mp->retval);
1954 vam->result_ready = 1;
1957 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1958 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 i32 retval = ntohl (mp->retval);
1962 if (vam->async_mode)
1964 vam->async_errors += (retval < 0);
1968 vam->retval = retval;
1969 vam->sw_if_index = ntohl (mp->sw_if_index);
1970 vam->result_ready = 1;
1974 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1975 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1977 vat_main_t *vam = &vat_main;
1978 vat_json_node_t node;
1980 vat_json_init_object (&node);
1981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1982 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1984 vat_json_print (vam->ofp, &node);
1985 vat_json_free (&node);
1987 vam->retval = ntohl (mp->retval);
1988 vam->result_ready = 1;
1991 static void vl_api_gre_add_del_tunnel_reply_t_handler
1992 (vl_api_gre_add_del_tunnel_reply_t * mp)
1994 vat_main_t *vam = &vat_main;
1995 i32 retval = ntohl (mp->retval);
1996 if (vam->async_mode)
1998 vam->async_errors += (retval < 0);
2002 vam->retval = retval;
2003 vam->sw_if_index = ntohl (mp->sw_if_index);
2004 vam->result_ready = 1;
2008 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2009 (vl_api_gre_add_del_tunnel_reply_t * mp)
2011 vat_main_t *vam = &vat_main;
2012 vat_json_node_t node;
2014 vat_json_init_object (&node);
2015 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2016 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2018 vat_json_print (vam->ofp, &node);
2019 vat_json_free (&node);
2021 vam->retval = ntohl (mp->retval);
2022 vam->result_ready = 1;
2025 static void vl_api_create_vhost_user_if_reply_t_handler
2026 (vl_api_create_vhost_user_if_reply_t * mp)
2028 vat_main_t *vam = &vat_main;
2029 i32 retval = ntohl (mp->retval);
2030 if (vam->async_mode)
2032 vam->async_errors += (retval < 0);
2036 vam->retval = retval;
2037 vam->sw_if_index = ntohl (mp->sw_if_index);
2038 vam->result_ready = 1;
2042 static void vl_api_create_vhost_user_if_reply_t_handler_json
2043 (vl_api_create_vhost_user_if_reply_t * mp)
2045 vat_main_t *vam = &vat_main;
2046 vat_json_node_t node;
2048 vat_json_init_object (&node);
2049 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2050 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2052 vat_json_print (vam->ofp, &node);
2053 vat_json_free (&node);
2055 vam->retval = ntohl (mp->retval);
2056 vam->result_ready = 1;
2059 static clib_error_t *
2060 receive_fd_msg (int socket_fd, int *my_fd)
2063 char ctl[CMSG_SPACE (sizeof (int)) + CMSG_SPACE (sizeof (struct ucred))];
2064 struct msghdr mh = { 0 };
2065 struct iovec iov[1];
2067 struct ucred *cr = 0;
2068 struct cmsghdr *cmsg;
2069 pid_t pid __attribute__ ((unused));
2070 uid_t uid __attribute__ ((unused));
2071 gid_t gid __attribute__ ((unused));
2073 iov[0].iov_base = msgbuf;
2077 mh.msg_control = ctl;
2078 mh.msg_controllen = sizeof (ctl);
2080 memset (ctl, 0, sizeof (ctl));
2082 /* receive the incoming message */
2083 size = recvmsg (socket_fd, &mh, 0);
2086 return (size == 0) ? clib_error_return (0, "disconnected") :
2087 clib_error_return_unix (0, "recvmsg: malformed message (fd %d)",
2091 cmsg = CMSG_FIRSTHDR (&mh);
2094 if (cmsg->cmsg_level == SOL_SOCKET)
2096 if (cmsg->cmsg_type == SCM_CREDENTIALS)
2098 cr = (struct ucred *) CMSG_DATA (cmsg);
2103 else if (cmsg->cmsg_type == SCM_RIGHTS)
2105 clib_memcpy (my_fd, CMSG_DATA (cmsg), sizeof (int));
2108 cmsg = CMSG_NXTHDR (&mh, cmsg);
2113 static void vl_api_memfd_segment_create_reply_t_handler
2114 (vl_api_memfd_segment_create_reply_t * mp)
2116 /* Dont bother in the builtin version */
2117 #if VPP_API_TEST_BUILTIN == 0
2118 vat_main_t *vam = &vat_main;
2119 api_main_t *am = &api_main;
2120 socket_client_main_t *scm = &vam->socket_client_main;
2122 clib_error_t *error;
2123 memfd_private_t memfd;
2124 i32 retval = ntohl (mp->retval);
2128 error = receive_fd_msg (scm->socket_fd, &my_fd);
2135 memset (&memfd, 0, sizeof (memfd));
2138 vam->client_index_invalid = 1;
2140 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("not implemented");
2215 static void vl_api_dns_resolve_ip_reply_t_handler
2216 (vl_api_dns_resolve_ip_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->result_ready = 1;
2231 clib_warning ("canonical name %s", mp->name);
2234 clib_warning ("retval %d", retval);
2238 static void vl_api_dns_resolve_ip_reply_t_handler_json
2239 (vl_api_dns_resolve_ip_reply_t * mp)
2241 clib_warning ("not implemented");
2245 static void vl_api_ip_address_details_t_handler
2246 (vl_api_ip_address_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_address_details_t empty_ip_address_details = { {0} };
2250 ip_address_details_t *address = NULL;
2251 ip_details_t *current_ip_details = NULL;
2252 ip_details_t *details = NULL;
2254 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2256 if (!details || vam->current_sw_if_index >= vec_len (details)
2257 || !details[vam->current_sw_if_index].present)
2259 errmsg ("ip address details arrived but not stored");
2260 errmsg ("ip_dump should be called first");
2264 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2266 #define addresses (current_ip_details->addr)
2268 vec_validate_init_empty (addresses, vec_len (addresses),
2269 empty_ip_address_details);
2271 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2273 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2274 address->prefix_length = mp->prefix_length;
2278 static void vl_api_ip_address_details_t_handler_json
2279 (vl_api_ip_address_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t *node = NULL;
2283 struct in6_addr ip6;
2286 if (VAT_JSON_ARRAY != vam->json_tree.type)
2288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2289 vat_json_init_array (&vam->json_tree);
2291 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2296 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2297 vat_json_object_add_ip6 (node, "ip", ip6);
2301 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2302 vat_json_object_add_ip4 (node, "ip", ip4);
2304 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2308 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 static ip_details_t empty_ip_details = { 0 };
2312 ip_details_t *ip = NULL;
2313 u32 sw_if_index = ~0;
2315 sw_if_index = ntohl (mp->sw_if_index);
2317 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2318 sw_if_index, empty_ip_details);
2320 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2327 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2331 if (VAT_JSON_ARRAY != vam->json_tree.type)
2333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2334 vat_json_init_array (&vam->json_tree);
2336 vat_json_array_add_uint (&vam->json_tree,
2337 clib_net_to_host_u32 (mp->sw_if_index));
2340 static void vl_api_map_domain_details_t_handler_json
2341 (vl_api_map_domain_details_t * mp)
2343 vat_json_node_t *node = NULL;
2344 vat_main_t *vam = &vat_main;
2345 struct in6_addr ip6;
2348 if (VAT_JSON_ARRAY != vam->json_tree.type)
2350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2351 vat_json_init_array (&vam->json_tree);
2354 node = vat_json_array_add (&vam->json_tree);
2355 vat_json_init_object (node);
2357 vat_json_object_add_uint (node, "domain_index",
2358 clib_net_to_host_u32 (mp->domain_index));
2359 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2361 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2362 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2363 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2364 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2365 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2366 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2367 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2368 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2369 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2370 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2371 vat_json_object_add_uint (node, "flags", mp->flags);
2372 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2373 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2376 static void vl_api_map_domain_details_t_handler
2377 (vl_api_map_domain_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2381 if (mp->is_translation)
2384 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2385 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2386 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2387 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2388 clib_net_to_host_u32 (mp->domain_index));
2393 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2394 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2395 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2396 format_ip6_address, mp->ip6_src,
2397 clib_net_to_host_u32 (mp->domain_index));
2399 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2400 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2401 mp->is_translation ? "map-t" : "");
2404 static void vl_api_map_rule_details_t_handler_json
2405 (vl_api_map_rule_details_t * mp)
2407 struct in6_addr ip6;
2408 vat_json_node_t *node = NULL;
2409 vat_main_t *vam = &vat_main;
2411 if (VAT_JSON_ARRAY != vam->json_tree.type)
2413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2414 vat_json_init_array (&vam->json_tree);
2417 node = vat_json_array_add (&vam->json_tree);
2418 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2421 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2422 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2426 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2430 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2434 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2436 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2437 "router_addr %U host_mac %U",
2438 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2439 format_ip4_address, &mp->host_address,
2440 format_ip4_address, &mp->router_address,
2441 format_ethernet_address, mp->host_mac);
2444 static void vl_api_dhcp_compl_event_t_handler_json
2445 (vl_api_dhcp_compl_event_t * mp)
2447 /* JSON output not supported */
2451 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2454 vat_main_t *vam = &vat_main;
2455 static u64 default_counter = 0;
2457 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2459 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2460 sw_if_index, default_counter);
2461 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2465 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2466 interface_counter_t counter)
2468 vat_main_t *vam = &vat_main;
2469 static interface_counter_t default_counter = { 0, };
2471 vec_validate_init_empty (vam->combined_interface_counters,
2472 vnet_counter_type, NULL);
2473 vec_validate_init_empty (vam->combined_interface_counters
2474 [vnet_counter_type], sw_if_index, default_counter);
2475 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2478 static void vl_api_vnet_interface_simple_counters_t_handler
2479 (vl_api_vnet_interface_simple_counters_t * mp)
2484 static void vl_api_vnet_interface_combined_counters_t_handler
2485 (vl_api_vnet_interface_combined_counters_t * mp)
2490 static void vl_api_vnet_interface_simple_counters_t_handler_json
2491 (vl_api_vnet_interface_simple_counters_t * mp)
2496 u32 first_sw_if_index;
2499 count = ntohl (mp->count);
2500 first_sw_if_index = ntohl (mp->first_sw_if_index);
2502 v_packets = (u64 *) & mp->data;
2503 for (i = 0; i < count; i++)
2505 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2506 set_simple_interface_counter (mp->vnet_counter_type,
2507 first_sw_if_index + i, packets);
2512 static void vl_api_vnet_interface_combined_counters_t_handler_json
2513 (vl_api_vnet_interface_combined_counters_t * mp)
2515 interface_counter_t counter;
2517 u32 first_sw_if_index;
2521 count = ntohl (mp->count);
2522 first_sw_if_index = ntohl (mp->first_sw_if_index);
2524 v = (vlib_counter_t *) & mp->data;
2525 for (i = 0; i < count; i++)
2528 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2530 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2531 set_combined_interface_counter (mp->vnet_counter_type,
2532 first_sw_if_index + i, counter);
2538 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2540 vat_main_t *vam = &vat_main;
2543 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2545 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2554 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2556 vat_main_t *vam = &vat_main;
2559 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2561 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2569 static void vl_api_vnet_ip4_fib_counters_t_handler
2570 (vl_api_vnet_ip4_fib_counters_t * mp)
2575 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2576 (vl_api_vnet_ip4_fib_counters_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 vl_api_ip4_fib_counter_t *v;
2580 ip4_fib_counter_t *counter;
2587 vrf_id = ntohl (mp->vrf_id);
2588 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2589 if (~0 == vrf_index)
2591 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2592 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2593 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2594 vec_validate (vam->ip4_fib_counters, vrf_index);
2595 vam->ip4_fib_counters[vrf_index] = NULL;
2598 vec_free (vam->ip4_fib_counters[vrf_index]);
2599 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2600 count = ntohl (mp->count);
2601 for (i = 0; i < count; i++)
2603 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2604 counter = &vam->ip4_fib_counters[vrf_index][i];
2605 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2606 counter->address = ip4;
2607 counter->address_length = v->address_length;
2608 counter->packets = clib_net_to_host_u64 (v->packets);
2609 counter->bytes = clib_net_to_host_u64 (v->bytes);
2614 static void vl_api_vnet_ip4_nbr_counters_t_handler
2615 (vl_api_vnet_ip4_nbr_counters_t * mp)
2620 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2621 (vl_api_vnet_ip4_nbr_counters_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vl_api_ip4_nbr_counter_t *v;
2625 ip4_nbr_counter_t *counter;
2630 sw_if_index = ntohl (mp->sw_if_index);
2631 count = ntohl (mp->count);
2632 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2635 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2637 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2638 for (i = 0; i < count; i++)
2640 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2641 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2642 counter->address.s_addr = v->address;
2643 counter->packets = clib_net_to_host_u64 (v->packets);
2644 counter->bytes = clib_net_to_host_u64 (v->bytes);
2645 counter->linkt = v->link_type;
2650 static void vl_api_vnet_ip6_fib_counters_t_handler
2651 (vl_api_vnet_ip6_fib_counters_t * mp)
2656 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2657 (vl_api_vnet_ip6_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip6_fib_counter_t *v;
2661 ip6_fib_counter_t *counter;
2662 struct in6_addr ip6;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip6_fib_counters, vrf_index);
2676 vam->ip6_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip6_fib_counters[vrf_index]);
2680 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2685 counter = &vam->ip6_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2687 counter->address = ip6;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip6_nbr_counters_t_handler
2696 (vl_api_vnet_ip6_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip6_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip6_nbr_counter_t *v;
2706 ip6_nbr_counter_t *counter;
2707 struct in6_addr ip6;
2712 sw_if_index = ntohl (mp->sw_if_index);
2713 count = ntohl (mp->count);
2714 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2717 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2719 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2720 for (i = 0; i < count; i++)
2722 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2723 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2724 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2725 counter->address = ip6;
2726 counter->packets = clib_net_to_host_u64 (v->packets);
2727 counter->bytes = clib_net_to_host_u64 (v->bytes);
2732 static void vl_api_get_first_msg_id_reply_t_handler
2733 (vl_api_get_first_msg_id_reply_t * mp)
2735 vat_main_t *vam = &vat_main;
2736 i32 retval = ntohl (mp->retval);
2738 if (vam->async_mode)
2740 vam->async_errors += (retval < 0);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2753 static void vl_api_get_first_msg_id_reply_t_handler_json
2754 (vl_api_get_first_msg_id_reply_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t node;
2759 vat_json_init_object (&node);
2760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2761 vat_json_object_add_uint (&node, "first_msg_id",
2762 (uint) ntohs (mp->first_msg_id));
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2771 static void vl_api_get_node_graph_reply_t_handler
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2776 i32 retval = ntohl (mp->retval);
2777 u8 *pvt_copy, *reply;
2782 if (vam->async_mode)
2784 vam->async_errors += (retval < 0);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2792 /* "Should never happen..." */
2796 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2797 pvt_copy = vec_dup (reply);
2799 /* Toss the shared-memory original... */
2800 pthread_mutex_lock (&am->vlib_rp->mutex);
2801 oldheap = svm_push_data_heap (am->vlib_rp);
2805 svm_pop_heap (oldheap);
2806 pthread_mutex_unlock (&am->vlib_rp->mutex);
2808 if (vam->graph_nodes)
2810 hash_free (vam->graph_node_index_by_name);
2812 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2814 node = vam->graph_nodes[i];
2815 vec_free (node->name);
2816 vec_free (node->next_nodes);
2819 vec_free (vam->graph_nodes);
2822 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2823 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2824 vec_free (pvt_copy);
2826 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2828 node = vam->graph_nodes[i];
2829 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2833 static void vl_api_get_node_graph_reply_t_handler_json
2834 (vl_api_get_node_graph_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 api_main_t *am = &api_main;
2839 vat_json_node_t node;
2842 /* $$$$ make this real? */
2843 vat_json_init_object (&node);
2844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2845 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2847 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2849 /* Toss the shared-memory original... */
2850 pthread_mutex_lock (&am->vlib_rp->mutex);
2851 oldheap = svm_push_data_heap (am->vlib_rp);
2855 svm_pop_heap (oldheap);
2856 pthread_mutex_unlock (&am->vlib_rp->mutex);
2858 vat_json_print (vam->ofp, &node);
2859 vat_json_free (&node);
2861 vam->retval = ntohl (mp->retval);
2862 vam->result_ready = 1;
2866 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2873 s = format (s, "%=16d%=16d%=16d",
2874 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2878 s = format (s, "%=16U%=16d%=16d",
2879 mp->is_ipv6 ? format_ip6_address :
2881 mp->ip_address, mp->priority, mp->weight);
2884 print (vam->ofp, "%v", s);
2889 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2892 vat_json_node_t *node = NULL;
2893 struct in6_addr ip6;
2896 if (VAT_JSON_ARRAY != vam->json_tree.type)
2898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2899 vat_json_init_array (&vam->json_tree);
2901 node = vat_json_array_add (&vam->json_tree);
2902 vat_json_init_object (node);
2904 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2905 vat_json_object_add_uint (node, "priority", mp->priority);
2906 vat_json_object_add_uint (node, "weight", mp->weight);
2909 vat_json_object_add_uint (node, "sw_if_index",
2910 clib_net_to_host_u32 (mp->sw_if_index));
2915 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2916 vat_json_object_add_ip6 (node, "address", ip6);
2920 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2921 vat_json_object_add_ip4 (node, "address", ip4);
2927 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2930 vat_main_t *vam = &vat_main;
2933 ls_name = format (0, "%s", mp->ls_name);
2935 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2941 vl_api_one_locator_set_details_t_handler_json
2942 (vl_api_one_locator_set_details_t * mp)
2944 vat_main_t *vam = &vat_main;
2945 vat_json_node_t *node = 0;
2948 ls_name = format (0, "%s", mp->ls_name);
2949 vec_add1 (ls_name, 0);
2951 if (VAT_JSON_ARRAY != vam->json_tree.type)
2953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2954 vat_json_init_array (&vam->json_tree);
2956 node = vat_json_array_add (&vam->json_tree);
2958 vat_json_init_object (node);
2959 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2960 vat_json_object_add_uint (node, "ls_index",
2961 clib_net_to_host_u32 (mp->ls_index));
2969 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2972 unformat_nsh_address (unformat_input_t * input, va_list * args)
2974 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2975 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2979 format_nsh_address_vat (u8 * s, va_list * args)
2981 nsh_t *a = va_arg (*args, nsh_t *);
2982 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2986 format_lisp_flat_eid (u8 * s, va_list * args)
2988 u32 type = va_arg (*args, u32);
2989 u8 *eid = va_arg (*args, u8 *);
2990 u32 eid_len = va_arg (*args, u32);
2995 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2997 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2999 return format (s, "%U", format_ethernet_address, eid);
3001 return format (s, "%U", format_nsh_address_vat, eid);
3007 format_lisp_eid_vat (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3012 u8 *seid = va_arg (*args, u8 *);
3013 u32 seid_len = va_arg (*args, u32);
3014 u32 is_src_dst = va_arg (*args, u32);
3017 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3019 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3025 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3027 vat_main_t *vam = &vat_main;
3028 u8 *s = 0, *eid = 0;
3030 if (~0 == mp->locator_set_index)
3031 s = format (0, "action: %d", mp->action);
3033 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3035 eid = format (0, "%U", format_lisp_eid_vat,
3039 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3042 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3043 clib_net_to_host_u32 (mp->vni),
3045 mp->is_local ? "local" : "remote",
3046 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3047 clib_net_to_host_u16 (mp->key_id), mp->key);
3054 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3057 vat_main_t *vam = &vat_main;
3058 vat_json_node_t *node = 0;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 if (~0 == mp->locator_set_index)
3070 vat_json_object_add_uint (node, "action", mp->action);
3072 vat_json_object_add_uint (node, "locator_set_index",
3073 clib_net_to_host_u32 (mp->locator_set_index));
3075 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3076 if (mp->eid_type == 3)
3078 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3079 vat_json_init_object (nsh_json);
3080 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3081 vat_json_object_add_uint (nsh_json, "spi",
3082 clib_net_to_host_u32 (nsh->spi));
3083 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3087 eid = format (0, "%U", format_lisp_eid_vat,
3091 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3093 vat_json_object_add_string_copy (node, "eid", eid);
3096 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3097 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3098 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3102 vat_json_object_add_uint (node, "key_id",
3103 clib_net_to_host_u16 (mp->key_id));
3104 vat_json_object_add_string_copy (node, "key", mp->key);
3109 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *seid = 0, *deid = 0;
3113 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3115 deid = format (0, "%U", format_lisp_eid_vat,
3116 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3118 seid = format (0, "%U", format_lisp_eid_vat,
3119 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3125 format_ip_address_fcn = format_ip4_address;
3127 format_ip_address_fcn = format_ip6_address;
3130 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3131 clib_net_to_host_u32 (mp->vni),
3133 format_ip_address_fcn, mp->lloc,
3134 format_ip_address_fcn, mp->rloc,
3135 clib_net_to_host_u32 (mp->pkt_count),
3136 clib_net_to_host_u32 (mp->bytes));
3143 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3145 struct in6_addr ip6;
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = 0;
3149 u8 *deid = 0, *seid = 0;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 deid = format (0, "%U", format_lisp_eid_vat,
3160 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3162 seid = format (0, "%U", format_lisp_eid_vat,
3163 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3168 vat_json_object_add_string_copy (node, "seid", seid);
3169 vat_json_object_add_string_copy (node, "deid", deid);
3170 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3174 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3175 vat_json_object_add_ip4 (node, "lloc", ip4);
3176 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3177 vat_json_object_add_ip4 (node, "rloc", ip4);
3181 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3182 vat_json_object_add_ip6 (node, "lloc", ip6);
3183 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3184 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 vat_json_object_add_uint (node, "pkt_count",
3187 clib_net_to_host_u32 (mp->pkt_count));
3188 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3195 vl_api_one_eid_table_map_details_t_handler
3196 (vl_api_one_eid_table_map_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3200 u8 *line = format (0, "%=10d%=10d",
3201 clib_net_to_host_u32 (mp->vni),
3202 clib_net_to_host_u32 (mp->dp_table));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_map_details_t_handler_json
3209 (vl_api_one_eid_table_map_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "dp_table",
3222 clib_net_to_host_u32 (mp->dp_table));
3223 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3227 vl_api_one_eid_table_vni_details_t_handler
3228 (vl_api_one_eid_table_vni_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3233 print (vam->ofp, "%v", line);
3238 vl_api_one_eid_table_vni_details_t_handler_json
3239 (vl_api_one_eid_table_vni_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3244 if (VAT_JSON_ARRAY != vam->json_tree.type)
3246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3247 vat_json_init_array (&vam->json_tree);
3249 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3256 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 int retval = clib_net_to_host_u32 (mp->retval);
3261 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3262 print (vam->ofp, "fallback threshold value: %d", mp->value);
3264 vam->retval = retval;
3265 vam->result_ready = 1;
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3270 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 vat_json_node_t _node, *node = &_node;
3274 int retval = clib_net_to_host_u32 (mp->retval);
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3277 vat_json_init_object (node);
3278 vat_json_object_add_uint (node, "value", mp->value);
3280 vat_json_print (vam->ofp, node);
3281 vat_json_free (node);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_state_reply_t_handler
3289 (vl_api_show_one_map_register_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_map_register_state_reply_t_handler_json
3302 (vl_api_show_one_map_register_state_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3339 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3367 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3375 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t _node, *node = &_node;
3379 int retval = clib_net_to_host_u32 (mp->retval);
3381 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "state", s);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3394 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3396 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3397 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3398 e->vni = clib_net_to_host_u32 (e->vni);
3402 gpe_fwd_entries_get_reply_t_net_to_host
3403 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3407 mp->count = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < mp->count; i++)
3410 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3415 format_gpe_encap_mode (u8 * s, va_list * args)
3417 u32 mode = va_arg (*args, u32);
3422 return format (s, "lisp");
3424 return format (s, "vxlan");
3430 vl_api_gpe_get_encap_mode_reply_t_handler
3431 (vl_api_gpe_get_encap_mode_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3436 vam->retval = ntohl (mp->retval);
3437 vam->result_ready = 1;
3441 vl_api_gpe_get_encap_mode_reply_t_handler_json
3442 (vl_api_gpe_get_encap_mode_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t node;
3447 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3448 vec_add1 (encap_mode, 0);
3450 vat_json_init_object (&node);
3451 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3453 vec_free (encap_mode);
3454 vat_json_print (vam->ofp, &node);
3455 vat_json_free (&node);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_fwd_entry_path_details_t_handler
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 if (mp->lcl_loc.is_ip4)
3469 format_ip_address_fcn = format_ip4_address;
3471 format_ip_address_fcn = format_ip6_address;
3473 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3474 format_ip_address_fcn, &mp->lcl_loc,
3475 format_ip_address_fcn, &mp->rmt_loc);
3479 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3481 struct in6_addr ip6;
3486 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3487 vat_json_object_add_ip4 (n, "address", ip4);
3491 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3494 vat_json_object_add_uint (n, "weight", loc->weight);
3498 vl_api_gpe_fwd_entry_path_details_t_handler_json
3499 (vl_api_gpe_fwd_entry_path_details_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = NULL;
3503 vat_json_node_t *loc_node;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3513 loc_node = vat_json_object_add (node, "local_locator");
3514 vat_json_init_object (loc_node);
3515 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3517 loc_node = vat_json_object_add (node, "remote_locator");
3518 vat_json_init_object (loc_node);
3519 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3523 vl_api_gpe_fwd_entries_get_reply_t_handler
3524 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *e;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3536 for (i = 0; i < mp->count; i++)
3538 e = &mp->entries[i];
3539 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3540 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3541 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3545 vam->retval = retval;
3546 vam->result_ready = 1;
3550 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3551 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t *e = 0, root;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_fwd_entry_t *fwd;
3563 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3564 vat_json_init_array (&root);
3566 for (i = 0; i < mp->count; i++)
3568 e = vat_json_array_add (&root);
3569 fwd = &mp->entries[i];
3571 vat_json_init_object (e);
3572 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3573 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3574 vat_json_object_add_int (e, "vni", fwd->vni);
3575 vat_json_object_add_int (e, "action", fwd->action);
3577 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3578 fwd->leid_prefix_len);
3580 vat_json_object_add_string_copy (e, "leid", s);
3583 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3584 fwd->reid_prefix_len);
3586 vat_json_object_add_string_copy (e, "reid", s);
3590 vat_json_print (vam->ofp, &root);
3591 vat_json_free (&root);
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3600 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3612 for (i = 0; i < n; i++)
3614 r = &mp->entries[i];
3615 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3616 clib_net_to_host_u32 (r->fib_index),
3617 clib_net_to_host_u32 (r->nh_sw_if_index),
3618 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3627 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3628 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t root, *e;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3634 vl_api_gpe_native_fwd_rpath_t *r;
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3645 e = vat_json_array_add (&root);
3646 vat_json_init_object (e);
3647 r = &mp->entries[i];
3649 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3652 vat_json_object_add_string_copy (e, "ip4", s);
3655 vat_json_object_add_uint (e, "fib_index",
3656 clib_net_to_host_u32 (r->fib_index));
3657 vat_json_object_add_uint (e, "nh_sw_if_index",
3658 clib_net_to_host_u32 (r->nh_sw_if_index));
3661 vat_json_print (vam->ofp, &root);
3662 vat_json_free (&root);
3665 vam->retval = retval;
3666 vam->result_ready = 1;
3670 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3671 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3673 vat_main_t *vam = &vat_main;
3675 int retval = clib_net_to_host_u32 (mp->retval);
3680 n = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < n; i++)
3683 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t root;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3702 n = clib_net_to_host_u32 (mp->count);
3703 vat_json_init_array (&root);
3705 for (i = 0; i < n; i++)
3706 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3708 vat_json_print (vam->ofp, &root);
3709 vat_json_free (&root);
3712 vam->retval = retval;
3713 vam->result_ready = 1;
3717 vl_api_one_ndp_entries_get_reply_t_handler
3718 (vl_api_one_ndp_entries_get_reply_t * mp)
3720 vat_main_t *vam = &vat_main;
3722 int retval = clib_net_to_host_u32 (mp->retval);
3727 n = clib_net_to_host_u32 (mp->count);
3729 for (i = 0; i < n; i++)
3730 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3731 format_ethernet_address, mp->entries[i].mac);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_one_ndp_entries_get_reply_t_handler_json
3740 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3744 vat_json_node_t *e = 0, root;
3746 int retval = clib_net_to_host_u32 (mp->retval);
3747 vl_api_one_ndp_entry_t *arp_entry;
3752 n = clib_net_to_host_u32 (mp->count);
3753 vat_json_init_array (&root);
3755 for (i = 0; i < n; i++)
3757 e = vat_json_array_add (&root);
3758 arp_entry = &mp->entries[i];
3760 vat_json_init_object (e);
3761 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3764 vat_json_object_add_string_copy (e, "mac", s);
3767 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3769 vat_json_object_add_string_copy (e, "ip6", s);
3773 vat_json_print (vam->ofp, &root);
3774 vat_json_free (&root);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_one_l2_arp_entries_get_reply_t_handler
3783 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3787 int retval = clib_net_to_host_u32 (mp->retval);
3792 n = clib_net_to_host_u32 (mp->count);
3794 for (i = 0; i < n; i++)
3795 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3796 format_ethernet_address, mp->entries[i].mac);
3799 vam->retval = retval;
3800 vam->result_ready = 1;
3804 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3805 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *e = 0, root;
3811 int retval = clib_net_to_host_u32 (mp->retval);
3812 vl_api_one_l2_arp_entry_t *arp_entry;
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 e = vat_json_array_add (&root);
3823 arp_entry = &mp->entries[i];
3825 vat_json_init_object (e);
3826 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3829 vat_json_object_add_string_copy (e, "mac", s);
3832 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3834 vat_json_object_add_string_copy (e, "ip4", s);
3838 vat_json_print (vam->ofp, &root);
3839 vat_json_free (&root);
3842 vam->retval = retval;
3843 vam->result_ready = 1;
3847 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3858 for (i = 0; i < n; i++)
3860 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_ndp_bd_get_reply_t_handler_json
3870 (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3873 vat_json_node_t root;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3880 n = clib_net_to_host_u32 (mp->count);
3881 vat_json_init_array (&root);
3883 for (i = 0; i < n; i++)
3885 vat_json_array_add_uint (&root,
3886 clib_net_to_host_u32 (mp->bridge_domains[i]));
3889 vat_json_print (vam->ofp, &root);
3890 vat_json_free (&root);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_one_l2_arp_bd_get_reply_t_handler
3899 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3908 n = clib_net_to_host_u32 (mp->count);
3910 for (i = 0; i < n; i++)
3912 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 vat_json_node_t root;
3927 int retval = clib_net_to_host_u32 (mp->retval);
3932 n = clib_net_to_host_u32 (mp->count);
3933 vat_json_init_array (&root);
3935 for (i = 0; i < n; i++)
3937 vat_json_array_add_uint (&root,
3938 clib_net_to_host_u32 (mp->bridge_domains[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_adjacencies_get_reply_t_handler
3951 (vl_api_one_adjacencies_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3965 a = &mp->adjacencies[i];
3966 print (vam->ofp, "%U %40U",
3967 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3968 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_one_adjacencies_get_reply_t_handler_json
3978 (vl_api_one_adjacencies_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3982 vat_json_node_t *e = 0, root;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3985 vl_api_one_adjacency_t *a;
3990 n = clib_net_to_host_u32 (mp->count);
3991 vat_json_init_array (&root);
3993 for (i = 0; i < n; i++)
3995 e = vat_json_array_add (&root);
3996 a = &mp->adjacencies[i];
3998 vat_json_init_object (e);
3999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4000 a->leid_prefix_len);
4002 vat_json_object_add_string_copy (e, "leid", s);
4005 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4006 a->reid_prefix_len);
4008 vat_json_object_add_string_copy (e, "reid", s);
4012 vat_json_print (vam->ofp, &root);
4013 vat_json_free (&root);
4016 vam->retval = retval;
4017 vam->result_ready = 1;
4021 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 print (vam->ofp, "%=20U",
4026 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4031 vl_api_one_map_server_details_t_handler_json
4032 (vl_api_one_map_server_details_t * mp)
4034 vat_main_t *vam = &vat_main;
4035 vat_json_node_t *node = NULL;
4036 struct in6_addr ip6;
4039 if (VAT_JSON_ARRAY != vam->json_tree.type)
4041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4042 vat_json_init_array (&vam->json_tree);
4044 node = vat_json_array_add (&vam->json_tree);
4046 vat_json_init_object (node);
4049 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4050 vat_json_object_add_ip6 (node, "map-server", ip6);
4054 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4055 vat_json_object_add_ip4 (node, "map-server", ip4);
4060 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4063 vat_main_t *vam = &vat_main;
4065 print (vam->ofp, "%=20U",
4066 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4071 vl_api_one_map_resolver_details_t_handler_json
4072 (vl_api_one_map_resolver_details_t * mp)
4074 vat_main_t *vam = &vat_main;
4075 vat_json_node_t *node = NULL;
4076 struct in6_addr ip6;
4079 if (VAT_JSON_ARRAY != vam->json_tree.type)
4081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4082 vat_json_init_array (&vam->json_tree);
4084 node = vat_json_array_add (&vam->json_tree);
4086 vat_json_init_object (node);
4089 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4090 vat_json_object_add_ip6 (node, "map resolver", ip6);
4094 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4095 vat_json_object_add_ip4 (node, "map resolver", ip4);
4100 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 print (vam->ofp, "feature: %s\ngpe: %s",
4108 mp->feature_status ? "enabled" : "disabled",
4109 mp->gpe_status ? "enabled" : "disabled");
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_status_reply_t_handler_json
4118 (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4122 u8 *gpe_status = NULL;
4123 u8 *feature_status = NULL;
4125 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4126 feature_status = format (0, "%s",
4127 mp->feature_status ? "enabled" : "disabled");
4128 vec_add1 (gpe_status, 0);
4129 vec_add1 (feature_status, 0);
4131 vat_json_init_object (&node);
4132 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4133 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4135 vec_free (gpe_status);
4136 vec_free (feature_status);
4138 vat_json_print (vam->ofp, &node);
4139 vat_json_free (&node);
4141 vam->retval = ntohl (mp->retval);
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 i32 retval = ntohl (mp->retval);
4154 print (vam->ofp, "%=20s", mp->locator_set_name);
4157 vam->retval = retval;
4158 vam->result_ready = 1;
4162 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4163 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4166 vat_json_node_t *node = NULL;
4168 if (VAT_JSON_ARRAY != vam->json_tree.type)
4170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4171 vat_json_init_array (&vam->json_tree);
4173 node = vat_json_array_add (&vam->json_tree);
4175 vat_json_init_object (node);
4176 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4178 vat_json_print (vam->ofp, node);
4179 vat_json_free (node);
4181 vam->retval = ntohl (mp->retval);
4182 vam->result_ready = 1;
4186 format_lisp_map_request_mode (u8 * s, va_list * args)
4188 u32 mode = va_arg (*args, u32);
4193 return format (0, "dst-only");
4195 return format (0, "src-dst");
4201 vl_api_show_one_map_request_mode_reply_t_handler
4202 (vl_api_show_one_map_request_mode_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 i32 retval = ntohl (mp->retval);
4209 u32 mode = mp->mode;
4210 print (vam->ofp, "map_request_mode: %U",
4211 format_lisp_map_request_mode, mode);
4214 vam->retval = retval;
4215 vam->result_ready = 1;
4219 vl_api_show_one_map_request_mode_reply_t_handler_json
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 vat_json_node_t node;
4228 s = format (0, "%U", format_lisp_map_request_mode, mode);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4233 vat_json_print (vam->ofp, &node);
4234 vat_json_free (&node);
4237 vam->retval = ntohl (mp->retval);
4238 vam->result_ready = 1;
4242 vl_api_one_show_xtr_mode_reply_t_handler
4243 (vl_api_one_show_xtr_mode_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 i32 retval = ntohl (mp->retval);
4250 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4253 vam->retval = retval;
4254 vam->result_ready = 1;
4258 vl_api_one_show_xtr_mode_reply_t_handler_json
4259 (vl_api_one_show_xtr_mode_reply_t * mp)
4261 vat_main_t *vam = &vat_main;
4262 vat_json_node_t node;
4265 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4266 vec_add1 (status, 0);
4268 vat_json_init_object (&node);
4269 vat_json_object_add_string_copy (&node, "status", status);
4273 vat_json_print (vam->ofp, &node);
4274 vat_json_free (&node);
4276 vam->retval = ntohl (mp->retval);
4277 vam->result_ready = 1;
4281 vl_api_one_show_pitr_mode_reply_t_handler
4282 (vl_api_one_show_pitr_mode_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 i32 retval = ntohl (mp->retval);
4289 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4292 vam->retval = retval;
4293 vam->result_ready = 1;
4297 vl_api_one_show_pitr_mode_reply_t_handler_json
4298 (vl_api_one_show_pitr_mode_reply_t * mp)
4300 vat_main_t *vam = &vat_main;
4301 vat_json_node_t node;
4304 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4305 vec_add1 (status, 0);
4307 vat_json_init_object (&node);
4308 vat_json_object_add_string_copy (&node, "status", status);
4312 vat_json_print (vam->ofp, &node);
4313 vat_json_free (&node);
4315 vam->retval = ntohl (mp->retval);
4316 vam->result_ready = 1;
4320 vl_api_one_show_petr_mode_reply_t_handler
4321 (vl_api_one_show_petr_mode_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 i32 retval = ntohl (mp->retval);
4328 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4331 vam->retval = retval;
4332 vam->result_ready = 1;
4336 vl_api_one_show_petr_mode_reply_t_handler_json
4337 (vl_api_one_show_petr_mode_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 vat_json_node_t node;
4343 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4344 vec_add1 (status, 0);
4346 vat_json_init_object (&node);
4347 vat_json_object_add_string_copy (&node, "status", status);
4351 vat_json_print (vam->ofp, &node);
4352 vat_json_free (&node);
4354 vam->retval = ntohl (mp->retval);
4355 vam->result_ready = 1;
4359 vl_api_show_one_use_petr_reply_t_handler
4360 (vl_api_show_one_use_petr_reply_t * mp)
4362 vat_main_t *vam = &vat_main;
4363 i32 retval = ntohl (mp->retval);
4367 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4370 print (vam->ofp, "Proxy-ETR address; %U",
4371 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4376 vam->retval = retval;
4377 vam->result_ready = 1;
4381 vl_api_show_one_use_petr_reply_t_handler_json
4382 (vl_api_show_one_use_petr_reply_t * mp)
4384 vat_main_t *vam = &vat_main;
4385 vat_json_node_t node;
4388 struct in6_addr ip6;
4390 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4391 vec_add1 (status, 0);
4393 vat_json_init_object (&node);
4394 vat_json_object_add_string_copy (&node, "status", status);
4399 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4400 vat_json_object_add_ip6 (&node, "address", ip6);
4404 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4405 vat_json_object_add_ip4 (&node, "address", ip4);
4411 vat_json_print (vam->ofp, &node);
4412 vat_json_free (&node);
4414 vam->retval = ntohl (mp->retval);
4415 vam->result_ready = 1;
4419 vl_api_show_one_nsh_mapping_reply_t_handler
4420 (vl_api_show_one_nsh_mapping_reply_t * mp)
4422 vat_main_t *vam = &vat_main;
4423 i32 retval = ntohl (mp->retval);
4427 print (vam->ofp, "%-20s%-16s",
4428 mp->is_set ? "set" : "not-set",
4429 mp->is_set ? (char *) mp->locator_set_name : "");
4432 vam->retval = retval;
4433 vam->result_ready = 1;
4437 vl_api_show_one_nsh_mapping_reply_t_handler_json
4438 (vl_api_show_one_nsh_mapping_reply_t * mp)
4440 vat_main_t *vam = &vat_main;
4441 vat_json_node_t node;
4444 status = format (0, "%s", mp->is_set ? "yes" : "no");
4445 vec_add1 (status, 0);
4447 vat_json_init_object (&node);
4448 vat_json_object_add_string_copy (&node, "is_set", status);
4451 vat_json_object_add_string_copy (&node, "locator_set",
4452 mp->locator_set_name);
4457 vat_json_print (vam->ofp, &node);
4458 vat_json_free (&node);
4460 vam->retval = ntohl (mp->retval);
4461 vam->result_ready = 1;
4465 vl_api_show_one_map_register_ttl_reply_t_handler
4466 (vl_api_show_one_map_register_ttl_reply_t * mp)
4468 vat_main_t *vam = &vat_main;
4469 i32 retval = ntohl (mp->retval);
4471 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4475 print (vam->ofp, "ttl: %u", mp->ttl);
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_show_one_map_register_ttl_reply_t_handler_json
4484 (vl_api_show_one_map_register_ttl_reply_t * mp)
4486 vat_main_t *vam = &vat_main;
4487 vat_json_node_t node;
4489 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4490 vat_json_init_object (&node);
4491 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4493 vat_json_print (vam->ofp, &node);
4494 vat_json_free (&node);
4496 vam->retval = ntohl (mp->retval);
4497 vam->result_ready = 1;
4501 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4503 vat_main_t *vam = &vat_main;
4504 i32 retval = ntohl (mp->retval);
4508 print (vam->ofp, "%-20s%-16s",
4509 mp->status ? "enabled" : "disabled",
4510 mp->status ? (char *) mp->locator_set_name : "");
4513 vam->retval = retval;
4514 vam->result_ready = 1;
4518 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4520 vat_main_t *vam = &vat_main;
4521 vat_json_node_t node;
4524 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4525 vec_add1 (status, 0);
4527 vat_json_init_object (&node);
4528 vat_json_object_add_string_copy (&node, "status", status);
4531 vat_json_object_add_string_copy (&node, "locator_set",
4532 mp->locator_set_name);
4537 vat_json_print (vam->ofp, &node);
4538 vat_json_free (&node);
4540 vam->retval = ntohl (mp->retval);
4541 vam->result_ready = 1;
4545 format_policer_type (u8 * s, va_list * va)
4547 u32 i = va_arg (*va, u32);
4549 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4550 s = format (s, "1r2c");
4551 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4552 s = format (s, "1r3c");
4553 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4554 s = format (s, "2r3c-2698");
4555 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4556 s = format (s, "2r3c-4115");
4557 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4558 s = format (s, "2r3c-mef5cf1");
4560 s = format (s, "ILLEGAL");
4565 format_policer_rate_type (u8 * s, va_list * va)
4567 u32 i = va_arg (*va, u32);
4569 if (i == SSE2_QOS_RATE_KBPS)
4570 s = format (s, "kbps");
4571 else if (i == SSE2_QOS_RATE_PPS)
4572 s = format (s, "pps");
4574 s = format (s, "ILLEGAL");
4579 format_policer_round_type (u8 * s, va_list * va)
4581 u32 i = va_arg (*va, u32);
4583 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4584 s = format (s, "closest");
4585 else if (i == SSE2_QOS_ROUND_TO_UP)
4586 s = format (s, "up");
4587 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4588 s = format (s, "down");
4590 s = format (s, "ILLEGAL");
4595 format_policer_action_type (u8 * s, va_list * va)
4597 u32 i = va_arg (*va, u32);
4599 if (i == SSE2_QOS_ACTION_DROP)
4600 s = format (s, "drop");
4601 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4602 s = format (s, "transmit");
4603 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4604 s = format (s, "mark-and-transmit");
4606 s = format (s, "ILLEGAL");
4611 format_dscp (u8 * s, va_list * va)
4613 u32 i = va_arg (*va, u32);
4618 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4622 return format (s, "ILLEGAL");
4624 s = format (s, "%s", t);
4629 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4631 vat_main_t *vam = &vat_main;
4632 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4634 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4635 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4637 conform_dscp_str = format (0, "");
4639 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4640 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4642 exceed_dscp_str = format (0, "");
4644 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4645 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4647 violate_dscp_str = format (0, "");
4649 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4650 "rate type %U, round type %U, %s rate, %s color-aware, "
4651 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4652 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4653 "conform action %U%s, exceed action %U%s, violate action %U%s",
4655 format_policer_type, mp->type,
4658 clib_net_to_host_u64 (mp->cb),
4659 clib_net_to_host_u64 (mp->eb),
4660 format_policer_rate_type, mp->rate_type,
4661 format_policer_round_type, mp->round_type,
4662 mp->single_rate ? "single" : "dual",
4663 mp->color_aware ? "is" : "not",
4664 ntohl (mp->cir_tokens_per_period),
4665 ntohl (mp->pir_tokens_per_period),
4667 ntohl (mp->current_limit),
4668 ntohl (mp->current_bucket),
4669 ntohl (mp->extended_limit),
4670 ntohl (mp->extended_bucket),
4671 clib_net_to_host_u64 (mp->last_update_time),
4672 format_policer_action_type, mp->conform_action_type,
4674 format_policer_action_type, mp->exceed_action_type,
4676 format_policer_action_type, mp->violate_action_type,
4679 vec_free (conform_dscp_str);
4680 vec_free (exceed_dscp_str);
4681 vec_free (violate_dscp_str);
4684 static void vl_api_policer_details_t_handler_json
4685 (vl_api_policer_details_t * mp)
4687 vat_main_t *vam = &vat_main;
4688 vat_json_node_t *node;
4689 u8 *rate_type_str, *round_type_str, *type_str;
4690 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4692 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4694 format (0, "%U", format_policer_round_type, mp->round_type);
4695 type_str = format (0, "%U", format_policer_type, mp->type);
4696 conform_action_str = format (0, "%U", format_policer_action_type,
4697 mp->conform_action_type);
4698 exceed_action_str = format (0, "%U", format_policer_action_type,
4699 mp->exceed_action_type);
4700 violate_action_str = format (0, "%U", format_policer_action_type,
4701 mp->violate_action_type);
4703 if (VAT_JSON_ARRAY != vam->json_tree.type)
4705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4706 vat_json_init_array (&vam->json_tree);
4708 node = vat_json_array_add (&vam->json_tree);
4710 vat_json_init_object (node);
4711 vat_json_object_add_string_copy (node, "name", mp->name);
4712 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4713 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4714 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4715 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4716 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4717 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4718 vat_json_object_add_string_copy (node, "type", type_str);
4719 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4720 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4721 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4722 vat_json_object_add_uint (node, "cir_tokens_per_period",
4723 ntohl (mp->cir_tokens_per_period));
4724 vat_json_object_add_uint (node, "eir_tokens_per_period",
4725 ntohl (mp->pir_tokens_per_period));
4726 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4727 vat_json_object_add_uint (node, "current_bucket",
4728 ntohl (mp->current_bucket));
4729 vat_json_object_add_uint (node, "extended_limit",
4730 ntohl (mp->extended_limit));
4731 vat_json_object_add_uint (node, "extended_bucket",
4732 ntohl (mp->extended_bucket));
4733 vat_json_object_add_uint (node, "last_update_time",
4734 ntohl (mp->last_update_time));
4735 vat_json_object_add_string_copy (node, "conform_action",
4736 conform_action_str);
4737 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4739 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4740 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4741 vec_free (dscp_str);
4743 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4744 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4746 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4747 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4748 vec_free (dscp_str);
4750 vat_json_object_add_string_copy (node, "violate_action",
4751 violate_action_str);
4752 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4754 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4755 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4756 vec_free (dscp_str);
4759 vec_free (rate_type_str);
4760 vec_free (round_type_str);
4761 vec_free (type_str);
4762 vec_free (conform_action_str);
4763 vec_free (exceed_action_str);
4764 vec_free (violate_action_str);
4768 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4771 vat_main_t *vam = &vat_main;
4772 int i, count = ntohl (mp->count);
4775 print (vam->ofp, "classify table ids (%d) : ", count);
4776 for (i = 0; i < count; i++)
4778 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4779 print (vam->ofp, (i < count - 1) ? "," : "");
4781 vam->retval = ntohl (mp->retval);
4782 vam->result_ready = 1;
4786 vl_api_classify_table_ids_reply_t_handler_json
4787 (vl_api_classify_table_ids_reply_t * mp)
4789 vat_main_t *vam = &vat_main;
4790 int i, count = ntohl (mp->count);
4794 vat_json_node_t node;
4796 vat_json_init_object (&node);
4797 for (i = 0; i < count; i++)
4799 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4801 vat_json_print (vam->ofp, &node);
4802 vat_json_free (&node);
4804 vam->retval = ntohl (mp->retval);
4805 vam->result_ready = 1;
4809 vl_api_classify_table_by_interface_reply_t_handler
4810 (vl_api_classify_table_by_interface_reply_t * mp)
4812 vat_main_t *vam = &vat_main;
4815 table_id = ntohl (mp->l2_table_id);
4817 print (vam->ofp, "l2 table id : %d", table_id);
4819 print (vam->ofp, "l2 table id : No input ACL tables configured");
4820 table_id = ntohl (mp->ip4_table_id);
4822 print (vam->ofp, "ip4 table id : %d", table_id);
4824 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4825 table_id = ntohl (mp->ip6_table_id);
4827 print (vam->ofp, "ip6 table id : %d", table_id);
4829 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4830 vam->retval = ntohl (mp->retval);
4831 vam->result_ready = 1;
4835 vl_api_classify_table_by_interface_reply_t_handler_json
4836 (vl_api_classify_table_by_interface_reply_t * mp)
4838 vat_main_t *vam = &vat_main;
4839 vat_json_node_t node;
4841 vat_json_init_object (&node);
4843 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4844 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4845 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4847 vat_json_print (vam->ofp, &node);
4848 vat_json_free (&node);
4850 vam->retval = ntohl (mp->retval);
4851 vam->result_ready = 1;
4854 static void vl_api_policer_add_del_reply_t_handler
4855 (vl_api_policer_add_del_reply_t * mp)
4857 vat_main_t *vam = &vat_main;
4858 i32 retval = ntohl (mp->retval);
4859 if (vam->async_mode)
4861 vam->async_errors += (retval < 0);
4865 vam->retval = retval;
4866 vam->result_ready = 1;
4867 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4869 * Note: this is just barely thread-safe, depends on
4870 * the main thread spinning waiting for an answer...
4872 errmsg ("policer index %d", ntohl (mp->policer_index));
4876 static void vl_api_policer_add_del_reply_t_handler_json
4877 (vl_api_policer_add_del_reply_t * mp)
4879 vat_main_t *vam = &vat_main;
4880 vat_json_node_t node;
4882 vat_json_init_object (&node);
4883 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4884 vat_json_object_add_uint (&node, "policer_index",
4885 ntohl (mp->policer_index));
4887 vat_json_print (vam->ofp, &node);
4888 vat_json_free (&node);
4890 vam->retval = ntohl (mp->retval);
4891 vam->result_ready = 1;
4894 /* Format hex dump. */
4896 format_hex_bytes (u8 * s, va_list * va)
4898 u8 *bytes = va_arg (*va, u8 *);
4899 int n_bytes = va_arg (*va, int);
4902 /* Print short or long form depending on byte count. */
4903 uword short_form = n_bytes <= 32;
4904 u32 indent = format_get_indent (s);
4909 for (i = 0; i < n_bytes; i++)
4911 if (!short_form && (i % 32) == 0)
4912 s = format (s, "%08x: ", i);
4913 s = format (s, "%02x", bytes[i]);
4914 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4915 s = format (s, "\n%U", format_white_space, indent);
4922 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4925 vat_main_t *vam = &vat_main;
4926 i32 retval = ntohl (mp->retval);
4929 print (vam->ofp, "classify table info :");
4930 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4931 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4932 ntohl (mp->miss_next_index));
4933 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4934 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4935 ntohl (mp->match_n_vectors));
4936 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4937 ntohl (mp->mask_length));
4939 vam->retval = retval;
4940 vam->result_ready = 1;
4944 vl_api_classify_table_info_reply_t_handler_json
4945 (vl_api_classify_table_info_reply_t * mp)
4947 vat_main_t *vam = &vat_main;
4948 vat_json_node_t node;
4950 i32 retval = ntohl (mp->retval);
4953 vat_json_init_object (&node);
4955 vat_json_object_add_int (&node, "sessions",
4956 ntohl (mp->active_sessions));
4957 vat_json_object_add_int (&node, "nexttbl",
4958 ntohl (mp->next_table_index));
4959 vat_json_object_add_int (&node, "nextnode",
4960 ntohl (mp->miss_next_index));
4961 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4962 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4963 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4964 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4965 ntohl (mp->mask_length), 0);
4966 vat_json_object_add_string_copy (&node, "mask", s);
4968 vat_json_print (vam->ofp, &node);
4969 vat_json_free (&node);
4971 vam->retval = ntohl (mp->retval);
4972 vam->result_ready = 1;
4976 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4979 vat_main_t *vam = &vat_main;
4981 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4982 ntohl (mp->hit_next_index), ntohl (mp->advance),
4983 ntohl (mp->opaque_index));
4984 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4985 ntohl (mp->match_length));
4989 vl_api_classify_session_details_t_handler_json
4990 (vl_api_classify_session_details_t * mp)
4992 vat_main_t *vam = &vat_main;
4993 vat_json_node_t *node = NULL;
4995 if (VAT_JSON_ARRAY != vam->json_tree.type)
4997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4998 vat_json_init_array (&vam->json_tree);
5000 node = vat_json_array_add (&vam->json_tree);
5002 vat_json_init_object (node);
5003 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5004 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5005 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5007 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5009 vat_json_object_add_string_copy (node, "match", s);
5012 static void vl_api_pg_create_interface_reply_t_handler
5013 (vl_api_pg_create_interface_reply_t * mp)
5015 vat_main_t *vam = &vat_main;
5017 vam->retval = ntohl (mp->retval);
5018 vam->result_ready = 1;
5021 static void vl_api_pg_create_interface_reply_t_handler_json
5022 (vl_api_pg_create_interface_reply_t * mp)
5024 vat_main_t *vam = &vat_main;
5025 vat_json_node_t node;
5027 i32 retval = ntohl (mp->retval);
5030 vat_json_init_object (&node);
5032 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5034 vat_json_print (vam->ofp, &node);
5035 vat_json_free (&node);
5037 vam->retval = ntohl (mp->retval);
5038 vam->result_ready = 1;
5041 static void vl_api_policer_classify_details_t_handler
5042 (vl_api_policer_classify_details_t * mp)
5044 vat_main_t *vam = &vat_main;
5046 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5047 ntohl (mp->table_index));
5050 static void vl_api_policer_classify_details_t_handler_json
5051 (vl_api_policer_classify_details_t * mp)
5053 vat_main_t *vam = &vat_main;
5054 vat_json_node_t *node;
5056 if (VAT_JSON_ARRAY != vam->json_tree.type)
5058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5059 vat_json_init_array (&vam->json_tree);
5061 node = vat_json_array_add (&vam->json_tree);
5063 vat_json_init_object (node);
5064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5065 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5068 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5069 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5071 vat_main_t *vam = &vat_main;
5072 i32 retval = ntohl (mp->retval);
5073 if (vam->async_mode)
5075 vam->async_errors += (retval < 0);
5079 vam->retval = retval;
5080 vam->sw_if_index = ntohl (mp->sw_if_index);
5081 vam->result_ready = 1;
5085 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5086 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5088 vat_main_t *vam = &vat_main;
5089 vat_json_node_t node;
5091 vat_json_init_object (&node);
5092 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5093 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5095 vat_json_print (vam->ofp, &node);
5096 vat_json_free (&node);
5098 vam->retval = ntohl (mp->retval);
5099 vam->result_ready = 1;
5102 static void vl_api_flow_classify_details_t_handler
5103 (vl_api_flow_classify_details_t * mp)
5105 vat_main_t *vam = &vat_main;
5107 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5108 ntohl (mp->table_index));
5111 static void vl_api_flow_classify_details_t_handler_json
5112 (vl_api_flow_classify_details_t * mp)
5114 vat_main_t *vam = &vat_main;
5115 vat_json_node_t *node;
5117 if (VAT_JSON_ARRAY != vam->json_tree.type)
5119 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5120 vat_json_init_array (&vam->json_tree);
5122 node = vat_json_array_add (&vam->json_tree);
5124 vat_json_init_object (node);
5125 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5126 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5129 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5130 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5131 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5132 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5133 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5134 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5135 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5136 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5137 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5138 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5139 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5140 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5141 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5142 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5143 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5144 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5145 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5146 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5147 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5148 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5149 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5150 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5153 * Generate boilerplate reply handlers, which
5154 * dig the return value out of the xxx_reply_t API message,
5155 * stick it into vam->retval, and set vam->result_ready
5157 * Could also do this by pointing N message decode slots at
5158 * a single function, but that could break in subtle ways.
5161 #define foreach_standard_reply_retval_handler \
5162 _(sw_interface_set_flags_reply) \
5163 _(sw_interface_add_del_address_reply) \
5164 _(sw_interface_set_rx_mode_reply) \
5165 _(sw_interface_set_table_reply) \
5166 _(sw_interface_set_mpls_enable_reply) \
5167 _(sw_interface_set_vpath_reply) \
5168 _(sw_interface_set_vxlan_bypass_reply) \
5169 _(sw_interface_set_geneve_bypass_reply) \
5170 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5171 _(sw_interface_set_l2_bridge_reply) \
5172 _(bridge_domain_add_del_reply) \
5173 _(sw_interface_set_l2_xconnect_reply) \
5174 _(l2fib_add_del_reply) \
5175 _(l2fib_flush_int_reply) \
5176 _(l2fib_flush_bd_reply) \
5177 _(ip_add_del_route_reply) \
5178 _(ip_table_add_del_reply) \
5179 _(ip_mroute_add_del_reply) \
5180 _(mpls_route_add_del_reply) \
5181 _(mpls_table_add_del_reply) \
5182 _(mpls_ip_bind_unbind_reply) \
5183 _(bier_route_add_del_reply) \
5184 _(bier_table_add_del_reply) \
5185 _(proxy_arp_add_del_reply) \
5186 _(proxy_arp_intfc_enable_disable_reply) \
5187 _(sw_interface_set_unnumbered_reply) \
5188 _(ip_neighbor_add_del_reply) \
5189 _(reset_vrf_reply) \
5190 _(oam_add_del_reply) \
5191 _(reset_fib_reply) \
5192 _(dhcp_proxy_config_reply) \
5193 _(dhcp_proxy_set_vss_reply) \
5194 _(dhcp_client_config_reply) \
5195 _(set_ip_flow_hash_reply) \
5196 _(sw_interface_ip6_enable_disable_reply) \
5197 _(sw_interface_ip6_set_link_local_address_reply) \
5198 _(ip6nd_proxy_add_del_reply) \
5199 _(sw_interface_ip6nd_ra_prefix_reply) \
5200 _(sw_interface_ip6nd_ra_config_reply) \
5201 _(set_arp_neighbor_limit_reply) \
5202 _(l2_patch_add_del_reply) \
5203 _(sr_policy_add_reply) \
5204 _(sr_policy_mod_reply) \
5205 _(sr_policy_del_reply) \
5206 _(sr_localsid_add_del_reply) \
5207 _(sr_steering_add_del_reply) \
5208 _(classify_add_del_session_reply) \
5209 _(classify_set_interface_ip_table_reply) \
5210 _(classify_set_interface_l2_tables_reply) \
5211 _(l2tpv3_set_tunnel_cookies_reply) \
5212 _(l2tpv3_interface_enable_disable_reply) \
5213 _(l2tpv3_set_lookup_key_reply) \
5214 _(l2_fib_clear_table_reply) \
5215 _(l2_interface_efp_filter_reply) \
5216 _(l2_interface_vlan_tag_rewrite_reply) \
5217 _(modify_vhost_user_if_reply) \
5218 _(delete_vhost_user_if_reply) \
5219 _(want_ip4_arp_events_reply) \
5220 _(want_ip6_nd_events_reply) \
5221 _(want_l2_macs_events_reply) \
5222 _(input_acl_set_interface_reply) \
5223 _(ipsec_spd_add_del_reply) \
5224 _(ipsec_interface_add_del_spd_reply) \
5225 _(ipsec_spd_add_del_entry_reply) \
5226 _(ipsec_sad_add_del_entry_reply) \
5227 _(ipsec_sa_set_key_reply) \
5228 _(ipsec_tunnel_if_add_del_reply) \
5229 _(ipsec_tunnel_if_set_key_reply) \
5230 _(ipsec_tunnel_if_set_sa_reply) \
5231 _(ikev2_profile_add_del_reply) \
5232 _(ikev2_profile_set_auth_reply) \
5233 _(ikev2_profile_set_id_reply) \
5234 _(ikev2_profile_set_ts_reply) \
5235 _(ikev2_set_local_key_reply) \
5236 _(ikev2_set_responder_reply) \
5237 _(ikev2_set_ike_transforms_reply) \
5238 _(ikev2_set_esp_transforms_reply) \
5239 _(ikev2_set_sa_lifetime_reply) \
5240 _(ikev2_initiate_sa_init_reply) \
5241 _(ikev2_initiate_del_ike_sa_reply) \
5242 _(ikev2_initiate_del_child_sa_reply) \
5243 _(ikev2_initiate_rekey_child_sa_reply) \
5244 _(delete_loopback_reply) \
5245 _(bd_ip_mac_add_del_reply) \
5246 _(map_del_domain_reply) \
5247 _(map_add_del_rule_reply) \
5248 _(want_interface_events_reply) \
5249 _(want_stats_reply) \
5250 _(cop_interface_enable_disable_reply) \
5251 _(cop_whitelist_enable_disable_reply) \
5252 _(sw_interface_clear_stats_reply) \
5253 _(ioam_enable_reply) \
5254 _(ioam_disable_reply) \
5255 _(one_add_del_locator_reply) \
5256 _(one_add_del_local_eid_reply) \
5257 _(one_add_del_remote_mapping_reply) \
5258 _(one_add_del_adjacency_reply) \
5259 _(one_add_del_map_resolver_reply) \
5260 _(one_add_del_map_server_reply) \
5261 _(one_enable_disable_reply) \
5262 _(one_rloc_probe_enable_disable_reply) \
5263 _(one_map_register_enable_disable_reply) \
5264 _(one_map_register_set_ttl_reply) \
5265 _(one_set_transport_protocol_reply) \
5266 _(one_map_register_fallback_threshold_reply) \
5267 _(one_pitr_set_locator_set_reply) \
5268 _(one_map_request_mode_reply) \
5269 _(one_add_del_map_request_itr_rlocs_reply) \
5270 _(one_eid_table_add_del_map_reply) \
5271 _(one_use_petr_reply) \
5272 _(one_stats_enable_disable_reply) \
5273 _(one_add_del_l2_arp_entry_reply) \
5274 _(one_add_del_ndp_entry_reply) \
5275 _(one_stats_flush_reply) \
5276 _(one_enable_disable_xtr_mode_reply) \
5277 _(one_enable_disable_pitr_mode_reply) \
5278 _(one_enable_disable_petr_mode_reply) \
5279 _(gpe_enable_disable_reply) \
5280 _(gpe_set_encap_mode_reply) \
5281 _(gpe_add_del_iface_reply) \
5282 _(gpe_add_del_native_fwd_rpath_reply) \
5283 _(af_packet_delete_reply) \
5284 _(policer_classify_set_interface_reply) \
5285 _(netmap_create_reply) \
5286 _(netmap_delete_reply) \
5287 _(set_ipfix_exporter_reply) \
5288 _(set_ipfix_classify_stream_reply) \
5289 _(ipfix_classify_table_add_del_reply) \
5290 _(flow_classify_set_interface_reply) \
5291 _(sw_interface_span_enable_disable_reply) \
5292 _(pg_capture_reply) \
5293 _(pg_enable_disable_reply) \
5294 _(ip_source_and_port_range_check_add_del_reply) \
5295 _(ip_source_and_port_range_check_interface_add_del_reply)\
5296 _(delete_subif_reply) \
5297 _(l2_interface_pbb_tag_rewrite_reply) \
5299 _(feature_enable_disable_reply) \
5300 _(sw_interface_tag_add_del_reply) \
5301 _(sw_interface_set_mtu_reply) \
5302 _(p2p_ethernet_add_reply) \
5303 _(p2p_ethernet_del_reply) \
5304 _(lldp_config_reply) \
5305 _(sw_interface_set_lldp_reply) \
5306 _(tcp_configure_src_addresses_reply) \
5307 _(dns_enable_disable_reply) \
5308 _(dns_name_server_add_del_reply) \
5309 _(session_rule_add_del_reply) \
5310 _(ip_container_proxy_add_del_reply)
5313 static void vl_api_##n##_t_handler \
5314 (vl_api_##n##_t * mp) \
5316 vat_main_t * vam = &vat_main; \
5317 i32 retval = ntohl(mp->retval); \
5318 if (vam->async_mode) { \
5319 vam->async_errors += (retval < 0); \
5321 vam->retval = retval; \
5322 vam->result_ready = 1; \
5325 foreach_standard_reply_retval_handler;
5329 static void vl_api_##n##_t_handler_json \
5330 (vl_api_##n##_t * mp) \
5332 vat_main_t * vam = &vat_main; \
5333 vat_json_node_t node; \
5334 vat_json_init_object(&node); \
5335 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5336 vat_json_print(vam->ofp, &node); \
5337 vam->retval = ntohl(mp->retval); \
5338 vam->result_ready = 1; \
5340 foreach_standard_reply_retval_handler;
5344 * Table of message reply handlers, must include boilerplate handlers
5348 #define foreach_vpe_api_reply_msg \
5349 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5350 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5351 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5352 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5353 _(CONTROL_PING_REPLY, control_ping_reply) \
5354 _(CLI_REPLY, cli_reply) \
5355 _(CLI_INBAND_REPLY, cli_inband_reply) \
5356 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5357 sw_interface_add_del_address_reply) \
5358 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5359 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5360 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5361 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5362 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5363 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5364 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5365 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5366 sw_interface_set_l2_xconnect_reply) \
5367 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5368 sw_interface_set_l2_bridge_reply) \
5369 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5370 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5371 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5372 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5373 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5374 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5375 _(L2_FLAGS_REPLY, l2_flags_reply) \
5376 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5377 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5378 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5379 _(TAP_DELETE_REPLY, tap_delete_reply) \
5380 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5381 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5382 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5383 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5384 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5385 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5386 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5387 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5388 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5389 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5390 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5391 proxy_arp_intfc_enable_disable_reply) \
5392 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5393 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5394 sw_interface_set_unnumbered_reply) \
5395 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5396 _(RESET_VRF_REPLY, reset_vrf_reply) \
5397 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5398 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5399 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5400 _(RESET_FIB_REPLY, reset_fib_reply) \
5401 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5402 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5403 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5404 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5405 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5406 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5407 sw_interface_ip6_enable_disable_reply) \
5408 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5409 sw_interface_ip6_set_link_local_address_reply) \
5410 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5411 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5412 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5413 sw_interface_ip6nd_ra_prefix_reply) \
5414 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5415 sw_interface_ip6nd_ra_config_reply) \
5416 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5417 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5418 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5419 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5420 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5421 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5422 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5423 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5424 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5425 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5426 classify_set_interface_ip_table_reply) \
5427 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5428 classify_set_interface_l2_tables_reply) \
5429 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5430 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5431 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5432 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5433 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5434 l2tpv3_interface_enable_disable_reply) \
5435 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5436 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5437 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5438 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5439 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5440 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5441 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5442 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5443 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5444 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5445 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5446 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5447 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5448 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5449 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5450 _(SHOW_VERSION_REPLY, show_version_reply) \
5451 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5452 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5453 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5454 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5455 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5456 _(IP4_ARP_EVENT, ip4_arp_event) \
5457 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5458 _(IP6_ND_EVENT, ip6_nd_event) \
5459 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5460 _(L2_MACS_EVENT, l2_macs_event) \
5461 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5462 _(IP_ADDRESS_DETAILS, ip_address_details) \
5463 _(IP_DETAILS, ip_details) \
5464 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5465 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5466 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5467 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5468 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5469 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5470 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5471 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5472 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5473 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5474 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5475 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5476 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5477 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5478 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5479 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5480 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5481 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5482 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5483 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5484 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5485 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5486 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5487 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5488 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5489 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5490 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5491 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5492 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5493 _(MAP_RULE_DETAILS, map_rule_details) \
5494 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5495 _(WANT_STATS_REPLY, want_stats_reply) \
5496 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5497 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5498 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5499 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5500 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5501 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5502 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5503 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5504 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5505 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5506 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5507 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5508 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5509 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5510 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5511 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5512 one_map_register_enable_disable_reply) \
5513 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5514 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5515 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5516 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5517 one_map_register_fallback_threshold_reply) \
5518 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5519 one_rloc_probe_enable_disable_reply) \
5520 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5521 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5522 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5523 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5524 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5525 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5526 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5527 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5528 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5529 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5530 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5531 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5532 _(ONE_STATS_DETAILS, one_stats_details) \
5533 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5534 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5535 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5536 show_one_stats_enable_disable_reply) \
5537 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5538 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5539 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5540 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5541 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5542 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5543 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5544 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5545 one_enable_disable_pitr_mode_reply) \
5546 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5547 one_enable_disable_petr_mode_reply) \
5548 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5549 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5550 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5551 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5552 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5553 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5554 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5555 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5556 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5557 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5558 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5559 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5560 gpe_add_del_native_fwd_rpath_reply) \
5561 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5562 gpe_fwd_entry_path_details) \
5563 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5564 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5565 one_add_del_map_request_itr_rlocs_reply) \
5566 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5567 one_get_map_request_itr_rlocs_reply) \
5568 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5569 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5570 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5571 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5572 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5573 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5574 show_one_map_register_state_reply) \
5575 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5576 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5577 show_one_map_register_fallback_threshold_reply) \
5578 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5579 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5580 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5581 _(POLICER_DETAILS, policer_details) \
5582 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5583 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5584 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5585 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5586 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5587 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5588 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5589 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5590 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5591 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5592 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5593 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5594 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5595 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5596 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5597 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5598 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5599 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5600 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5601 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5602 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5603 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5604 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5605 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5606 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5607 ip_source_and_port_range_check_add_del_reply) \
5608 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5609 ip_source_and_port_range_check_interface_add_del_reply) \
5610 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5611 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5612 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5613 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5614 _(PUNT_REPLY, punt_reply) \
5615 _(IP_FIB_DETAILS, ip_fib_details) \
5616 _(IP6_FIB_DETAILS, ip6_fib_details) \
5617 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5618 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5619 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5620 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5621 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5622 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5623 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5624 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5625 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5626 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5627 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5628 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5629 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5630 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5631 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5632 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5633 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5634 _(SESSION_RULES_DETAILS, session_rules_details) \
5635 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5637 #define foreach_standalone_reply_msg \
5638 _(SW_INTERFACE_EVENT, sw_interface_event) \
5639 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5640 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5641 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5642 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5643 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5644 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5645 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5654 #define STR_VTR_OP_CASE(op) \
5655 case L2_VTR_ ## op: \
5659 str_vtr_op (u32 vtr_op)
5663 STR_VTR_OP_CASE (DISABLED);
5664 STR_VTR_OP_CASE (PUSH_1);
5665 STR_VTR_OP_CASE (PUSH_2);
5666 STR_VTR_OP_CASE (POP_1);
5667 STR_VTR_OP_CASE (POP_2);
5668 STR_VTR_OP_CASE (TRANSLATE_1_1);
5669 STR_VTR_OP_CASE (TRANSLATE_1_2);
5670 STR_VTR_OP_CASE (TRANSLATE_2_1);
5671 STR_VTR_OP_CASE (TRANSLATE_2_2);
5678 dump_sub_interface_table (vat_main_t * vam)
5680 const sw_interface_subif_t *sub = NULL;
5682 if (vam->json_output)
5685 ("JSON output supported only for VPE API calls and dump_stats_table");
5690 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5691 "Interface", "sw_if_index",
5692 "sub id", "dot1ad", "tags", "outer id",
5693 "inner id", "exact", "default", "outer any", "inner any");
5695 vec_foreach (sub, vam->sw_if_subif_table)
5698 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5699 sub->interface_name,
5701 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5702 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5703 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5704 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5705 if (sub->vtr_op != L2_VTR_DISABLED)
5708 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5709 "tag1: %d tag2: %d ]",
5710 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5711 sub->vtr_tag1, sub->vtr_tag2);
5719 name_sort_cmp (void *a1, void *a2)
5721 name_sort_t *n1 = a1;
5722 name_sort_t *n2 = a2;
5724 return strcmp ((char *) n1->name, (char *) n2->name);
5728 dump_interface_table (vat_main_t * vam)
5731 name_sort_t *nses = 0, *ns;
5733 if (vam->json_output)
5736 ("JSON output supported only for VPE API calls and dump_stats_table");
5741 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5743 vec_add2 (nses, ns, 1);
5744 ns->name = (u8 *)(p->key);
5745 ns->value = (u32) p->value[0];
5749 vec_sort_with_function (nses, name_sort_cmp);
5751 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5752 vec_foreach (ns, nses)
5754 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5761 dump_ip_table (vat_main_t * vam, int is_ipv6)
5763 const ip_details_t *det = NULL;
5764 const ip_address_details_t *address = NULL;
5767 print (vam->ofp, "%-12s", "sw_if_index");
5769 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5776 print (vam->ofp, "%-12d", i);
5777 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5782 vec_foreach (address, det->addr)
5786 is_ipv6 ? format_ip6_address : format_ip4_address,
5787 address->ip, address->prefix_length);
5795 dump_ipv4_table (vat_main_t * vam)
5797 if (vam->json_output)
5800 ("JSON output supported only for VPE API calls and dump_stats_table");
5804 return dump_ip_table (vam, 0);
5808 dump_ipv6_table (vat_main_t * vam)
5810 if (vam->json_output)
5813 ("JSON output supported only for VPE API calls and dump_stats_table");
5817 return dump_ip_table (vam, 1);
5821 counter_type_to_str (u8 counter_type, u8 is_combined)
5825 switch (counter_type)
5827 case VNET_INTERFACE_COUNTER_DROP:
5829 case VNET_INTERFACE_COUNTER_PUNT:
5831 case VNET_INTERFACE_COUNTER_IP4:
5833 case VNET_INTERFACE_COUNTER_IP6:
5835 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5837 case VNET_INTERFACE_COUNTER_RX_MISS:
5839 case VNET_INTERFACE_COUNTER_RX_ERROR:
5841 case VNET_INTERFACE_COUNTER_TX_ERROR:
5844 return "INVALID-COUNTER-TYPE";
5849 switch (counter_type)
5851 case VNET_INTERFACE_COUNTER_RX:
5853 case VNET_INTERFACE_COUNTER_TX:
5856 return "INVALID-COUNTER-TYPE";
5862 dump_stats_table (vat_main_t * vam)
5864 vat_json_node_t node;
5865 vat_json_node_t *msg_array;
5866 vat_json_node_t *msg;
5867 vat_json_node_t *counter_array;
5868 vat_json_node_t *counter;
5869 interface_counter_t c;
5871 ip4_fib_counter_t *c4;
5872 ip6_fib_counter_t *c6;
5873 ip4_nbr_counter_t *n4;
5874 ip6_nbr_counter_t *n6;
5877 if (!vam->json_output)
5879 clib_warning ("dump_stats_table supported only in JSON format");
5883 vat_json_init_object (&node);
5885 /* interface counters */
5886 msg_array = vat_json_object_add (&node, "interface_counters");
5887 vat_json_init_array (msg_array);
5888 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5890 msg = vat_json_array_add (msg_array);
5891 vat_json_init_object (msg);
5892 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5893 (u8 *) counter_type_to_str (i, 0));
5894 vat_json_object_add_int (msg, "is_combined", 0);
5895 counter_array = vat_json_object_add (msg, "data");
5896 vat_json_init_array (counter_array);
5897 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5899 packets = vam->simple_interface_counters[i][j];
5900 vat_json_array_add_uint (counter_array, packets);
5903 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5905 msg = vat_json_array_add (msg_array);
5906 vat_json_init_object (msg);
5907 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5908 (u8 *) counter_type_to_str (i, 1));
5909 vat_json_object_add_int (msg, "is_combined", 1);
5910 counter_array = vat_json_object_add (msg, "data");
5911 vat_json_init_array (counter_array);
5912 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5914 c = vam->combined_interface_counters[i][j];
5915 counter = vat_json_array_add (counter_array);
5916 vat_json_init_object (counter);
5917 vat_json_object_add_uint (counter, "packets", c.packets);
5918 vat_json_object_add_uint (counter, "bytes", c.bytes);
5922 /* ip4 fib counters */
5923 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5924 vat_json_init_array (msg_array);
5925 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5927 msg = vat_json_array_add (msg_array);
5928 vat_json_init_object (msg);
5929 vat_json_object_add_uint (msg, "vrf_id",
5930 vam->ip4_fib_counters_vrf_id_by_index[i]);
5931 counter_array = vat_json_object_add (msg, "c");
5932 vat_json_init_array (counter_array);
5933 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5935 counter = vat_json_array_add (counter_array);
5936 vat_json_init_object (counter);
5937 c4 = &vam->ip4_fib_counters[i][j];
5938 vat_json_object_add_ip4 (counter, "address", c4->address);
5939 vat_json_object_add_uint (counter, "address_length",
5940 c4->address_length);
5941 vat_json_object_add_uint (counter, "packets", c4->packets);
5942 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5946 /* ip6 fib counters */
5947 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5948 vat_json_init_array (msg_array);
5949 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5951 msg = vat_json_array_add (msg_array);
5952 vat_json_init_object (msg);
5953 vat_json_object_add_uint (msg, "vrf_id",
5954 vam->ip6_fib_counters_vrf_id_by_index[i]);
5955 counter_array = vat_json_object_add (msg, "c");
5956 vat_json_init_array (counter_array);
5957 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5959 counter = vat_json_array_add (counter_array);
5960 vat_json_init_object (counter);
5961 c6 = &vam->ip6_fib_counters[i][j];
5962 vat_json_object_add_ip6 (counter, "address", c6->address);
5963 vat_json_object_add_uint (counter, "address_length",
5964 c6->address_length);
5965 vat_json_object_add_uint (counter, "packets", c6->packets);
5966 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5970 /* ip4 nbr counters */
5971 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5972 vat_json_init_array (msg_array);
5973 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5975 msg = vat_json_array_add (msg_array);
5976 vat_json_init_object (msg);
5977 vat_json_object_add_uint (msg, "sw_if_index", i);
5978 counter_array = vat_json_object_add (msg, "c");
5979 vat_json_init_array (counter_array);
5980 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5982 counter = vat_json_array_add (counter_array);
5983 vat_json_init_object (counter);
5984 n4 = &vam->ip4_nbr_counters[i][j];
5985 vat_json_object_add_ip4 (counter, "address", n4->address);
5986 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5987 vat_json_object_add_uint (counter, "packets", n4->packets);
5988 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5992 /* ip6 nbr counters */
5993 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5994 vat_json_init_array (msg_array);
5995 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5997 msg = vat_json_array_add (msg_array);
5998 vat_json_init_object (msg);
5999 vat_json_object_add_uint (msg, "sw_if_index", i);
6000 counter_array = vat_json_object_add (msg, "c");
6001 vat_json_init_array (counter_array);
6002 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
6004 counter = vat_json_array_add (counter_array);
6005 vat_json_init_object (counter);
6006 n6 = &vam->ip6_nbr_counters[i][j];
6007 vat_json_object_add_ip6 (counter, "address", n6->address);
6008 vat_json_object_add_uint (counter, "packets", n6->packets);
6009 vat_json_object_add_uint (counter, "bytes", n6->bytes);
6013 vat_json_print (vam->ofp, &node);
6014 vat_json_free (&node);
6020 * Pass CLI buffers directly in the CLI_INBAND API message,
6021 * instead of an additional shared memory area.
6024 exec_inband (vat_main_t * vam)
6026 vl_api_cli_inband_t *mp;
6027 unformat_input_t *i = vam->input;
6030 if (vec_len (i->buffer) == 0)
6033 if (vam->exec_mode == 0 && unformat (i, "mode"))
6038 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
6045 * In order for the CLI command to work, it
6046 * must be a vector ending in \n, not a C-string ending
6049 u32 len = vec_len (vam->input->buffer);
6050 M2 (CLI_INBAND, mp, len);
6051 clib_memcpy (mp->cmd, vam->input->buffer, len);
6052 mp->length = htonl (len);
6056 /* json responses may or may not include a useful reply... */
6057 if (vec_len (vam->cmd_reply))
6058 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
6063 exec (vat_main_t * vam)
6065 return exec_inband (vam);
6069 api_create_loopback (vat_main_t * vam)
6071 unformat_input_t *i = vam->input;
6072 vl_api_create_loopback_t *mp;
6073 vl_api_create_loopback_instance_t *mp_lbi;
6076 u8 is_specified = 0;
6077 u32 user_instance = 0;
6080 memset (mac_address, 0, sizeof (mac_address));
6082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6084 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6086 if (unformat (i, "instance %d", &user_instance))
6094 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
6095 mp_lbi->is_specified = is_specified;
6097 mp_lbi->user_instance = htonl (user_instance);
6099 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
6104 /* Construct the API message */
6105 M (CREATE_LOOPBACK, mp);
6107 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
6116 api_delete_loopback (vat_main_t * vam)
6118 unformat_input_t *i = vam->input;
6119 vl_api_delete_loopback_t *mp;
6120 u32 sw_if_index = ~0;
6123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6125 if (unformat (i, "sw_if_index %d", &sw_if_index))
6131 if (sw_if_index == ~0)
6133 errmsg ("missing sw_if_index");
6137 /* Construct the API message */
6138 M (DELETE_LOOPBACK, mp);
6139 mp->sw_if_index = ntohl (sw_if_index);
6147 api_want_stats (vat_main_t * vam)
6149 unformat_input_t *i = vam->input;
6150 vl_api_want_stats_t *mp;
6154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6156 if (unformat (i, "enable"))
6158 else if (unformat (i, "disable"))
6166 errmsg ("missing enable|disable");
6171 mp->enable_disable = enable;
6179 api_want_interface_events (vat_main_t * vam)
6181 unformat_input_t *i = vam->input;
6182 vl_api_want_interface_events_t *mp;
6186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6188 if (unformat (i, "enable"))
6190 else if (unformat (i, "disable"))
6198 errmsg ("missing enable|disable");
6202 M (WANT_INTERFACE_EVENTS, mp);
6203 mp->enable_disable = enable;
6205 vam->interface_event_display = enable;
6213 /* Note: non-static, called once to set up the initial intfc table */
6215 api_sw_interface_dump (vat_main_t * vam)
6217 vl_api_sw_interface_dump_t *mp;
6218 vl_api_control_ping_t *mp_ping;
6220 name_sort_t *nses = 0, *ns;
6221 sw_interface_subif_t *sub = NULL;
6224 /* Toss the old name table */
6226 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6228 vec_add2 (nses, ns, 1);
6229 ns->name = (u8 *)(p->key);
6230 ns->value = (u32) p->value[0];
6234 hash_free (vam->sw_if_index_by_interface_name);
6236 vec_foreach (ns, nses) vec_free (ns->name);
6240 vec_foreach (sub, vam->sw_if_subif_table)
6242 vec_free (sub->interface_name);
6244 vec_free (vam->sw_if_subif_table);
6246 /* recreate the interface name hash table */
6247 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6249 /* Get list of ethernets */
6250 M (SW_INTERFACE_DUMP, mp);
6251 mp->name_filter_valid = 1;
6252 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6255 /* and local / loopback interfaces */
6256 M (SW_INTERFACE_DUMP, mp);
6257 mp->name_filter_valid = 1;
6258 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6261 /* and packet-generator interfaces */
6262 M (SW_INTERFACE_DUMP, mp);
6263 mp->name_filter_valid = 1;
6264 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6267 /* and vxlan-gpe tunnel interfaces */
6268 M (SW_INTERFACE_DUMP, mp);
6269 mp->name_filter_valid = 1;
6270 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6271 sizeof (mp->name_filter) - 1);
6274 /* and vxlan tunnel interfaces */
6275 M (SW_INTERFACE_DUMP, mp);
6276 mp->name_filter_valid = 1;
6277 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6280 /* and geneve tunnel interfaces */
6281 M (SW_INTERFACE_DUMP, mp);
6282 mp->name_filter_valid = 1;
6283 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6286 /* and host (af_packet) interfaces */
6287 M (SW_INTERFACE_DUMP, mp);
6288 mp->name_filter_valid = 1;
6289 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6292 /* and l2tpv3 tunnel interfaces */
6293 M (SW_INTERFACE_DUMP, mp);
6294 mp->name_filter_valid = 1;
6295 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6296 sizeof (mp->name_filter) - 1);
6299 /* and GRE tunnel interfaces */
6300 M (SW_INTERFACE_DUMP, mp);
6301 mp->name_filter_valid = 1;
6302 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6305 /* and LISP-GPE interfaces */
6306 M (SW_INTERFACE_DUMP, mp);
6307 mp->name_filter_valid = 1;
6308 strncpy ((char *) mp->name_filter, "lisp_gpe",
6309 sizeof (mp->name_filter) - 1);
6312 /* and IPSEC tunnel interfaces */
6313 M (SW_INTERFACE_DUMP, mp);
6314 mp->name_filter_valid = 1;
6315 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6318 /* Use a control ping for synchronization */
6319 MPING (CONTROL_PING, mp_ping);
6327 api_sw_interface_set_flags (vat_main_t * vam)
6329 unformat_input_t *i = vam->input;
6330 vl_api_sw_interface_set_flags_t *mp;
6332 u8 sw_if_index_set = 0;
6336 /* Parse args required to build the message */
6337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6339 if (unformat (i, "admin-up"))
6341 else if (unformat (i, "admin-down"))
6344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6345 sw_if_index_set = 1;
6346 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6347 sw_if_index_set = 1;
6352 if (sw_if_index_set == 0)
6354 errmsg ("missing interface name or sw_if_index");
6358 /* Construct the API message */
6359 M (SW_INTERFACE_SET_FLAGS, mp);
6360 mp->sw_if_index = ntohl (sw_if_index);
6361 mp->admin_up_down = admin_up;
6366 /* Wait for a reply, return the good/bad news... */
6372 api_sw_interface_set_rx_mode (vat_main_t * vam)
6374 unformat_input_t *i = vam->input;
6375 vl_api_sw_interface_set_rx_mode_t *mp;
6377 u8 sw_if_index_set = 0;
6379 u8 queue_id_valid = 0;
6381 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6383 /* Parse args required to build the message */
6384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6386 if (unformat (i, "queue %d", &queue_id))
6388 else if (unformat (i, "polling"))
6389 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6390 else if (unformat (i, "interrupt"))
6391 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6392 else if (unformat (i, "adaptive"))
6393 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6396 sw_if_index_set = 1;
6397 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6398 sw_if_index_set = 1;
6403 if (sw_if_index_set == 0)
6405 errmsg ("missing interface name or sw_if_index");
6408 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6410 errmsg ("missing rx-mode");
6414 /* Construct the API message */
6415 M (SW_INTERFACE_SET_RX_MODE, mp);
6416 mp->sw_if_index = ntohl (sw_if_index);
6418 mp->queue_id_valid = queue_id_valid;
6419 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6424 /* Wait for a reply, return the good/bad news... */
6430 api_sw_interface_clear_stats (vat_main_t * vam)
6432 unformat_input_t *i = vam->input;
6433 vl_api_sw_interface_clear_stats_t *mp;
6435 u8 sw_if_index_set = 0;
6438 /* Parse args required to build the message */
6439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6441 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6442 sw_if_index_set = 1;
6443 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6444 sw_if_index_set = 1;
6449 /* Construct the API message */
6450 M (SW_INTERFACE_CLEAR_STATS, mp);
6452 if (sw_if_index_set == 1)
6453 mp->sw_if_index = ntohl (sw_if_index);
6455 mp->sw_if_index = ~0;
6460 /* Wait for a reply, return the good/bad news... */
6466 api_sw_interface_add_del_address (vat_main_t * vam)
6468 unformat_input_t *i = vam->input;
6469 vl_api_sw_interface_add_del_address_t *mp;
6471 u8 sw_if_index_set = 0;
6472 u8 is_add = 1, del_all = 0;
6473 u32 address_length = 0;
6474 u8 v4_address_set = 0;
6475 u8 v6_address_set = 0;
6476 ip4_address_t v4address;
6477 ip6_address_t v6address;
6480 /* Parse args required to build the message */
6481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6483 if (unformat (i, "del-all"))
6485 else if (unformat (i, "del"))
6488 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6489 sw_if_index_set = 1;
6490 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6491 sw_if_index_set = 1;
6492 else if (unformat (i, "%U/%d",
6493 unformat_ip4_address, &v4address, &address_length))
6495 else if (unformat (i, "%U/%d",
6496 unformat_ip6_address, &v6address, &address_length))
6502 if (sw_if_index_set == 0)
6504 errmsg ("missing interface name or sw_if_index");
6507 if (v4_address_set && v6_address_set)
6509 errmsg ("both v4 and v6 addresses set");
6512 if (!v4_address_set && !v6_address_set && !del_all)
6514 errmsg ("no addresses set");
6518 /* Construct the API message */
6519 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6521 mp->sw_if_index = ntohl (sw_if_index);
6522 mp->is_add = is_add;
6523 mp->del_all = del_all;
6527 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6531 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6533 mp->address_length = address_length;
6538 /* Wait for a reply, return good/bad news */
6544 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6546 unformat_input_t *i = vam->input;
6547 vl_api_sw_interface_set_mpls_enable_t *mp;
6549 u8 sw_if_index_set = 0;
6553 /* Parse args required to build the message */
6554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6556 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6557 sw_if_index_set = 1;
6558 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6559 sw_if_index_set = 1;
6560 else if (unformat (i, "disable"))
6562 else if (unformat (i, "dis"))
6568 if (sw_if_index_set == 0)
6570 errmsg ("missing interface name or sw_if_index");
6574 /* Construct the API message */
6575 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6577 mp->sw_if_index = ntohl (sw_if_index);
6578 mp->enable = enable;
6583 /* Wait for a reply... */
6589 api_sw_interface_set_table (vat_main_t * vam)
6591 unformat_input_t *i = vam->input;
6592 vl_api_sw_interface_set_table_t *mp;
6593 u32 sw_if_index, vrf_id = 0;
6594 u8 sw_if_index_set = 0;
6598 /* Parse args required to build the message */
6599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6601 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6602 sw_if_index_set = 1;
6603 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6604 sw_if_index_set = 1;
6605 else if (unformat (i, "vrf %d", &vrf_id))
6607 else if (unformat (i, "ipv6"))
6613 if (sw_if_index_set == 0)
6615 errmsg ("missing interface name or sw_if_index");
6619 /* Construct the API message */
6620 M (SW_INTERFACE_SET_TABLE, mp);
6622 mp->sw_if_index = ntohl (sw_if_index);
6623 mp->is_ipv6 = is_ipv6;
6624 mp->vrf_id = ntohl (vrf_id);
6629 /* Wait for a reply... */
6634 static void vl_api_sw_interface_get_table_reply_t_handler
6635 (vl_api_sw_interface_get_table_reply_t * mp)
6637 vat_main_t *vam = &vat_main;
6639 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6641 vam->retval = ntohl (mp->retval);
6642 vam->result_ready = 1;
6646 static void vl_api_sw_interface_get_table_reply_t_handler_json
6647 (vl_api_sw_interface_get_table_reply_t * mp)
6649 vat_main_t *vam = &vat_main;
6650 vat_json_node_t node;
6652 vat_json_init_object (&node);
6653 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6654 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6656 vat_json_print (vam->ofp, &node);
6657 vat_json_free (&node);
6659 vam->retval = ntohl (mp->retval);
6660 vam->result_ready = 1;
6664 api_sw_interface_get_table (vat_main_t * vam)
6666 unformat_input_t *i = vam->input;
6667 vl_api_sw_interface_get_table_t *mp;
6669 u8 sw_if_index_set = 0;
6673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
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, "ipv6"))
6685 if (sw_if_index_set == 0)
6687 errmsg ("missing interface name or sw_if_index");
6691 M (SW_INTERFACE_GET_TABLE, mp);
6692 mp->sw_if_index = htonl (sw_if_index);
6693 mp->is_ipv6 = is_ipv6;
6701 api_sw_interface_set_vpath (vat_main_t * vam)
6703 unformat_input_t *i = vam->input;
6704 vl_api_sw_interface_set_vpath_t *mp;
6705 u32 sw_if_index = 0;
6706 u8 sw_if_index_set = 0;
6710 /* Parse args required to build the message */
6711 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6713 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6714 sw_if_index_set = 1;
6715 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6716 sw_if_index_set = 1;
6717 else if (unformat (i, "enable"))
6719 else if (unformat (i, "disable"))
6725 if (sw_if_index_set == 0)
6727 errmsg ("missing interface name or sw_if_index");
6731 /* Construct the API message */
6732 M (SW_INTERFACE_SET_VPATH, mp);
6734 mp->sw_if_index = ntohl (sw_if_index);
6735 mp->enable = is_enable;
6740 /* Wait for a reply... */
6746 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6748 unformat_input_t *i = vam->input;
6749 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6750 u32 sw_if_index = 0;
6751 u8 sw_if_index_set = 0;
6756 /* Parse args required to build the message */
6757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6759 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6760 sw_if_index_set = 1;
6761 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6762 sw_if_index_set = 1;
6763 else if (unformat (i, "enable"))
6765 else if (unformat (i, "disable"))
6767 else if (unformat (i, "ip4"))
6769 else if (unformat (i, "ip6"))
6775 if (sw_if_index_set == 0)
6777 errmsg ("missing interface name or sw_if_index");
6781 /* Construct the API message */
6782 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6784 mp->sw_if_index = ntohl (sw_if_index);
6785 mp->enable = is_enable;
6786 mp->is_ipv6 = is_ipv6;
6791 /* Wait for a reply... */
6797 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6799 unformat_input_t *i = vam->input;
6800 vl_api_sw_interface_set_geneve_bypass_t *mp;
6801 u32 sw_if_index = 0;
6802 u8 sw_if_index_set = 0;
6807 /* Parse args required to build the message */
6808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6810 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6811 sw_if_index_set = 1;
6812 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6813 sw_if_index_set = 1;
6814 else if (unformat (i, "enable"))
6816 else if (unformat (i, "disable"))
6818 else if (unformat (i, "ip4"))
6820 else if (unformat (i, "ip6"))
6826 if (sw_if_index_set == 0)
6828 errmsg ("missing interface name or sw_if_index");
6832 /* Construct the API message */
6833 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6835 mp->sw_if_index = ntohl (sw_if_index);
6836 mp->enable = is_enable;
6837 mp->is_ipv6 = is_ipv6;
6842 /* Wait for a reply... */
6848 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6850 unformat_input_t *i = vam->input;
6851 vl_api_sw_interface_set_l2_xconnect_t *mp;
6853 u8 rx_sw_if_index_set = 0;
6855 u8 tx_sw_if_index_set = 0;
6859 /* Parse args required to build the message */
6860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6862 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6863 rx_sw_if_index_set = 1;
6864 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6865 tx_sw_if_index_set = 1;
6866 else if (unformat (i, "rx"))
6868 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6870 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6872 rx_sw_if_index_set = 1;
6877 else if (unformat (i, "tx"))
6879 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6881 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6883 tx_sw_if_index_set = 1;
6888 else if (unformat (i, "enable"))
6890 else if (unformat (i, "disable"))
6896 if (rx_sw_if_index_set == 0)
6898 errmsg ("missing rx interface name or rx_sw_if_index");
6902 if (enable && (tx_sw_if_index_set == 0))
6904 errmsg ("missing tx interface name or tx_sw_if_index");
6908 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6910 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6911 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6912 mp->enable = enable;
6920 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6922 unformat_input_t *i = vam->input;
6923 vl_api_sw_interface_set_l2_bridge_t *mp;
6925 u8 rx_sw_if_index_set = 0;
6933 /* Parse args required to build the message */
6934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6936 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6937 rx_sw_if_index_set = 1;
6938 else if (unformat (i, "bd_id %d", &bd_id))
6942 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6943 rx_sw_if_index_set = 1;
6944 else if (unformat (i, "shg %d", &shg))
6946 else if (unformat (i, "bvi"))
6948 else if (unformat (i, "enable"))
6950 else if (unformat (i, "disable"))
6956 if (rx_sw_if_index_set == 0)
6958 errmsg ("missing rx interface name or sw_if_index");
6962 if (enable && (bd_id_set == 0))
6964 errmsg ("missing bridge domain");
6968 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6970 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6971 mp->bd_id = ntohl (bd_id);
6974 mp->enable = enable;
6982 api_bridge_domain_dump (vat_main_t * vam)
6984 unformat_input_t *i = vam->input;
6985 vl_api_bridge_domain_dump_t *mp;
6986 vl_api_control_ping_t *mp_ping;
6990 /* Parse args required to build the message */
6991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6993 if (unformat (i, "bd_id %d", &bd_id))
6999 M (BRIDGE_DOMAIN_DUMP, mp);
7000 mp->bd_id = ntohl (bd_id);
7003 /* Use a control ping for synchronization */
7004 MPING (CONTROL_PING, mp_ping);
7012 api_bridge_domain_add_del (vat_main_t * vam)
7014 unformat_input_t *i = vam->input;
7015 vl_api_bridge_domain_add_del_t *mp;
7018 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
7023 /* Parse args required to build the message */
7024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7026 if (unformat (i, "bd_id %d", &bd_id))
7028 else if (unformat (i, "flood %d", &flood))
7030 else if (unformat (i, "uu-flood %d", &uu_flood))
7032 else if (unformat (i, "forward %d", &forward))
7034 else if (unformat (i, "learn %d", &learn))
7036 else if (unformat (i, "arp-term %d", &arp_term))
7038 else if (unformat (i, "mac-age %d", &mac_age))
7040 else if (unformat (i, "bd-tag %s", &bd_tag))
7042 else if (unformat (i, "del"))
7045 flood = uu_flood = forward = learn = 0;
7053 errmsg ("missing bridge domain");
7060 errmsg ("mac age must be less than 256 ");
7065 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
7067 errmsg ("bd-tag cannot be longer than 63");
7072 M (BRIDGE_DOMAIN_ADD_DEL, mp);
7074 mp->bd_id = ntohl (bd_id);
7076 mp->uu_flood = uu_flood;
7077 mp->forward = forward;
7079 mp->arp_term = arp_term;
7080 mp->is_add = is_add;
7081 mp->mac_age = (u8) mac_age;
7083 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
7094 api_l2fib_flush_bd (vat_main_t * vam)
7096 unformat_input_t *i = vam->input;
7097 vl_api_l2fib_flush_bd_t *mp;
7101 /* Parse args required to build the message */
7102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7104 if (unformat (i, "bd_id %d", &bd_id));
7111 errmsg ("missing bridge domain");
7115 M (L2FIB_FLUSH_BD, mp);
7117 mp->bd_id = htonl (bd_id);
7125 api_l2fib_flush_int (vat_main_t * vam)
7127 unformat_input_t *i = vam->input;
7128 vl_api_l2fib_flush_int_t *mp;
7129 u32 sw_if_index = ~0;
7132 /* Parse args required to build the message */
7133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7135 if (unformat (i, "sw_if_index %d", &sw_if_index));
7137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
7142 if (sw_if_index == ~0)
7144 errmsg ("missing interface name or sw_if_index");
7148 M (L2FIB_FLUSH_INT, mp);
7150 mp->sw_if_index = ntohl (sw_if_index);
7158 api_l2fib_add_del (vat_main_t * vam)
7160 unformat_input_t *i = vam->input;
7161 vl_api_l2fib_add_del_t *mp;
7167 u32 sw_if_index = ~0;
7168 u8 sw_if_index_set = 0;
7177 /* Parse args required to build the message */
7178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7180 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
7182 else if (unformat (i, "bd_id %d", &bd_id))
7184 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7185 sw_if_index_set = 1;
7186 else if (unformat (i, "sw_if"))
7188 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7191 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7192 sw_if_index_set = 1;
7197 else if (unformat (i, "static"))
7199 else if (unformat (i, "filter"))
7204 else if (unformat (i, "bvi"))
7209 else if (unformat (i, "del"))
7211 else if (unformat (i, "count %d", &count))
7219 errmsg ("missing mac address");
7225 errmsg ("missing bridge domain");
7229 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7231 errmsg ("missing interface name or sw_if_index");
7237 /* Turn on async mode */
7238 vam->async_mode = 1;
7239 vam->async_errors = 0;
7240 before = vat_time_now (vam);
7243 for (j = 0; j < count; j++)
7245 M (L2FIB_ADD_DEL, mp);
7247 clib_memcpy (mp->mac, mac, 6);
7248 mp->bd_id = ntohl (bd_id);
7249 mp->is_add = is_add;
7253 mp->sw_if_index = ntohl (sw_if_index);
7254 mp->static_mac = static_mac;
7255 mp->filter_mac = filter_mac;
7256 mp->bvi_mac = bvi_mac;
7258 increment_mac_address (mac);
7265 vl_api_control_ping_t *mp_ping;
7268 /* Shut off async mode */
7269 vam->async_mode = 0;
7271 MPING (CONTROL_PING, mp_ping);
7274 timeout = vat_time_now (vam) + 1.0;
7275 while (vat_time_now (vam) < timeout)
7276 if (vam->result_ready == 1)
7281 if (vam->retval == -99)
7284 if (vam->async_errors > 0)
7286 errmsg ("%d asynchronous errors", vam->async_errors);
7289 vam->async_errors = 0;
7290 after = vat_time_now (vam);
7292 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7293 count, after - before, count / (after - before));
7299 /* Wait for a reply... */
7303 /* Return the good/bad news */
7304 return (vam->retval);
7308 api_bridge_domain_set_mac_age (vat_main_t * vam)
7310 unformat_input_t *i = vam->input;
7311 vl_api_bridge_domain_set_mac_age_t *mp;
7316 /* Parse args required to build the message */
7317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7319 if (unformat (i, "bd_id %d", &bd_id));
7320 else if (unformat (i, "mac-age %d", &mac_age));
7327 errmsg ("missing bridge domain");
7333 errmsg ("mac age must be less than 256 ");
7337 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7339 mp->bd_id = htonl (bd_id);
7340 mp->mac_age = (u8) mac_age;
7348 api_l2_flags (vat_main_t * vam)
7350 unformat_input_t *i = vam->input;
7351 vl_api_l2_flags_t *mp;
7354 u8 sw_if_index_set = 0;
7358 /* Parse args required to build the message */
7359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7361 if (unformat (i, "sw_if_index %d", &sw_if_index))
7362 sw_if_index_set = 1;
7363 else if (unformat (i, "sw_if"))
7365 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7368 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7369 sw_if_index_set = 1;
7374 else if (unformat (i, "learn"))
7376 else if (unformat (i, "forward"))
7378 else if (unformat (i, "flood"))
7380 else if (unformat (i, "uu-flood"))
7381 flags |= L2_UU_FLOOD;
7382 else if (unformat (i, "arp-term"))
7383 flags |= L2_ARP_TERM;
7384 else if (unformat (i, "off"))
7386 else if (unformat (i, "disable"))
7392 if (sw_if_index_set == 0)
7394 errmsg ("missing interface name or sw_if_index");
7400 mp->sw_if_index = ntohl (sw_if_index);
7401 mp->feature_bitmap = ntohl (flags);
7402 mp->is_set = is_set;
7410 api_bridge_flags (vat_main_t * vam)
7412 unformat_input_t *i = vam->input;
7413 vl_api_bridge_flags_t *mp;
7420 /* Parse args required to build the message */
7421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7423 if (unformat (i, "bd_id %d", &bd_id))
7425 else if (unformat (i, "learn"))
7427 else if (unformat (i, "forward"))
7429 else if (unformat (i, "flood"))
7431 else if (unformat (i, "uu-flood"))
7432 flags |= L2_UU_FLOOD;
7433 else if (unformat (i, "arp-term"))
7434 flags |= L2_ARP_TERM;
7435 else if (unformat (i, "off"))
7437 else if (unformat (i, "disable"))
7445 errmsg ("missing bridge domain");
7449 M (BRIDGE_FLAGS, mp);
7451 mp->bd_id = ntohl (bd_id);
7452 mp->feature_bitmap = ntohl (flags);
7453 mp->is_set = is_set;
7461 api_bd_ip_mac_add_del (vat_main_t * vam)
7463 unformat_input_t *i = vam->input;
7464 vl_api_bd_ip_mac_add_del_t *mp;
7471 ip4_address_t v4addr;
7472 ip6_address_t v6addr;
7477 /* Parse args required to build the message */
7478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7480 if (unformat (i, "bd_id %d", &bd_id))
7484 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7488 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7493 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7497 else if (unformat (i, "del"))
7505 errmsg ("missing bridge domain");
7508 else if (ip_set == 0)
7510 errmsg ("missing IP address");
7513 else if (mac_set == 0)
7515 errmsg ("missing MAC address");
7519 M (BD_IP_MAC_ADD_DEL, mp);
7521 mp->bd_id = ntohl (bd_id);
7522 mp->is_ipv6 = is_ipv6;
7523 mp->is_add = is_add;
7525 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7527 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7528 clib_memcpy (mp->mac_address, macaddr, 6);
7535 api_tap_connect (vat_main_t * vam)
7537 unformat_input_t *i = vam->input;
7538 vl_api_tap_connect_t *mp;
7544 ip4_address_t ip4_address;
7546 int ip4_address_set = 0;
7547 ip6_address_t ip6_address;
7549 int ip6_address_set = 0;
7552 memset (mac_address, 0, sizeof (mac_address));
7554 /* Parse args required to build the message */
7555 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7557 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7561 else if (unformat (i, "random-mac"))
7563 else if (unformat (i, "tapname %s", &tap_name))
7565 else if (unformat (i, "tag %s", &tag))
7567 else if (unformat (i, "address %U/%d",
7568 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7569 ip4_address_set = 1;
7570 else if (unformat (i, "address %U/%d",
7571 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7572 ip6_address_set = 1;
7579 errmsg ("missing tap name");
7582 if (vec_len (tap_name) > 63)
7584 errmsg ("tap name too long");
7587 vec_add1 (tap_name, 0);
7589 if (vec_len (tag) > 63)
7591 errmsg ("tag too long");
7595 /* Construct the API message */
7596 M (TAP_CONNECT, mp);
7598 mp->use_random_mac = random_mac;
7599 clib_memcpy (mp->mac_address, mac_address, 6);
7600 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7602 clib_memcpy (mp->tag, tag, vec_len (tag));
7604 if (ip4_address_set)
7606 mp->ip4_address_set = 1;
7607 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7608 mp->ip4_mask_width = ip4_mask_width;
7610 if (ip6_address_set)
7612 mp->ip6_address_set = 1;
7613 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7614 mp->ip6_mask_width = ip6_mask_width;
7617 vec_free (tap_name);
7623 /* Wait for a reply... */
7629 api_tap_modify (vat_main_t * vam)
7631 unformat_input_t *i = vam->input;
7632 vl_api_tap_modify_t *mp;
7637 u32 sw_if_index = ~0;
7638 u8 sw_if_index_set = 0;
7641 memset (mac_address, 0, sizeof (mac_address));
7643 /* Parse args required to build the message */
7644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7647 sw_if_index_set = 1;
7648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7649 sw_if_index_set = 1;
7650 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7654 else if (unformat (i, "random-mac"))
7656 else if (unformat (i, "tapname %s", &tap_name))
7662 if (sw_if_index_set == 0)
7664 errmsg ("missing vpp interface name");
7669 errmsg ("missing tap name");
7672 if (vec_len (tap_name) > 63)
7674 errmsg ("tap name too long");
7676 vec_add1 (tap_name, 0);
7678 /* Construct the API message */
7681 mp->use_random_mac = random_mac;
7682 mp->sw_if_index = ntohl (sw_if_index);
7683 clib_memcpy (mp->mac_address, mac_address, 6);
7684 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7685 vec_free (tap_name);
7690 /* Wait for a reply... */
7696 api_tap_delete (vat_main_t * vam)
7698 unformat_input_t *i = vam->input;
7699 vl_api_tap_delete_t *mp;
7700 u32 sw_if_index = ~0;
7701 u8 sw_if_index_set = 0;
7704 /* Parse args required to build the message */
7705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7707 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7708 sw_if_index_set = 1;
7709 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7710 sw_if_index_set = 1;
7715 if (sw_if_index_set == 0)
7717 errmsg ("missing vpp interface name");
7721 /* Construct the API message */
7724 mp->sw_if_index = ntohl (sw_if_index);
7729 /* Wait for a reply... */
7735 api_ip_table_add_del (vat_main_t * vam)
7737 unformat_input_t *i = vam->input;
7738 vl_api_ip_table_add_del_t *mp;
7744 /* Parse args required to build the message */
7745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7747 if (unformat (i, "ipv6"))
7749 else if (unformat (i, "del"))
7751 else if (unformat (i, "add"))
7753 else if (unformat (i, "table %d", &table_id))
7757 clib_warning ("parse error '%U'", format_unformat_error, i);
7764 errmsg ("missing table-ID");
7768 /* Construct the API message */
7769 M (IP_TABLE_ADD_DEL, mp);
7771 mp->table_id = ntohl (table_id);
7772 mp->is_ipv6 = is_ipv6;
7773 mp->is_add = is_add;
7778 /* Wait for a reply... */
7785 api_ip_add_del_route (vat_main_t * vam)
7787 unformat_input_t *i = vam->input;
7788 vl_api_ip_add_del_route_t *mp;
7789 u32 sw_if_index = ~0, vrf_id = 0;
7791 u8 is_local = 0, is_drop = 0;
7792 u8 is_unreach = 0, is_prohibit = 0;
7793 u8 create_vrf_if_needed = 0;
7795 u32 next_hop_weight = 1;
7796 u8 is_multipath = 0;
7798 u8 address_length_set = 0;
7799 u32 next_hop_table_id = 0;
7800 u32 resolve_attempts = 0;
7801 u32 dst_address_length = 0;
7802 u8 next_hop_set = 0;
7803 ip4_address_t v4_dst_address, v4_next_hop_address;
7804 ip6_address_t v6_dst_address, v6_next_hop_address;
7808 u32 random_add_del = 0;
7809 u32 *random_vector = 0;
7811 u32 random_seed = 0xdeaddabe;
7812 u32 classify_table_index = ~0;
7814 u8 resolve_host = 0, resolve_attached = 0;
7815 mpls_label_t *next_hop_out_label_stack = NULL;
7816 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7817 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7819 /* Parse args required to build the message */
7820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7826 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7831 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7836 else if (unformat (i, "/%d", &dst_address_length))
7838 address_length_set = 1;
7841 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7842 &v4_next_hop_address))
7846 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7847 &v6_next_hop_address))
7851 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7853 else if (unformat (i, "weight %d", &next_hop_weight))
7855 else if (unformat (i, "drop"))
7859 else if (unformat (i, "null-send-unreach"))
7863 else if (unformat (i, "null-send-prohibit"))
7867 else if (unformat (i, "local"))
7871 else if (unformat (i, "classify %d", &classify_table_index))
7875 else if (unformat (i, "del"))
7877 else if (unformat (i, "add"))
7879 else if (unformat (i, "resolve-via-host"))
7881 else if (unformat (i, "resolve-via-attached"))
7882 resolve_attached = 1;
7883 else if (unformat (i, "multipath"))
7885 else if (unformat (i, "vrf %d", &vrf_id))
7887 else if (unformat (i, "create-vrf"))
7888 create_vrf_if_needed = 1;
7889 else if (unformat (i, "count %d", &count))
7891 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7893 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7895 else if (unformat (i, "out-label %d", &next_hop_out_label))
7896 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7897 else if (unformat (i, "via-label %d", &next_hop_via_label))
7899 else if (unformat (i, "random"))
7901 else if (unformat (i, "seed %d", &random_seed))
7905 clib_warning ("parse error '%U'", format_unformat_error, i);
7910 if (!next_hop_set && !is_drop && !is_local &&
7911 !is_classify && !is_unreach && !is_prohibit &&
7912 MPLS_LABEL_INVALID == next_hop_via_label)
7915 ("next hop / local / drop / unreach / prohibit / classify not set");
7919 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7921 errmsg ("next hop and next-hop via label set");
7924 if (address_set == 0)
7926 errmsg ("missing addresses");
7930 if (address_length_set == 0)
7932 errmsg ("missing address length");
7936 /* Generate a pile of unique, random routes */
7939 u32 this_random_address;
7940 random_hash = hash_create (count, sizeof (uword));
7942 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7943 for (j = 0; j <= count; j++)
7947 this_random_address = random_u32 (&random_seed);
7948 this_random_address =
7949 clib_host_to_net_u32 (this_random_address);
7951 while (hash_get (random_hash, this_random_address));
7952 vec_add1 (random_vector, this_random_address);
7953 hash_set (random_hash, this_random_address, 1);
7955 hash_free (random_hash);
7956 v4_dst_address.as_u32 = random_vector[0];
7961 /* Turn on async mode */
7962 vam->async_mode = 1;
7963 vam->async_errors = 0;
7964 before = vat_time_now (vam);
7967 for (j = 0; j < count; j++)
7969 /* Construct the API message */
7970 M2 (IP_ADD_DEL_ROUTE, mp,
7971 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7973 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7974 mp->table_id = ntohl (vrf_id);
7975 mp->create_vrf_if_needed = create_vrf_if_needed;
7977 mp->is_add = is_add;
7978 mp->is_drop = is_drop;
7979 mp->is_unreach = is_unreach;
7980 mp->is_prohibit = is_prohibit;
7981 mp->is_ipv6 = is_ipv6;
7982 mp->is_local = is_local;
7983 mp->is_classify = is_classify;
7984 mp->is_multipath = is_multipath;
7985 mp->is_resolve_host = resolve_host;
7986 mp->is_resolve_attached = resolve_attached;
7987 mp->next_hop_weight = next_hop_weight;
7988 mp->dst_address_length = dst_address_length;
7989 mp->next_hop_table_id = ntohl (next_hop_table_id);
7990 mp->classify_table_index = ntohl (classify_table_index);
7991 mp->next_hop_via_label = ntohl (next_hop_via_label);
7992 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7993 if (0 != mp->next_hop_n_out_labels)
7995 memcpy (mp->next_hop_out_label_stack,
7996 next_hop_out_label_stack,
7997 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7998 vec_free (next_hop_out_label_stack);
8003 clib_memcpy (mp->dst_address, &v6_dst_address,
8004 sizeof (v6_dst_address));
8006 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8007 sizeof (v6_next_hop_address));
8008 increment_v6_address (&v6_dst_address);
8012 clib_memcpy (mp->dst_address, &v4_dst_address,
8013 sizeof (v4_dst_address));
8015 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8016 sizeof (v4_next_hop_address));
8018 v4_dst_address.as_u32 = random_vector[j + 1];
8020 increment_v4_address (&v4_dst_address);
8024 /* If we receive SIGTERM, stop now... */
8029 /* When testing multiple add/del ops, use a control-ping to sync */
8032 vl_api_control_ping_t *mp_ping;
8036 /* Shut off async mode */
8037 vam->async_mode = 0;
8039 MPING (CONTROL_PING, mp_ping);
8042 timeout = vat_time_now (vam) + 1.0;
8043 while (vat_time_now (vam) < timeout)
8044 if (vam->result_ready == 1)
8049 if (vam->retval == -99)
8052 if (vam->async_errors > 0)
8054 errmsg ("%d asynchronous errors", vam->async_errors);
8057 vam->async_errors = 0;
8058 after = vat_time_now (vam);
8060 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8064 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8065 count, after - before, count / (after - before));
8071 /* Wait for a reply... */
8076 /* Return the good/bad news */
8077 return (vam->retval);
8081 api_ip_mroute_add_del (vat_main_t * vam)
8083 unformat_input_t *i = vam->input;
8084 vl_api_ip_mroute_add_del_t *mp;
8085 u32 sw_if_index = ~0, vrf_id = 0;
8088 u8 create_vrf_if_needed = 0;
8091 u32 grp_address_length = 0;
8092 ip4_address_t v4_grp_address, v4_src_address;
8093 ip6_address_t v6_grp_address, v6_src_address;
8094 mfib_itf_flags_t iflags = 0;
8095 mfib_entry_flags_t eflags = 0;
8098 /* Parse args required to build the message */
8099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8101 if (unformat (i, "sw_if_index %d", &sw_if_index))
8103 else if (unformat (i, "%U %U",
8104 unformat_ip4_address, &v4_src_address,
8105 unformat_ip4_address, &v4_grp_address))
8107 grp_address_length = 64;
8111 else if (unformat (i, "%U %U",
8112 unformat_ip6_address, &v6_src_address,
8113 unformat_ip6_address, &v6_grp_address))
8115 grp_address_length = 256;
8119 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8121 memset (&v4_src_address, 0, sizeof (v4_src_address));
8122 grp_address_length = 32;
8126 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8128 memset (&v6_src_address, 0, sizeof (v6_src_address));
8129 grp_address_length = 128;
8133 else if (unformat (i, "/%d", &grp_address_length))
8135 else if (unformat (i, "local"))
8139 else if (unformat (i, "del"))
8141 else if (unformat (i, "add"))
8143 else if (unformat (i, "vrf %d", &vrf_id))
8145 else if (unformat (i, "create-vrf"))
8146 create_vrf_if_needed = 1;
8147 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8149 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8153 clib_warning ("parse error '%U'", format_unformat_error, i);
8158 if (address_set == 0)
8160 errmsg ("missing addresses\n");
8164 /* Construct the API message */
8165 M (IP_MROUTE_ADD_DEL, mp);
8167 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8168 mp->table_id = ntohl (vrf_id);
8169 mp->create_vrf_if_needed = create_vrf_if_needed;
8171 mp->is_add = is_add;
8172 mp->is_ipv6 = is_ipv6;
8173 mp->is_local = is_local;
8174 mp->itf_flags = ntohl (iflags);
8175 mp->entry_flags = ntohl (eflags);
8176 mp->grp_address_length = grp_address_length;
8177 mp->grp_address_length = ntohs (mp->grp_address_length);
8181 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8182 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8186 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8187 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8193 /* Wait for a reply... */
8199 api_mpls_table_add_del (vat_main_t * vam)
8201 unformat_input_t *i = vam->input;
8202 vl_api_mpls_table_add_del_t *mp;
8207 /* Parse args required to build the message */
8208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8210 if (unformat (i, "table %d", &table_id))
8212 else if (unformat (i, "del"))
8214 else if (unformat (i, "add"))
8218 clib_warning ("parse error '%U'", format_unformat_error, i);
8225 errmsg ("missing table-ID");
8229 /* Construct the API message */
8230 M (MPLS_TABLE_ADD_DEL, mp);
8232 mp->mt_table_id = ntohl (table_id);
8233 mp->mt_is_add = is_add;
8238 /* Wait for a reply... */
8245 api_mpls_route_add_del (vat_main_t * vam)
8247 unformat_input_t *i = vam->input;
8248 vl_api_mpls_route_add_del_t *mp;
8249 u32 sw_if_index = ~0, table_id = 0;
8250 u8 create_table_if_needed = 0;
8252 u32 next_hop_weight = 1;
8253 u8 is_multipath = 0;
8254 u32 next_hop_table_id = 0;
8255 u8 next_hop_set = 0;
8256 ip4_address_t v4_next_hop_address = {
8259 ip6_address_t v6_next_hop_address = { {0} };
8263 u32 classify_table_index = ~0;
8265 u8 resolve_host = 0, resolve_attached = 0;
8266 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8267 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8268 mpls_label_t *next_hop_out_label_stack = NULL;
8269 mpls_label_t local_label = MPLS_LABEL_INVALID;
8271 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8273 /* Parse args required to build the message */
8274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8276 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8278 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8280 else if (unformat (i, "%d", &local_label))
8282 else if (unformat (i, "eos"))
8284 else if (unformat (i, "non-eos"))
8286 else if (unformat (i, "via %U", unformat_ip4_address,
8287 &v4_next_hop_address))
8290 next_hop_proto = DPO_PROTO_IP4;
8292 else if (unformat (i, "via %U", unformat_ip6_address,
8293 &v6_next_hop_address))
8296 next_hop_proto = DPO_PROTO_IP6;
8298 else if (unformat (i, "weight %d", &next_hop_weight))
8300 else if (unformat (i, "create-table"))
8301 create_table_if_needed = 1;
8302 else if (unformat (i, "classify %d", &classify_table_index))
8306 else if (unformat (i, "del"))
8308 else if (unformat (i, "add"))
8310 else if (unformat (i, "resolve-via-host"))
8312 else if (unformat (i, "resolve-via-attached"))
8313 resolve_attached = 1;
8314 else if (unformat (i, "multipath"))
8316 else if (unformat (i, "count %d", &count))
8318 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8321 next_hop_proto = DPO_PROTO_IP4;
8323 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8326 next_hop_proto = DPO_PROTO_IP6;
8328 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8330 else if (unformat (i, "via-label %d", &next_hop_via_label))
8332 else if (unformat (i, "out-label %d", &next_hop_out_label))
8333 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8336 clib_warning ("parse error '%U'", format_unformat_error, i);
8341 if (!next_hop_set && !is_classify)
8343 errmsg ("next hop / classify not set");
8347 if (MPLS_LABEL_INVALID == local_label)
8349 errmsg ("missing label");
8355 /* Turn on async mode */
8356 vam->async_mode = 1;
8357 vam->async_errors = 0;
8358 before = vat_time_now (vam);
8361 for (j = 0; j < count; j++)
8363 /* Construct the API message */
8364 M2 (MPLS_ROUTE_ADD_DEL, mp,
8365 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8367 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8368 mp->mr_table_id = ntohl (table_id);
8369 mp->mr_create_table_if_needed = create_table_if_needed;
8371 mp->mr_is_add = is_add;
8372 mp->mr_next_hop_proto = next_hop_proto;
8373 mp->mr_is_classify = is_classify;
8374 mp->mr_is_multipath = is_multipath;
8375 mp->mr_is_resolve_host = resolve_host;
8376 mp->mr_is_resolve_attached = resolve_attached;
8377 mp->mr_next_hop_weight = next_hop_weight;
8378 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8379 mp->mr_classify_table_index = ntohl (classify_table_index);
8380 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8381 mp->mr_label = ntohl (local_label);
8382 mp->mr_eos = is_eos;
8384 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8385 if (0 != mp->mr_next_hop_n_out_labels)
8387 memcpy (mp->mr_next_hop_out_label_stack,
8388 next_hop_out_label_stack,
8389 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8390 vec_free (next_hop_out_label_stack);
8395 if (DPO_PROTO_IP4 == next_hop_proto)
8397 clib_memcpy (mp->mr_next_hop,
8398 &v4_next_hop_address,
8399 sizeof (v4_next_hop_address));
8401 else if (DPO_PROTO_IP6 == next_hop_proto)
8404 clib_memcpy (mp->mr_next_hop,
8405 &v6_next_hop_address,
8406 sizeof (v6_next_hop_address));
8413 /* If we receive SIGTERM, stop now... */
8418 /* When testing multiple add/del ops, use a control-ping to sync */
8421 vl_api_control_ping_t *mp_ping;
8425 /* Shut off async mode */
8426 vam->async_mode = 0;
8428 MPING (CONTROL_PING, mp_ping);
8431 timeout = vat_time_now (vam) + 1.0;
8432 while (vat_time_now (vam) < timeout)
8433 if (vam->result_ready == 1)
8438 if (vam->retval == -99)
8441 if (vam->async_errors > 0)
8443 errmsg ("%d asynchronous errors", vam->async_errors);
8446 vam->async_errors = 0;
8447 after = vat_time_now (vam);
8449 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8453 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8454 count, after - before, count / (after - before));
8460 /* Wait for a reply... */
8465 /* Return the good/bad news */
8466 return (vam->retval);
8470 api_mpls_ip_bind_unbind (vat_main_t * vam)
8472 unformat_input_t *i = vam->input;
8473 vl_api_mpls_ip_bind_unbind_t *mp;
8474 u32 ip_table_id = 0;
8475 u8 create_table_if_needed = 0;
8478 ip4_address_t v4_address;
8479 ip6_address_t v6_address;
8482 mpls_label_t local_label = MPLS_LABEL_INVALID;
8485 /* Parse args required to build the message */
8486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8488 if (unformat (i, "%U/%d", unformat_ip4_address,
8489 &v4_address, &address_length))
8494 else if (unformat (i, "%U/%d", unformat_ip6_address,
8495 &v6_address, &address_length))
8500 else if (unformat (i, "%d", &local_label))
8502 else if (unformat (i, "create-table"))
8503 create_table_if_needed = 1;
8504 else if (unformat (i, "table-id %d", &ip_table_id))
8506 else if (unformat (i, "unbind"))
8508 else if (unformat (i, "bind"))
8512 clib_warning ("parse error '%U'", format_unformat_error, i);
8519 errmsg ("IP addres not set");
8523 if (MPLS_LABEL_INVALID == local_label)
8525 errmsg ("missing label");
8529 /* Construct the API message */
8530 M (MPLS_IP_BIND_UNBIND, mp);
8532 mp->mb_create_table_if_needed = create_table_if_needed;
8533 mp->mb_is_bind = is_bind;
8534 mp->mb_is_ip4 = is_ip4;
8535 mp->mb_ip_table_id = ntohl (ip_table_id);
8536 mp->mb_mpls_table_id = 0;
8537 mp->mb_label = ntohl (local_label);
8538 mp->mb_address_length = address_length;
8541 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8543 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8548 /* Wait for a reply... */
8554 api_bier_table_add_del (vat_main_t * vam)
8556 unformat_input_t *i = vam->input;
8557 vl_api_bier_table_add_del_t *mp;
8559 u32 set = 0, sub_domain = 0, hdr_len = 3;
8560 mpls_label_t local_label = MPLS_LABEL_INVALID;
8563 /* Parse args required to build the message */
8564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8566 if (unformat (i, "sub-domain %d", &sub_domain))
8568 else if (unformat (i, "set %d", &set))
8570 else if (unformat (i, "label %d", &local_label))
8572 else if (unformat (i, "hdr-len %d", &hdr_len))
8574 else if (unformat (i, "add"))
8576 else if (unformat (i, "del"))
8580 clib_warning ("parse error '%U'", format_unformat_error, i);
8585 if (MPLS_LABEL_INVALID == local_label)
8587 errmsg ("missing label\n");
8591 /* Construct the API message */
8592 M (BIER_TABLE_ADD_DEL, mp);
8594 mp->bt_is_add = is_add;
8595 mp->bt_label = ntohl (local_label);
8596 mp->bt_tbl_id.bt_set = set;
8597 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8598 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8603 /* Wait for a reply... */
8610 api_bier_route_add_del (vat_main_t * vam)
8612 unformat_input_t *i = vam->input;
8613 vl_api_bier_route_add_del_t *mp;
8615 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8616 ip4_address_t v4_next_hop_address;
8617 ip6_address_t v6_next_hop_address;
8618 u8 next_hop_set = 0;
8619 u8 next_hop_proto_is_ip4 = 1;
8620 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8623 /* Parse args required to build the message */
8624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8626 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8628 next_hop_proto_is_ip4 = 1;
8631 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8633 next_hop_proto_is_ip4 = 0;
8636 if (unformat (i, "sub-domain %d", &sub_domain))
8638 else if (unformat (i, "set %d", &set))
8640 else if (unformat (i, "hdr-len %d", &hdr_len))
8642 else if (unformat (i, "bp %d", &bp))
8644 else if (unformat (i, "add"))
8646 else if (unformat (i, "del"))
8648 else if (unformat (i, "out-label %d", &next_hop_out_label))
8652 clib_warning ("parse error '%U'", format_unformat_error, i);
8657 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8659 errmsg ("next hop / label set\n");
8664 errmsg ("bit=position not set\n");
8668 /* Construct the API message */
8669 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path3_t));
8671 mp->br_is_add = is_add;
8672 mp->br_tbl_id.bt_set = set;
8673 mp->br_tbl_id.bt_sub_domain = sub_domain;
8674 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
8675 mp->br_bp = ntohs (bp);
8677 mp->br_paths[0].n_labels = 1;
8678 mp->br_paths[0].label_stack[0] = ntohl (next_hop_out_label);
8679 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
8681 if (next_hop_proto_is_ip4)
8683 clib_memcpy (mp->br_paths[0].next_hop,
8684 &v4_next_hop_address, sizeof (v4_next_hop_address));
8688 clib_memcpy (mp->br_paths[0].next_hop,
8689 &v6_next_hop_address, sizeof (v6_next_hop_address));
8695 /* Wait for a reply... */
8702 api_proxy_arp_add_del (vat_main_t * vam)
8704 unformat_input_t *i = vam->input;
8705 vl_api_proxy_arp_add_del_t *mp;
8708 ip4_address_t lo, hi;
8712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8714 if (unformat (i, "vrf %d", &vrf_id))
8716 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8717 unformat_ip4_address, &hi))
8719 else if (unformat (i, "del"))
8723 clib_warning ("parse error '%U'", format_unformat_error, i);
8730 errmsg ("address range not set");
8734 M (PROXY_ARP_ADD_DEL, mp);
8736 mp->vrf_id = ntohl (vrf_id);
8737 mp->is_add = is_add;
8738 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8739 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8747 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8749 unformat_input_t *i = vam->input;
8750 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8753 u8 sw_if_index_set = 0;
8756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8759 sw_if_index_set = 1;
8760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8761 sw_if_index_set = 1;
8762 else if (unformat (i, "enable"))
8764 else if (unformat (i, "disable"))
8768 clib_warning ("parse error '%U'", format_unformat_error, i);
8773 if (sw_if_index_set == 0)
8775 errmsg ("missing interface name or sw_if_index");
8779 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8781 mp->sw_if_index = ntohl (sw_if_index);
8782 mp->enable_disable = enable;
8790 api_mpls_tunnel_add_del (vat_main_t * vam)
8792 unformat_input_t *i = vam->input;
8793 vl_api_mpls_tunnel_add_del_t *mp;
8797 u32 sw_if_index = ~0;
8798 u32 next_hop_sw_if_index = ~0;
8799 u32 next_hop_proto_is_ip4 = 1;
8801 u32 next_hop_table_id = 0;
8802 ip4_address_t v4_next_hop_address = {
8805 ip6_address_t v6_next_hop_address = { {0} };
8806 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8811 if (unformat (i, "add"))
8813 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8815 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8817 else if (unformat (i, "via %U",
8818 unformat_ip4_address, &v4_next_hop_address))
8820 next_hop_proto_is_ip4 = 1;
8822 else if (unformat (i, "via %U",
8823 unformat_ip6_address, &v6_next_hop_address))
8825 next_hop_proto_is_ip4 = 0;
8827 else if (unformat (i, "l2-only"))
8829 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8831 else if (unformat (i, "out-label %d", &next_hop_out_label))
8832 vec_add1 (labels, ntohl (next_hop_out_label));
8835 clib_warning ("parse error '%U'", format_unformat_error, i);
8840 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8842 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8843 mp->mt_sw_if_index = ntohl (sw_if_index);
8844 mp->mt_is_add = is_add;
8845 mp->mt_l2_only = l2_only;
8846 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8847 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8849 mp->mt_next_hop_n_out_labels = vec_len (labels);
8851 if (0 != mp->mt_next_hop_n_out_labels)
8853 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8854 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8858 if (next_hop_proto_is_ip4)
8860 clib_memcpy (mp->mt_next_hop,
8861 &v4_next_hop_address, sizeof (v4_next_hop_address));
8865 clib_memcpy (mp->mt_next_hop,
8866 &v6_next_hop_address, sizeof (v6_next_hop_address));
8875 api_sw_interface_set_unnumbered (vat_main_t * vam)
8877 unformat_input_t *i = vam->input;
8878 vl_api_sw_interface_set_unnumbered_t *mp;
8880 u32 unnum_sw_index = ~0;
8882 u8 sw_if_index_set = 0;
8885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8888 sw_if_index_set = 1;
8889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8890 sw_if_index_set = 1;
8891 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8893 else if (unformat (i, "del"))
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8902 if (sw_if_index_set == 0)
8904 errmsg ("missing interface name or sw_if_index");
8908 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8910 mp->sw_if_index = ntohl (sw_if_index);
8911 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8912 mp->is_add = is_add;
8920 api_ip_neighbor_add_del (vat_main_t * vam)
8922 unformat_input_t *i = vam->input;
8923 vl_api_ip_neighbor_add_del_t *mp;
8925 u8 sw_if_index_set = 0;
8928 u8 is_no_fib_entry = 0;
8931 u8 v4_address_set = 0;
8932 u8 v6_address_set = 0;
8933 ip4_address_t v4address;
8934 ip6_address_t v6address;
8937 memset (mac_address, 0, sizeof (mac_address));
8939 /* Parse args required to build the message */
8940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8942 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8946 else if (unformat (i, "del"))
8949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8950 sw_if_index_set = 1;
8951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8952 sw_if_index_set = 1;
8953 else if (unformat (i, "is_static"))
8955 else if (unformat (i, "no-fib-entry"))
8956 is_no_fib_entry = 1;
8957 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8959 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8963 clib_warning ("parse error '%U'", format_unformat_error, i);
8968 if (sw_if_index_set == 0)
8970 errmsg ("missing interface name or sw_if_index");
8973 if (v4_address_set && v6_address_set)
8975 errmsg ("both v4 and v6 addresses set");
8978 if (!v4_address_set && !v6_address_set)
8980 errmsg ("no address set");
8984 /* Construct the API message */
8985 M (IP_NEIGHBOR_ADD_DEL, mp);
8987 mp->sw_if_index = ntohl (sw_if_index);
8988 mp->is_add = is_add;
8989 mp->is_static = is_static;
8990 mp->is_no_adj_fib = is_no_fib_entry;
8992 clib_memcpy (mp->mac_address, mac_address, 6);
8996 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
9000 /* mp->is_ipv6 = 0; via memset in M macro above */
9001 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
9007 /* Wait for a reply, return good/bad news */
9013 api_reset_vrf (vat_main_t * vam)
9015 unformat_input_t *i = vam->input;
9016 vl_api_reset_vrf_t *mp;
9022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9024 if (unformat (i, "vrf %d", &vrf_id))
9026 else if (unformat (i, "ipv6"))
9030 clib_warning ("parse error '%U'", format_unformat_error, i);
9035 if (vrf_id_set == 0)
9037 errmsg ("missing vrf id");
9043 mp->vrf_id = ntohl (vrf_id);
9044 mp->is_ipv6 = is_ipv6;
9052 api_create_vlan_subif (vat_main_t * vam)
9054 unformat_input_t *i = vam->input;
9055 vl_api_create_vlan_subif_t *mp;
9057 u8 sw_if_index_set = 0;
9062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9064 if (unformat (i, "sw_if_index %d", &sw_if_index))
9065 sw_if_index_set = 1;
9067 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9068 sw_if_index_set = 1;
9069 else if (unformat (i, "vlan %d", &vlan_id))
9073 clib_warning ("parse error '%U'", format_unformat_error, i);
9078 if (sw_if_index_set == 0)
9080 errmsg ("missing interface name or sw_if_index");
9084 if (vlan_id_set == 0)
9086 errmsg ("missing vlan_id");
9089 M (CREATE_VLAN_SUBIF, mp);
9091 mp->sw_if_index = ntohl (sw_if_index);
9092 mp->vlan_id = ntohl (vlan_id);
9099 #define foreach_create_subif_bit \
9106 _(outer_vlan_id_any) \
9107 _(inner_vlan_id_any)
9110 api_create_subif (vat_main_t * vam)
9112 unformat_input_t *i = vam->input;
9113 vl_api_create_subif_t *mp;
9115 u8 sw_if_index_set = 0;
9122 u32 exact_match = 0;
9123 u32 default_sub = 0;
9124 u32 outer_vlan_id_any = 0;
9125 u32 inner_vlan_id_any = 0;
9127 u16 outer_vlan_id = 0;
9128 u16 inner_vlan_id = 0;
9131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9133 if (unformat (i, "sw_if_index %d", &sw_if_index))
9134 sw_if_index_set = 1;
9136 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9137 sw_if_index_set = 1;
9138 else if (unformat (i, "sub_id %d", &sub_id))
9140 else if (unformat (i, "outer_vlan_id %d", &tmp))
9141 outer_vlan_id = tmp;
9142 else if (unformat (i, "inner_vlan_id %d", &tmp))
9143 inner_vlan_id = tmp;
9145 #define _(a) else if (unformat (i, #a)) a = 1 ;
9146 foreach_create_subif_bit
9150 clib_warning ("parse error '%U'", format_unformat_error, i);
9155 if (sw_if_index_set == 0)
9157 errmsg ("missing interface name or sw_if_index");
9161 if (sub_id_set == 0)
9163 errmsg ("missing sub_id");
9166 M (CREATE_SUBIF, mp);
9168 mp->sw_if_index = ntohl (sw_if_index);
9169 mp->sub_id = ntohl (sub_id);
9171 #define _(a) mp->a = a;
9172 foreach_create_subif_bit;
9175 mp->outer_vlan_id = ntohs (outer_vlan_id);
9176 mp->inner_vlan_id = ntohs (inner_vlan_id);
9184 api_oam_add_del (vat_main_t * vam)
9186 unformat_input_t *i = vam->input;
9187 vl_api_oam_add_del_t *mp;
9190 ip4_address_t src, dst;
9195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9197 if (unformat (i, "vrf %d", &vrf_id))
9199 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9201 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9203 else if (unformat (i, "del"))
9207 clib_warning ("parse error '%U'", format_unformat_error, i);
9214 errmsg ("missing src addr");
9220 errmsg ("missing dst addr");
9224 M (OAM_ADD_DEL, mp);
9226 mp->vrf_id = ntohl (vrf_id);
9227 mp->is_add = is_add;
9228 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9229 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9237 api_reset_fib (vat_main_t * vam)
9239 unformat_input_t *i = vam->input;
9240 vl_api_reset_fib_t *mp;
9246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9248 if (unformat (i, "vrf %d", &vrf_id))
9250 else if (unformat (i, "ipv6"))
9254 clib_warning ("parse error '%U'", format_unformat_error, i);
9259 if (vrf_id_set == 0)
9261 errmsg ("missing vrf id");
9267 mp->vrf_id = ntohl (vrf_id);
9268 mp->is_ipv6 = is_ipv6;
9276 api_dhcp_proxy_config (vat_main_t * vam)
9278 unformat_input_t *i = vam->input;
9279 vl_api_dhcp_proxy_config_t *mp;
9281 u32 server_vrf_id = 0;
9283 u8 v4_address_set = 0;
9284 u8 v6_address_set = 0;
9285 ip4_address_t v4address;
9286 ip6_address_t v6address;
9287 u8 v4_src_address_set = 0;
9288 u8 v6_src_address_set = 0;
9289 ip4_address_t v4srcaddress;
9290 ip6_address_t v6srcaddress;
9293 /* Parse args required to build the message */
9294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9296 if (unformat (i, "del"))
9298 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9300 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9302 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9304 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9306 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9307 v4_src_address_set = 1;
9308 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9309 v6_src_address_set = 1;
9314 if (v4_address_set && v6_address_set)
9316 errmsg ("both v4 and v6 server addresses set");
9319 if (!v4_address_set && !v6_address_set)
9321 errmsg ("no server addresses set");
9325 if (v4_src_address_set && v6_src_address_set)
9327 errmsg ("both v4 and v6 src addresses set");
9330 if (!v4_src_address_set && !v6_src_address_set)
9332 errmsg ("no src addresses set");
9336 if (!(v4_src_address_set && v4_address_set) &&
9337 !(v6_src_address_set && v6_address_set))
9339 errmsg ("no matching server and src addresses set");
9343 /* Construct the API message */
9344 M (DHCP_PROXY_CONFIG, mp);
9346 mp->is_add = is_add;
9347 mp->rx_vrf_id = ntohl (rx_vrf_id);
9348 mp->server_vrf_id = ntohl (server_vrf_id);
9352 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9353 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9357 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9358 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9364 /* Wait for a reply, return good/bad news */
9369 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9370 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9373 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9375 vat_main_t *vam = &vat_main;
9376 u32 i, count = mp->count;
9377 vl_api_dhcp_server_t *s;
9381 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9382 ntohl (mp->rx_vrf_id),
9383 format_ip6_address, mp->dhcp_src_address,
9384 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9387 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9388 ntohl (mp->rx_vrf_id),
9389 format_ip4_address, mp->dhcp_src_address,
9390 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9392 for (i = 0; i < count; i++)
9394 s = &mp->servers[i];
9398 " Server Table-ID %d, Server Address %U",
9399 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9402 " Server Table-ID %d, Server Address %U",
9403 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9407 static void vl_api_dhcp_proxy_details_t_handler_json
9408 (vl_api_dhcp_proxy_details_t * mp)
9410 vat_main_t *vam = &vat_main;
9411 vat_json_node_t *node = NULL;
9412 u32 i, count = mp->count;
9414 struct in6_addr ip6;
9415 vl_api_dhcp_server_t *s;
9417 if (VAT_JSON_ARRAY != vam->json_tree.type)
9419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9420 vat_json_init_array (&vam->json_tree);
9422 node = vat_json_array_add (&vam->json_tree);
9424 vat_json_init_object (node);
9425 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9426 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9427 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9431 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9432 vat_json_object_add_ip6 (node, "src_address", ip6);
9436 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9437 vat_json_object_add_ip4 (node, "src_address", ip4);
9440 for (i = 0; i < count; i++)
9442 s = &mp->servers[i];
9444 vat_json_object_add_uint (node, "server-table-id",
9445 ntohl (s->server_vrf_id));
9449 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9450 vat_json_object_add_ip4 (node, "src_address", ip4);
9454 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9455 vat_json_object_add_ip6 (node, "server_address", ip6);
9461 api_dhcp_proxy_dump (vat_main_t * vam)
9463 unformat_input_t *i = vam->input;
9464 vl_api_control_ping_t *mp_ping;
9465 vl_api_dhcp_proxy_dump_t *mp;
9469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9471 if (unformat (i, "ipv6"))
9475 clib_warning ("parse error '%U'", format_unformat_error, i);
9480 M (DHCP_PROXY_DUMP, mp);
9482 mp->is_ip6 = is_ipv6;
9485 /* Use a control ping for synchronization */
9486 MPING (CONTROL_PING, mp_ping);
9494 api_dhcp_proxy_set_vss (vat_main_t * vam)
9496 unformat_input_t *i = vam->input;
9497 vl_api_dhcp_proxy_set_vss_t *mp;
9508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9510 if (unformat (i, "tbl_id %d", &tbl_id))
9512 if (unformat (i, "fib_id %d", &fib_id))
9514 if (unformat (i, "oui %d", &oui))
9516 else if (unformat (i, "ipv6"))
9518 else if (unformat (i, "del"))
9522 clib_warning ("parse error '%U'", format_unformat_error, i);
9527 if (tbl_id_set == 0)
9529 errmsg ("missing tbl id");
9533 if (fib_id_set == 0)
9535 errmsg ("missing fib id");
9540 errmsg ("missing oui");
9544 M (DHCP_PROXY_SET_VSS, mp);
9545 mp->tbl_id = ntohl (tbl_id);
9546 mp->fib_id = ntohl (fib_id);
9547 mp->oui = ntohl (oui);
9548 mp->is_ipv6 = is_ipv6;
9549 mp->is_add = is_add;
9557 api_dhcp_client_config (vat_main_t * vam)
9559 unformat_input_t *i = vam->input;
9560 vl_api_dhcp_client_config_t *mp;
9562 u8 sw_if_index_set = 0;
9565 u8 disable_event = 0;
9568 /* Parse args required to build the message */
9569 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9571 if (unformat (i, "del"))
9574 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9575 sw_if_index_set = 1;
9576 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9577 sw_if_index_set = 1;
9578 else if (unformat (i, "hostname %s", &hostname))
9580 else if (unformat (i, "disable_event"))
9586 if (sw_if_index_set == 0)
9588 errmsg ("missing interface name or sw_if_index");
9592 if (vec_len (hostname) > 63)
9594 errmsg ("hostname too long");
9596 vec_add1 (hostname, 0);
9598 /* Construct the API message */
9599 M (DHCP_CLIENT_CONFIG, mp);
9601 mp->sw_if_index = htonl (sw_if_index);
9602 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9603 vec_free (hostname);
9604 mp->is_add = is_add;
9605 mp->want_dhcp_event = disable_event ? 0 : 1;
9606 mp->pid = htonl (getpid ());
9611 /* Wait for a reply, return good/bad news */
9617 api_set_ip_flow_hash (vat_main_t * vam)
9619 unformat_input_t *i = vam->input;
9620 vl_api_set_ip_flow_hash_t *mp;
9632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9634 if (unformat (i, "vrf %d", &vrf_id))
9636 else if (unformat (i, "ipv6"))
9638 else if (unformat (i, "src"))
9640 else if (unformat (i, "dst"))
9642 else if (unformat (i, "sport"))
9644 else if (unformat (i, "dport"))
9646 else if (unformat (i, "proto"))
9648 else if (unformat (i, "reverse"))
9653 clib_warning ("parse error '%U'", format_unformat_error, i);
9658 if (vrf_id_set == 0)
9660 errmsg ("missing vrf id");
9664 M (SET_IP_FLOW_HASH, mp);
9670 mp->reverse = reverse;
9671 mp->vrf_id = ntohl (vrf_id);
9672 mp->is_ipv6 = is_ipv6;
9680 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9682 unformat_input_t *i = vam->input;
9683 vl_api_sw_interface_ip6_enable_disable_t *mp;
9685 u8 sw_if_index_set = 0;
9689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9691 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9692 sw_if_index_set = 1;
9693 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9694 sw_if_index_set = 1;
9695 else if (unformat (i, "enable"))
9697 else if (unformat (i, "disable"))
9701 clib_warning ("parse error '%U'", format_unformat_error, i);
9706 if (sw_if_index_set == 0)
9708 errmsg ("missing interface name or sw_if_index");
9712 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9714 mp->sw_if_index = ntohl (sw_if_index);
9715 mp->enable = enable;
9723 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9725 unformat_input_t *i = vam->input;
9726 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9728 u8 sw_if_index_set = 0;
9729 u8 v6_address_set = 0;
9730 ip6_address_t v6address;
9733 /* Parse args required to build the message */
9734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9736 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9737 sw_if_index_set = 1;
9738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9739 sw_if_index_set = 1;
9740 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9746 if (sw_if_index_set == 0)
9748 errmsg ("missing interface name or sw_if_index");
9751 if (!v6_address_set)
9753 errmsg ("no address set");
9757 /* Construct the API message */
9758 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9760 mp->sw_if_index = ntohl (sw_if_index);
9761 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9766 /* Wait for a reply, return good/bad news */
9772 api_ip6nd_proxy_add_del (vat_main_t * vam)
9774 unformat_input_t *i = vam->input;
9775 vl_api_ip6nd_proxy_add_del_t *mp;
9776 u32 sw_if_index = ~0;
9777 u8 v6_address_set = 0;
9778 ip6_address_t v6address;
9782 /* Parse args required to build the message */
9783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9785 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9787 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9789 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9791 if (unformat (i, "del"))
9795 clib_warning ("parse error '%U'", format_unformat_error, i);
9800 if (sw_if_index == ~0)
9802 errmsg ("missing interface name or sw_if_index");
9805 if (!v6_address_set)
9807 errmsg ("no address set");
9811 /* Construct the API message */
9812 M (IP6ND_PROXY_ADD_DEL, mp);
9814 mp->is_del = is_del;
9815 mp->sw_if_index = ntohl (sw_if_index);
9816 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9821 /* Wait for a reply, return good/bad news */
9827 api_ip6nd_proxy_dump (vat_main_t * vam)
9829 vl_api_ip6nd_proxy_dump_t *mp;
9830 vl_api_control_ping_t *mp_ping;
9833 M (IP6ND_PROXY_DUMP, mp);
9837 /* Use a control ping for synchronization */
9838 MPING (CONTROL_PING, mp_ping);
9845 static void vl_api_ip6nd_proxy_details_t_handler
9846 (vl_api_ip6nd_proxy_details_t * mp)
9848 vat_main_t *vam = &vat_main;
9850 print (vam->ofp, "host %U sw_if_index %d",
9851 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9854 static void vl_api_ip6nd_proxy_details_t_handler_json
9855 (vl_api_ip6nd_proxy_details_t * mp)
9857 vat_main_t *vam = &vat_main;
9858 struct in6_addr ip6;
9859 vat_json_node_t *node = NULL;
9861 if (VAT_JSON_ARRAY != vam->json_tree.type)
9863 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9864 vat_json_init_array (&vam->json_tree);
9866 node = vat_json_array_add (&vam->json_tree);
9868 vat_json_init_object (node);
9869 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9871 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9872 vat_json_object_add_ip6 (node, "host", ip6);
9876 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9878 unformat_input_t *i = vam->input;
9879 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9881 u8 sw_if_index_set = 0;
9882 u32 address_length = 0;
9883 u8 v6_address_set = 0;
9884 ip6_address_t v6address;
9886 u8 no_advertise = 0;
9888 u8 no_autoconfig = 0;
9891 u32 val_lifetime = 0;
9892 u32 pref_lifetime = 0;
9895 /* Parse args required to build the message */
9896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9899 sw_if_index_set = 1;
9900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9901 sw_if_index_set = 1;
9902 else if (unformat (i, "%U/%d",
9903 unformat_ip6_address, &v6address, &address_length))
9905 else if (unformat (i, "val_life %d", &val_lifetime))
9907 else if (unformat (i, "pref_life %d", &pref_lifetime))
9909 else if (unformat (i, "def"))
9911 else if (unformat (i, "noadv"))
9913 else if (unformat (i, "offl"))
9915 else if (unformat (i, "noauto"))
9917 else if (unformat (i, "nolink"))
9919 else if (unformat (i, "isno"))
9923 clib_warning ("parse error '%U'", format_unformat_error, i);
9928 if (sw_if_index_set == 0)
9930 errmsg ("missing interface name or sw_if_index");
9933 if (!v6_address_set)
9935 errmsg ("no address set");
9939 /* Construct the API message */
9940 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9942 mp->sw_if_index = ntohl (sw_if_index);
9943 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9944 mp->address_length = address_length;
9945 mp->use_default = use_default;
9946 mp->no_advertise = no_advertise;
9947 mp->off_link = off_link;
9948 mp->no_autoconfig = no_autoconfig;
9949 mp->no_onlink = no_onlink;
9951 mp->val_lifetime = ntohl (val_lifetime);
9952 mp->pref_lifetime = ntohl (pref_lifetime);
9957 /* Wait for a reply, return good/bad news */
9963 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9965 unformat_input_t *i = vam->input;
9966 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9968 u8 sw_if_index_set = 0;
9973 u8 send_unicast = 0;
9976 u8 default_router = 0;
9977 u32 max_interval = 0;
9978 u32 min_interval = 0;
9980 u32 initial_count = 0;
9981 u32 initial_interval = 0;
9985 /* Parse args required to build the message */
9986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9989 sw_if_index_set = 1;
9990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9991 sw_if_index_set = 1;
9992 else if (unformat (i, "maxint %d", &max_interval))
9994 else if (unformat (i, "minint %d", &min_interval))
9996 else if (unformat (i, "life %d", &lifetime))
9998 else if (unformat (i, "count %d", &initial_count))
10000 else if (unformat (i, "interval %d", &initial_interval))
10002 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10004 else if (unformat (i, "managed"))
10006 else if (unformat (i, "other"))
10008 else if (unformat (i, "ll"))
10010 else if (unformat (i, "send"))
10012 else if (unformat (i, "cease"))
10014 else if (unformat (i, "isno"))
10016 else if (unformat (i, "def"))
10017 default_router = 1;
10020 clib_warning ("parse error '%U'", format_unformat_error, i);
10025 if (sw_if_index_set == 0)
10027 errmsg ("missing interface name or sw_if_index");
10031 /* Construct the API message */
10032 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10034 mp->sw_if_index = ntohl (sw_if_index);
10035 mp->max_interval = ntohl (max_interval);
10036 mp->min_interval = ntohl (min_interval);
10037 mp->lifetime = ntohl (lifetime);
10038 mp->initial_count = ntohl (initial_count);
10039 mp->initial_interval = ntohl (initial_interval);
10040 mp->suppress = suppress;
10041 mp->managed = managed;
10043 mp->ll_option = ll_option;
10044 mp->send_unicast = send_unicast;
10047 mp->default_router = default_router;
10052 /* Wait for a reply, return good/bad news */
10058 api_set_arp_neighbor_limit (vat_main_t * vam)
10060 unformat_input_t *i = vam->input;
10061 vl_api_set_arp_neighbor_limit_t *mp;
10067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10069 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10071 else if (unformat (i, "ipv6"))
10075 clib_warning ("parse error '%U'", format_unformat_error, i);
10080 if (limit_set == 0)
10082 errmsg ("missing limit value");
10086 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10088 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10089 mp->is_ipv6 = is_ipv6;
10097 api_l2_patch_add_del (vat_main_t * vam)
10099 unformat_input_t *i = vam->input;
10100 vl_api_l2_patch_add_del_t *mp;
10101 u32 rx_sw_if_index;
10102 u8 rx_sw_if_index_set = 0;
10103 u32 tx_sw_if_index;
10104 u8 tx_sw_if_index_set = 0;
10108 /* Parse args required to build the message */
10109 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10111 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10112 rx_sw_if_index_set = 1;
10113 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10114 tx_sw_if_index_set = 1;
10115 else if (unformat (i, "rx"))
10117 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10119 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10121 rx_sw_if_index_set = 1;
10126 else if (unformat (i, "tx"))
10128 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10130 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10132 tx_sw_if_index_set = 1;
10137 else if (unformat (i, "del"))
10143 if (rx_sw_if_index_set == 0)
10145 errmsg ("missing rx interface name or rx_sw_if_index");
10149 if (tx_sw_if_index_set == 0)
10151 errmsg ("missing tx interface name or tx_sw_if_index");
10155 M (L2_PATCH_ADD_DEL, mp);
10157 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10158 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10159 mp->is_add = is_add;
10167 u8 localsid_addr[16];
10176 api_sr_localsid_add_del (vat_main_t * vam)
10178 unformat_input_t *i = vam->input;
10179 vl_api_sr_localsid_add_del_t *mp;
10182 ip6_address_t localsid;
10186 u32 fib_table = ~(u32) 0;
10187 ip6_address_t next_hop;
10189 bool nexthop_set = 0;
10193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10195 if (unformat (i, "del"))
10197 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10198 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
10200 else if (unformat (i, "behavior %u", &behavior));
10201 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10202 else if (unformat (i, "fib-table %u", &fib_table));
10203 else if (unformat (i, "end.psp %u", &behavior));
10208 M (SR_LOCALSID_ADD_DEL, mp);
10210 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
10212 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
10213 mp->behavior = behavior;
10214 mp->sw_if_index = ntohl (sw_if_index);
10215 mp->fib_table = ntohl (fib_table);
10216 mp->end_psp = end_psp;
10217 mp->is_del = is_del;
10225 api_ioam_enable (vat_main_t * vam)
10227 unformat_input_t *input = vam->input;
10228 vl_api_ioam_enable_t *mp;
10230 int has_trace_option = 0;
10231 int has_pot_option = 0;
10232 int has_seqno_option = 0;
10233 int has_analyse_option = 0;
10236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10238 if (unformat (input, "trace"))
10239 has_trace_option = 1;
10240 else if (unformat (input, "pot"))
10241 has_pot_option = 1;
10242 else if (unformat (input, "seqno"))
10243 has_seqno_option = 1;
10244 else if (unformat (input, "analyse"))
10245 has_analyse_option = 1;
10249 M (IOAM_ENABLE, mp);
10250 mp->id = htons (id);
10251 mp->seqno = has_seqno_option;
10252 mp->analyse = has_analyse_option;
10253 mp->pot_enable = has_pot_option;
10254 mp->trace_enable = has_trace_option;
10263 api_ioam_disable (vat_main_t * vam)
10265 vl_api_ioam_disable_t *mp;
10268 M (IOAM_DISABLE, mp);
10274 #define foreach_tcp_proto_field \
10278 #define foreach_udp_proto_field \
10282 #define foreach_ip4_proto_field \
10294 u16 src_port, dst_port;
10297 #if VPP_API_TEST_BUILTIN == 0
10299 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10301 u8 **maskp = va_arg (*args, u8 **);
10303 u8 found_something = 0;
10306 #define _(a) u8 a=0;
10307 foreach_tcp_proto_field;
10310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10313 #define _(a) else if (unformat (input, #a)) a=1;
10314 foreach_tcp_proto_field
10320 #define _(a) found_something += a;
10321 foreach_tcp_proto_field;
10324 if (found_something == 0)
10327 vec_validate (mask, sizeof (*tcp) - 1);
10329 tcp = (tcp_header_t *) mask;
10331 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
10332 foreach_tcp_proto_field;
10340 unformat_udp_mask (unformat_input_t * input, va_list * args)
10342 u8 **maskp = va_arg (*args, u8 **);
10344 u8 found_something = 0;
10347 #define _(a) u8 a=0;
10348 foreach_udp_proto_field;
10351 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10354 #define _(a) else if (unformat (input, #a)) a=1;
10355 foreach_udp_proto_field
10361 #define _(a) found_something += a;
10362 foreach_udp_proto_field;
10365 if (found_something == 0)
10368 vec_validate (mask, sizeof (*udp) - 1);
10370 udp = (udp_header_t *) mask;
10372 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10373 foreach_udp_proto_field;
10381 unformat_l4_mask (unformat_input_t * input, va_list * args)
10383 u8 **maskp = va_arg (*args, u8 **);
10384 u16 src_port = 0, dst_port = 0;
10385 tcpudp_header_t *tcpudp;
10387 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10389 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10391 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10393 else if (unformat (input, "src_port"))
10395 else if (unformat (input, "dst_port"))
10401 if (!src_port && !dst_port)
10405 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10407 tcpudp = (tcpudp_header_t *) mask;
10408 tcpudp->src_port = src_port;
10409 tcpudp->dst_port = dst_port;
10417 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10419 u8 **maskp = va_arg (*args, u8 **);
10421 u8 found_something = 0;
10424 #define _(a) u8 a=0;
10425 foreach_ip4_proto_field;
10431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10433 if (unformat (input, "version"))
10435 else if (unformat (input, "hdr_length"))
10437 else if (unformat (input, "src"))
10439 else if (unformat (input, "dst"))
10441 else if (unformat (input, "proto"))
10444 #define _(a) else if (unformat (input, #a)) a=1;
10445 foreach_ip4_proto_field
10451 #define _(a) found_something += a;
10452 foreach_ip4_proto_field;
10455 if (found_something == 0)
10458 vec_validate (mask, sizeof (*ip) - 1);
10460 ip = (ip4_header_t *) mask;
10462 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10463 foreach_ip4_proto_field;
10466 ip->ip_version_and_header_length = 0;
10469 ip->ip_version_and_header_length |= 0xF0;
10472 ip->ip_version_and_header_length |= 0x0F;
10478 #define foreach_ip6_proto_field \
10481 _(payload_length) \
10486 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10488 u8 **maskp = va_arg (*args, u8 **);
10490 u8 found_something = 0;
10492 u32 ip_version_traffic_class_and_flow_label;
10494 #define _(a) u8 a=0;
10495 foreach_ip6_proto_field;
10498 u8 traffic_class = 0;
10501 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10503 if (unformat (input, "version"))
10505 else if (unformat (input, "traffic-class"))
10507 else if (unformat (input, "flow-label"))
10509 else if (unformat (input, "src"))
10511 else if (unformat (input, "dst"))
10513 else if (unformat (input, "proto"))
10516 #define _(a) else if (unformat (input, #a)) a=1;
10517 foreach_ip6_proto_field
10523 #define _(a) found_something += a;
10524 foreach_ip6_proto_field;
10527 if (found_something == 0)
10530 vec_validate (mask, sizeof (*ip) - 1);
10532 ip = (ip6_header_t *) mask;
10534 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10535 foreach_ip6_proto_field;
10538 ip_version_traffic_class_and_flow_label = 0;
10541 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10544 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10547 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10549 ip->ip_version_traffic_class_and_flow_label =
10550 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10557 unformat_l3_mask (unformat_input_t * input, va_list * args)
10559 u8 **maskp = va_arg (*args, u8 **);
10561 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10563 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10565 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10574 unformat_l2_mask (unformat_input_t * input, va_list * args)
10576 u8 **maskp = va_arg (*args, u8 **);
10583 u8 ignore_tag1 = 0;
10584 u8 ignore_tag2 = 0;
10591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10593 if (unformat (input, "src"))
10595 else if (unformat (input, "dst"))
10597 else if (unformat (input, "proto"))
10599 else if (unformat (input, "tag1"))
10601 else if (unformat (input, "tag2"))
10603 else if (unformat (input, "ignore-tag1"))
10605 else if (unformat (input, "ignore-tag2"))
10607 else if (unformat (input, "cos1"))
10609 else if (unformat (input, "cos2"))
10611 else if (unformat (input, "dot1q"))
10613 else if (unformat (input, "dot1ad"))
10618 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10619 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10622 if (tag1 || ignore_tag1 || cos1 || dot1q)
10624 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10627 vec_validate (mask, len - 1);
10630 memset (mask, 0xff, 6);
10633 memset (mask + 6, 0xff, 6);
10635 if (tag2 || dot1ad)
10637 /* inner vlan tag */
10646 mask[21] = mask[20] = 0xff;
10667 mask[16] = mask[17] = 0xff;
10677 mask[12] = mask[13] = 0xff;
10684 unformat_classify_mask (unformat_input_t * input, va_list * args)
10686 u8 **maskp = va_arg (*args, u8 **);
10687 u32 *skipp = va_arg (*args, u32 *);
10688 u32 *matchp = va_arg (*args, u32 *);
10696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10698 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10700 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10702 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10704 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10718 if (mask || l2 || l3 || l4)
10720 if (l2 || l3 || l4)
10722 /* "With a free Ethernet header in every package" */
10724 vec_validate (l2, 13);
10728 vec_append (mask, l3);
10733 vec_append (mask, l4);
10738 /* Scan forward looking for the first significant mask octet */
10739 for (i = 0; i < vec_len (mask); i++)
10743 /* compute (skip, match) params */
10744 *skipp = i / sizeof (u32x4);
10745 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10747 /* Pad mask to an even multiple of the vector size */
10748 while (vec_len (mask) % sizeof (u32x4))
10749 vec_add1 (mask, 0);
10751 match = vec_len (mask) / sizeof (u32x4);
10753 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10755 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10756 if (*tmp || *(tmp + 1))
10761 clib_warning ("BUG: match 0");
10763 _vec_len (mask) = match * sizeof (u32x4);
10773 #endif /* VPP_API_TEST_BUILTIN */
10775 #define foreach_l2_next \
10777 _(ethernet, ETHERNET_INPUT) \
10778 _(ip4, IP4_INPUT) \
10782 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10784 u32 *miss_next_indexp = va_arg (*args, u32 *);
10785 u32 next_index = 0;
10789 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10793 if (unformat (input, "%d", &tmp))
10802 *miss_next_indexp = next_index;
10806 #define foreach_ip_next \
10809 _(rewrite, REWRITE)
10812 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10814 u32 *miss_next_indexp = va_arg (*args, u32 *);
10815 u32 next_index = 0;
10819 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10823 if (unformat (input, "%d", &tmp))
10832 *miss_next_indexp = next_index;
10836 #define foreach_acl_next \
10840 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10842 u32 *miss_next_indexp = va_arg (*args, u32 *);
10843 u32 next_index = 0;
10847 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10851 if (unformat (input, "permit"))
10856 else if (unformat (input, "%d", &tmp))
10865 *miss_next_indexp = next_index;
10870 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10872 u32 *r = va_arg (*args, u32 *);
10874 if (unformat (input, "conform-color"))
10875 *r = POLICE_CONFORM;
10876 else if (unformat (input, "exceed-color"))
10877 *r = POLICE_EXCEED;
10885 api_classify_add_del_table (vat_main_t * vam)
10887 unformat_input_t *i = vam->input;
10888 vl_api_classify_add_del_table_t *mp;
10895 u32 table_index = ~0;
10896 u32 next_table_index = ~0;
10897 u32 miss_next_index = ~0;
10898 u32 memory_size = 32 << 20;
10900 u32 current_data_flag = 0;
10901 int current_data_offset = 0;
10904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10906 if (unformat (i, "del"))
10908 else if (unformat (i, "del-chain"))
10913 else if (unformat (i, "buckets %d", &nbuckets))
10915 else if (unformat (i, "memory_size %d", &memory_size))
10917 else if (unformat (i, "skip %d", &skip))
10919 else if (unformat (i, "match %d", &match))
10921 else if (unformat (i, "table %d", &table_index))
10923 else if (unformat (i, "mask %U", unformat_classify_mask,
10924 &mask, &skip, &match))
10926 else if (unformat (i, "next-table %d", &next_table_index))
10928 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10931 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10934 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10937 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10939 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10945 if (is_add && mask == 0)
10947 errmsg ("Mask required");
10951 if (is_add && skip == ~0)
10953 errmsg ("skip count required");
10957 if (is_add && match == ~0)
10959 errmsg ("match count required");
10963 if (!is_add && table_index == ~0)
10965 errmsg ("table index required for delete");
10969 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10971 mp->is_add = is_add;
10972 mp->del_chain = del_chain;
10973 mp->table_index = ntohl (table_index);
10974 mp->nbuckets = ntohl (nbuckets);
10975 mp->memory_size = ntohl (memory_size);
10976 mp->skip_n_vectors = ntohl (skip);
10977 mp->match_n_vectors = ntohl (match);
10978 mp->next_table_index = ntohl (next_table_index);
10979 mp->miss_next_index = ntohl (miss_next_index);
10980 mp->current_data_flag = ntohl (current_data_flag);
10981 mp->current_data_offset = ntohl (current_data_offset);
10982 clib_memcpy (mp->mask, mask, vec_len (mask));
10991 #if VPP_API_TEST_BUILTIN == 0
10993 unformat_l4_match (unformat_input_t * input, va_list * args)
10995 u8 **matchp = va_arg (*args, u8 **);
10997 u8 *proto_header = 0;
11003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11005 if (unformat (input, "src_port %d", &src_port))
11007 else if (unformat (input, "dst_port %d", &dst_port))
11013 h.src_port = clib_host_to_net_u16 (src_port);
11014 h.dst_port = clib_host_to_net_u16 (dst_port);
11015 vec_validate (proto_header, sizeof (h) - 1);
11016 memcpy (proto_header, &h, sizeof (h));
11018 *matchp = proto_header;
11024 unformat_ip4_match (unformat_input_t * input, va_list * args)
11026 u8 **matchp = va_arg (*args, u8 **);
11031 int hdr_length = 0;
11032 u32 hdr_length_val;
11033 int src = 0, dst = 0;
11034 ip4_address_t src_val, dst_val;
11041 int fragment_id = 0;
11042 u32 fragment_id_val;
11048 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11050 if (unformat (input, "version %d", &version_val))
11052 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11054 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11056 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11058 else if (unformat (input, "proto %d", &proto_val))
11060 else if (unformat (input, "tos %d", &tos_val))
11062 else if (unformat (input, "length %d", &length_val))
11064 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11066 else if (unformat (input, "ttl %d", &ttl_val))
11068 else if (unformat (input, "checksum %d", &checksum_val))
11074 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11075 + ttl + checksum == 0)
11079 * Aligned because we use the real comparison functions
11081 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11083 ip = (ip4_header_t *) match;
11085 /* These are realistically matched in practice */
11087 ip->src_address.as_u32 = src_val.as_u32;
11090 ip->dst_address.as_u32 = dst_val.as_u32;
11093 ip->protocol = proto_val;
11096 /* These are not, but they're included for completeness */
11098 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11101 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11107 ip->length = clib_host_to_net_u16 (length_val);
11113 ip->checksum = clib_host_to_net_u16 (checksum_val);
11120 unformat_ip6_match (unformat_input_t * input, va_list * args)
11122 u8 **matchp = va_arg (*args, u8 **);
11127 u8 traffic_class = 0;
11128 u32 traffic_class_val = 0;
11131 int src = 0, dst = 0;
11132 ip6_address_t src_val, dst_val;
11135 int payload_length = 0;
11136 u32 payload_length_val;
11139 u32 ip_version_traffic_class_and_flow_label;
11141 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11143 if (unformat (input, "version %d", &version_val))
11145 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11147 else if (unformat (input, "flow_label %d", &flow_label_val))
11149 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11151 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11153 else if (unformat (input, "proto %d", &proto_val))
11155 else if (unformat (input, "payload_length %d", &payload_length_val))
11156 payload_length = 1;
11157 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11163 if (version + traffic_class + flow_label + src + dst + proto +
11164 payload_length + hop_limit == 0)
11168 * Aligned because we use the real comparison functions
11170 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11172 ip = (ip6_header_t *) match;
11175 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11178 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11181 ip->protocol = proto_val;
11183 ip_version_traffic_class_and_flow_label = 0;
11186 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11189 ip_version_traffic_class_and_flow_label |=
11190 (traffic_class_val & 0xFF) << 20;
11193 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11195 ip->ip_version_traffic_class_and_flow_label =
11196 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11198 if (payload_length)
11199 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11202 ip->hop_limit = hop_limit_val;
11209 unformat_l3_match (unformat_input_t * input, va_list * args)
11211 u8 **matchp = va_arg (*args, u8 **);
11213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11215 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11217 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11226 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11228 u8 *tagp = va_arg (*args, u8 *);
11231 if (unformat (input, "%d", &tag))
11233 tagp[0] = (tag >> 8) & 0x0F;
11234 tagp[1] = tag & 0xFF;
11242 unformat_l2_match (unformat_input_t * input, va_list * args)
11244 u8 **matchp = va_arg (*args, u8 **);
11257 u8 ignore_tag1 = 0;
11258 u8 ignore_tag2 = 0;
11264 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11266 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11269 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11271 else if (unformat (input, "proto %U",
11272 unformat_ethernet_type_host_byte_order, &proto_val))
11274 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11276 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11278 else if (unformat (input, "ignore-tag1"))
11280 else if (unformat (input, "ignore-tag2"))
11282 else if (unformat (input, "cos1 %d", &cos1_val))
11284 else if (unformat (input, "cos2 %d", &cos2_val))
11289 if ((src + dst + proto + tag1 + tag2 +
11290 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11293 if (tag1 || ignore_tag1 || cos1)
11295 if (tag2 || ignore_tag2 || cos2)
11298 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11301 clib_memcpy (match, dst_val, 6);
11304 clib_memcpy (match + 6, src_val, 6);
11308 /* inner vlan tag */
11309 match[19] = tag2_val[1];
11310 match[18] = tag2_val[0];
11312 match[18] |= (cos2_val & 0x7) << 5;
11315 match[21] = proto_val & 0xff;
11316 match[20] = proto_val >> 8;
11320 match[15] = tag1_val[1];
11321 match[14] = tag1_val[0];
11324 match[14] |= (cos1_val & 0x7) << 5;
11330 match[15] = tag1_val[1];
11331 match[14] = tag1_val[0];
11334 match[17] = proto_val & 0xff;
11335 match[16] = proto_val >> 8;
11338 match[14] |= (cos1_val & 0x7) << 5;
11344 match[18] |= (cos2_val & 0x7) << 5;
11346 match[14] |= (cos1_val & 0x7) << 5;
11349 match[13] = proto_val & 0xff;
11350 match[12] = proto_val >> 8;
11359 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11361 u8 **matchp = va_arg (*args, u8 **);
11362 u32 skip_n_vectors = va_arg (*args, u32);
11363 u32 match_n_vectors = va_arg (*args, u32);
11370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11372 if (unformat (input, "hex %U", unformat_hex_string, &match))
11374 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11376 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11378 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11392 if (match || l2 || l3 || l4)
11394 if (l2 || l3 || l4)
11396 /* "Win a free Ethernet header in every packet" */
11398 vec_validate_aligned (l2, 13, sizeof (u32x4));
11402 vec_append_aligned (match, l3, sizeof (u32x4));
11407 vec_append_aligned (match, l4, sizeof (u32x4));
11412 /* Make sure the vector is big enough even if key is all 0's */
11413 vec_validate_aligned
11414 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11417 /* Set size, include skipped vectors */
11418 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11429 api_classify_add_del_session (vat_main_t * vam)
11431 unformat_input_t *i = vam->input;
11432 vl_api_classify_add_del_session_t *mp;
11434 u32 table_index = ~0;
11435 u32 hit_next_index = ~0;
11436 u32 opaque_index = ~0;
11439 u32 skip_n_vectors = 0;
11440 u32 match_n_vectors = 0;
11446 * Warning: you have to supply skip_n and match_n
11447 * because the API client cant simply look at the classify
11451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11453 if (unformat (i, "del"))
11455 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11458 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11461 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11464 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11466 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11468 else if (unformat (i, "opaque-index %d", &opaque_index))
11470 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11472 else if (unformat (i, "match_n %d", &match_n_vectors))
11474 else if (unformat (i, "match %U", api_unformat_classify_match,
11475 &match, skip_n_vectors, match_n_vectors))
11477 else if (unformat (i, "advance %d", &advance))
11479 else if (unformat (i, "table-index %d", &table_index))
11481 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11483 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11485 else if (unformat (i, "action %d", &action))
11487 else if (unformat (i, "metadata %d", &metadata))
11493 if (table_index == ~0)
11495 errmsg ("Table index required");
11499 if (is_add && match == 0)
11501 errmsg ("Match value required");
11505 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11507 mp->is_add = is_add;
11508 mp->table_index = ntohl (table_index);
11509 mp->hit_next_index = ntohl (hit_next_index);
11510 mp->opaque_index = ntohl (opaque_index);
11511 mp->advance = ntohl (advance);
11512 mp->action = action;
11513 mp->metadata = ntohl (metadata);
11514 clib_memcpy (mp->match, match, vec_len (match));
11523 api_classify_set_interface_ip_table (vat_main_t * vam)
11525 unformat_input_t *i = vam->input;
11526 vl_api_classify_set_interface_ip_table_t *mp;
11528 int sw_if_index_set;
11529 u32 table_index = ~0;
11533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11536 sw_if_index_set = 1;
11537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11538 sw_if_index_set = 1;
11539 else if (unformat (i, "table %d", &table_index))
11543 clib_warning ("parse error '%U'", format_unformat_error, i);
11548 if (sw_if_index_set == 0)
11550 errmsg ("missing interface name or sw_if_index");
11555 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11557 mp->sw_if_index = ntohl (sw_if_index);
11558 mp->table_index = ntohl (table_index);
11559 mp->is_ipv6 = is_ipv6;
11567 api_classify_set_interface_l2_tables (vat_main_t * vam)
11569 unformat_input_t *i = vam->input;
11570 vl_api_classify_set_interface_l2_tables_t *mp;
11572 int sw_if_index_set;
11573 u32 ip4_table_index = ~0;
11574 u32 ip6_table_index = ~0;
11575 u32 other_table_index = ~0;
11579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11582 sw_if_index_set = 1;
11583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11584 sw_if_index_set = 1;
11585 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11587 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11589 else if (unformat (i, "other-table %d", &other_table_index))
11591 else if (unformat (i, "is-input %d", &is_input))
11595 clib_warning ("parse error '%U'", format_unformat_error, i);
11600 if (sw_if_index_set == 0)
11602 errmsg ("missing interface name or sw_if_index");
11607 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11609 mp->sw_if_index = ntohl (sw_if_index);
11610 mp->ip4_table_index = ntohl (ip4_table_index);
11611 mp->ip6_table_index = ntohl (ip6_table_index);
11612 mp->other_table_index = ntohl (other_table_index);
11613 mp->is_input = (u8) is_input;
11621 api_set_ipfix_exporter (vat_main_t * vam)
11623 unformat_input_t *i = vam->input;
11624 vl_api_set_ipfix_exporter_t *mp;
11625 ip4_address_t collector_address;
11626 u8 collector_address_set = 0;
11627 u32 collector_port = ~0;
11628 ip4_address_t src_address;
11629 u8 src_address_set = 0;
11632 u32 template_interval = ~0;
11633 u8 udp_checksum = 0;
11636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11638 if (unformat (i, "collector_address %U", unformat_ip4_address,
11639 &collector_address))
11640 collector_address_set = 1;
11641 else if (unformat (i, "collector_port %d", &collector_port))
11643 else if (unformat (i, "src_address %U", unformat_ip4_address,
11645 src_address_set = 1;
11646 else if (unformat (i, "vrf_id %d", &vrf_id))
11648 else if (unformat (i, "path_mtu %d", &path_mtu))
11650 else if (unformat (i, "template_interval %d", &template_interval))
11652 else if (unformat (i, "udp_checksum"))
11658 if (collector_address_set == 0)
11660 errmsg ("collector_address required");
11664 if (src_address_set == 0)
11666 errmsg ("src_address required");
11670 M (SET_IPFIX_EXPORTER, mp);
11672 memcpy (mp->collector_address, collector_address.data,
11673 sizeof (collector_address.data));
11674 mp->collector_port = htons ((u16) collector_port);
11675 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11676 mp->vrf_id = htonl (vrf_id);
11677 mp->path_mtu = htonl (path_mtu);
11678 mp->template_interval = htonl (template_interval);
11679 mp->udp_checksum = udp_checksum;
11687 api_set_ipfix_classify_stream (vat_main_t * vam)
11689 unformat_input_t *i = vam->input;
11690 vl_api_set_ipfix_classify_stream_t *mp;
11692 u32 src_port = UDP_DST_PORT_ipfix;
11695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11697 if (unformat (i, "domain %d", &domain_id))
11699 else if (unformat (i, "src_port %d", &src_port))
11703 errmsg ("unknown input `%U'", format_unformat_error, i);
11708 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11710 mp->domain_id = htonl (domain_id);
11711 mp->src_port = htons ((u16) src_port);
11719 api_ipfix_classify_table_add_del (vat_main_t * vam)
11721 unformat_input_t *i = vam->input;
11722 vl_api_ipfix_classify_table_add_del_t *mp;
11724 u32 classify_table_index = ~0;
11726 u8 transport_protocol = 255;
11729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11731 if (unformat (i, "add"))
11733 else if (unformat (i, "del"))
11735 else if (unformat (i, "table %d", &classify_table_index))
11737 else if (unformat (i, "ip4"))
11739 else if (unformat (i, "ip6"))
11741 else if (unformat (i, "tcp"))
11742 transport_protocol = 6;
11743 else if (unformat (i, "udp"))
11744 transport_protocol = 17;
11747 errmsg ("unknown input `%U'", format_unformat_error, i);
11754 errmsg ("expecting: add|del");
11757 if (classify_table_index == ~0)
11759 errmsg ("classifier table not specified");
11762 if (ip_version == 0)
11764 errmsg ("IP version not specified");
11768 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11770 mp->is_add = is_add;
11771 mp->table_id = htonl (classify_table_index);
11772 mp->ip_version = ip_version;
11773 mp->transport_protocol = transport_protocol;
11781 api_get_node_index (vat_main_t * vam)
11783 unformat_input_t *i = vam->input;
11784 vl_api_get_node_index_t *mp;
11788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11790 if (unformat (i, "node %s", &name))
11797 errmsg ("node name required");
11800 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11802 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11806 M (GET_NODE_INDEX, mp);
11807 clib_memcpy (mp->node_name, name, vec_len (name));
11816 api_get_next_index (vat_main_t * vam)
11818 unformat_input_t *i = vam->input;
11819 vl_api_get_next_index_t *mp;
11820 u8 *node_name = 0, *next_node_name = 0;
11823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11825 if (unformat (i, "node-name %s", &node_name))
11827 else if (unformat (i, "next-node-name %s", &next_node_name))
11831 if (node_name == 0)
11833 errmsg ("node name required");
11836 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11838 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11842 if (next_node_name == 0)
11844 errmsg ("next node name required");
11847 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11849 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11853 M (GET_NEXT_INDEX, mp);
11854 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11855 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11856 vec_free (node_name);
11857 vec_free (next_node_name);
11865 api_add_node_next (vat_main_t * vam)
11867 unformat_input_t *i = vam->input;
11868 vl_api_add_node_next_t *mp;
11873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11875 if (unformat (i, "node %s", &name))
11877 else if (unformat (i, "next %s", &next))
11884 errmsg ("node name required");
11887 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11889 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11894 errmsg ("next node required");
11897 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11899 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11903 M (ADD_NODE_NEXT, mp);
11904 clib_memcpy (mp->node_name, name, vec_len (name));
11905 clib_memcpy (mp->next_name, next, vec_len (next));
11915 api_l2tpv3_create_tunnel (vat_main_t * vam)
11917 unformat_input_t *i = vam->input;
11918 ip6_address_t client_address, our_address;
11919 int client_address_set = 0;
11920 int our_address_set = 0;
11921 u32 local_session_id = 0;
11922 u32 remote_session_id = 0;
11923 u64 local_cookie = 0;
11924 u64 remote_cookie = 0;
11925 u8 l2_sublayer_present = 0;
11926 vl_api_l2tpv3_create_tunnel_t *mp;
11929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11931 if (unformat (i, "client_address %U", unformat_ip6_address,
11933 client_address_set = 1;
11934 else if (unformat (i, "our_address %U", unformat_ip6_address,
11936 our_address_set = 1;
11937 else if (unformat (i, "local_session_id %d", &local_session_id))
11939 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11941 else if (unformat (i, "local_cookie %lld", &local_cookie))
11943 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11945 else if (unformat (i, "l2-sublayer-present"))
11946 l2_sublayer_present = 1;
11951 if (client_address_set == 0)
11953 errmsg ("client_address required");
11957 if (our_address_set == 0)
11959 errmsg ("our_address required");
11963 M (L2TPV3_CREATE_TUNNEL, mp);
11965 clib_memcpy (mp->client_address, client_address.as_u8,
11966 sizeof (mp->client_address));
11968 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11970 mp->local_session_id = ntohl (local_session_id);
11971 mp->remote_session_id = ntohl (remote_session_id);
11972 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11973 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11974 mp->l2_sublayer_present = l2_sublayer_present;
11983 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11985 unformat_input_t *i = vam->input;
11987 u8 sw_if_index_set = 0;
11988 u64 new_local_cookie = 0;
11989 u64 new_remote_cookie = 0;
11990 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11996 sw_if_index_set = 1;
11997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11998 sw_if_index_set = 1;
11999 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12001 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12007 if (sw_if_index_set == 0)
12009 errmsg ("missing interface name or sw_if_index");
12013 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12015 mp->sw_if_index = ntohl (sw_if_index);
12016 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12017 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12025 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12027 unformat_input_t *i = vam->input;
12028 vl_api_l2tpv3_interface_enable_disable_t *mp;
12030 u8 sw_if_index_set = 0;
12031 u8 enable_disable = 1;
12034 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12036 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12037 sw_if_index_set = 1;
12038 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12039 sw_if_index_set = 1;
12040 else if (unformat (i, "enable"))
12041 enable_disable = 1;
12042 else if (unformat (i, "disable"))
12043 enable_disable = 0;
12048 if (sw_if_index_set == 0)
12050 errmsg ("missing interface name or sw_if_index");
12054 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12056 mp->sw_if_index = ntohl (sw_if_index);
12057 mp->enable_disable = enable_disable;
12065 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12067 unformat_input_t *i = vam->input;
12068 vl_api_l2tpv3_set_lookup_key_t *mp;
12072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12074 if (unformat (i, "lookup_v6_src"))
12075 key = L2T_LOOKUP_SRC_ADDRESS;
12076 else if (unformat (i, "lookup_v6_dst"))
12077 key = L2T_LOOKUP_DST_ADDRESS;
12078 else if (unformat (i, "lookup_session_id"))
12079 key = L2T_LOOKUP_SESSION_ID;
12084 if (key == (u8) ~ 0)
12086 errmsg ("l2tp session lookup key unset");
12090 M (L2TPV3_SET_LOOKUP_KEY, mp);
12099 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12100 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12102 vat_main_t *vam = &vat_main;
12104 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12105 format_ip6_address, mp->our_address,
12106 format_ip6_address, mp->client_address,
12107 clib_net_to_host_u32 (mp->sw_if_index));
12110 " local cookies %016llx %016llx remote cookie %016llx",
12111 clib_net_to_host_u64 (mp->local_cookie[0]),
12112 clib_net_to_host_u64 (mp->local_cookie[1]),
12113 clib_net_to_host_u64 (mp->remote_cookie));
12115 print (vam->ofp, " local session-id %d remote session-id %d",
12116 clib_net_to_host_u32 (mp->local_session_id),
12117 clib_net_to_host_u32 (mp->remote_session_id));
12119 print (vam->ofp, " l2 specific sublayer %s\n",
12120 mp->l2_sublayer_present ? "preset" : "absent");
12124 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12125 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12127 vat_main_t *vam = &vat_main;
12128 vat_json_node_t *node = NULL;
12129 struct in6_addr addr;
12131 if (VAT_JSON_ARRAY != vam->json_tree.type)
12133 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12134 vat_json_init_array (&vam->json_tree);
12136 node = vat_json_array_add (&vam->json_tree);
12138 vat_json_init_object (node);
12140 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12141 vat_json_object_add_ip6 (node, "our_address", addr);
12142 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12143 vat_json_object_add_ip6 (node, "client_address", addr);
12145 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12146 vat_json_init_array (lc);
12147 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12148 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12149 vat_json_object_add_uint (node, "remote_cookie",
12150 clib_net_to_host_u64 (mp->remote_cookie));
12152 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12153 vat_json_object_add_uint (node, "local_session_id",
12154 clib_net_to_host_u32 (mp->local_session_id));
12155 vat_json_object_add_uint (node, "remote_session_id",
12156 clib_net_to_host_u32 (mp->remote_session_id));
12157 vat_json_object_add_string_copy (node, "l2_sublayer",
12158 mp->l2_sublayer_present ? (u8 *) "present"
12159 : (u8 *) "absent");
12163 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12165 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12166 vl_api_control_ping_t *mp_ping;
12169 /* Get list of l2tpv3-tunnel interfaces */
12170 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12173 /* Use a control ping for synchronization */
12174 MPING (CONTROL_PING, mp_ping);
12182 static void vl_api_sw_interface_tap_details_t_handler
12183 (vl_api_sw_interface_tap_details_t * mp)
12185 vat_main_t *vam = &vat_main;
12187 print (vam->ofp, "%-16s %d",
12188 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
12191 static void vl_api_sw_interface_tap_details_t_handler_json
12192 (vl_api_sw_interface_tap_details_t * mp)
12194 vat_main_t *vam = &vat_main;
12195 vat_json_node_t *node = NULL;
12197 if (VAT_JSON_ARRAY != vam->json_tree.type)
12199 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12200 vat_json_init_array (&vam->json_tree);
12202 node = vat_json_array_add (&vam->json_tree);
12204 vat_json_init_object (node);
12205 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12206 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12210 api_sw_interface_tap_dump (vat_main_t * vam)
12212 vl_api_sw_interface_tap_dump_t *mp;
12213 vl_api_control_ping_t *mp_ping;
12216 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
12217 /* Get list of tap interfaces */
12218 M (SW_INTERFACE_TAP_DUMP, mp);
12221 /* Use a control ping for synchronization */
12222 MPING (CONTROL_PING, mp_ping);
12229 static uword unformat_vxlan_decap_next
12230 (unformat_input_t * input, va_list * args)
12232 u32 *result = va_arg (*args, u32 *);
12235 if (unformat (input, "l2"))
12236 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12237 else if (unformat (input, "%d", &tmp))
12245 api_vxlan_add_del_tunnel (vat_main_t * vam)
12247 unformat_input_t *line_input = vam->input;
12248 vl_api_vxlan_add_del_tunnel_t *mp;
12249 ip46_address_t src, dst;
12251 u8 ipv4_set = 0, ipv6_set = 0;
12255 u32 mcast_sw_if_index = ~0;
12256 u32 encap_vrf_id = 0;
12257 u32 decap_next_index = ~0;
12261 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12262 memset (&src, 0, sizeof src);
12263 memset (&dst, 0, sizeof dst);
12265 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12267 if (unformat (line_input, "del"))
12270 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12276 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12282 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12288 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12293 else if (unformat (line_input, "group %U %U",
12294 unformat_ip4_address, &dst.ip4,
12295 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12297 grp_set = dst_set = 1;
12300 else if (unformat (line_input, "group %U",
12301 unformat_ip4_address, &dst.ip4))
12303 grp_set = dst_set = 1;
12306 else if (unformat (line_input, "group %U %U",
12307 unformat_ip6_address, &dst.ip6,
12308 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12310 grp_set = dst_set = 1;
12313 else if (unformat (line_input, "group %U",
12314 unformat_ip6_address, &dst.ip6))
12316 grp_set = dst_set = 1;
12320 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12322 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12324 else if (unformat (line_input, "decap-next %U",
12325 unformat_vxlan_decap_next, &decap_next_index))
12327 else if (unformat (line_input, "vni %d", &vni))
12331 errmsg ("parse error '%U'", format_unformat_error, line_input);
12338 errmsg ("tunnel src address not specified");
12343 errmsg ("tunnel dst address not specified");
12347 if (grp_set && !ip46_address_is_multicast (&dst))
12349 errmsg ("tunnel group address not multicast");
12352 if (grp_set && mcast_sw_if_index == ~0)
12354 errmsg ("tunnel nonexistent multicast device");
12357 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12359 errmsg ("tunnel dst address must be unicast");
12364 if (ipv4_set && ipv6_set)
12366 errmsg ("both IPv4 and IPv6 addresses specified");
12370 if ((vni == 0) || (vni >> 24))
12372 errmsg ("vni not specified or out of range");
12376 M (VXLAN_ADD_DEL_TUNNEL, mp);
12380 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12381 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12385 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12386 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12388 mp->encap_vrf_id = ntohl (encap_vrf_id);
12389 mp->decap_next_index = ntohl (decap_next_index);
12390 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12391 mp->vni = ntohl (vni);
12392 mp->is_add = is_add;
12393 mp->is_ipv6 = ipv6_set;
12400 static void vl_api_vxlan_tunnel_details_t_handler
12401 (vl_api_vxlan_tunnel_details_t * mp)
12403 vat_main_t *vam = &vat_main;
12404 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12405 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12407 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12408 ntohl (mp->sw_if_index),
12409 format_ip46_address, &src, IP46_TYPE_ANY,
12410 format_ip46_address, &dst, IP46_TYPE_ANY,
12411 ntohl (mp->encap_vrf_id),
12412 ntohl (mp->decap_next_index), ntohl (mp->vni),
12413 ntohl (mp->mcast_sw_if_index));
12416 static void vl_api_vxlan_tunnel_details_t_handler_json
12417 (vl_api_vxlan_tunnel_details_t * mp)
12419 vat_main_t *vam = &vat_main;
12420 vat_json_node_t *node = NULL;
12422 if (VAT_JSON_ARRAY != vam->json_tree.type)
12424 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12425 vat_json_init_array (&vam->json_tree);
12427 node = vat_json_array_add (&vam->json_tree);
12429 vat_json_init_object (node);
12430 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12433 struct in6_addr ip6;
12435 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12436 vat_json_object_add_ip6 (node, "src_address", ip6);
12437 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12438 vat_json_object_add_ip6 (node, "dst_address", ip6);
12442 struct in_addr ip4;
12444 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12445 vat_json_object_add_ip4 (node, "src_address", ip4);
12446 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12447 vat_json_object_add_ip4 (node, "dst_address", ip4);
12449 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12450 vat_json_object_add_uint (node, "decap_next_index",
12451 ntohl (mp->decap_next_index));
12452 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12453 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12454 vat_json_object_add_uint (node, "mcast_sw_if_index",
12455 ntohl (mp->mcast_sw_if_index));
12459 api_vxlan_tunnel_dump (vat_main_t * vam)
12461 unformat_input_t *i = vam->input;
12462 vl_api_vxlan_tunnel_dump_t *mp;
12463 vl_api_control_ping_t *mp_ping;
12465 u8 sw_if_index_set = 0;
12468 /* Parse args required to build the message */
12469 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12471 if (unformat (i, "sw_if_index %d", &sw_if_index))
12472 sw_if_index_set = 1;
12477 if (sw_if_index_set == 0)
12482 if (!vam->json_output)
12484 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12485 "sw_if_index", "src_address", "dst_address",
12486 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12489 /* Get list of vxlan-tunnel interfaces */
12490 M (VXLAN_TUNNEL_DUMP, mp);
12492 mp->sw_if_index = htonl (sw_if_index);
12496 /* Use a control ping for synchronization */
12497 MPING (CONTROL_PING, mp_ping);
12504 static uword unformat_geneve_decap_next
12505 (unformat_input_t * input, va_list * args)
12507 u32 *result = va_arg (*args, u32 *);
12510 if (unformat (input, "l2"))
12511 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12512 else if (unformat (input, "%d", &tmp))
12520 api_geneve_add_del_tunnel (vat_main_t * vam)
12522 unformat_input_t *line_input = vam->input;
12523 vl_api_geneve_add_del_tunnel_t *mp;
12524 ip46_address_t src, dst;
12526 u8 ipv4_set = 0, ipv6_set = 0;
12530 u32 mcast_sw_if_index = ~0;
12531 u32 encap_vrf_id = 0;
12532 u32 decap_next_index = ~0;
12536 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12537 memset (&src, 0, sizeof src);
12538 memset (&dst, 0, sizeof dst);
12540 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12542 if (unformat (line_input, "del"))
12545 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12551 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12557 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12563 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12568 else if (unformat (line_input, "group %U %U",
12569 unformat_ip4_address, &dst.ip4,
12570 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12572 grp_set = dst_set = 1;
12575 else if (unformat (line_input, "group %U",
12576 unformat_ip4_address, &dst.ip4))
12578 grp_set = dst_set = 1;
12581 else if (unformat (line_input, "group %U %U",
12582 unformat_ip6_address, &dst.ip6,
12583 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12585 grp_set = dst_set = 1;
12588 else if (unformat (line_input, "group %U",
12589 unformat_ip6_address, &dst.ip6))
12591 grp_set = dst_set = 1;
12595 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12597 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12599 else if (unformat (line_input, "decap-next %U",
12600 unformat_geneve_decap_next, &decap_next_index))
12602 else if (unformat (line_input, "vni %d", &vni))
12606 errmsg ("parse error '%U'", format_unformat_error, line_input);
12613 errmsg ("tunnel src address not specified");
12618 errmsg ("tunnel dst address not specified");
12622 if (grp_set && !ip46_address_is_multicast (&dst))
12624 errmsg ("tunnel group address not multicast");
12627 if (grp_set && mcast_sw_if_index == ~0)
12629 errmsg ("tunnel nonexistent multicast device");
12632 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12634 errmsg ("tunnel dst address must be unicast");
12639 if (ipv4_set && ipv6_set)
12641 errmsg ("both IPv4 and IPv6 addresses specified");
12645 if ((vni == 0) || (vni >> 24))
12647 errmsg ("vni not specified or out of range");
12651 M (GENEVE_ADD_DEL_TUNNEL, mp);
12655 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12656 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12660 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12661 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12663 mp->encap_vrf_id = ntohl (encap_vrf_id);
12664 mp->decap_next_index = ntohl (decap_next_index);
12665 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12666 mp->vni = ntohl (vni);
12667 mp->is_add = is_add;
12668 mp->is_ipv6 = ipv6_set;
12675 static void vl_api_geneve_tunnel_details_t_handler
12676 (vl_api_geneve_tunnel_details_t * mp)
12678 vat_main_t *vam = &vat_main;
12679 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12680 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12682 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12683 ntohl (mp->sw_if_index),
12684 format_ip46_address, &src, IP46_TYPE_ANY,
12685 format_ip46_address, &dst, IP46_TYPE_ANY,
12686 ntohl (mp->encap_vrf_id),
12687 ntohl (mp->decap_next_index), ntohl (mp->vni),
12688 ntohl (mp->mcast_sw_if_index));
12691 static void vl_api_geneve_tunnel_details_t_handler_json
12692 (vl_api_geneve_tunnel_details_t * mp)
12694 vat_main_t *vam = &vat_main;
12695 vat_json_node_t *node = NULL;
12697 if (VAT_JSON_ARRAY != vam->json_tree.type)
12699 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12700 vat_json_init_array (&vam->json_tree);
12702 node = vat_json_array_add (&vam->json_tree);
12704 vat_json_init_object (node);
12705 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12708 struct in6_addr ip6;
12710 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12711 vat_json_object_add_ip6 (node, "src_address", ip6);
12712 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12713 vat_json_object_add_ip6 (node, "dst_address", ip6);
12717 struct in_addr ip4;
12719 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12720 vat_json_object_add_ip4 (node, "src_address", ip4);
12721 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12722 vat_json_object_add_ip4 (node, "dst_address", ip4);
12724 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12725 vat_json_object_add_uint (node, "decap_next_index",
12726 ntohl (mp->decap_next_index));
12727 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12728 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12729 vat_json_object_add_uint (node, "mcast_sw_if_index",
12730 ntohl (mp->mcast_sw_if_index));
12734 api_geneve_tunnel_dump (vat_main_t * vam)
12736 unformat_input_t *i = vam->input;
12737 vl_api_geneve_tunnel_dump_t *mp;
12738 vl_api_control_ping_t *mp_ping;
12740 u8 sw_if_index_set = 0;
12743 /* Parse args required to build the message */
12744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12746 if (unformat (i, "sw_if_index %d", &sw_if_index))
12747 sw_if_index_set = 1;
12752 if (sw_if_index_set == 0)
12757 if (!vam->json_output)
12759 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12760 "sw_if_index", "local_address", "remote_address",
12761 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12764 /* Get list of geneve-tunnel interfaces */
12765 M (GENEVE_TUNNEL_DUMP, mp);
12767 mp->sw_if_index = htonl (sw_if_index);
12771 /* Use a control ping for synchronization */
12772 M (CONTROL_PING, mp_ping);
12780 api_gre_add_del_tunnel (vat_main_t * vam)
12782 unformat_input_t *line_input = vam->input;
12783 vl_api_gre_add_del_tunnel_t *mp;
12784 ip4_address_t src4, dst4;
12785 ip6_address_t src6, dst6;
12792 u32 outer_fib_id = 0;
12795 memset (&src4, 0, sizeof src4);
12796 memset (&dst4, 0, sizeof dst4);
12797 memset (&src6, 0, sizeof src6);
12798 memset (&dst6, 0, sizeof dst6);
12800 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12802 if (unformat (line_input, "del"))
12804 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12809 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12814 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12819 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12824 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12826 else if (unformat (line_input, "teb"))
12830 errmsg ("parse error '%U'", format_unformat_error, line_input);
12837 errmsg ("tunnel src address not specified");
12842 errmsg ("tunnel dst address not specified");
12845 if (ipv4_set && ipv6_set)
12847 errmsg ("both IPv4 and IPv6 addresses specified");
12852 M (GRE_ADD_DEL_TUNNEL, mp);
12856 clib_memcpy (&mp->src_address, &src4, 4);
12857 clib_memcpy (&mp->dst_address, &dst4, 4);
12861 clib_memcpy (&mp->src_address, &src6, 16);
12862 clib_memcpy (&mp->dst_address, &dst6, 16);
12864 mp->outer_fib_id = ntohl (outer_fib_id);
12865 mp->is_add = is_add;
12867 mp->is_ipv6 = ipv6_set;
12874 static void vl_api_gre_tunnel_details_t_handler
12875 (vl_api_gre_tunnel_details_t * mp)
12877 vat_main_t *vam = &vat_main;
12878 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12879 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12881 print (vam->ofp, "%11d%24U%24U%6d%14d",
12882 ntohl (mp->sw_if_index),
12883 format_ip46_address, &src, IP46_TYPE_ANY,
12884 format_ip46_address, &dst, IP46_TYPE_ANY,
12885 mp->teb, ntohl (mp->outer_fib_id));
12888 static void vl_api_gre_tunnel_details_t_handler_json
12889 (vl_api_gre_tunnel_details_t * mp)
12891 vat_main_t *vam = &vat_main;
12892 vat_json_node_t *node = NULL;
12893 struct in_addr ip4;
12894 struct in6_addr ip6;
12896 if (VAT_JSON_ARRAY != vam->json_tree.type)
12898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12899 vat_json_init_array (&vam->json_tree);
12901 node = vat_json_array_add (&vam->json_tree);
12903 vat_json_init_object (node);
12904 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12907 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12908 vat_json_object_add_ip4 (node, "src_address", ip4);
12909 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12910 vat_json_object_add_ip4 (node, "dst_address", ip4);
12914 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12915 vat_json_object_add_ip6 (node, "src_address", ip6);
12916 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12917 vat_json_object_add_ip6 (node, "dst_address", ip6);
12919 vat_json_object_add_uint (node, "teb", mp->teb);
12920 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12921 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12925 api_gre_tunnel_dump (vat_main_t * vam)
12927 unformat_input_t *i = vam->input;
12928 vl_api_gre_tunnel_dump_t *mp;
12929 vl_api_control_ping_t *mp_ping;
12931 u8 sw_if_index_set = 0;
12934 /* Parse args required to build the message */
12935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12937 if (unformat (i, "sw_if_index %d", &sw_if_index))
12938 sw_if_index_set = 1;
12943 if (sw_if_index_set == 0)
12948 if (!vam->json_output)
12950 print (vam->ofp, "%11s%24s%24s%6s%14s",
12951 "sw_if_index", "src_address", "dst_address", "teb",
12955 /* Get list of gre-tunnel interfaces */
12956 M (GRE_TUNNEL_DUMP, mp);
12958 mp->sw_if_index = htonl (sw_if_index);
12962 /* Use a control ping for synchronization */
12963 MPING (CONTROL_PING, mp_ping);
12971 api_l2_fib_clear_table (vat_main_t * vam)
12973 // unformat_input_t * i = vam->input;
12974 vl_api_l2_fib_clear_table_t *mp;
12977 M (L2_FIB_CLEAR_TABLE, mp);
12985 api_l2_interface_efp_filter (vat_main_t * vam)
12987 unformat_input_t *i = vam->input;
12988 vl_api_l2_interface_efp_filter_t *mp;
12991 u8 sw_if_index_set = 0;
12994 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12996 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12997 sw_if_index_set = 1;
12998 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12999 sw_if_index_set = 1;
13000 else if (unformat (i, "enable"))
13002 else if (unformat (i, "disable"))
13006 clib_warning ("parse error '%U'", format_unformat_error, i);
13011 if (sw_if_index_set == 0)
13013 errmsg ("missing sw_if_index");
13017 M (L2_INTERFACE_EFP_FILTER, mp);
13019 mp->sw_if_index = ntohl (sw_if_index);
13020 mp->enable_disable = enable;
13027 #define foreach_vtr_op \
13028 _("disable", L2_VTR_DISABLED) \
13029 _("push-1", L2_VTR_PUSH_1) \
13030 _("push-2", L2_VTR_PUSH_2) \
13031 _("pop-1", L2_VTR_POP_1) \
13032 _("pop-2", L2_VTR_POP_2) \
13033 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13034 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13035 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13036 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13039 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13041 unformat_input_t *i = vam->input;
13042 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13044 u8 sw_if_index_set = 0;
13047 u32 push_dot1q = 1;
13052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13054 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13055 sw_if_index_set = 1;
13056 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13057 sw_if_index_set = 1;
13058 else if (unformat (i, "vtr_op %d", &vtr_op))
13060 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13063 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13065 else if (unformat (i, "tag1 %d", &tag1))
13067 else if (unformat (i, "tag2 %d", &tag2))
13071 clib_warning ("parse error '%U'", format_unformat_error, i);
13076 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13078 errmsg ("missing vtr operation or sw_if_index");
13082 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13083 mp->sw_if_index = ntohl (sw_if_index);
13084 mp->vtr_op = ntohl (vtr_op);
13085 mp->push_dot1q = ntohl (push_dot1q);
13086 mp->tag1 = ntohl (tag1);
13087 mp->tag2 = ntohl (tag2);
13095 api_create_vhost_user_if (vat_main_t * vam)
13097 unformat_input_t *i = vam->input;
13098 vl_api_create_vhost_user_if_t *mp;
13101 u8 file_name_set = 0;
13102 u32 custom_dev_instance = ~0;
13104 u8 use_custom_mac = 0;
13108 /* Shut up coverity */
13109 memset (hwaddr, 0, sizeof (hwaddr));
13111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13113 if (unformat (i, "socket %s", &file_name))
13117 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13119 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13120 use_custom_mac = 1;
13121 else if (unformat (i, "server"))
13123 else if (unformat (i, "tag %s", &tag))
13129 if (file_name_set == 0)
13131 errmsg ("missing socket file name");
13135 if (vec_len (file_name) > 255)
13137 errmsg ("socket file name too long");
13140 vec_add1 (file_name, 0);
13142 M (CREATE_VHOST_USER_IF, mp);
13144 mp->is_server = is_server;
13145 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13146 vec_free (file_name);
13147 if (custom_dev_instance != ~0)
13150 mp->custom_dev_instance = ntohl (custom_dev_instance);
13152 mp->use_custom_mac = use_custom_mac;
13153 clib_memcpy (mp->mac_address, hwaddr, 6);
13155 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13164 api_modify_vhost_user_if (vat_main_t * vam)
13166 unformat_input_t *i = vam->input;
13167 vl_api_modify_vhost_user_if_t *mp;
13170 u8 file_name_set = 0;
13171 u32 custom_dev_instance = ~0;
13172 u8 sw_if_index_set = 0;
13173 u32 sw_if_index = (u32) ~ 0;
13176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13178 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13179 sw_if_index_set = 1;
13180 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13181 sw_if_index_set = 1;
13182 else if (unformat (i, "socket %s", &file_name))
13186 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13188 else if (unformat (i, "server"))
13194 if (sw_if_index_set == 0)
13196 errmsg ("missing sw_if_index or interface name");
13200 if (file_name_set == 0)
13202 errmsg ("missing socket file name");
13206 if (vec_len (file_name) > 255)
13208 errmsg ("socket file name too long");
13211 vec_add1 (file_name, 0);
13213 M (MODIFY_VHOST_USER_IF, mp);
13215 mp->sw_if_index = ntohl (sw_if_index);
13216 mp->is_server = is_server;
13217 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13218 vec_free (file_name);
13219 if (custom_dev_instance != ~0)
13222 mp->custom_dev_instance = ntohl (custom_dev_instance);
13231 api_delete_vhost_user_if (vat_main_t * vam)
13233 unformat_input_t *i = vam->input;
13234 vl_api_delete_vhost_user_if_t *mp;
13235 u32 sw_if_index = ~0;
13236 u8 sw_if_index_set = 0;
13239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13241 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13242 sw_if_index_set = 1;
13243 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13244 sw_if_index_set = 1;
13249 if (sw_if_index_set == 0)
13251 errmsg ("missing sw_if_index or interface name");
13256 M (DELETE_VHOST_USER_IF, mp);
13258 mp->sw_if_index = ntohl (sw_if_index);
13265 static void vl_api_sw_interface_vhost_user_details_t_handler
13266 (vl_api_sw_interface_vhost_user_details_t * mp)
13268 vat_main_t *vam = &vat_main;
13270 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13271 (char *) mp->interface_name,
13272 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13273 clib_net_to_host_u64 (mp->features), mp->is_server,
13274 ntohl (mp->num_regions), (char *) mp->sock_filename);
13275 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13278 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13279 (vl_api_sw_interface_vhost_user_details_t * mp)
13281 vat_main_t *vam = &vat_main;
13282 vat_json_node_t *node = NULL;
13284 if (VAT_JSON_ARRAY != vam->json_tree.type)
13286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13287 vat_json_init_array (&vam->json_tree);
13289 node = vat_json_array_add (&vam->json_tree);
13291 vat_json_init_object (node);
13292 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13293 vat_json_object_add_string_copy (node, "interface_name",
13294 mp->interface_name);
13295 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13296 ntohl (mp->virtio_net_hdr_sz));
13297 vat_json_object_add_uint (node, "features",
13298 clib_net_to_host_u64 (mp->features));
13299 vat_json_object_add_uint (node, "is_server", mp->is_server);
13300 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13301 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13302 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13306 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13308 vl_api_sw_interface_vhost_user_dump_t *mp;
13309 vl_api_control_ping_t *mp_ping;
13312 "Interface name idx hdr_sz features server regions filename");
13314 /* Get list of vhost-user interfaces */
13315 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13318 /* Use a control ping for synchronization */
13319 MPING (CONTROL_PING, mp_ping);
13327 api_show_version (vat_main_t * vam)
13329 vl_api_show_version_t *mp;
13332 M (SHOW_VERSION, mp);
13341 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13343 unformat_input_t *line_input = vam->input;
13344 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13345 ip4_address_t local4, remote4;
13346 ip6_address_t local6, remote6;
13348 u8 ipv4_set = 0, ipv6_set = 0;
13352 u32 mcast_sw_if_index = ~0;
13353 u32 encap_vrf_id = 0;
13354 u32 decap_vrf_id = 0;
13360 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13361 memset (&local4, 0, sizeof local4);
13362 memset (&remote4, 0, sizeof remote4);
13363 memset (&local6, 0, sizeof local6);
13364 memset (&remote6, 0, sizeof remote6);
13366 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13368 if (unformat (line_input, "del"))
13370 else if (unformat (line_input, "local %U",
13371 unformat_ip4_address, &local4))
13376 else if (unformat (line_input, "remote %U",
13377 unformat_ip4_address, &remote4))
13382 else if (unformat (line_input, "local %U",
13383 unformat_ip6_address, &local6))
13388 else if (unformat (line_input, "remote %U",
13389 unformat_ip6_address, &remote6))
13394 else if (unformat (line_input, "group %U %U",
13395 unformat_ip4_address, &remote4,
13396 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13398 grp_set = remote_set = 1;
13401 else if (unformat (line_input, "group %U",
13402 unformat_ip4_address, &remote4))
13404 grp_set = remote_set = 1;
13407 else if (unformat (line_input, "group %U %U",
13408 unformat_ip6_address, &remote6,
13409 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13411 grp_set = remote_set = 1;
13414 else if (unformat (line_input, "group %U",
13415 unformat_ip6_address, &remote6))
13417 grp_set = remote_set = 1;
13421 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13423 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13425 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13427 else if (unformat (line_input, "vni %d", &vni))
13429 else if (unformat (line_input, "next-ip4"))
13431 else if (unformat (line_input, "next-ip6"))
13433 else if (unformat (line_input, "next-ethernet"))
13435 else if (unformat (line_input, "next-nsh"))
13439 errmsg ("parse error '%U'", format_unformat_error, line_input);
13444 if (local_set == 0)
13446 errmsg ("tunnel local address not specified");
13449 if (remote_set == 0)
13451 errmsg ("tunnel remote address not specified");
13454 if (grp_set && mcast_sw_if_index == ~0)
13456 errmsg ("tunnel nonexistent multicast device");
13459 if (ipv4_set && ipv6_set)
13461 errmsg ("both IPv4 and IPv6 addresses specified");
13467 errmsg ("vni not specified");
13471 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13476 clib_memcpy (&mp->local, &local6, sizeof (local6));
13477 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13481 clib_memcpy (&mp->local, &local4, sizeof (local4));
13482 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13485 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13486 mp->encap_vrf_id = ntohl (encap_vrf_id);
13487 mp->decap_vrf_id = ntohl (decap_vrf_id);
13488 mp->protocol = protocol;
13489 mp->vni = ntohl (vni);
13490 mp->is_add = is_add;
13491 mp->is_ipv6 = ipv6_set;
13498 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13499 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13501 vat_main_t *vam = &vat_main;
13502 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13503 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13505 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13506 ntohl (mp->sw_if_index),
13507 format_ip46_address, &local, IP46_TYPE_ANY,
13508 format_ip46_address, &remote, IP46_TYPE_ANY,
13509 ntohl (mp->vni), mp->protocol,
13510 ntohl (mp->mcast_sw_if_index),
13511 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13515 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13516 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13518 vat_main_t *vam = &vat_main;
13519 vat_json_node_t *node = NULL;
13520 struct in_addr ip4;
13521 struct in6_addr ip6;
13523 if (VAT_JSON_ARRAY != vam->json_tree.type)
13525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13526 vat_json_init_array (&vam->json_tree);
13528 node = vat_json_array_add (&vam->json_tree);
13530 vat_json_init_object (node);
13531 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13534 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13535 vat_json_object_add_ip6 (node, "local", ip6);
13536 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13537 vat_json_object_add_ip6 (node, "remote", ip6);
13541 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13542 vat_json_object_add_ip4 (node, "local", ip4);
13543 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13544 vat_json_object_add_ip4 (node, "remote", ip4);
13546 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13547 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13548 vat_json_object_add_uint (node, "mcast_sw_if_index",
13549 ntohl (mp->mcast_sw_if_index));
13550 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13551 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13552 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13556 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13558 unformat_input_t *i = vam->input;
13559 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13560 vl_api_control_ping_t *mp_ping;
13562 u8 sw_if_index_set = 0;
13565 /* Parse args required to build the message */
13566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13568 if (unformat (i, "sw_if_index %d", &sw_if_index))
13569 sw_if_index_set = 1;
13574 if (sw_if_index_set == 0)
13579 if (!vam->json_output)
13581 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13582 "sw_if_index", "local", "remote", "vni",
13583 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13586 /* Get list of vxlan-tunnel interfaces */
13587 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13589 mp->sw_if_index = htonl (sw_if_index);
13593 /* Use a control ping for synchronization */
13594 MPING (CONTROL_PING, mp_ping);
13601 static void vl_api_l2_fib_table_details_t_handler
13602 (vl_api_l2_fib_table_details_t * mp)
13604 vat_main_t *vam = &vat_main;
13606 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13608 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13609 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13613 static void vl_api_l2_fib_table_details_t_handler_json
13614 (vl_api_l2_fib_table_details_t * mp)
13616 vat_main_t *vam = &vat_main;
13617 vat_json_node_t *node = NULL;
13619 if (VAT_JSON_ARRAY != vam->json_tree.type)
13621 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13622 vat_json_init_array (&vam->json_tree);
13624 node = vat_json_array_add (&vam->json_tree);
13626 vat_json_init_object (node);
13627 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13628 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13629 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13630 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13631 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13632 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13636 api_l2_fib_table_dump (vat_main_t * vam)
13638 unformat_input_t *i = vam->input;
13639 vl_api_l2_fib_table_dump_t *mp;
13640 vl_api_control_ping_t *mp_ping;
13645 /* Parse args required to build the message */
13646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13648 if (unformat (i, "bd_id %d", &bd_id))
13654 if (bd_id_set == 0)
13656 errmsg ("missing bridge domain");
13660 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13662 /* Get list of l2 fib entries */
13663 M (L2_FIB_TABLE_DUMP, mp);
13665 mp->bd_id = ntohl (bd_id);
13668 /* Use a control ping for synchronization */
13669 MPING (CONTROL_PING, mp_ping);
13678 api_interface_name_renumber (vat_main_t * vam)
13680 unformat_input_t *line_input = vam->input;
13681 vl_api_interface_name_renumber_t *mp;
13682 u32 sw_if_index = ~0;
13683 u32 new_show_dev_instance = ~0;
13686 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13688 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13691 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13693 else if (unformat (line_input, "new_show_dev_instance %d",
13694 &new_show_dev_instance))
13700 if (sw_if_index == ~0)
13702 errmsg ("missing interface name or sw_if_index");
13706 if (new_show_dev_instance == ~0)
13708 errmsg ("missing new_show_dev_instance");
13712 M (INTERFACE_NAME_RENUMBER, mp);
13714 mp->sw_if_index = ntohl (sw_if_index);
13715 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13723 api_want_ip4_arp_events (vat_main_t * vam)
13725 unformat_input_t *line_input = vam->input;
13726 vl_api_want_ip4_arp_events_t *mp;
13727 ip4_address_t address;
13728 int address_set = 0;
13729 u32 enable_disable = 1;
13732 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13734 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13736 else if (unformat (line_input, "del"))
13737 enable_disable = 0;
13742 if (address_set == 0)
13744 errmsg ("missing addresses");
13748 M (WANT_IP4_ARP_EVENTS, mp);
13749 mp->enable_disable = enable_disable;
13750 mp->pid = htonl (getpid ());
13751 mp->address = address.as_u32;
13759 api_want_ip6_nd_events (vat_main_t * vam)
13761 unformat_input_t *line_input = vam->input;
13762 vl_api_want_ip6_nd_events_t *mp;
13763 ip6_address_t address;
13764 int address_set = 0;
13765 u32 enable_disable = 1;
13768 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13770 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13772 else if (unformat (line_input, "del"))
13773 enable_disable = 0;
13778 if (address_set == 0)
13780 errmsg ("missing addresses");
13784 M (WANT_IP6_ND_EVENTS, mp);
13785 mp->enable_disable = enable_disable;
13786 mp->pid = htonl (getpid ());
13787 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13795 api_want_l2_macs_events (vat_main_t * vam)
13797 unformat_input_t *line_input = vam->input;
13798 vl_api_want_l2_macs_events_t *mp;
13799 u8 enable_disable = 1;
13800 u32 scan_delay = 0;
13801 u32 max_macs_in_event = 0;
13802 u32 learn_limit = 0;
13805 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13807 if (unformat (line_input, "learn-limit %d", &learn_limit))
13809 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13811 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13813 else if (unformat (line_input, "disable"))
13814 enable_disable = 0;
13819 M (WANT_L2_MACS_EVENTS, mp);
13820 mp->enable_disable = enable_disable;
13821 mp->pid = htonl (getpid ());
13822 mp->learn_limit = htonl (learn_limit);
13823 mp->scan_delay = (u8) scan_delay;
13824 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13831 api_input_acl_set_interface (vat_main_t * vam)
13833 unformat_input_t *i = vam->input;
13834 vl_api_input_acl_set_interface_t *mp;
13836 int sw_if_index_set;
13837 u32 ip4_table_index = ~0;
13838 u32 ip6_table_index = ~0;
13839 u32 l2_table_index = ~0;
13843 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13845 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13846 sw_if_index_set = 1;
13847 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13848 sw_if_index_set = 1;
13849 else if (unformat (i, "del"))
13851 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13853 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13855 else if (unformat (i, "l2-table %d", &l2_table_index))
13859 clib_warning ("parse error '%U'", format_unformat_error, i);
13864 if (sw_if_index_set == 0)
13866 errmsg ("missing interface name or sw_if_index");
13870 M (INPUT_ACL_SET_INTERFACE, mp);
13872 mp->sw_if_index = ntohl (sw_if_index);
13873 mp->ip4_table_index = ntohl (ip4_table_index);
13874 mp->ip6_table_index = ntohl (ip6_table_index);
13875 mp->l2_table_index = ntohl (l2_table_index);
13876 mp->is_add = is_add;
13884 api_ip_address_dump (vat_main_t * vam)
13886 unformat_input_t *i = vam->input;
13887 vl_api_ip_address_dump_t *mp;
13888 vl_api_control_ping_t *mp_ping;
13889 u32 sw_if_index = ~0;
13890 u8 sw_if_index_set = 0;
13895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13897 if (unformat (i, "sw_if_index %d", &sw_if_index))
13898 sw_if_index_set = 1;
13900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13901 sw_if_index_set = 1;
13902 else if (unformat (i, "ipv4"))
13904 else if (unformat (i, "ipv6"))
13910 if (ipv4_set && ipv6_set)
13912 errmsg ("ipv4 and ipv6 flags cannot be both set");
13916 if ((!ipv4_set) && (!ipv6_set))
13918 errmsg ("no ipv4 nor ipv6 flag set");
13922 if (sw_if_index_set == 0)
13924 errmsg ("missing interface name or sw_if_index");
13928 vam->current_sw_if_index = sw_if_index;
13929 vam->is_ipv6 = ipv6_set;
13931 M (IP_ADDRESS_DUMP, mp);
13932 mp->sw_if_index = ntohl (sw_if_index);
13933 mp->is_ipv6 = ipv6_set;
13936 /* Use a control ping for synchronization */
13937 MPING (CONTROL_PING, mp_ping);
13945 api_ip_dump (vat_main_t * vam)
13947 vl_api_ip_dump_t *mp;
13948 vl_api_control_ping_t *mp_ping;
13949 unformat_input_t *in = vam->input;
13956 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13958 if (unformat (in, "ipv4"))
13960 else if (unformat (in, "ipv6"))
13966 if (ipv4_set && ipv6_set)
13968 errmsg ("ipv4 and ipv6 flags cannot be both set");
13972 if ((!ipv4_set) && (!ipv6_set))
13974 errmsg ("no ipv4 nor ipv6 flag set");
13978 is_ipv6 = ipv6_set;
13979 vam->is_ipv6 = is_ipv6;
13981 /* free old data */
13982 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13984 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13986 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13989 mp->is_ipv6 = ipv6_set;
13992 /* Use a control ping for synchronization */
13993 MPING (CONTROL_PING, mp_ping);
14001 api_ipsec_spd_add_del (vat_main_t * vam)
14003 unformat_input_t *i = vam->input;
14004 vl_api_ipsec_spd_add_del_t *mp;
14009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14011 if (unformat (i, "spd_id %d", &spd_id))
14013 else if (unformat (i, "del"))
14017 clib_warning ("parse error '%U'", format_unformat_error, i);
14023 errmsg ("spd_id must be set");
14027 M (IPSEC_SPD_ADD_DEL, mp);
14029 mp->spd_id = ntohl (spd_id);
14030 mp->is_add = is_add;
14038 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14040 unformat_input_t *i = vam->input;
14041 vl_api_ipsec_interface_add_del_spd_t *mp;
14043 u8 sw_if_index_set = 0;
14044 u32 spd_id = (u32) ~ 0;
14048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14050 if (unformat (i, "del"))
14052 else if (unformat (i, "spd_id %d", &spd_id))
14055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14056 sw_if_index_set = 1;
14057 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14058 sw_if_index_set = 1;
14061 clib_warning ("parse error '%U'", format_unformat_error, i);
14067 if (spd_id == (u32) ~ 0)
14069 errmsg ("spd_id must be set");
14073 if (sw_if_index_set == 0)
14075 errmsg ("missing interface name or sw_if_index");
14079 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14081 mp->spd_id = ntohl (spd_id);
14082 mp->sw_if_index = ntohl (sw_if_index);
14083 mp->is_add = is_add;
14091 api_ipsec_spd_add_del_entry (vat_main_t * vam)
14093 unformat_input_t *i = vam->input;
14094 vl_api_ipsec_spd_add_del_entry_t *mp;
14095 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14096 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14098 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14099 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14100 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
14101 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
14104 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
14105 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
14106 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
14107 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
14108 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
14109 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
14111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14113 if (unformat (i, "del"))
14115 if (unformat (i, "outbound"))
14117 if (unformat (i, "inbound"))
14119 else if (unformat (i, "spd_id %d", &spd_id))
14121 else if (unformat (i, "sa_id %d", &sa_id))
14123 else if (unformat (i, "priority %d", &priority))
14125 else if (unformat (i, "protocol %d", &protocol))
14127 else if (unformat (i, "lport_start %d", &lport_start))
14129 else if (unformat (i, "lport_stop %d", &lport_stop))
14131 else if (unformat (i, "rport_start %d", &rport_start))
14133 else if (unformat (i, "rport_stop %d", &rport_stop))
14137 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
14143 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
14150 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
14156 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
14163 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
14169 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
14176 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
14182 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
14188 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14190 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14192 clib_warning ("unsupported action: 'resolve'");
14198 clib_warning ("parse error '%U'", format_unformat_error, i);
14204 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
14206 mp->spd_id = ntohl (spd_id);
14207 mp->priority = ntohl (priority);
14208 mp->is_outbound = is_outbound;
14210 mp->is_ipv6 = is_ipv6;
14211 if (is_ipv6 || is_ip_any)
14213 clib_memcpy (mp->remote_address_start, &raddr6_start,
14214 sizeof (ip6_address_t));
14215 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
14216 sizeof (ip6_address_t));
14217 clib_memcpy (mp->local_address_start, &laddr6_start,
14218 sizeof (ip6_address_t));
14219 clib_memcpy (mp->local_address_stop, &laddr6_stop,
14220 sizeof (ip6_address_t));
14224 clib_memcpy (mp->remote_address_start, &raddr4_start,
14225 sizeof (ip4_address_t));
14226 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
14227 sizeof (ip4_address_t));
14228 clib_memcpy (mp->local_address_start, &laddr4_start,
14229 sizeof (ip4_address_t));
14230 clib_memcpy (mp->local_address_stop, &laddr4_stop,
14231 sizeof (ip4_address_t));
14233 mp->protocol = (u8) protocol;
14234 mp->local_port_start = ntohs ((u16) lport_start);
14235 mp->local_port_stop = ntohs ((u16) lport_stop);
14236 mp->remote_port_start = ntohs ((u16) rport_start);
14237 mp->remote_port_stop = ntohs ((u16) rport_stop);
14238 mp->policy = (u8) policy;
14239 mp->sa_id = ntohl (sa_id);
14240 mp->is_add = is_add;
14241 mp->is_ip_any = is_ip_any;
14248 api_ipsec_sad_add_del_entry (vat_main_t * vam)
14250 unformat_input_t *i = vam->input;
14251 vl_api_ipsec_sad_add_del_entry_t *mp;
14252 u32 sad_id = 0, spi = 0;
14253 u8 *ck = 0, *ik = 0;
14256 u8 protocol = IPSEC_PROTOCOL_AH;
14257 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
14258 u32 crypto_alg = 0, integ_alg = 0;
14259 ip4_address_t tun_src4;
14260 ip4_address_t tun_dst4;
14261 ip6_address_t tun_src6;
14262 ip6_address_t tun_dst6;
14265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14267 if (unformat (i, "del"))
14269 else if (unformat (i, "sad_id %d", &sad_id))
14271 else if (unformat (i, "spi %d", &spi))
14273 else if (unformat (i, "esp"))
14274 protocol = IPSEC_PROTOCOL_ESP;
14275 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
14278 is_tunnel_ipv6 = 0;
14280 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
14283 is_tunnel_ipv6 = 0;
14285 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
14288 is_tunnel_ipv6 = 1;
14290 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
14293 is_tunnel_ipv6 = 1;
14297 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14299 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14300 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14302 clib_warning ("unsupported crypto-alg: '%U'",
14303 format_ipsec_crypto_alg, crypto_alg);
14307 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14311 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14313 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14314 integ_alg >= IPSEC_INTEG_N_ALG)
14316 clib_warning ("unsupported integ-alg: '%U'",
14317 format_ipsec_integ_alg, integ_alg);
14321 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14325 clib_warning ("parse error '%U'", format_unformat_error, i);
14331 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
14333 mp->sad_id = ntohl (sad_id);
14334 mp->is_add = is_add;
14335 mp->protocol = protocol;
14336 mp->spi = ntohl (spi);
14337 mp->is_tunnel = is_tunnel;
14338 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14339 mp->crypto_algorithm = crypto_alg;
14340 mp->integrity_algorithm = integ_alg;
14341 mp->crypto_key_length = vec_len (ck);
14342 mp->integrity_key_length = vec_len (ik);
14344 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14345 mp->crypto_key_length = sizeof (mp->crypto_key);
14347 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14348 mp->integrity_key_length = sizeof (mp->integrity_key);
14351 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14353 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14357 if (is_tunnel_ipv6)
14359 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14360 sizeof (ip6_address_t));
14361 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14362 sizeof (ip6_address_t));
14366 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14367 sizeof (ip4_address_t));
14368 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14369 sizeof (ip4_address_t));
14379 api_ipsec_sa_set_key (vat_main_t * vam)
14381 unformat_input_t *i = vam->input;
14382 vl_api_ipsec_sa_set_key_t *mp;
14384 u8 *ck = 0, *ik = 0;
14387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14389 if (unformat (i, "sa_id %d", &sa_id))
14391 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14393 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14397 clib_warning ("parse error '%U'", format_unformat_error, i);
14402 M (IPSEC_SA_SET_KEY, mp);
14404 mp->sa_id = ntohl (sa_id);
14405 mp->crypto_key_length = vec_len (ck);
14406 mp->integrity_key_length = vec_len (ik);
14408 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14409 mp->crypto_key_length = sizeof (mp->crypto_key);
14411 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14412 mp->integrity_key_length = sizeof (mp->integrity_key);
14415 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14417 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14425 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14427 unformat_input_t *i = vam->input;
14428 vl_api_ipsec_tunnel_if_add_del_t *mp;
14429 u32 local_spi = 0, remote_spi = 0;
14430 u32 crypto_alg = 0, integ_alg = 0;
14431 u8 *lck = NULL, *rck = NULL;
14432 u8 *lik = NULL, *rik = NULL;
14433 ip4_address_t local_ip = { {0} };
14434 ip4_address_t remote_ip = { {0} };
14437 u8 anti_replay = 0;
14440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14442 if (unformat (i, "del"))
14444 else if (unformat (i, "esn"))
14446 else if (unformat (i, "anti_replay"))
14448 else if (unformat (i, "local_spi %d", &local_spi))
14450 else if (unformat (i, "remote_spi %d", &remote_spi))
14452 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14454 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14456 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14459 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14461 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14463 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14467 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14469 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14470 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14472 errmsg ("unsupported crypto-alg: '%U'\n",
14473 format_ipsec_crypto_alg, crypto_alg);
14479 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14481 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14482 integ_alg >= IPSEC_INTEG_N_ALG)
14484 errmsg ("unsupported integ-alg: '%U'\n",
14485 format_ipsec_integ_alg, integ_alg);
14491 errmsg ("parse error '%U'\n", format_unformat_error, i);
14496 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14498 mp->is_add = is_add;
14500 mp->anti_replay = anti_replay;
14502 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14503 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14505 mp->local_spi = htonl (local_spi);
14506 mp->remote_spi = htonl (remote_spi);
14507 mp->crypto_alg = (u8) crypto_alg;
14509 mp->local_crypto_key_len = 0;
14512 mp->local_crypto_key_len = vec_len (lck);
14513 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14514 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14515 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14518 mp->remote_crypto_key_len = 0;
14521 mp->remote_crypto_key_len = vec_len (rck);
14522 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14523 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14524 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14527 mp->integ_alg = (u8) integ_alg;
14529 mp->local_integ_key_len = 0;
14532 mp->local_integ_key_len = vec_len (lik);
14533 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14534 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14535 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14538 mp->remote_integ_key_len = 0;
14541 mp->remote_integ_key_len = vec_len (rik);
14542 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14543 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14544 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14553 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14555 vat_main_t *vam = &vat_main;
14557 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14558 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14559 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14560 "tunnel_src_addr %U tunnel_dst_addr %U "
14561 "salt %u seq_outbound %lu last_seq_inbound %lu "
14562 "replay_window %lu total_data_size %lu\n",
14563 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14565 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14566 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14567 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14568 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14569 mp->tunnel_src_addr,
14570 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14571 mp->tunnel_dst_addr,
14573 clib_net_to_host_u64 (mp->seq_outbound),
14574 clib_net_to_host_u64 (mp->last_seq_inbound),
14575 clib_net_to_host_u64 (mp->replay_window),
14576 clib_net_to_host_u64 (mp->total_data_size));
14579 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14580 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14582 static void vl_api_ipsec_sa_details_t_handler_json
14583 (vl_api_ipsec_sa_details_t * mp)
14585 vat_main_t *vam = &vat_main;
14586 vat_json_node_t *node = NULL;
14587 struct in_addr src_ip4, dst_ip4;
14588 struct in6_addr src_ip6, dst_ip6;
14590 if (VAT_JSON_ARRAY != vam->json_tree.type)
14592 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14593 vat_json_init_array (&vam->json_tree);
14595 node = vat_json_array_add (&vam->json_tree);
14597 vat_json_init_object (node);
14598 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14599 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14600 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14601 vat_json_object_add_uint (node, "proto", mp->protocol);
14602 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14603 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14604 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14605 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14606 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14607 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14608 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14609 mp->crypto_key_len);
14610 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14611 mp->integ_key_len);
14612 if (mp->is_tunnel_ip6)
14614 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14615 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14616 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14617 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14621 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14622 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14623 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14624 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14626 vat_json_object_add_uint (node, "replay_window",
14627 clib_net_to_host_u64 (mp->replay_window));
14628 vat_json_object_add_uint (node, "total_data_size",
14629 clib_net_to_host_u64 (mp->total_data_size));
14634 api_ipsec_sa_dump (vat_main_t * vam)
14636 unformat_input_t *i = vam->input;
14637 vl_api_ipsec_sa_dump_t *mp;
14638 vl_api_control_ping_t *mp_ping;
14642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14644 if (unformat (i, "sa_id %d", &sa_id))
14648 clib_warning ("parse error '%U'", format_unformat_error, i);
14653 M (IPSEC_SA_DUMP, mp);
14655 mp->sa_id = ntohl (sa_id);
14659 /* Use a control ping for synchronization */
14660 M (CONTROL_PING, mp_ping);
14668 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14670 unformat_input_t *i = vam->input;
14671 vl_api_ipsec_tunnel_if_set_key_t *mp;
14672 u32 sw_if_index = ~0;
14673 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14683 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14684 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14686 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14687 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14688 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14689 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14691 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14692 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14693 else if (unformat (i, "%U", unformat_hex_string, &key))
14697 clib_warning ("parse error '%U'", format_unformat_error, i);
14702 if (sw_if_index == ~0)
14704 errmsg ("interface must be specified");
14708 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14710 errmsg ("key type must be specified");
14716 errmsg ("algorithm must be specified");
14720 if (vec_len (key) == 0)
14722 errmsg ("key must be specified");
14726 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14728 mp->sw_if_index = htonl (sw_if_index);
14730 mp->key_type = key_type;
14731 mp->key_len = vec_len (key);
14732 clib_memcpy (mp->key, key, vec_len (key));
14741 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14743 unformat_input_t *i = vam->input;
14744 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14745 u32 sw_if_index = ~0;
14747 u8 is_outbound = (u8) ~ 0;
14750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14754 else if (unformat (i, "sa_id %d", &sa_id))
14756 else if (unformat (i, "outbound"))
14758 else if (unformat (i, "inbound"))
14762 clib_warning ("parse error '%U'", format_unformat_error, i);
14767 if (sw_if_index == ~0)
14769 errmsg ("interface must be specified");
14775 errmsg ("SA ID must be specified");
14779 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14781 mp->sw_if_index = htonl (sw_if_index);
14782 mp->sa_id = htonl (sa_id);
14783 mp->is_outbound = is_outbound;
14792 api_ikev2_profile_add_del (vat_main_t * vam)
14794 unformat_input_t *i = vam->input;
14795 vl_api_ikev2_profile_add_del_t *mp;
14800 const char *valid_chars = "a-zA-Z0-9_";
14802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14804 if (unformat (i, "del"))
14806 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14807 vec_add1 (name, 0);
14810 errmsg ("parse error '%U'", format_unformat_error, i);
14815 if (!vec_len (name))
14817 errmsg ("profile name must be specified");
14821 if (vec_len (name) > 64)
14823 errmsg ("profile name too long");
14827 M (IKEV2_PROFILE_ADD_DEL, mp);
14829 clib_memcpy (mp->name, name, vec_len (name));
14830 mp->is_add = is_add;
14839 api_ikev2_profile_set_auth (vat_main_t * vam)
14841 unformat_input_t *i = vam->input;
14842 vl_api_ikev2_profile_set_auth_t *mp;
14845 u32 auth_method = 0;
14849 const char *valid_chars = "a-zA-Z0-9_";
14851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14853 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14854 vec_add1 (name, 0);
14855 else if (unformat (i, "auth_method %U",
14856 unformat_ikev2_auth_method, &auth_method))
14858 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14860 else if (unformat (i, "auth_data %v", &data))
14864 errmsg ("parse error '%U'", format_unformat_error, i);
14869 if (!vec_len (name))
14871 errmsg ("profile name must be specified");
14875 if (vec_len (name) > 64)
14877 errmsg ("profile name too long");
14881 if (!vec_len (data))
14883 errmsg ("auth_data must be specified");
14889 errmsg ("auth_method must be specified");
14893 M (IKEV2_PROFILE_SET_AUTH, mp);
14895 mp->is_hex = is_hex;
14896 mp->auth_method = (u8) auth_method;
14897 mp->data_len = vec_len (data);
14898 clib_memcpy (mp->name, name, vec_len (name));
14899 clib_memcpy (mp->data, data, vec_len (data));
14909 api_ikev2_profile_set_id (vat_main_t * vam)
14911 unformat_input_t *i = vam->input;
14912 vl_api_ikev2_profile_set_id_t *mp;
14920 const char *valid_chars = "a-zA-Z0-9_";
14922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14924 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14925 vec_add1 (name, 0);
14926 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14928 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14930 data = vec_new (u8, 4);
14931 clib_memcpy (data, ip4.as_u8, 4);
14933 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14935 else if (unformat (i, "id_data %v", &data))
14937 else if (unformat (i, "local"))
14939 else if (unformat (i, "remote"))
14943 errmsg ("parse error '%U'", format_unformat_error, i);
14948 if (!vec_len (name))
14950 errmsg ("profile name must be specified");
14954 if (vec_len (name) > 64)
14956 errmsg ("profile name too long");
14960 if (!vec_len (data))
14962 errmsg ("id_data must be specified");
14968 errmsg ("id_type must be specified");
14972 M (IKEV2_PROFILE_SET_ID, mp);
14974 mp->is_local = is_local;
14975 mp->id_type = (u8) id_type;
14976 mp->data_len = vec_len (data);
14977 clib_memcpy (mp->name, name, vec_len (name));
14978 clib_memcpy (mp->data, data, vec_len (data));
14988 api_ikev2_profile_set_ts (vat_main_t * vam)
14990 unformat_input_t *i = vam->input;
14991 vl_api_ikev2_profile_set_ts_t *mp;
14994 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14995 ip4_address_t start_addr, end_addr;
14997 const char *valid_chars = "a-zA-Z0-9_";
15000 start_addr.as_u32 = 0;
15001 end_addr.as_u32 = (u32) ~ 0;
15003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15005 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
15006 vec_add1 (name, 0);
15007 else if (unformat (i, "protocol %d", &proto))
15009 else if (unformat (i, "start_port %d", &start_port))
15011 else if (unformat (i, "end_port %d", &end_port))
15014 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
15016 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
15018 else if (unformat (i, "local"))
15020 else if (unformat (i, "remote"))
15024 errmsg ("parse error '%U'", format_unformat_error, i);
15029 if (!vec_len (name))
15031 errmsg ("profile name must be specified");
15035 if (vec_len (name) > 64)
15037 errmsg ("profile name too long");
15041 M (IKEV2_PROFILE_SET_TS, mp);
15043 mp->is_local = is_local;
15044 mp->proto = (u8) proto;
15045 mp->start_port = (u16) start_port;
15046 mp->end_port = (u16) end_port;
15047 mp->start_addr = start_addr.as_u32;
15048 mp->end_addr = end_addr.as_u32;
15049 clib_memcpy (mp->name, name, vec_len (name));
15058 api_ikev2_set_local_key (vat_main_t * vam)
15060 unformat_input_t *i = vam->input;
15061 vl_api_ikev2_set_local_key_t *mp;
15065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15067 if (unformat (i, "file %v", &file))
15068 vec_add1 (file, 0);
15071 errmsg ("parse error '%U'", format_unformat_error, i);
15076 if (!vec_len (file))
15078 errmsg ("RSA key file must be specified");
15082 if (vec_len (file) > 256)
15084 errmsg ("file name too long");
15088 M (IKEV2_SET_LOCAL_KEY, mp);
15090 clib_memcpy (mp->key_file, file, vec_len (file));
15099 api_ikev2_set_responder (vat_main_t * vam)
15101 unformat_input_t *i = vam->input;
15102 vl_api_ikev2_set_responder_t *mp;
15105 u32 sw_if_index = ~0;
15106 ip4_address_t address;
15108 const char *valid_chars = "a-zA-Z0-9_";
15110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15113 (i, "%U interface %d address %U", unformat_token, valid_chars,
15114 &name, &sw_if_index, unformat_ip4_address, &address))
15115 vec_add1 (name, 0);
15118 errmsg ("parse error '%U'", format_unformat_error, i);
15123 if (!vec_len (name))
15125 errmsg ("profile name must be specified");
15129 if (vec_len (name) > 64)
15131 errmsg ("profile name too long");
15135 M (IKEV2_SET_RESPONDER, mp);
15137 clib_memcpy (mp->name, name, vec_len (name));
15140 mp->sw_if_index = sw_if_index;
15141 clib_memcpy (mp->address, &address, sizeof (address));
15149 api_ikev2_set_ike_transforms (vat_main_t * vam)
15151 unformat_input_t *i = vam->input;
15152 vl_api_ikev2_set_ike_transforms_t *mp;
15155 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15157 const char *valid_chars = "a-zA-Z0-9_";
15159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15161 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15162 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15163 vec_add1 (name, 0);
15166 errmsg ("parse error '%U'", format_unformat_error, i);
15171 if (!vec_len (name))
15173 errmsg ("profile name must be specified");
15177 if (vec_len (name) > 64)
15179 errmsg ("profile name too long");
15183 M (IKEV2_SET_IKE_TRANSFORMS, mp);
15185 clib_memcpy (mp->name, name, vec_len (name));
15187 mp->crypto_alg = crypto_alg;
15188 mp->crypto_key_size = crypto_key_size;
15189 mp->integ_alg = integ_alg;
15190 mp->dh_group = dh_group;
15199 api_ikev2_set_esp_transforms (vat_main_t * vam)
15201 unformat_input_t *i = vam->input;
15202 vl_api_ikev2_set_esp_transforms_t *mp;
15205 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
15207 const char *valid_chars = "a-zA-Z0-9_";
15209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15211 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
15212 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
15213 vec_add1 (name, 0);
15216 errmsg ("parse error '%U'", format_unformat_error, i);
15221 if (!vec_len (name))
15223 errmsg ("profile name must be specified");
15227 if (vec_len (name) > 64)
15229 errmsg ("profile name too long");
15233 M (IKEV2_SET_ESP_TRANSFORMS, mp);
15235 clib_memcpy (mp->name, name, vec_len (name));
15237 mp->crypto_alg = crypto_alg;
15238 mp->crypto_key_size = crypto_key_size;
15239 mp->integ_alg = integ_alg;
15240 mp->dh_group = dh_group;
15248 api_ikev2_set_sa_lifetime (vat_main_t * vam)
15250 unformat_input_t *i = vam->input;
15251 vl_api_ikev2_set_sa_lifetime_t *mp;
15254 u64 lifetime, lifetime_maxdata;
15255 u32 lifetime_jitter, handover;
15257 const char *valid_chars = "a-zA-Z0-9_";
15259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15261 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
15262 &lifetime, &lifetime_jitter, &handover,
15263 &lifetime_maxdata))
15264 vec_add1 (name, 0);
15267 errmsg ("parse error '%U'", format_unformat_error, i);
15272 if (!vec_len (name))
15274 errmsg ("profile name must be specified");
15278 if (vec_len (name) > 64)
15280 errmsg ("profile name too long");
15284 M (IKEV2_SET_SA_LIFETIME, mp);
15286 clib_memcpy (mp->name, name, vec_len (name));
15288 mp->lifetime = lifetime;
15289 mp->lifetime_jitter = lifetime_jitter;
15290 mp->handover = handover;
15291 mp->lifetime_maxdata = lifetime_maxdata;
15299 api_ikev2_initiate_sa_init (vat_main_t * vam)
15301 unformat_input_t *i = vam->input;
15302 vl_api_ikev2_initiate_sa_init_t *mp;
15306 const char *valid_chars = "a-zA-Z0-9_";
15308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15310 if (unformat (i, "%U", unformat_token, valid_chars, &name))
15311 vec_add1 (name, 0);
15314 errmsg ("parse error '%U'", format_unformat_error, i);
15319 if (!vec_len (name))
15321 errmsg ("profile name must be specified");
15325 if (vec_len (name) > 64)
15327 errmsg ("profile name too long");
15331 M (IKEV2_INITIATE_SA_INIT, mp);
15333 clib_memcpy (mp->name, name, vec_len (name));
15342 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
15344 unformat_input_t *i = vam->input;
15345 vl_api_ikev2_initiate_del_ike_sa_t *mp;
15350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15352 if (unformat (i, "%lx", &ispi))
15356 errmsg ("parse error '%U'", format_unformat_error, i);
15361 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
15371 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
15373 unformat_input_t *i = vam->input;
15374 vl_api_ikev2_initiate_del_child_sa_t *mp;
15379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15381 if (unformat (i, "%x", &ispi))
15385 errmsg ("parse error '%U'", format_unformat_error, i);
15390 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15400 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15402 unformat_input_t *i = vam->input;
15403 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15410 if (unformat (i, "%x", &ispi))
15414 errmsg ("parse error '%U'", format_unformat_error, i);
15419 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15432 api_map_add_domain (vat_main_t * vam)
15434 unformat_input_t *i = vam->input;
15435 vl_api_map_add_domain_t *mp;
15437 ip4_address_t ip4_prefix;
15438 ip6_address_t ip6_prefix;
15439 ip6_address_t ip6_src;
15440 u32 num_m_args = 0;
15441 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15442 0, psid_length = 0;
15443 u8 is_translation = 0;
15445 u32 ip6_src_len = 128;
15448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15450 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15451 &ip4_prefix, &ip4_prefix_len))
15453 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15454 &ip6_prefix, &ip6_prefix_len))
15458 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15461 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15463 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15465 else if (unformat (i, "psid-offset %d", &psid_offset))
15467 else if (unformat (i, "psid-len %d", &psid_length))
15469 else if (unformat (i, "mtu %d", &mtu))
15471 else if (unformat (i, "map-t"))
15472 is_translation = 1;
15475 clib_warning ("parse error '%U'", format_unformat_error, i);
15480 if (num_m_args < 3)
15482 errmsg ("mandatory argument(s) missing");
15486 /* Construct the API message */
15487 M (MAP_ADD_DOMAIN, mp);
15489 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15490 mp->ip4_prefix_len = ip4_prefix_len;
15492 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15493 mp->ip6_prefix_len = ip6_prefix_len;
15495 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15496 mp->ip6_src_prefix_len = ip6_src_len;
15498 mp->ea_bits_len = ea_bits_len;
15499 mp->psid_offset = psid_offset;
15500 mp->psid_length = psid_length;
15501 mp->is_translation = is_translation;
15502 mp->mtu = htons (mtu);
15507 /* Wait for a reply, return good/bad news */
15513 api_map_del_domain (vat_main_t * vam)
15515 unformat_input_t *i = vam->input;
15516 vl_api_map_del_domain_t *mp;
15518 u32 num_m_args = 0;
15522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15524 if (unformat (i, "index %d", &index))
15528 clib_warning ("parse error '%U'", format_unformat_error, i);
15533 if (num_m_args != 1)
15535 errmsg ("mandatory argument(s) missing");
15539 /* Construct the API message */
15540 M (MAP_DEL_DOMAIN, mp);
15542 mp->index = ntohl (index);
15547 /* Wait for a reply, return good/bad news */
15553 api_map_add_del_rule (vat_main_t * vam)
15555 unformat_input_t *i = vam->input;
15556 vl_api_map_add_del_rule_t *mp;
15558 ip6_address_t ip6_dst;
15559 u32 num_m_args = 0, index, psid = 0;
15562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15564 if (unformat (i, "index %d", &index))
15566 else if (unformat (i, "psid %d", &psid))
15568 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15570 else if (unformat (i, "del"))
15576 clib_warning ("parse error '%U'", format_unformat_error, i);
15581 /* Construct the API message */
15582 M (MAP_ADD_DEL_RULE, mp);
15584 mp->index = ntohl (index);
15585 mp->is_add = is_add;
15586 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15587 mp->psid = ntohs (psid);
15592 /* Wait for a reply, return good/bad news */
15598 api_map_domain_dump (vat_main_t * vam)
15600 vl_api_map_domain_dump_t *mp;
15601 vl_api_control_ping_t *mp_ping;
15604 /* Construct the API message */
15605 M (MAP_DOMAIN_DUMP, mp);
15610 /* Use a control ping for synchronization */
15611 MPING (CONTROL_PING, mp_ping);
15619 api_map_rule_dump (vat_main_t * vam)
15621 unformat_input_t *i = vam->input;
15622 vl_api_map_rule_dump_t *mp;
15623 vl_api_control_ping_t *mp_ping;
15624 u32 domain_index = ~0;
15627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15629 if (unformat (i, "index %u", &domain_index))
15635 if (domain_index == ~0)
15637 clib_warning ("parse error: domain index expected");
15641 /* Construct the API message */
15642 M (MAP_RULE_DUMP, mp);
15644 mp->domain_index = htonl (domain_index);
15649 /* Use a control ping for synchronization */
15650 MPING (CONTROL_PING, mp_ping);
15657 static void vl_api_map_add_domain_reply_t_handler
15658 (vl_api_map_add_domain_reply_t * mp)
15660 vat_main_t *vam = &vat_main;
15661 i32 retval = ntohl (mp->retval);
15663 if (vam->async_mode)
15665 vam->async_errors += (retval < 0);
15669 vam->retval = retval;
15670 vam->result_ready = 1;
15674 static void vl_api_map_add_domain_reply_t_handler_json
15675 (vl_api_map_add_domain_reply_t * mp)
15677 vat_main_t *vam = &vat_main;
15678 vat_json_node_t node;
15680 vat_json_init_object (&node);
15681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15682 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15684 vat_json_print (vam->ofp, &node);
15685 vat_json_free (&node);
15687 vam->retval = ntohl (mp->retval);
15688 vam->result_ready = 1;
15692 api_get_first_msg_id (vat_main_t * vam)
15694 vl_api_get_first_msg_id_t *mp;
15695 unformat_input_t *i = vam->input;
15700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15702 if (unformat (i, "client %s", &name))
15710 errmsg ("missing client name");
15713 vec_add1 (name, 0);
15715 if (vec_len (name) > 63)
15717 errmsg ("client name too long");
15721 M (GET_FIRST_MSG_ID, mp);
15722 clib_memcpy (mp->name, name, vec_len (name));
15729 api_cop_interface_enable_disable (vat_main_t * vam)
15731 unformat_input_t *line_input = vam->input;
15732 vl_api_cop_interface_enable_disable_t *mp;
15733 u32 sw_if_index = ~0;
15734 u8 enable_disable = 1;
15737 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (line_input, "disable"))
15740 enable_disable = 0;
15741 if (unformat (line_input, "enable"))
15742 enable_disable = 1;
15743 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15744 vam, &sw_if_index))
15746 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15752 if (sw_if_index == ~0)
15754 errmsg ("missing interface name or sw_if_index");
15758 /* Construct the API message */
15759 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15760 mp->sw_if_index = ntohl (sw_if_index);
15761 mp->enable_disable = enable_disable;
15765 /* Wait for the reply */
15771 api_cop_whitelist_enable_disable (vat_main_t * vam)
15773 unformat_input_t *line_input = vam->input;
15774 vl_api_cop_whitelist_enable_disable_t *mp;
15775 u32 sw_if_index = ~0;
15776 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15780 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15782 if (unformat (line_input, "ip4"))
15784 else if (unformat (line_input, "ip6"))
15786 else if (unformat (line_input, "default"))
15788 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15789 vam, &sw_if_index))
15791 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15793 else if (unformat (line_input, "fib-id %d", &fib_id))
15799 if (sw_if_index == ~0)
15801 errmsg ("missing interface name or sw_if_index");
15805 /* Construct the API message */
15806 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15807 mp->sw_if_index = ntohl (sw_if_index);
15808 mp->fib_id = ntohl (fib_id);
15811 mp->default_cop = default_cop;
15815 /* Wait for the reply */
15821 api_get_node_graph (vat_main_t * vam)
15823 vl_api_get_node_graph_t *mp;
15826 M (GET_NODE_GRAPH, mp);
15830 /* Wait for the reply */
15836 /** Used for parsing LISP eids */
15837 typedef CLIB_PACKED(struct{
15838 u8 addr[16]; /**< eid address */
15839 u32 len; /**< prefix length if IP */
15840 u8 type; /**< type of eid */
15845 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15847 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15849 memset (a, 0, sizeof (a[0]));
15851 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15853 a->type = 0; /* ipv4 type */
15855 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15857 a->type = 1; /* ipv6 type */
15859 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15861 a->type = 2; /* mac type */
15863 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15865 a->type = 3; /* NSH type */
15866 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15867 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15874 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15883 lisp_eid_size_vat (u8 type)
15900 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15902 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15906 api_one_add_del_locator_set (vat_main_t * vam)
15908 unformat_input_t *input = vam->input;
15909 vl_api_one_add_del_locator_set_t *mp;
15911 u8 *locator_set_name = NULL;
15912 u8 locator_set_name_set = 0;
15913 vl_api_local_locator_t locator, *locators = 0;
15914 u32 sw_if_index, priority, weight;
15918 /* Parse args required to build the message */
15919 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15921 if (unformat (input, "del"))
15925 else if (unformat (input, "locator-set %s", &locator_set_name))
15927 locator_set_name_set = 1;
15929 else if (unformat (input, "sw_if_index %u p %u w %u",
15930 &sw_if_index, &priority, &weight))
15932 locator.sw_if_index = htonl (sw_if_index);
15933 locator.priority = priority;
15934 locator.weight = weight;
15935 vec_add1 (locators, locator);
15939 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15940 &sw_if_index, &priority, &weight))
15942 locator.sw_if_index = htonl (sw_if_index);
15943 locator.priority = priority;
15944 locator.weight = weight;
15945 vec_add1 (locators, locator);
15951 if (locator_set_name_set == 0)
15953 errmsg ("missing locator-set name");
15954 vec_free (locators);
15958 if (vec_len (locator_set_name) > 64)
15960 errmsg ("locator-set name too long");
15961 vec_free (locator_set_name);
15962 vec_free (locators);
15965 vec_add1 (locator_set_name, 0);
15967 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15969 /* Construct the API message */
15970 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15972 mp->is_add = is_add;
15973 clib_memcpy (mp->locator_set_name, locator_set_name,
15974 vec_len (locator_set_name));
15975 vec_free (locator_set_name);
15977 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15979 clib_memcpy (mp->locators, locators, data_len);
15980 vec_free (locators);
15985 /* Wait for a reply... */
15990 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15993 api_one_add_del_locator (vat_main_t * vam)
15995 unformat_input_t *input = vam->input;
15996 vl_api_one_add_del_locator_t *mp;
15997 u32 tmp_if_index = ~0;
15998 u32 sw_if_index = ~0;
15999 u8 sw_if_index_set = 0;
16000 u8 sw_if_index_if_name_set = 0;
16002 u8 priority_set = 0;
16006 u8 *locator_set_name = NULL;
16007 u8 locator_set_name_set = 0;
16010 /* Parse args required to build the message */
16011 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16013 if (unformat (input, "del"))
16017 else if (unformat (input, "locator-set %s", &locator_set_name))
16019 locator_set_name_set = 1;
16021 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
16024 sw_if_index_if_name_set = 1;
16025 sw_if_index = tmp_if_index;
16027 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
16029 sw_if_index_set = 1;
16030 sw_if_index = tmp_if_index;
16032 else if (unformat (input, "p %d", &priority))
16036 else if (unformat (input, "w %d", &weight))
16044 if (locator_set_name_set == 0)
16046 errmsg ("missing locator-set name");
16050 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
16052 errmsg ("missing sw_if_index");
16053 vec_free (locator_set_name);
16057 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
16059 errmsg ("cannot use both params interface name and sw_if_index");
16060 vec_free (locator_set_name);
16064 if (priority_set == 0)
16066 errmsg ("missing locator-set priority");
16067 vec_free (locator_set_name);
16071 if (weight_set == 0)
16073 errmsg ("missing locator-set weight");
16074 vec_free (locator_set_name);
16078 if (vec_len (locator_set_name) > 64)
16080 errmsg ("locator-set name too long");
16081 vec_free (locator_set_name);
16084 vec_add1 (locator_set_name, 0);
16086 /* Construct the API message */
16087 M (ONE_ADD_DEL_LOCATOR, mp);
16089 mp->is_add = is_add;
16090 mp->sw_if_index = ntohl (sw_if_index);
16091 mp->priority = priority;
16092 mp->weight = weight;
16093 clib_memcpy (mp->locator_set_name, locator_set_name,
16094 vec_len (locator_set_name));
16095 vec_free (locator_set_name);
16100 /* Wait for a reply... */
16105 #define api_lisp_add_del_locator api_one_add_del_locator
16108 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
16110 u32 *key_id = va_arg (*args, u32 *);
16113 if (unformat (input, "%s", &s))
16115 if (!strcmp ((char *) s, "sha1"))
16116 key_id[0] = HMAC_SHA_1_96;
16117 else if (!strcmp ((char *) s, "sha256"))
16118 key_id[0] = HMAC_SHA_256_128;
16121 clib_warning ("invalid key_id: '%s'", s);
16122 key_id[0] = HMAC_NO_KEY;
16133 api_one_add_del_local_eid (vat_main_t * vam)
16135 unformat_input_t *input = vam->input;
16136 vl_api_one_add_del_local_eid_t *mp;
16139 lisp_eid_vat_t _eid, *eid = &_eid;
16140 u8 *locator_set_name = 0;
16141 u8 locator_set_name_set = 0;
16147 /* Parse args required to build the message */
16148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (input, "del"))
16154 else if (unformat (input, "vni %d", &vni))
16158 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16162 else if (unformat (input, "locator-set %s", &locator_set_name))
16164 locator_set_name_set = 1;
16166 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
16168 else if (unformat (input, "secret-key %_%v%_", &key))
16174 if (locator_set_name_set == 0)
16176 errmsg ("missing locator-set name");
16182 errmsg ("EID address not set!");
16183 vec_free (locator_set_name);
16187 if (key && (0 == key_id))
16189 errmsg ("invalid key_id!");
16193 if (vec_len (key) > 64)
16195 errmsg ("key too long");
16200 if (vec_len (locator_set_name) > 64)
16202 errmsg ("locator-set name too long");
16203 vec_free (locator_set_name);
16206 vec_add1 (locator_set_name, 0);
16208 /* Construct the API message */
16209 M (ONE_ADD_DEL_LOCAL_EID, mp);
16211 mp->is_add = is_add;
16212 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16213 mp->eid_type = eid->type;
16214 mp->prefix_len = eid->len;
16215 mp->vni = clib_host_to_net_u32 (vni);
16216 mp->key_id = clib_host_to_net_u16 (key_id);
16217 clib_memcpy (mp->locator_set_name, locator_set_name,
16218 vec_len (locator_set_name));
16219 clib_memcpy (mp->key, key, vec_len (key));
16221 vec_free (locator_set_name);
16227 /* Wait for a reply... */
16232 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16235 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16237 u32 dp_table = 0, vni = 0;;
16238 unformat_input_t *input = vam->input;
16239 vl_api_gpe_add_del_fwd_entry_t *mp;
16241 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16242 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16243 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16244 u32 action = ~0, w;
16245 ip4_address_t rmt_rloc4, lcl_rloc4;
16246 ip6_address_t rmt_rloc6, lcl_rloc6;
16247 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16250 memset (&rloc, 0, sizeof (rloc));
16252 /* Parse args required to build the message */
16253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16255 if (unformat (input, "del"))
16257 else if (unformat (input, "add"))
16259 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16263 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16267 else if (unformat (input, "vrf %d", &dp_table))
16269 else if (unformat (input, "bd %d", &dp_table))
16271 else if (unformat (input, "vni %d", &vni))
16273 else if (unformat (input, "w %d", &w))
16277 errmsg ("No RLOC configured for setting priority/weight!");
16280 curr_rloc->weight = w;
16282 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16283 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16287 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16289 vec_add1 (lcl_locs, rloc);
16291 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16292 vec_add1 (rmt_locs, rloc);
16293 /* weight saved in rmt loc */
16294 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16296 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16297 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16300 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16302 vec_add1 (lcl_locs, rloc);
16304 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16305 vec_add1 (rmt_locs, rloc);
16306 /* weight saved in rmt loc */
16307 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16309 else if (unformat (input, "action %d", &action))
16315 clib_warning ("parse error '%U'", format_unformat_error, input);
16322 errmsg ("remote eid addresses not set");
16326 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16328 errmsg ("eid types don't match");
16332 if (0 == rmt_locs && (u32) ~ 0 == action)
16334 errmsg ("action not set for negative mapping");
16338 /* Construct the API message */
16339 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16340 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16342 mp->is_add = is_add;
16343 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16344 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16345 mp->eid_type = rmt_eid->type;
16346 mp->dp_table = clib_host_to_net_u32 (dp_table);
16347 mp->vni = clib_host_to_net_u32 (vni);
16348 mp->rmt_len = rmt_eid->len;
16349 mp->lcl_len = lcl_eid->len;
16350 mp->action = action;
16352 if (0 != rmt_locs && 0 != lcl_locs)
16354 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16355 clib_memcpy (mp->locs, lcl_locs,
16356 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16358 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16359 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16360 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16362 vec_free (lcl_locs);
16363 vec_free (rmt_locs);
16368 /* Wait for a reply... */
16374 api_one_add_del_map_server (vat_main_t * vam)
16376 unformat_input_t *input = vam->input;
16377 vl_api_one_add_del_map_server_t *mp;
16381 ip4_address_t ipv4;
16382 ip6_address_t ipv6;
16385 /* Parse args required to build the message */
16386 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16388 if (unformat (input, "del"))
16392 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16396 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16404 if (ipv4_set && ipv6_set)
16406 errmsg ("both eid v4 and v6 addresses set");
16410 if (!ipv4_set && !ipv6_set)
16412 errmsg ("eid addresses not set");
16416 /* Construct the API message */
16417 M (ONE_ADD_DEL_MAP_SERVER, mp);
16419 mp->is_add = is_add;
16423 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16428 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16434 /* Wait for a reply... */
16439 #define api_lisp_add_del_map_server api_one_add_del_map_server
16442 api_one_add_del_map_resolver (vat_main_t * vam)
16444 unformat_input_t *input = vam->input;
16445 vl_api_one_add_del_map_resolver_t *mp;
16449 ip4_address_t ipv4;
16450 ip6_address_t ipv6;
16453 /* Parse args required to build the message */
16454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16456 if (unformat (input, "del"))
16460 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16464 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16472 if (ipv4_set && ipv6_set)
16474 errmsg ("both eid v4 and v6 addresses set");
16478 if (!ipv4_set && !ipv6_set)
16480 errmsg ("eid addresses not set");
16484 /* Construct the API message */
16485 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16487 mp->is_add = is_add;
16491 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16496 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16502 /* Wait for a reply... */
16507 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16510 api_lisp_gpe_enable_disable (vat_main_t * vam)
16512 unformat_input_t *input = vam->input;
16513 vl_api_gpe_enable_disable_t *mp;
16518 /* Parse args required to build the message */
16519 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16521 if (unformat (input, "enable"))
16526 else if (unformat (input, "disable"))
16537 errmsg ("Value not set");
16541 /* Construct the API message */
16542 M (GPE_ENABLE_DISABLE, mp);
16549 /* Wait for a reply... */
16555 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16557 unformat_input_t *input = vam->input;
16558 vl_api_one_rloc_probe_enable_disable_t *mp;
16563 /* Parse args required to build the message */
16564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16566 if (unformat (input, "enable"))
16571 else if (unformat (input, "disable"))
16579 errmsg ("Value not set");
16583 /* Construct the API message */
16584 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16586 mp->is_enabled = is_en;
16591 /* Wait for a reply... */
16596 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16599 api_one_map_register_enable_disable (vat_main_t * vam)
16601 unformat_input_t *input = vam->input;
16602 vl_api_one_map_register_enable_disable_t *mp;
16607 /* Parse args required to build the message */
16608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16610 if (unformat (input, "enable"))
16615 else if (unformat (input, "disable"))
16623 errmsg ("Value not set");
16627 /* Construct the API message */
16628 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16630 mp->is_enabled = is_en;
16635 /* Wait for a reply... */
16640 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16643 api_one_enable_disable (vat_main_t * vam)
16645 unformat_input_t *input = vam->input;
16646 vl_api_one_enable_disable_t *mp;
16651 /* Parse args required to build the message */
16652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16654 if (unformat (input, "enable"))
16659 else if (unformat (input, "disable"))
16669 errmsg ("Value not set");
16673 /* Construct the API message */
16674 M (ONE_ENABLE_DISABLE, mp);
16681 /* Wait for a reply... */
16686 #define api_lisp_enable_disable api_one_enable_disable
16689 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16691 unformat_input_t *input = vam->input;
16692 vl_api_one_enable_disable_xtr_mode_t *mp;
16697 /* Parse args required to build the message */
16698 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16700 if (unformat (input, "enable"))
16705 else if (unformat (input, "disable"))
16715 errmsg ("Value not set");
16719 /* Construct the API message */
16720 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16727 /* Wait for a reply... */
16733 api_one_show_xtr_mode (vat_main_t * vam)
16735 vl_api_one_show_xtr_mode_t *mp;
16738 /* Construct the API message */
16739 M (ONE_SHOW_XTR_MODE, mp);
16744 /* Wait for a reply... */
16750 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16752 unformat_input_t *input = vam->input;
16753 vl_api_one_enable_disable_pitr_mode_t *mp;
16758 /* Parse args required to build the message */
16759 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16761 if (unformat (input, "enable"))
16766 else if (unformat (input, "disable"))
16776 errmsg ("Value not set");
16780 /* Construct the API message */
16781 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16788 /* Wait for a reply... */
16794 api_one_show_pitr_mode (vat_main_t * vam)
16796 vl_api_one_show_pitr_mode_t *mp;
16799 /* Construct the API message */
16800 M (ONE_SHOW_PITR_MODE, mp);
16805 /* Wait for a reply... */
16811 api_one_enable_disable_petr_mode (vat_main_t * vam)
16813 unformat_input_t *input = vam->input;
16814 vl_api_one_enable_disable_petr_mode_t *mp;
16819 /* Parse args required to build the message */
16820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16822 if (unformat (input, "enable"))
16827 else if (unformat (input, "disable"))
16837 errmsg ("Value not set");
16841 /* Construct the API message */
16842 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16849 /* Wait for a reply... */
16855 api_one_show_petr_mode (vat_main_t * vam)
16857 vl_api_one_show_petr_mode_t *mp;
16860 /* Construct the API message */
16861 M (ONE_SHOW_PETR_MODE, mp);
16866 /* Wait for a reply... */
16872 api_show_one_map_register_state (vat_main_t * vam)
16874 vl_api_show_one_map_register_state_t *mp;
16877 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16882 /* wait for reply */
16887 #define api_show_lisp_map_register_state api_show_one_map_register_state
16890 api_show_one_rloc_probe_state (vat_main_t * vam)
16892 vl_api_show_one_rloc_probe_state_t *mp;
16895 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16900 /* wait for reply */
16905 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16908 api_one_add_del_ndp_entry (vat_main_t * vam)
16910 vl_api_one_add_del_ndp_entry_t *mp;
16911 unformat_input_t *input = vam->input;
16916 u8 mac[6] = { 0, };
16917 u8 ip6[16] = { 0, };
16921 /* Parse args required to build the message */
16922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16924 if (unformat (input, "del"))
16926 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16928 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16930 else if (unformat (input, "bd %d", &bd))
16934 errmsg ("parse error '%U'", format_unformat_error, input);
16939 if (!bd_set || !ip_set || (!mac_set && is_add))
16941 errmsg ("Missing BD, IP or MAC!");
16945 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16946 mp->is_add = is_add;
16947 clib_memcpy (mp->mac, mac, 6);
16948 mp->bd = clib_host_to_net_u32 (bd);
16949 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16954 /* wait for reply */
16960 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16962 vl_api_one_add_del_l2_arp_entry_t *mp;
16963 unformat_input_t *input = vam->input;
16968 u8 mac[6] = { 0, };
16969 u32 ip4 = 0, bd = ~0;
16972 /* Parse args required to build the message */
16973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16975 if (unformat (input, "del"))
16977 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16979 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16981 else if (unformat (input, "bd %d", &bd))
16985 errmsg ("parse error '%U'", format_unformat_error, input);
16990 if (!bd_set || !ip_set || (!mac_set && is_add))
16992 errmsg ("Missing BD, IP or MAC!");
16996 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16997 mp->is_add = is_add;
16998 clib_memcpy (mp->mac, mac, 6);
16999 mp->bd = clib_host_to_net_u32 (bd);
17005 /* wait for reply */
17011 api_one_ndp_bd_get (vat_main_t * vam)
17013 vl_api_one_ndp_bd_get_t *mp;
17016 M (ONE_NDP_BD_GET, mp);
17021 /* wait for reply */
17027 api_one_ndp_entries_get (vat_main_t * vam)
17029 vl_api_one_ndp_entries_get_t *mp;
17030 unformat_input_t *input = vam->input;
17035 /* Parse args required to build the message */
17036 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17038 if (unformat (input, "bd %d", &bd))
17042 errmsg ("parse error '%U'", format_unformat_error, input);
17049 errmsg ("Expected bridge domain!");
17053 M (ONE_NDP_ENTRIES_GET, mp);
17054 mp->bd = clib_host_to_net_u32 (bd);
17059 /* wait for reply */
17065 api_one_l2_arp_bd_get (vat_main_t * vam)
17067 vl_api_one_l2_arp_bd_get_t *mp;
17070 M (ONE_L2_ARP_BD_GET, mp);
17075 /* wait for reply */
17081 api_one_l2_arp_entries_get (vat_main_t * vam)
17083 vl_api_one_l2_arp_entries_get_t *mp;
17084 unformat_input_t *input = vam->input;
17089 /* Parse args required to build the message */
17090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17092 if (unformat (input, "bd %d", &bd))
17096 errmsg ("parse error '%U'", format_unformat_error, input);
17103 errmsg ("Expected bridge domain!");
17107 M (ONE_L2_ARP_ENTRIES_GET, mp);
17108 mp->bd = clib_host_to_net_u32 (bd);
17113 /* wait for reply */
17119 api_one_stats_enable_disable (vat_main_t * vam)
17121 vl_api_one_stats_enable_disable_t *mp;
17122 unformat_input_t *input = vam->input;
17127 /* Parse args required to build the message */
17128 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17130 if (unformat (input, "enable"))
17135 else if (unformat (input, "disable"))
17145 errmsg ("Value not set");
17149 M (ONE_STATS_ENABLE_DISABLE, mp);
17155 /* wait for reply */
17161 api_show_one_stats_enable_disable (vat_main_t * vam)
17163 vl_api_show_one_stats_enable_disable_t *mp;
17166 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
17171 /* wait for reply */
17177 api_show_one_map_request_mode (vat_main_t * vam)
17179 vl_api_show_one_map_request_mode_t *mp;
17182 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
17187 /* wait for reply */
17192 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
17195 api_one_map_request_mode (vat_main_t * vam)
17197 unformat_input_t *input = vam->input;
17198 vl_api_one_map_request_mode_t *mp;
17202 /* Parse args required to build the message */
17203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17205 if (unformat (input, "dst-only"))
17207 else if (unformat (input, "src-dst"))
17211 errmsg ("parse error '%U'", format_unformat_error, input);
17216 M (ONE_MAP_REQUEST_MODE, mp);
17223 /* wait for reply */
17228 #define api_lisp_map_request_mode api_one_map_request_mode
17231 * Enable/disable ONE proxy ITR.
17233 * @param vam vpp API test context
17234 * @return return code
17237 api_one_pitr_set_locator_set (vat_main_t * vam)
17239 u8 ls_name_set = 0;
17240 unformat_input_t *input = vam->input;
17241 vl_api_one_pitr_set_locator_set_t *mp;
17246 /* Parse args required to build the message */
17247 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17249 if (unformat (input, "del"))
17251 else if (unformat (input, "locator-set %s", &ls_name))
17255 errmsg ("parse error '%U'", format_unformat_error, input);
17262 errmsg ("locator-set name not set!");
17266 M (ONE_PITR_SET_LOCATOR_SET, mp);
17268 mp->is_add = is_add;
17269 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17270 vec_free (ls_name);
17275 /* wait for reply */
17280 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17283 api_one_nsh_set_locator_set (vat_main_t * vam)
17285 u8 ls_name_set = 0;
17286 unformat_input_t *input = vam->input;
17287 vl_api_one_nsh_set_locator_set_t *mp;
17292 /* Parse args required to build the message */
17293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17295 if (unformat (input, "del"))
17297 else if (unformat (input, "ls %s", &ls_name))
17301 errmsg ("parse error '%U'", format_unformat_error, input);
17306 if (!ls_name_set && is_add)
17308 errmsg ("locator-set name not set!");
17312 M (ONE_NSH_SET_LOCATOR_SET, mp);
17314 mp->is_add = is_add;
17315 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17316 vec_free (ls_name);
17321 /* wait for reply */
17327 api_show_one_pitr (vat_main_t * vam)
17329 vl_api_show_one_pitr_t *mp;
17332 if (!vam->json_output)
17334 print (vam->ofp, "%=20s", "lisp status:");
17337 M (SHOW_ONE_PITR, mp);
17341 /* Wait for a reply... */
17346 #define api_show_lisp_pitr api_show_one_pitr
17349 api_one_use_petr (vat_main_t * vam)
17351 unformat_input_t *input = vam->input;
17352 vl_api_one_use_petr_t *mp;
17357 memset (&ip, 0, sizeof (ip));
17359 /* Parse args required to build the message */
17360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17362 if (unformat (input, "disable"))
17365 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17368 ip_addr_version (&ip) = IP4;
17371 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17374 ip_addr_version (&ip) = IP6;
17378 errmsg ("parse error '%U'", format_unformat_error, input);
17383 M (ONE_USE_PETR, mp);
17385 mp->is_add = is_add;
17388 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17390 clib_memcpy (mp->address, &ip, 4);
17392 clib_memcpy (mp->address, &ip, 16);
17398 /* wait for reply */
17403 #define api_lisp_use_petr api_one_use_petr
17406 api_show_one_nsh_mapping (vat_main_t * vam)
17408 vl_api_show_one_use_petr_t *mp;
17411 if (!vam->json_output)
17413 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17416 M (SHOW_ONE_NSH_MAPPING, mp);
17420 /* Wait for a reply... */
17426 api_show_one_use_petr (vat_main_t * vam)
17428 vl_api_show_one_use_petr_t *mp;
17431 if (!vam->json_output)
17433 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17436 M (SHOW_ONE_USE_PETR, mp);
17440 /* Wait for a reply... */
17445 #define api_show_lisp_use_petr api_show_one_use_petr
17448 * Add/delete mapping between vni and vrf
17451 api_one_eid_table_add_del_map (vat_main_t * vam)
17453 unformat_input_t *input = vam->input;
17454 vl_api_one_eid_table_add_del_map_t *mp;
17455 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17456 u32 vni, vrf, bd_index;
17459 /* Parse args required to build the message */
17460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17462 if (unformat (input, "del"))
17464 else if (unformat (input, "vrf %d", &vrf))
17466 else if (unformat (input, "bd_index %d", &bd_index))
17468 else if (unformat (input, "vni %d", &vni))
17474 if (!vni_set || (!vrf_set && !bd_index_set))
17476 errmsg ("missing arguments!");
17480 if (vrf_set && bd_index_set)
17482 errmsg ("error: both vrf and bd entered!");
17486 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17488 mp->is_add = is_add;
17489 mp->vni = htonl (vni);
17490 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17491 mp->is_l2 = bd_index_set;
17496 /* wait for reply */
17501 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17504 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17506 u32 *action = va_arg (*args, u32 *);
17509 if (unformat (input, "%s", &s))
17511 if (!strcmp ((char *) s, "no-action"))
17513 else if (!strcmp ((char *) s, "natively-forward"))
17515 else if (!strcmp ((char *) s, "send-map-request"))
17517 else if (!strcmp ((char *) s, "drop"))
17521 clib_warning ("invalid action: '%s'", s);
17533 * Add/del remote mapping to/from ONE control plane
17535 * @param vam vpp API test context
17536 * @return return code
17539 api_one_add_del_remote_mapping (vat_main_t * vam)
17541 unformat_input_t *input = vam->input;
17542 vl_api_one_add_del_remote_mapping_t *mp;
17544 lisp_eid_vat_t _eid, *eid = &_eid;
17545 lisp_eid_vat_t _seid, *seid = &_seid;
17546 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17547 u32 action = ~0, p, w, data_len;
17548 ip4_address_t rloc4;
17549 ip6_address_t rloc6;
17550 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17553 memset (&rloc, 0, sizeof (rloc));
17555 /* Parse args required to build the message */
17556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17558 if (unformat (input, "del-all"))
17562 else if (unformat (input, "del"))
17566 else if (unformat (input, "add"))
17570 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17574 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17578 else if (unformat (input, "vni %d", &vni))
17582 else if (unformat (input, "p %d w %d", &p, &w))
17586 errmsg ("No RLOC configured for setting priority/weight!");
17589 curr_rloc->priority = p;
17590 curr_rloc->weight = w;
17592 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17595 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17596 vec_add1 (rlocs, rloc);
17597 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17599 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17602 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17603 vec_add1 (rlocs, rloc);
17604 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17606 else if (unformat (input, "action %U",
17607 unformat_negative_mapping_action, &action))
17613 clib_warning ("parse error '%U'", format_unformat_error, input);
17620 errmsg ("missing params!");
17624 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17626 errmsg ("no action set for negative map-reply!");
17630 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17632 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17633 mp->is_add = is_add;
17634 mp->vni = htonl (vni);
17635 mp->action = (u8) action;
17636 mp->is_src_dst = seid_set;
17637 mp->eid_len = eid->len;
17638 mp->seid_len = seid->len;
17639 mp->del_all = del_all;
17640 mp->eid_type = eid->type;
17641 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17642 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17644 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17645 clib_memcpy (mp->rlocs, rlocs, data_len);
17651 /* Wait for a reply... */
17656 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17659 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17660 * forwarding entries in data-plane accordingly.
17662 * @param vam vpp API test context
17663 * @return return code
17666 api_one_add_del_adjacency (vat_main_t * vam)
17668 unformat_input_t *input = vam->input;
17669 vl_api_one_add_del_adjacency_t *mp;
17671 ip4_address_t leid4, reid4;
17672 ip6_address_t leid6, reid6;
17673 u8 reid_mac[6] = { 0 };
17674 u8 leid_mac[6] = { 0 };
17675 u8 reid_type, leid_type;
17676 u32 leid_len = 0, reid_len = 0, len;
17680 leid_type = reid_type = (u8) ~ 0;
17682 /* Parse args required to build the message */
17683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17685 if (unformat (input, "del"))
17689 else if (unformat (input, "add"))
17693 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17696 reid_type = 0; /* ipv4 */
17699 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17702 reid_type = 1; /* ipv6 */
17705 else if (unformat (input, "reid %U", unformat_ethernet_address,
17708 reid_type = 2; /* mac */
17710 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17713 leid_type = 0; /* ipv4 */
17716 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17719 leid_type = 1; /* ipv6 */
17722 else if (unformat (input, "leid %U", unformat_ethernet_address,
17725 leid_type = 2; /* mac */
17727 else if (unformat (input, "vni %d", &vni))
17733 errmsg ("parse error '%U'", format_unformat_error, input);
17738 if ((u8) ~ 0 == reid_type)
17740 errmsg ("missing params!");
17744 if (leid_type != reid_type)
17746 errmsg ("remote and local EIDs are of different types!");
17750 M (ONE_ADD_DEL_ADJACENCY, mp);
17751 mp->is_add = is_add;
17752 mp->vni = htonl (vni);
17753 mp->leid_len = leid_len;
17754 mp->reid_len = reid_len;
17755 mp->eid_type = reid_type;
17757 switch (mp->eid_type)
17760 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17761 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17764 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17765 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17768 clib_memcpy (mp->leid, leid_mac, 6);
17769 clib_memcpy (mp->reid, reid_mac, 6);
17772 errmsg ("unknown EID type %d!", mp->eid_type);
17779 /* Wait for a reply... */
17784 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17787 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17789 u32 *mode = va_arg (*args, u32 *);
17791 if (unformat (input, "lisp"))
17793 else if (unformat (input, "vxlan"))
17802 api_gpe_get_encap_mode (vat_main_t * vam)
17804 vl_api_gpe_get_encap_mode_t *mp;
17807 /* Construct the API message */
17808 M (GPE_GET_ENCAP_MODE, mp);
17813 /* Wait for a reply... */
17819 api_gpe_set_encap_mode (vat_main_t * vam)
17821 unformat_input_t *input = vam->input;
17822 vl_api_gpe_set_encap_mode_t *mp;
17826 /* Parse args required to build the message */
17827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17829 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17835 /* Construct the API message */
17836 M (GPE_SET_ENCAP_MODE, mp);
17843 /* Wait for a reply... */
17849 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17851 unformat_input_t *input = vam->input;
17852 vl_api_gpe_add_del_iface_t *mp;
17853 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17854 u32 dp_table = 0, vni = 0;
17857 /* Parse args required to build the message */
17858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17860 if (unformat (input, "up"))
17865 else if (unformat (input, "down"))
17870 else if (unformat (input, "table_id %d", &dp_table))
17874 else if (unformat (input, "bd_id %d", &dp_table))
17879 else if (unformat (input, "vni %d", &vni))
17887 if (action_set == 0)
17889 errmsg ("Action not set");
17892 if (dp_table_set == 0 || vni_set == 0)
17894 errmsg ("vni and dp_table must be set");
17898 /* Construct the API message */
17899 M (GPE_ADD_DEL_IFACE, mp);
17901 mp->is_add = is_add;
17902 mp->dp_table = clib_host_to_net_u32 (dp_table);
17904 mp->vni = clib_host_to_net_u32 (vni);
17909 /* Wait for a reply... */
17915 api_one_map_register_fallback_threshold (vat_main_t * vam)
17917 unformat_input_t *input = vam->input;
17918 vl_api_one_map_register_fallback_threshold_t *mp;
17923 /* Parse args required to build the message */
17924 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17926 if (unformat (input, "%u", &value))
17930 clib_warning ("parse error '%U'", format_unformat_error, input);
17937 errmsg ("fallback threshold value is missing!");
17941 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17942 mp->value = clib_host_to_net_u32 (value);
17947 /* Wait for a reply... */
17953 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17955 vl_api_show_one_map_register_fallback_threshold_t *mp;
17958 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17963 /* Wait for a reply... */
17969 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17971 u32 *proto = va_arg (*args, u32 *);
17973 if (unformat (input, "udp"))
17975 else if (unformat (input, "api"))
17984 api_one_set_transport_protocol (vat_main_t * vam)
17986 unformat_input_t *input = vam->input;
17987 vl_api_one_set_transport_protocol_t *mp;
17992 /* Parse args required to build the message */
17993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17995 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17999 clib_warning ("parse error '%U'", format_unformat_error, input);
18006 errmsg ("Transport protocol missing!");
18010 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
18011 mp->protocol = (u8) protocol;
18016 /* Wait for a reply... */
18022 api_one_get_transport_protocol (vat_main_t * vam)
18024 vl_api_one_get_transport_protocol_t *mp;
18027 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
18032 /* Wait for a reply... */
18038 api_one_map_register_set_ttl (vat_main_t * vam)
18040 unformat_input_t *input = vam->input;
18041 vl_api_one_map_register_set_ttl_t *mp;
18046 /* Parse args required to build the message */
18047 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18049 if (unformat (input, "%u", &ttl))
18053 clib_warning ("parse error '%U'", format_unformat_error, input);
18060 errmsg ("TTL value missing!");
18064 M (ONE_MAP_REGISTER_SET_TTL, mp);
18065 mp->ttl = clib_host_to_net_u32 (ttl);
18070 /* Wait for a reply... */
18076 api_show_one_map_register_ttl (vat_main_t * vam)
18078 vl_api_show_one_map_register_ttl_t *mp;
18081 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
18086 /* Wait for a reply... */
18092 * Add/del map request itr rlocs from ONE control plane and updates
18094 * @param vam vpp API test context
18095 * @return return code
18098 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
18100 unformat_input_t *input = vam->input;
18101 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
18102 u8 *locator_set_name = 0;
18103 u8 locator_set_name_set = 0;
18107 /* Parse args required to build the message */
18108 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18110 if (unformat (input, "del"))
18114 else if (unformat (input, "%_%v%_", &locator_set_name))
18116 locator_set_name_set = 1;
18120 clib_warning ("parse error '%U'", format_unformat_error, input);
18125 if (is_add && !locator_set_name_set)
18127 errmsg ("itr-rloc is not set!");
18131 if (is_add && vec_len (locator_set_name) > 64)
18133 errmsg ("itr-rloc locator-set name too long");
18134 vec_free (locator_set_name);
18138 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
18139 mp->is_add = is_add;
18142 clib_memcpy (mp->locator_set_name, locator_set_name,
18143 vec_len (locator_set_name));
18147 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
18149 vec_free (locator_set_name);
18154 /* Wait for a reply... */
18159 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
18162 api_one_locator_dump (vat_main_t * vam)
18164 unformat_input_t *input = vam->input;
18165 vl_api_one_locator_dump_t *mp;
18166 vl_api_control_ping_t *mp_ping;
18167 u8 is_index_set = 0, is_name_set = 0;
18172 /* Parse args required to build the message */
18173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18175 if (unformat (input, "ls_name %_%v%_", &ls_name))
18179 else if (unformat (input, "ls_index %d", &ls_index))
18185 errmsg ("parse error '%U'", format_unformat_error, input);
18190 if (!is_index_set && !is_name_set)
18192 errmsg ("error: expected one of index or name!");
18196 if (is_index_set && is_name_set)
18198 errmsg ("error: only one param expected!");
18202 if (vec_len (ls_name) > 62)
18204 errmsg ("error: locator set name too long!");
18208 if (!vam->json_output)
18210 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
18213 M (ONE_LOCATOR_DUMP, mp);
18214 mp->is_index_set = is_index_set;
18217 mp->ls_index = clib_host_to_net_u32 (ls_index);
18220 vec_add1 (ls_name, 0);
18221 strncpy ((char *) mp->ls_name, (char *) ls_name,
18222 sizeof (mp->ls_name) - 1);
18228 /* Use a control ping for synchronization */
18229 MPING (CONTROL_PING, mp_ping);
18232 /* Wait for a reply... */
18237 #define api_lisp_locator_dump api_one_locator_dump
18240 api_one_locator_set_dump (vat_main_t * vam)
18242 vl_api_one_locator_set_dump_t *mp;
18243 vl_api_control_ping_t *mp_ping;
18244 unformat_input_t *input = vam->input;
18248 /* Parse args required to build the message */
18249 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18251 if (unformat (input, "local"))
18255 else if (unformat (input, "remote"))
18261 errmsg ("parse error '%U'", format_unformat_error, input);
18266 if (!vam->json_output)
18268 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18271 M (ONE_LOCATOR_SET_DUMP, mp);
18273 mp->filter = filter;
18278 /* Use a control ping for synchronization */
18279 MPING (CONTROL_PING, mp_ping);
18282 /* Wait for a reply... */
18287 #define api_lisp_locator_set_dump api_one_locator_set_dump
18290 api_one_eid_table_map_dump (vat_main_t * vam)
18294 unformat_input_t *input = vam->input;
18295 vl_api_one_eid_table_map_dump_t *mp;
18296 vl_api_control_ping_t *mp_ping;
18299 /* Parse args required to build the message */
18300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18302 if (unformat (input, "l2"))
18307 else if (unformat (input, "l3"))
18314 errmsg ("parse error '%U'", format_unformat_error, input);
18321 errmsg ("expected one of 'l2' or 'l3' parameter!");
18325 if (!vam->json_output)
18327 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18330 M (ONE_EID_TABLE_MAP_DUMP, mp);
18336 /* Use a control ping for synchronization */
18337 MPING (CONTROL_PING, mp_ping);
18340 /* Wait for a reply... */
18345 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18348 api_one_eid_table_vni_dump (vat_main_t * vam)
18350 vl_api_one_eid_table_vni_dump_t *mp;
18351 vl_api_control_ping_t *mp_ping;
18354 if (!vam->json_output)
18356 print (vam->ofp, "VNI");
18359 M (ONE_EID_TABLE_VNI_DUMP, mp);
18364 /* Use a control ping for synchronization */
18365 MPING (CONTROL_PING, mp_ping);
18368 /* Wait for a reply... */
18373 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18376 api_one_eid_table_dump (vat_main_t * vam)
18378 unformat_input_t *i = vam->input;
18379 vl_api_one_eid_table_dump_t *mp;
18380 vl_api_control_ping_t *mp_ping;
18381 struct in_addr ip4;
18382 struct in6_addr ip6;
18384 u8 eid_type = ~0, eid_set = 0;
18385 u32 prefix_length = ~0, t, vni = 0;
18388 lisp_nsh_api_t nsh;
18390 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18392 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18398 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18404 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18409 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18414 else if (unformat (i, "vni %d", &t))
18418 else if (unformat (i, "local"))
18422 else if (unformat (i, "remote"))
18428 errmsg ("parse error '%U'", format_unformat_error, i);
18433 if (!vam->json_output)
18435 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18436 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18439 M (ONE_EID_TABLE_DUMP, mp);
18441 mp->filter = filter;
18445 mp->vni = htonl (vni);
18446 mp->eid_type = eid_type;
18450 mp->prefix_length = prefix_length;
18451 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18454 mp->prefix_length = prefix_length;
18455 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18458 clib_memcpy (mp->eid, mac, sizeof (mac));
18461 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18464 errmsg ("unknown EID type %d!", eid_type);
18472 /* Use a control ping for synchronization */
18473 MPING (CONTROL_PING, mp_ping);
18476 /* Wait for a reply... */
18481 #define api_lisp_eid_table_dump api_one_eid_table_dump
18484 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18486 unformat_input_t *i = vam->input;
18487 vl_api_gpe_fwd_entries_get_t *mp;
18492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18494 if (unformat (i, "vni %d", &vni))
18500 errmsg ("parse error '%U'", format_unformat_error, i);
18507 errmsg ("vni not set!");
18511 if (!vam->json_output)
18513 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18517 M (GPE_FWD_ENTRIES_GET, mp);
18518 mp->vni = clib_host_to_net_u32 (vni);
18523 /* Wait for a reply... */
18528 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18529 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18530 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18531 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18532 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18533 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18534 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18535 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18538 api_one_adjacencies_get (vat_main_t * vam)
18540 unformat_input_t *i = vam->input;
18541 vl_api_one_adjacencies_get_t *mp;
18546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18548 if (unformat (i, "vni %d", &vni))
18554 errmsg ("parse error '%U'", format_unformat_error, i);
18561 errmsg ("vni not set!");
18565 if (!vam->json_output)
18567 print (vam->ofp, "%s %40s", "leid", "reid");
18570 M (ONE_ADJACENCIES_GET, mp);
18571 mp->vni = clib_host_to_net_u32 (vni);
18576 /* Wait for a reply... */
18581 #define api_lisp_adjacencies_get api_one_adjacencies_get
18584 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18586 unformat_input_t *i = vam->input;
18587 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18589 u8 ip_family_set = 0, is_ip4 = 1;
18591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18593 if (unformat (i, "ip4"))
18598 else if (unformat (i, "ip6"))
18605 errmsg ("parse error '%U'", format_unformat_error, i);
18610 if (!ip_family_set)
18612 errmsg ("ip family not set!");
18616 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18617 mp->is_ip4 = is_ip4;
18622 /* Wait for a reply... */
18628 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18630 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18633 if (!vam->json_output)
18635 print (vam->ofp, "VNIs");
18638 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18643 /* Wait for a reply... */
18649 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18651 unformat_input_t *i = vam->input;
18652 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18654 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18655 struct in_addr ip4;
18656 struct in6_addr ip6;
18657 u32 table_id = 0, nh_sw_if_index = ~0;
18659 memset (&ip4, 0, sizeof (ip4));
18660 memset (&ip6, 0, sizeof (ip6));
18662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18664 if (unformat (i, "del"))
18666 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18667 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18672 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18673 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18678 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18682 nh_sw_if_index = ~0;
18684 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18688 nh_sw_if_index = ~0;
18690 else if (unformat (i, "table %d", &table_id))
18694 errmsg ("parse error '%U'", format_unformat_error, i);
18701 errmsg ("nh addr not set!");
18705 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18706 mp->is_add = is_add;
18707 mp->table_id = clib_host_to_net_u32 (table_id);
18708 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18709 mp->is_ip4 = is_ip4;
18711 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18713 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18718 /* Wait for a reply... */
18724 api_one_map_server_dump (vat_main_t * vam)
18726 vl_api_one_map_server_dump_t *mp;
18727 vl_api_control_ping_t *mp_ping;
18730 if (!vam->json_output)
18732 print (vam->ofp, "%=20s", "Map server");
18735 M (ONE_MAP_SERVER_DUMP, mp);
18739 /* Use a control ping for synchronization */
18740 MPING (CONTROL_PING, mp_ping);
18743 /* Wait for a reply... */
18748 #define api_lisp_map_server_dump api_one_map_server_dump
18751 api_one_map_resolver_dump (vat_main_t * vam)
18753 vl_api_one_map_resolver_dump_t *mp;
18754 vl_api_control_ping_t *mp_ping;
18757 if (!vam->json_output)
18759 print (vam->ofp, "%=20s", "Map resolver");
18762 M (ONE_MAP_RESOLVER_DUMP, mp);
18766 /* Use a control ping for synchronization */
18767 MPING (CONTROL_PING, mp_ping);
18770 /* Wait for a reply... */
18775 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18778 api_one_stats_flush (vat_main_t * vam)
18780 vl_api_one_stats_flush_t *mp;
18783 M (ONE_STATS_FLUSH, mp);
18790 api_one_stats_dump (vat_main_t * vam)
18792 vl_api_one_stats_dump_t *mp;
18793 vl_api_control_ping_t *mp_ping;
18796 M (ONE_STATS_DUMP, mp);
18800 /* Use a control ping for synchronization */
18801 MPING (CONTROL_PING, mp_ping);
18804 /* Wait for a reply... */
18810 api_show_one_status (vat_main_t * vam)
18812 vl_api_show_one_status_t *mp;
18815 if (!vam->json_output)
18817 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18820 M (SHOW_ONE_STATUS, mp);
18823 /* Wait for a reply... */
18828 #define api_show_lisp_status api_show_one_status
18831 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18833 vl_api_gpe_fwd_entry_path_dump_t *mp;
18834 vl_api_control_ping_t *mp_ping;
18835 unformat_input_t *i = vam->input;
18836 u32 fwd_entry_index = ~0;
18839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18841 if (unformat (i, "index %d", &fwd_entry_index))
18847 if (~0 == fwd_entry_index)
18849 errmsg ("no index specified!");
18853 if (!vam->json_output)
18855 print (vam->ofp, "first line");
18858 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18862 /* Use a control ping for synchronization */
18863 MPING (CONTROL_PING, mp_ping);
18866 /* Wait for a reply... */
18872 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18874 vl_api_one_get_map_request_itr_rlocs_t *mp;
18877 if (!vam->json_output)
18879 print (vam->ofp, "%=20s", "itr-rlocs:");
18882 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18885 /* Wait for a reply... */
18890 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18893 api_af_packet_create (vat_main_t * vam)
18895 unformat_input_t *i = vam->input;
18896 vl_api_af_packet_create_t *mp;
18897 u8 *host_if_name = 0;
18899 u8 random_hw_addr = 1;
18902 memset (hw_addr, 0, sizeof (hw_addr));
18904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18906 if (unformat (i, "name %s", &host_if_name))
18907 vec_add1 (host_if_name, 0);
18908 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18909 random_hw_addr = 0;
18914 if (!vec_len (host_if_name))
18916 errmsg ("host-interface name must be specified");
18920 if (vec_len (host_if_name) > 64)
18922 errmsg ("host-interface name too long");
18926 M (AF_PACKET_CREATE, mp);
18928 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18929 clib_memcpy (mp->hw_addr, hw_addr, 6);
18930 mp->use_random_hw_addr = random_hw_addr;
18931 vec_free (host_if_name);
18939 fprintf (vam->ofp ? vam->ofp : stderr,
18940 " new sw_if_index = %d\n", vam->sw_if_index);
18947 api_af_packet_delete (vat_main_t * vam)
18949 unformat_input_t *i = vam->input;
18950 vl_api_af_packet_delete_t *mp;
18951 u8 *host_if_name = 0;
18954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18956 if (unformat (i, "name %s", &host_if_name))
18957 vec_add1 (host_if_name, 0);
18962 if (!vec_len (host_if_name))
18964 errmsg ("host-interface name must be specified");
18968 if (vec_len (host_if_name) > 64)
18970 errmsg ("host-interface name too long");
18974 M (AF_PACKET_DELETE, mp);
18976 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18977 vec_free (host_if_name);
18985 api_policer_add_del (vat_main_t * vam)
18987 unformat_input_t *i = vam->input;
18988 vl_api_policer_add_del_t *mp;
18998 u8 color_aware = 0;
18999 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
19002 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
19003 conform_action.dscp = 0;
19004 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
19005 exceed_action.dscp = 0;
19006 violate_action.action_type = SSE2_QOS_ACTION_DROP;
19007 violate_action.dscp = 0;
19009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19011 if (unformat (i, "del"))
19013 else if (unformat (i, "name %s", &name))
19014 vec_add1 (name, 0);
19015 else if (unformat (i, "cir %u", &cir))
19017 else if (unformat (i, "eir %u", &eir))
19019 else if (unformat (i, "cb %u", &cb))
19021 else if (unformat (i, "eb %u", &eb))
19023 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
19026 else if (unformat (i, "round_type %U", unformat_policer_round_type,
19029 else if (unformat (i, "type %U", unformat_policer_type, &type))
19031 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
19034 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
19037 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
19040 else if (unformat (i, "color-aware"))
19046 if (!vec_len (name))
19048 errmsg ("policer name must be specified");
19052 if (vec_len (name) > 64)
19054 errmsg ("policer name too long");
19058 M (POLICER_ADD_DEL, mp);
19060 clib_memcpy (mp->name, name, vec_len (name));
19062 mp->is_add = is_add;
19063 mp->cir = ntohl (cir);
19064 mp->eir = ntohl (eir);
19065 mp->cb = clib_net_to_host_u64 (cb);
19066 mp->eb = clib_net_to_host_u64 (eb);
19067 mp->rate_type = rate_type;
19068 mp->round_type = round_type;
19070 mp->conform_action_type = conform_action.action_type;
19071 mp->conform_dscp = conform_action.dscp;
19072 mp->exceed_action_type = exceed_action.action_type;
19073 mp->exceed_dscp = exceed_action.dscp;
19074 mp->violate_action_type = violate_action.action_type;
19075 mp->violate_dscp = violate_action.dscp;
19076 mp->color_aware = color_aware;
19084 api_policer_dump (vat_main_t * vam)
19086 unformat_input_t *i = vam->input;
19087 vl_api_policer_dump_t *mp;
19088 vl_api_control_ping_t *mp_ping;
19089 u8 *match_name = 0;
19090 u8 match_name_valid = 0;
19093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19095 if (unformat (i, "name %s", &match_name))
19097 vec_add1 (match_name, 0);
19098 match_name_valid = 1;
19104 M (POLICER_DUMP, mp);
19105 mp->match_name_valid = match_name_valid;
19106 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
19107 vec_free (match_name);
19111 /* Use a control ping for synchronization */
19112 MPING (CONTROL_PING, mp_ping);
19115 /* Wait for a reply... */
19121 api_policer_classify_set_interface (vat_main_t * vam)
19123 unformat_input_t *i = vam->input;
19124 vl_api_policer_classify_set_interface_t *mp;
19126 int sw_if_index_set;
19127 u32 ip4_table_index = ~0;
19128 u32 ip6_table_index = ~0;
19129 u32 l2_table_index = ~0;
19133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19135 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19136 sw_if_index_set = 1;
19137 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19138 sw_if_index_set = 1;
19139 else if (unformat (i, "del"))
19141 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19143 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19145 else if (unformat (i, "l2-table %d", &l2_table_index))
19149 clib_warning ("parse error '%U'", format_unformat_error, i);
19154 if (sw_if_index_set == 0)
19156 errmsg ("missing interface name or sw_if_index");
19160 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
19162 mp->sw_if_index = ntohl (sw_if_index);
19163 mp->ip4_table_index = ntohl (ip4_table_index);
19164 mp->ip6_table_index = ntohl (ip6_table_index);
19165 mp->l2_table_index = ntohl (l2_table_index);
19166 mp->is_add = is_add;
19174 api_policer_classify_dump (vat_main_t * vam)
19176 unformat_input_t *i = vam->input;
19177 vl_api_policer_classify_dump_t *mp;
19178 vl_api_control_ping_t *mp_ping;
19179 u8 type = POLICER_CLASSIFY_N_TABLES;
19182 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19186 errmsg ("classify table type must be specified");
19190 if (!vam->json_output)
19192 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19195 M (POLICER_CLASSIFY_DUMP, mp);
19200 /* Use a control ping for synchronization */
19201 MPING (CONTROL_PING, mp_ping);
19204 /* Wait for a reply... */
19210 api_netmap_create (vat_main_t * vam)
19212 unformat_input_t *i = vam->input;
19213 vl_api_netmap_create_t *mp;
19216 u8 random_hw_addr = 1;
19221 memset (hw_addr, 0, sizeof (hw_addr));
19223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19225 if (unformat (i, "name %s", &if_name))
19226 vec_add1 (if_name, 0);
19227 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19228 random_hw_addr = 0;
19229 else if (unformat (i, "pipe"))
19231 else if (unformat (i, "master"))
19233 else if (unformat (i, "slave"))
19239 if (!vec_len (if_name))
19241 errmsg ("interface name must be specified");
19245 if (vec_len (if_name) > 64)
19247 errmsg ("interface name too long");
19251 M (NETMAP_CREATE, mp);
19253 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19254 clib_memcpy (mp->hw_addr, hw_addr, 6);
19255 mp->use_random_hw_addr = random_hw_addr;
19256 mp->is_pipe = is_pipe;
19257 mp->is_master = is_master;
19258 vec_free (if_name);
19266 api_netmap_delete (vat_main_t * vam)
19268 unformat_input_t *i = vam->input;
19269 vl_api_netmap_delete_t *mp;
19273 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19275 if (unformat (i, "name %s", &if_name))
19276 vec_add1 (if_name, 0);
19281 if (!vec_len (if_name))
19283 errmsg ("interface name must be specified");
19287 if (vec_len (if_name) > 64)
19289 errmsg ("interface name too long");
19293 M (NETMAP_DELETE, mp);
19295 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19296 vec_free (if_name);
19304 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
19306 if (fp->afi == IP46_TYPE_IP6)
19308 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19309 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19310 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19311 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19312 format_ip6_address, fp->next_hop);
19313 else if (fp->afi == IP46_TYPE_IP4)
19315 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19316 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19317 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19318 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19319 format_ip4_address, fp->next_hop);
19323 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19324 vl_api_fib_path2_t * fp)
19326 struct in_addr ip4;
19327 struct in6_addr ip6;
19329 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19330 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19331 vat_json_object_add_uint (node, "is_local", fp->is_local);
19332 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19333 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19334 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19335 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19336 if (fp->afi == IP46_TYPE_IP4)
19338 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19339 vat_json_object_add_ip4 (node, "next_hop", ip4);
19341 else if (fp->afi == IP46_TYPE_IP6)
19343 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19344 vat_json_object_add_ip6 (node, "next_hop", ip6);
19349 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19351 vat_main_t *vam = &vat_main;
19352 int count = ntohl (mp->mt_count);
19353 vl_api_fib_path2_t *fp;
19356 print (vam->ofp, "[%d]: sw_if_index %d via:",
19357 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19359 for (i = 0; i < count; i++)
19361 vl_api_mpls_fib_path_print (vam, fp);
19365 print (vam->ofp, "");
19368 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19369 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19372 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19374 vat_main_t *vam = &vat_main;
19375 vat_json_node_t *node = NULL;
19376 int count = ntohl (mp->mt_count);
19377 vl_api_fib_path2_t *fp;
19380 if (VAT_JSON_ARRAY != vam->json_tree.type)
19382 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19383 vat_json_init_array (&vam->json_tree);
19385 node = vat_json_array_add (&vam->json_tree);
19387 vat_json_init_object (node);
19388 vat_json_object_add_uint (node, "tunnel_index",
19389 ntohl (mp->mt_tunnel_index));
19390 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19392 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19395 for (i = 0; i < count; i++)
19397 vl_api_mpls_fib_path_json_print (node, fp);
19403 api_mpls_tunnel_dump (vat_main_t * vam)
19405 vl_api_mpls_tunnel_dump_t *mp;
19406 vl_api_control_ping_t *mp_ping;
19410 /* Parse args required to build the message */
19411 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19413 if (!unformat (vam->input, "tunnel_index %d", &index))
19420 print (vam->ofp, " tunnel_index %d", index);
19422 M (MPLS_TUNNEL_DUMP, mp);
19423 mp->tunnel_index = htonl (index);
19426 /* Use a control ping for synchronization */
19427 MPING (CONTROL_PING, mp_ping);
19434 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19435 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19439 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19441 vat_main_t *vam = &vat_main;
19442 int count = ntohl (mp->count);
19443 vl_api_fib_path2_t *fp;
19447 "table-id %d, label %u, ess_bit %u",
19448 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19450 for (i = 0; i < count; i++)
19452 vl_api_mpls_fib_path_print (vam, fp);
19457 static void vl_api_mpls_fib_details_t_handler_json
19458 (vl_api_mpls_fib_details_t * mp)
19460 vat_main_t *vam = &vat_main;
19461 int count = ntohl (mp->count);
19462 vat_json_node_t *node = NULL;
19463 vl_api_fib_path2_t *fp;
19466 if (VAT_JSON_ARRAY != vam->json_tree.type)
19468 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19469 vat_json_init_array (&vam->json_tree);
19471 node = vat_json_array_add (&vam->json_tree);
19473 vat_json_init_object (node);
19474 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19475 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19476 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19477 vat_json_object_add_uint (node, "path_count", count);
19479 for (i = 0; i < count; i++)
19481 vl_api_mpls_fib_path_json_print (node, fp);
19487 api_mpls_fib_dump (vat_main_t * vam)
19489 vl_api_mpls_fib_dump_t *mp;
19490 vl_api_control_ping_t *mp_ping;
19493 M (MPLS_FIB_DUMP, mp);
19496 /* Use a control ping for synchronization */
19497 MPING (CONTROL_PING, mp_ping);
19504 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19505 #define vl_api_ip_fib_details_t_print vl_noop_handler
19508 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19510 vat_main_t *vam = &vat_main;
19511 int count = ntohl (mp->count);
19512 vl_api_fib_path_t *fp;
19516 "table-id %d, prefix %U/%d",
19517 ntohl (mp->table_id), format_ip4_address, mp->address,
19518 mp->address_length);
19520 for (i = 0; i < count; i++)
19522 if (fp->afi == IP46_TYPE_IP6)
19524 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19525 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19526 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19527 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19528 format_ip6_address, fp->next_hop);
19529 else if (fp->afi == IP46_TYPE_IP4)
19531 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19532 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19533 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19534 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19535 format_ip4_address, fp->next_hop);
19540 static void vl_api_ip_fib_details_t_handler_json
19541 (vl_api_ip_fib_details_t * mp)
19543 vat_main_t *vam = &vat_main;
19544 int count = ntohl (mp->count);
19545 vat_json_node_t *node = NULL;
19546 struct in_addr ip4;
19547 struct in6_addr ip6;
19548 vl_api_fib_path_t *fp;
19551 if (VAT_JSON_ARRAY != vam->json_tree.type)
19553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19554 vat_json_init_array (&vam->json_tree);
19556 node = vat_json_array_add (&vam->json_tree);
19558 vat_json_init_object (node);
19559 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19560 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19561 vat_json_object_add_ip4 (node, "prefix", ip4);
19562 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19563 vat_json_object_add_uint (node, "path_count", count);
19565 for (i = 0; i < count; i++)
19567 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19568 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19569 vat_json_object_add_uint (node, "is_local", fp->is_local);
19570 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19571 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19572 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19573 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19574 if (fp->afi == IP46_TYPE_IP4)
19576 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19577 vat_json_object_add_ip4 (node, "next_hop", ip4);
19579 else if (fp->afi == IP46_TYPE_IP6)
19581 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19582 vat_json_object_add_ip6 (node, "next_hop", ip6);
19588 api_ip_fib_dump (vat_main_t * vam)
19590 vl_api_ip_fib_dump_t *mp;
19591 vl_api_control_ping_t *mp_ping;
19594 M (IP_FIB_DUMP, mp);
19597 /* Use a control ping for synchronization */
19598 MPING (CONTROL_PING, mp_ping);
19606 api_ip_mfib_dump (vat_main_t * vam)
19608 vl_api_ip_mfib_dump_t *mp;
19609 vl_api_control_ping_t *mp_ping;
19612 M (IP_MFIB_DUMP, mp);
19615 /* Use a control ping for synchronization */
19616 MPING (CONTROL_PING, mp_ping);
19623 static void vl_api_ip_neighbor_details_t_handler
19624 (vl_api_ip_neighbor_details_t * mp)
19626 vat_main_t *vam = &vat_main;
19628 print (vam->ofp, "%c %U %U",
19629 (mp->is_static) ? 'S' : 'D',
19630 format_ethernet_address, &mp->mac_address,
19631 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19635 static void vl_api_ip_neighbor_details_t_handler_json
19636 (vl_api_ip_neighbor_details_t * mp)
19639 vat_main_t *vam = &vat_main;
19640 vat_json_node_t *node;
19641 struct in_addr ip4;
19642 struct in6_addr ip6;
19644 if (VAT_JSON_ARRAY != vam->json_tree.type)
19646 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19647 vat_json_init_array (&vam->json_tree);
19649 node = vat_json_array_add (&vam->json_tree);
19651 vat_json_init_object (node);
19652 vat_json_object_add_string_copy (node, "flag",
19653 (mp->is_static) ? (u8 *) "static" : (u8 *)
19656 vat_json_object_add_string_copy (node, "link_layer",
19657 format (0, "%U", format_ethernet_address,
19658 &mp->mac_address));
19662 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19663 vat_json_object_add_ip6 (node, "ip_address", ip6);
19667 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19668 vat_json_object_add_ip4 (node, "ip_address", ip4);
19673 api_ip_neighbor_dump (vat_main_t * vam)
19675 unformat_input_t *i = vam->input;
19676 vl_api_ip_neighbor_dump_t *mp;
19677 vl_api_control_ping_t *mp_ping;
19679 u32 sw_if_index = ~0;
19682 /* Parse args required to build the message */
19683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19685 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19687 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19689 else if (unformat (i, "ip6"))
19695 if (sw_if_index == ~0)
19697 errmsg ("missing interface name or sw_if_index");
19701 M (IP_NEIGHBOR_DUMP, mp);
19702 mp->is_ipv6 = (u8) is_ipv6;
19703 mp->sw_if_index = ntohl (sw_if_index);
19706 /* Use a control ping for synchronization */
19707 MPING (CONTROL_PING, mp_ping);
19714 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19715 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19718 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19720 vat_main_t *vam = &vat_main;
19721 int count = ntohl (mp->count);
19722 vl_api_fib_path_t *fp;
19726 "table-id %d, prefix %U/%d",
19727 ntohl (mp->table_id), format_ip6_address, mp->address,
19728 mp->address_length);
19730 for (i = 0; i < count; i++)
19732 if (fp->afi == IP46_TYPE_IP6)
19734 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19735 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19736 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19737 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19738 format_ip6_address, fp->next_hop);
19739 else if (fp->afi == IP46_TYPE_IP4)
19741 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19742 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19743 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19744 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19745 format_ip4_address, fp->next_hop);
19750 static void vl_api_ip6_fib_details_t_handler_json
19751 (vl_api_ip6_fib_details_t * mp)
19753 vat_main_t *vam = &vat_main;
19754 int count = ntohl (mp->count);
19755 vat_json_node_t *node = NULL;
19756 struct in_addr ip4;
19757 struct in6_addr ip6;
19758 vl_api_fib_path_t *fp;
19761 if (VAT_JSON_ARRAY != vam->json_tree.type)
19763 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19764 vat_json_init_array (&vam->json_tree);
19766 node = vat_json_array_add (&vam->json_tree);
19768 vat_json_init_object (node);
19769 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19770 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19771 vat_json_object_add_ip6 (node, "prefix", ip6);
19772 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19773 vat_json_object_add_uint (node, "path_count", count);
19775 for (i = 0; i < count; i++)
19777 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19778 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19779 vat_json_object_add_uint (node, "is_local", fp->is_local);
19780 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19781 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19782 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19783 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19784 if (fp->afi == IP46_TYPE_IP4)
19786 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19787 vat_json_object_add_ip4 (node, "next_hop", ip4);
19789 else if (fp->afi == IP46_TYPE_IP6)
19791 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19792 vat_json_object_add_ip6 (node, "next_hop", ip6);
19798 api_ip6_fib_dump (vat_main_t * vam)
19800 vl_api_ip6_fib_dump_t *mp;
19801 vl_api_control_ping_t *mp_ping;
19804 M (IP6_FIB_DUMP, mp);
19807 /* Use a control ping for synchronization */
19808 MPING (CONTROL_PING, mp_ping);
19816 api_ip6_mfib_dump (vat_main_t * vam)
19818 vl_api_ip6_mfib_dump_t *mp;
19819 vl_api_control_ping_t *mp_ping;
19822 M (IP6_MFIB_DUMP, mp);
19825 /* Use a control ping for synchronization */
19826 MPING (CONTROL_PING, mp_ping);
19834 api_classify_table_ids (vat_main_t * vam)
19836 vl_api_classify_table_ids_t *mp;
19839 /* Construct the API message */
19840 M (CLASSIFY_TABLE_IDS, mp);
19849 api_classify_table_by_interface (vat_main_t * vam)
19851 unformat_input_t *input = vam->input;
19852 vl_api_classify_table_by_interface_t *mp;
19854 u32 sw_if_index = ~0;
19856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19858 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19860 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19865 if (sw_if_index == ~0)
19867 errmsg ("missing interface name or sw_if_index");
19871 /* Construct the API message */
19872 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19874 mp->sw_if_index = ntohl (sw_if_index);
19882 api_classify_table_info (vat_main_t * vam)
19884 unformat_input_t *input = vam->input;
19885 vl_api_classify_table_info_t *mp;
19889 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19891 if (unformat (input, "table_id %d", &table_id))
19896 if (table_id == ~0)
19898 errmsg ("missing table id");
19902 /* Construct the API message */
19903 M (CLASSIFY_TABLE_INFO, mp);
19905 mp->table_id = ntohl (table_id);
19913 api_classify_session_dump (vat_main_t * vam)
19915 unformat_input_t *input = vam->input;
19916 vl_api_classify_session_dump_t *mp;
19917 vl_api_control_ping_t *mp_ping;
19921 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19923 if (unformat (input, "table_id %d", &table_id))
19928 if (table_id == ~0)
19930 errmsg ("missing table id");
19934 /* Construct the API message */
19935 M (CLASSIFY_SESSION_DUMP, mp);
19937 mp->table_id = ntohl (table_id);
19940 /* Use a control ping for synchronization */
19941 MPING (CONTROL_PING, mp_ping);
19949 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19951 vat_main_t *vam = &vat_main;
19953 print (vam->ofp, "collector_address %U, collector_port %d, "
19954 "src_address %U, vrf_id %d, path_mtu %u, "
19955 "template_interval %u, udp_checksum %d",
19956 format_ip4_address, mp->collector_address,
19957 ntohs (mp->collector_port),
19958 format_ip4_address, mp->src_address,
19959 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19960 ntohl (mp->template_interval), mp->udp_checksum);
19963 vam->result_ready = 1;
19967 vl_api_ipfix_exporter_details_t_handler_json
19968 (vl_api_ipfix_exporter_details_t * mp)
19970 vat_main_t *vam = &vat_main;
19971 vat_json_node_t node;
19972 struct in_addr collector_address;
19973 struct in_addr src_address;
19975 vat_json_init_object (&node);
19976 clib_memcpy (&collector_address, &mp->collector_address,
19977 sizeof (collector_address));
19978 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19979 vat_json_object_add_uint (&node, "collector_port",
19980 ntohs (mp->collector_port));
19981 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19982 vat_json_object_add_ip4 (&node, "src_address", src_address);
19983 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19984 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19985 vat_json_object_add_uint (&node, "template_interval",
19986 ntohl (mp->template_interval));
19987 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19989 vat_json_print (vam->ofp, &node);
19990 vat_json_free (&node);
19992 vam->result_ready = 1;
19996 api_ipfix_exporter_dump (vat_main_t * vam)
19998 vl_api_ipfix_exporter_dump_t *mp;
20001 /* Construct the API message */
20002 M (IPFIX_EXPORTER_DUMP, mp);
20011 api_ipfix_classify_stream_dump (vat_main_t * vam)
20013 vl_api_ipfix_classify_stream_dump_t *mp;
20016 /* Construct the API message */
20017 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
20028 vl_api_ipfix_classify_stream_details_t_handler
20029 (vl_api_ipfix_classify_stream_details_t * mp)
20031 vat_main_t *vam = &vat_main;
20032 print (vam->ofp, "domain_id %d, src_port %d",
20033 ntohl (mp->domain_id), ntohs (mp->src_port));
20035 vam->result_ready = 1;
20039 vl_api_ipfix_classify_stream_details_t_handler_json
20040 (vl_api_ipfix_classify_stream_details_t * mp)
20042 vat_main_t *vam = &vat_main;
20043 vat_json_node_t node;
20045 vat_json_init_object (&node);
20046 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
20047 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
20049 vat_json_print (vam->ofp, &node);
20050 vat_json_free (&node);
20052 vam->result_ready = 1;
20056 api_ipfix_classify_table_dump (vat_main_t * vam)
20058 vl_api_ipfix_classify_table_dump_t *mp;
20059 vl_api_control_ping_t *mp_ping;
20062 if (!vam->json_output)
20064 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
20065 "transport_protocol");
20068 /* Construct the API message */
20069 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
20074 /* Use a control ping for synchronization */
20075 MPING (CONTROL_PING, mp_ping);
20083 vl_api_ipfix_classify_table_details_t_handler
20084 (vl_api_ipfix_classify_table_details_t * mp)
20086 vat_main_t *vam = &vat_main;
20087 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
20088 mp->transport_protocol);
20092 vl_api_ipfix_classify_table_details_t_handler_json
20093 (vl_api_ipfix_classify_table_details_t * mp)
20095 vat_json_node_t *node = NULL;
20096 vat_main_t *vam = &vat_main;
20098 if (VAT_JSON_ARRAY != vam->json_tree.type)
20100 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20101 vat_json_init_array (&vam->json_tree);
20104 node = vat_json_array_add (&vam->json_tree);
20105 vat_json_init_object (node);
20107 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
20108 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
20109 vat_json_object_add_uint (node, "transport_protocol",
20110 mp->transport_protocol);
20114 api_sw_interface_span_enable_disable (vat_main_t * vam)
20116 unformat_input_t *i = vam->input;
20117 vl_api_sw_interface_span_enable_disable_t *mp;
20118 u32 src_sw_if_index = ~0;
20119 u32 dst_sw_if_index = ~0;
20124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20127 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
20129 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
20133 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
20135 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
20137 else if (unformat (i, "disable"))
20139 else if (unformat (i, "rx"))
20141 else if (unformat (i, "tx"))
20143 else if (unformat (i, "both"))
20145 else if (unformat (i, "l2"))
20151 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
20153 mp->sw_if_index_from = htonl (src_sw_if_index);
20154 mp->sw_if_index_to = htonl (dst_sw_if_index);
20164 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
20167 vat_main_t *vam = &vat_main;
20168 u8 *sw_if_from_name = 0;
20169 u8 *sw_if_to_name = 0;
20170 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20171 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20172 char *states[] = { "none", "rx", "tx", "both" };
20176 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20178 if ((u32) p->value[0] == sw_if_index_from)
20180 sw_if_from_name = (u8 *)(p->key);
20184 if ((u32) p->value[0] == sw_if_index_to)
20186 sw_if_to_name = (u8 *)(p->key);
20187 if (sw_if_from_name)
20192 print (vam->ofp, "%20s => %20s (%s)",
20193 sw_if_from_name, sw_if_to_name, states[mp->state]);
20197 vl_api_sw_interface_span_details_t_handler_json
20198 (vl_api_sw_interface_span_details_t * mp)
20200 vat_main_t *vam = &vat_main;
20201 vat_json_node_t *node = NULL;
20202 u8 *sw_if_from_name = 0;
20203 u8 *sw_if_to_name = 0;
20204 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20205 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20209 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20211 if ((u32) p->value[0] == sw_if_index_from)
20213 sw_if_from_name = (u8 *)(p->key);
20217 if ((u32) p->value[0] == sw_if_index_to)
20219 sw_if_to_name = (u8 *)(p->key);
20220 if (sw_if_from_name)
20226 if (VAT_JSON_ARRAY != vam->json_tree.type)
20228 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20229 vat_json_init_array (&vam->json_tree);
20231 node = vat_json_array_add (&vam->json_tree);
20233 vat_json_init_object (node);
20234 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20235 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20236 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20237 if (0 != sw_if_to_name)
20239 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20241 vat_json_object_add_uint (node, "state", mp->state);
20245 api_sw_interface_span_dump (vat_main_t * vam)
20247 unformat_input_t *input = vam->input;
20248 vl_api_sw_interface_span_dump_t *mp;
20249 vl_api_control_ping_t *mp_ping;
20253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20255 if (unformat (input, "l2"))
20261 M (SW_INTERFACE_SPAN_DUMP, mp);
20265 /* Use a control ping for synchronization */
20266 MPING (CONTROL_PING, mp_ping);
20274 api_pg_create_interface (vat_main_t * vam)
20276 unformat_input_t *input = vam->input;
20277 vl_api_pg_create_interface_t *mp;
20281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20283 if (unformat (input, "if_id %d", &if_id))
20290 errmsg ("missing pg interface index");
20294 /* Construct the API message */
20295 M (PG_CREATE_INTERFACE, mp);
20297 mp->interface_id = ntohl (if_id);
20305 api_pg_capture (vat_main_t * vam)
20307 unformat_input_t *input = vam->input;
20308 vl_api_pg_capture_t *mp;
20313 u8 pcap_file_set = 0;
20316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20318 if (unformat (input, "if_id %d", &if_id))
20320 else if (unformat (input, "pcap %s", &pcap_file))
20322 else if (unformat (input, "count %d", &count))
20324 else if (unformat (input, "disable"))
20331 errmsg ("missing pg interface index");
20334 if (pcap_file_set > 0)
20336 if (vec_len (pcap_file) > 255)
20338 errmsg ("pcap file name is too long");
20343 u32 name_len = vec_len (pcap_file);
20344 /* Construct the API message */
20345 M (PG_CAPTURE, mp);
20347 mp->interface_id = ntohl (if_id);
20348 mp->is_enabled = enable;
20349 mp->count = ntohl (count);
20350 mp->pcap_name_length = ntohl (name_len);
20351 if (pcap_file_set != 0)
20353 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20355 vec_free (pcap_file);
20363 api_pg_enable_disable (vat_main_t * vam)
20365 unformat_input_t *input = vam->input;
20366 vl_api_pg_enable_disable_t *mp;
20369 u8 stream_name_set = 0;
20370 u8 *stream_name = 0;
20372 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20374 if (unformat (input, "stream %s", &stream_name))
20375 stream_name_set = 1;
20376 else if (unformat (input, "disable"))
20382 if (stream_name_set > 0)
20384 if (vec_len (stream_name) > 255)
20386 errmsg ("stream name too long");
20391 u32 name_len = vec_len (stream_name);
20392 /* Construct the API message */
20393 M (PG_ENABLE_DISABLE, mp);
20395 mp->is_enabled = enable;
20396 if (stream_name_set != 0)
20398 mp->stream_name_length = ntohl (name_len);
20399 clib_memcpy (mp->stream_name, stream_name, name_len);
20401 vec_free (stream_name);
20409 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20411 unformat_input_t *input = vam->input;
20412 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20414 u16 *low_ports = 0;
20415 u16 *high_ports = 0;
20418 ip4_address_t ip4_addr;
20419 ip6_address_t ip6_addr;
20428 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20430 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
20436 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
20441 else if (unformat (input, "vrf %d", &vrf_id))
20443 else if (unformat (input, "del"))
20445 else if (unformat (input, "port %d", &tmp))
20447 if (tmp == 0 || tmp > 65535)
20449 errmsg ("port %d out of range", tmp);
20453 this_hi = this_low + 1;
20454 vec_add1 (low_ports, this_low);
20455 vec_add1 (high_ports, this_hi);
20457 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20459 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20461 errmsg ("incorrect range parameters");
20465 /* Note: in debug CLI +1 is added to high before
20466 passing to real fn that does "the work"
20467 (ip_source_and_port_range_check_add_del).
20468 This fn is a wrapper around the binary API fn a
20469 control plane will call, which expects this increment
20470 to have occurred. Hence letting the binary API control
20471 plane fn do the increment for consistency between VAT
20472 and other control planes.
20475 vec_add1 (low_ports, this_low);
20476 vec_add1 (high_ports, this_hi);
20482 if (prefix_set == 0)
20484 errmsg ("<address>/<mask> not specified");
20490 errmsg ("VRF ID required, not specified");
20497 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20501 if (vec_len (low_ports) == 0)
20503 errmsg ("At least one port or port range required");
20507 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20509 mp->is_add = is_add;
20514 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
20519 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
20522 mp->mask_length = length;
20523 mp->number_of_ranges = vec_len (low_ports);
20525 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20526 vec_free (low_ports);
20528 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20529 vec_free (high_ports);
20531 mp->vrf_id = ntohl (vrf_id);
20539 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20541 unformat_input_t *input = vam->input;
20542 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20543 u32 sw_if_index = ~0;
20545 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20546 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20552 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20554 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20556 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20558 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20560 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20562 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20564 else if (unformat (input, "del"))
20570 if (sw_if_index == ~0)
20572 errmsg ("Interface required but not specified");
20578 errmsg ("VRF ID required but not specified");
20582 if (tcp_out_vrf_id == 0
20583 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20586 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20590 /* Construct the API message */
20591 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20593 mp->sw_if_index = ntohl (sw_if_index);
20594 mp->is_add = is_add;
20595 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20596 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20597 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20598 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20603 /* Wait for a reply... */
20609 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20611 unformat_input_t *i = vam->input;
20612 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20613 u32 local_sa_id = 0;
20614 u32 remote_sa_id = 0;
20615 ip4_address_t src_address;
20616 ip4_address_t dst_address;
20620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20622 if (unformat (i, "local_sa %d", &local_sa_id))
20624 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20626 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20628 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20630 else if (unformat (i, "del"))
20634 clib_warning ("parse error '%U'", format_unformat_error, i);
20639 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20641 mp->local_sa_id = ntohl (local_sa_id);
20642 mp->remote_sa_id = ntohl (remote_sa_id);
20643 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20644 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20645 mp->is_add = is_add;
20653 api_punt (vat_main_t * vam)
20655 unformat_input_t *i = vam->input;
20663 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20665 if (unformat (i, "ip %d", &ipv))
20667 else if (unformat (i, "protocol %d", &protocol))
20669 else if (unformat (i, "port %d", &port))
20671 else if (unformat (i, "del"))
20675 clib_warning ("parse error '%U'", format_unformat_error, i);
20682 mp->is_add = (u8) is_add;
20683 mp->ipv = (u8) ipv;
20684 mp->l4_protocol = (u8) protocol;
20685 mp->l4_port = htons ((u16) port);
20692 static void vl_api_ipsec_gre_tunnel_details_t_handler
20693 (vl_api_ipsec_gre_tunnel_details_t * mp)
20695 vat_main_t *vam = &vat_main;
20697 print (vam->ofp, "%11d%15U%15U%14d%14d",
20698 ntohl (mp->sw_if_index),
20699 format_ip4_address, &mp->src_address,
20700 format_ip4_address, &mp->dst_address,
20701 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20704 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20705 (vl_api_ipsec_gre_tunnel_details_t * mp)
20707 vat_main_t *vam = &vat_main;
20708 vat_json_node_t *node = NULL;
20709 struct in_addr ip4;
20711 if (VAT_JSON_ARRAY != vam->json_tree.type)
20713 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20714 vat_json_init_array (&vam->json_tree);
20716 node = vat_json_array_add (&vam->json_tree);
20718 vat_json_init_object (node);
20719 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20720 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20721 vat_json_object_add_ip4 (node, "src_address", ip4);
20722 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20723 vat_json_object_add_ip4 (node, "dst_address", ip4);
20724 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20725 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20729 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20731 unformat_input_t *i = vam->input;
20732 vl_api_ipsec_gre_tunnel_dump_t *mp;
20733 vl_api_control_ping_t *mp_ping;
20735 u8 sw_if_index_set = 0;
20738 /* Parse args required to build the message */
20739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20741 if (unformat (i, "sw_if_index %d", &sw_if_index))
20742 sw_if_index_set = 1;
20747 if (sw_if_index_set == 0)
20752 if (!vam->json_output)
20754 print (vam->ofp, "%11s%15s%15s%14s%14s",
20755 "sw_if_index", "src_address", "dst_address",
20756 "local_sa_id", "remote_sa_id");
20759 /* Get list of gre-tunnel interfaces */
20760 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20762 mp->sw_if_index = htonl (sw_if_index);
20766 /* Use a control ping for synchronization */
20767 MPING (CONTROL_PING, mp_ping);
20775 api_delete_subif (vat_main_t * vam)
20777 unformat_input_t *i = vam->input;
20778 vl_api_delete_subif_t *mp;
20779 u32 sw_if_index = ~0;
20782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20784 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20786 if (unformat (i, "sw_if_index %d", &sw_if_index))
20792 if (sw_if_index == ~0)
20794 errmsg ("missing sw_if_index");
20798 /* Construct the API message */
20799 M (DELETE_SUBIF, mp);
20800 mp->sw_if_index = ntohl (sw_if_index);
20807 #define foreach_pbb_vtr_op \
20808 _("disable", L2_VTR_DISABLED) \
20809 _("pop", L2_VTR_POP_2) \
20810 _("push", L2_VTR_PUSH_2)
20813 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20815 unformat_input_t *i = vam->input;
20816 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20817 u32 sw_if_index = ~0, vtr_op = ~0;
20818 u16 outer_tag = ~0;
20819 u8 dmac[6], smac[6];
20820 u8 dmac_set = 0, smac_set = 0;
20826 /* Shut up coverity */
20827 memset (dmac, 0, sizeof (dmac));
20828 memset (smac, 0, sizeof (smac));
20830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20836 else if (unformat (i, "vtr_op %d", &vtr_op))
20838 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20841 else if (unformat (i, "translate_pbb_stag"))
20843 if (unformat (i, "%d", &tmp))
20845 vtr_op = L2_VTR_TRANSLATE_2_1;
20851 ("translate_pbb_stag operation requires outer tag definition");
20855 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20857 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20859 else if (unformat (i, "sid %d", &sid))
20861 else if (unformat (i, "vlanid %d", &tmp))
20865 clib_warning ("parse error '%U'", format_unformat_error, i);
20870 if ((sw_if_index == ~0) || (vtr_op == ~0))
20872 errmsg ("missing sw_if_index or vtr operation");
20875 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20876 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20879 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20883 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20884 mp->sw_if_index = ntohl (sw_if_index);
20885 mp->vtr_op = ntohl (vtr_op);
20886 mp->outer_tag = ntohs (outer_tag);
20887 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20888 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20889 mp->b_vlanid = ntohs (vlanid);
20890 mp->i_sid = ntohl (sid);
20898 api_flow_classify_set_interface (vat_main_t * vam)
20900 unformat_input_t *i = vam->input;
20901 vl_api_flow_classify_set_interface_t *mp;
20903 int sw_if_index_set;
20904 u32 ip4_table_index = ~0;
20905 u32 ip6_table_index = ~0;
20909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20912 sw_if_index_set = 1;
20913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20914 sw_if_index_set = 1;
20915 else if (unformat (i, "del"))
20917 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20919 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20923 clib_warning ("parse error '%U'", format_unformat_error, i);
20928 if (sw_if_index_set == 0)
20930 errmsg ("missing interface name or sw_if_index");
20934 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20936 mp->sw_if_index = ntohl (sw_if_index);
20937 mp->ip4_table_index = ntohl (ip4_table_index);
20938 mp->ip6_table_index = ntohl (ip6_table_index);
20939 mp->is_add = is_add;
20947 api_flow_classify_dump (vat_main_t * vam)
20949 unformat_input_t *i = vam->input;
20950 vl_api_flow_classify_dump_t *mp;
20951 vl_api_control_ping_t *mp_ping;
20952 u8 type = FLOW_CLASSIFY_N_TABLES;
20955 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20959 errmsg ("classify table type must be specified");
20963 if (!vam->json_output)
20965 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20968 M (FLOW_CLASSIFY_DUMP, mp);
20973 /* Use a control ping for synchronization */
20974 MPING (CONTROL_PING, mp_ping);
20977 /* Wait for a reply... */
20983 api_feature_enable_disable (vat_main_t * vam)
20985 unformat_input_t *i = vam->input;
20986 vl_api_feature_enable_disable_t *mp;
20988 u8 *feature_name = 0;
20989 u32 sw_if_index = ~0;
20993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20995 if (unformat (i, "arc_name %s", &arc_name))
20997 else if (unformat (i, "feature_name %s", &feature_name))
21000 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21002 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21004 else if (unformat (i, "disable"))
21012 errmsg ("missing arc name");
21015 if (vec_len (arc_name) > 63)
21017 errmsg ("arc name too long");
21020 if (feature_name == 0)
21022 errmsg ("missing feature name");
21025 if (vec_len (feature_name) > 63)
21027 errmsg ("feature name too long");
21030 if (sw_if_index == ~0)
21032 errmsg ("missing interface name or sw_if_index");
21036 /* Construct the API message */
21037 M (FEATURE_ENABLE_DISABLE, mp);
21038 mp->sw_if_index = ntohl (sw_if_index);
21039 mp->enable = enable;
21040 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
21041 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
21042 vec_free (arc_name);
21043 vec_free (feature_name);
21051 api_sw_interface_tag_add_del (vat_main_t * vam)
21053 unformat_input_t *i = vam->input;
21054 vl_api_sw_interface_tag_add_del_t *mp;
21055 u32 sw_if_index = ~0;
21060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21062 if (unformat (i, "tag %s", &tag))
21064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21068 else if (unformat (i, "del"))
21074 if (sw_if_index == ~0)
21076 errmsg ("missing interface name or sw_if_index");
21080 if (enable && (tag == 0))
21082 errmsg ("no tag specified");
21086 /* Construct the API message */
21087 M (SW_INTERFACE_TAG_ADD_DEL, mp);
21088 mp->sw_if_index = ntohl (sw_if_index);
21089 mp->is_add = enable;
21091 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
21099 static void vl_api_l2_xconnect_details_t_handler
21100 (vl_api_l2_xconnect_details_t * mp)
21102 vat_main_t *vam = &vat_main;
21104 print (vam->ofp, "%15d%15d",
21105 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
21108 static void vl_api_l2_xconnect_details_t_handler_json
21109 (vl_api_l2_xconnect_details_t * mp)
21111 vat_main_t *vam = &vat_main;
21112 vat_json_node_t *node = NULL;
21114 if (VAT_JSON_ARRAY != vam->json_tree.type)
21116 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21117 vat_json_init_array (&vam->json_tree);
21119 node = vat_json_array_add (&vam->json_tree);
21121 vat_json_init_object (node);
21122 vat_json_object_add_uint (node, "rx_sw_if_index",
21123 ntohl (mp->rx_sw_if_index));
21124 vat_json_object_add_uint (node, "tx_sw_if_index",
21125 ntohl (mp->tx_sw_if_index));
21129 api_l2_xconnect_dump (vat_main_t * vam)
21131 vl_api_l2_xconnect_dump_t *mp;
21132 vl_api_control_ping_t *mp_ping;
21135 if (!vam->json_output)
21137 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
21140 M (L2_XCONNECT_DUMP, mp);
21144 /* Use a control ping for synchronization */
21145 MPING (CONTROL_PING, mp_ping);
21153 api_sw_interface_set_mtu (vat_main_t * vam)
21155 unformat_input_t *i = vam->input;
21156 vl_api_sw_interface_set_mtu_t *mp;
21157 u32 sw_if_index = ~0;
21161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21163 if (unformat (i, "mtu %d", &mtu))
21165 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21167 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21173 if (sw_if_index == ~0)
21175 errmsg ("missing interface name or sw_if_index");
21181 errmsg ("no mtu specified");
21185 /* Construct the API message */
21186 M (SW_INTERFACE_SET_MTU, mp);
21187 mp->sw_if_index = ntohl (sw_if_index);
21188 mp->mtu = ntohs ((u16) mtu);
21196 api_p2p_ethernet_add (vat_main_t * vam)
21198 unformat_input_t *i = vam->input;
21199 vl_api_p2p_ethernet_add_t *mp;
21200 u32 parent_if_index = ~0;
21206 memset (remote_mac, 0, sizeof (remote_mac));
21207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21211 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21215 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21217 else if (unformat (i, "sub_id %d", &sub_id))
21221 clib_warning ("parse error '%U'", format_unformat_error, i);
21226 if (parent_if_index == ~0)
21228 errmsg ("missing interface name or sw_if_index");
21233 errmsg ("missing remote mac address");
21238 errmsg ("missing sub-interface id");
21242 M (P2P_ETHERNET_ADD, mp);
21243 mp->parent_if_index = ntohl (parent_if_index);
21244 mp->subif_id = ntohl (sub_id);
21245 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21253 api_p2p_ethernet_del (vat_main_t * vam)
21255 unformat_input_t *i = vam->input;
21256 vl_api_p2p_ethernet_del_t *mp;
21257 u32 parent_if_index = ~0;
21262 memset (remote_mac, 0, sizeof (remote_mac));
21263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21267 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21271 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21275 clib_warning ("parse error '%U'", format_unformat_error, i);
21280 if (parent_if_index == ~0)
21282 errmsg ("missing interface name or sw_if_index");
21287 errmsg ("missing remote mac address");
21291 M (P2P_ETHERNET_DEL, mp);
21292 mp->parent_if_index = ntohl (parent_if_index);
21293 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21301 api_lldp_config (vat_main_t * vam)
21303 unformat_input_t *i = vam->input;
21304 vl_api_lldp_config_t *mp;
21306 int tx_interval = 0;
21307 u8 *sys_name = NULL;
21310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21312 if (unformat (i, "system-name %s", &sys_name))
21314 else if (unformat (i, "tx-hold %d", &tx_hold))
21316 else if (unformat (i, "tx-interval %d", &tx_interval))
21320 clib_warning ("parse error '%U'", format_unformat_error, i);
21325 vec_add1 (sys_name, 0);
21327 M (LLDP_CONFIG, mp);
21328 mp->tx_hold = htonl (tx_hold);
21329 mp->tx_interval = htonl (tx_interval);
21330 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21331 vec_free (sys_name);
21339 api_sw_interface_set_lldp (vat_main_t * vam)
21341 unformat_input_t *i = vam->input;
21342 vl_api_sw_interface_set_lldp_t *mp;
21343 u32 sw_if_index = ~0;
21345 u8 *port_desc = NULL, *mgmt_oid = NULL;
21346 ip4_address_t ip4_addr;
21347 ip6_address_t ip6_addr;
21350 memset (&ip4_addr, 0, sizeof (ip4_addr));
21351 memset (&ip6_addr, 0, sizeof (ip6_addr));
21353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21355 if (unformat (i, "disable"))
21358 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21360 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21362 else if (unformat (i, "port-desc %s", &port_desc))
21364 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21366 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21368 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21374 if (sw_if_index == ~0)
21376 errmsg ("missing interface name or sw_if_index");
21380 /* Construct the API message */
21381 vec_add1 (port_desc, 0);
21382 vec_add1 (mgmt_oid, 0);
21383 M (SW_INTERFACE_SET_LLDP, mp);
21384 mp->sw_if_index = ntohl (sw_if_index);
21385 mp->enable = enable;
21386 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21387 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21388 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21389 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21390 vec_free (port_desc);
21391 vec_free (mgmt_oid);
21399 api_tcp_configure_src_addresses (vat_main_t * vam)
21401 vl_api_tcp_configure_src_addresses_t *mp;
21402 unformat_input_t *i = vam->input;
21403 ip4_address_t v4first, v4last;
21404 ip6_address_t v6first, v6last;
21409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21411 if (unformat (i, "%U - %U",
21412 unformat_ip4_address, &v4first,
21413 unformat_ip4_address, &v4last))
21417 errmsg ("one range per message (range already set)");
21422 else if (unformat (i, "%U - %U",
21423 unformat_ip6_address, &v6first,
21424 unformat_ip6_address, &v6last))
21428 errmsg ("one range per message (range already set)");
21433 else if (unformat (i, "vrf %d", &vrf_id))
21439 if (range_set == 0)
21441 errmsg ("address range not set");
21445 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21446 mp->vrf_id = ntohl (vrf_id);
21448 if (range_set == 2)
21451 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21452 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21457 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21458 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21465 static void vl_api_app_namespace_add_del_reply_t_handler
21466 (vl_api_app_namespace_add_del_reply_t * mp)
21468 vat_main_t *vam = &vat_main;
21469 i32 retval = ntohl (mp->retval);
21470 if (vam->async_mode)
21472 vam->async_errors += (retval < 0);
21476 vam->retval = retval;
21478 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21479 vam->result_ready = 1;
21483 static void vl_api_app_namespace_add_del_reply_t_handler_json
21484 (vl_api_app_namespace_add_del_reply_t * mp)
21486 vat_main_t *vam = &vat_main;
21487 vat_json_node_t node;
21489 vat_json_init_object (&node);
21490 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21491 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21493 vat_json_print (vam->ofp, &node);
21494 vat_json_free (&node);
21496 vam->retval = ntohl (mp->retval);
21497 vam->result_ready = 1;
21501 api_app_namespace_add_del (vat_main_t * vam)
21503 vl_api_app_namespace_add_del_t *mp;
21504 unformat_input_t *i = vam->input;
21505 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21506 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21512 if (unformat (i, "id %_%v%_", &ns_id))
21514 else if (unformat (i, "secret %lu", &secret))
21516 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21517 sw_if_index_set = 1;
21518 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21520 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21525 if (!ns_id || !secret_set || !sw_if_index_set)
21527 errmsg ("namespace id, secret and sw_if_index must be set");
21530 if (vec_len (ns_id) > 64)
21532 errmsg ("namespace id too long");
21535 M (APP_NAMESPACE_ADD_DEL, mp);
21537 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21538 mp->namespace_id_len = vec_len (ns_id);
21539 mp->secret = clib_host_to_net_u64 (secret);
21540 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21541 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21542 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21550 api_memfd_segment_create (vat_main_t * vam)
21552 #if VPP_API_TEST_BUILTIN == 0
21553 unformat_input_t *i = vam->input;
21554 vl_api_memfd_segment_create_t *mp;
21555 u64 size = 64 << 20;
21558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21560 if (unformat (i, "size %U", unformat_memory_size, &size))
21566 M (MEMFD_SEGMENT_CREATE, mp);
21567 mp->requested_size = size;
21573 errmsg ("memfd_segment_create (builtin) not supported");
21579 api_dns_enable_disable (vat_main_t * vam)
21581 unformat_input_t *line_input = vam->input;
21582 vl_api_dns_enable_disable_t *mp;
21583 u8 enable_disable = 1;
21586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21588 if (unformat (line_input, "disable"))
21589 enable_disable = 0;
21590 if (unformat (line_input, "enable"))
21591 enable_disable = 1;
21596 /* Construct the API message */
21597 M (DNS_ENABLE_DISABLE, mp);
21598 mp->enable = enable_disable;
21602 /* Wait for the reply */
21608 api_dns_resolve_name (vat_main_t * vam)
21610 unformat_input_t *line_input = vam->input;
21611 vl_api_dns_resolve_name_t *mp;
21615 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21617 if (unformat (line_input, "%s", &name))
21623 if (vec_len (name) > 127)
21625 errmsg ("name too long");
21629 /* Construct the API message */
21630 M (DNS_RESOLVE_NAME, mp);
21631 memcpy (mp->name, name, vec_len (name));
21636 /* Wait for the reply */
21642 api_dns_resolve_ip (vat_main_t * vam)
21644 unformat_input_t *line_input = vam->input;
21645 vl_api_dns_resolve_ip_t *mp;
21647 ip4_address_t addr4;
21648 ip6_address_t addr6;
21651 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21653 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21655 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21663 errmsg ("missing address");
21667 /* Construct the API message */
21668 M (DNS_RESOLVE_IP, mp);
21669 mp->is_ip6 = is_ip6;
21671 memcpy (mp->address, &addr6, sizeof (addr6));
21673 memcpy (mp->address, &addr4, sizeof (addr4));
21677 /* Wait for the reply */
21683 api_dns_name_server_add_del (vat_main_t * vam)
21685 unformat_input_t *i = vam->input;
21686 vl_api_dns_name_server_add_del_t *mp;
21688 ip6_address_t ip6_server;
21689 ip4_address_t ip4_server;
21694 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21696 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21698 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21700 else if (unformat (i, "del"))
21704 clib_warning ("parse error '%U'", format_unformat_error, i);
21709 if (ip4_set && ip6_set)
21711 errmsg ("Only one server address allowed per message");
21714 if ((ip4_set + ip6_set) == 0)
21716 errmsg ("Server address required");
21720 /* Construct the API message */
21721 M (DNS_NAME_SERVER_ADD_DEL, mp);
21725 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21730 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21734 mp->is_add = is_add;
21739 /* Wait for a reply, return good/bad news */
21745 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21747 vat_main_t *vam = &vat_main;
21752 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21753 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21754 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21755 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21756 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21757 clib_net_to_host_u32 (mp->action_index), mp->tag);
21762 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21763 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21764 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21765 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21766 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21767 clib_net_to_host_u32 (mp->action_index), mp->tag);
21772 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21775 vat_main_t *vam = &vat_main;
21776 vat_json_node_t *node = NULL;
21777 struct in6_addr ip6;
21778 struct in_addr ip4;
21780 if (VAT_JSON_ARRAY != vam->json_tree.type)
21782 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21783 vat_json_init_array (&vam->json_tree);
21785 node = vat_json_array_add (&vam->json_tree);
21786 vat_json_init_object (node);
21788 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21789 vat_json_object_add_uint (node, "appns_index",
21790 clib_net_to_host_u32 (mp->appns_index));
21791 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21792 vat_json_object_add_uint (node, "scope", mp->scope);
21793 vat_json_object_add_uint (node, "action_index",
21794 clib_net_to_host_u32 (mp->action_index));
21795 vat_json_object_add_uint (node, "lcl_port",
21796 clib_net_to_host_u16 (mp->lcl_port));
21797 vat_json_object_add_uint (node, "rmt_port",
21798 clib_net_to_host_u16 (mp->rmt_port));
21799 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21800 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21801 vat_json_object_add_string_copy (node, "tag", mp->tag);
21804 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21805 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21806 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21807 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21811 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21812 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21813 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21814 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21819 api_session_rule_add_del (vat_main_t * vam)
21821 vl_api_session_rule_add_del_t *mp;
21822 unformat_input_t *i = vam->input;
21823 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21824 u32 appns_index = 0, scope = 0;
21825 ip4_address_t lcl_ip4, rmt_ip4;
21826 ip6_address_t lcl_ip6, rmt_ip6;
21827 u8 is_ip4 = 1, conn_set = 0;
21828 u8 is_add = 1, *tag = 0;
21831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21833 if (unformat (i, "del"))
21835 else if (unformat (i, "add"))
21837 else if (unformat (i, "proto tcp"))
21839 else if (unformat (i, "proto udp"))
21841 else if (unformat (i, "appns %d", &appns_index))
21843 else if (unformat (i, "scope %d", &scope))
21845 else if (unformat (i, "tag %_%v%_", &tag))
21849 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21850 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21858 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21859 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21865 else if (unformat (i, "action %d", &action))
21870 if (proto == ~0 || !conn_set || action == ~0)
21872 errmsg ("transport proto, connection and action must be set");
21878 errmsg ("scope should be 0-3");
21882 M (SESSION_RULE_ADD_DEL, mp);
21884 mp->is_ip4 = is_ip4;
21885 mp->transport_proto = proto;
21886 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21887 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21888 mp->lcl_plen = lcl_plen;
21889 mp->rmt_plen = rmt_plen;
21890 mp->action_index = clib_host_to_net_u32 (action);
21891 mp->appns_index = clib_host_to_net_u32 (appns_index);
21893 mp->is_add = is_add;
21896 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21897 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21901 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21902 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21906 clib_memcpy (mp->tag, tag, vec_len (tag));
21916 api_session_rules_dump (vat_main_t * vam)
21918 vl_api_session_rules_dump_t *mp;
21919 vl_api_control_ping_t *mp_ping;
21922 if (!vam->json_output)
21924 print (vam->ofp, "%=20s", "Session Rules");
21927 M (SESSION_RULES_DUMP, mp);
21931 /* Use a control ping for synchronization */
21932 MPING (CONTROL_PING, mp_ping);
21935 /* Wait for a reply... */
21941 api_ip_container_proxy_add_del (vat_main_t * vam)
21943 vl_api_ip_container_proxy_add_del_t *mp;
21944 unformat_input_t *i = vam->input;
21945 u32 plen = ~0, sw_if_index = ~0;
21952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21954 if (unformat (i, "del"))
21956 else if (unformat (i, "add"))
21958 if (unformat (i, "%U", unformat_ip4_address, &ip4))
21963 else if (unformat (i, "%U", unformat_ip6_address, &ip6))
21968 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21973 if (sw_if_index == ~0 || plen == ~0)
21975 errmsg ("address and sw_if_index must be set");
21979 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21981 mp->is_ip4 = is_ip4;
21982 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21984 mp->is_add = is_add;
21986 clib_memcpy (mp->ip, &ip4, sizeof (ip4));
21988 clib_memcpy (mp->ip, &ip6, sizeof (ip6));
21996 q_or_quit (vat_main_t * vam)
21998 #if VPP_API_TEST_BUILTIN == 0
21999 longjmp (vam->jump_buf, 1);
22001 return 0; /* not so much */
22005 q (vat_main_t * vam)
22007 return q_or_quit (vam);
22011 quit (vat_main_t * vam)
22013 return q_or_quit (vam);
22017 comment (vat_main_t * vam)
22023 cmd_cmp (void *a1, void *a2)
22028 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
22032 help (vat_main_t * vam)
22037 unformat_input_t *i = vam->input;
22040 if (unformat (i, "%s", &name))
22044 vec_add1 (name, 0);
22046 hs = hash_get_mem (vam->help_by_name, name);
22048 print (vam->ofp, "usage: %s %s", name, hs[0]);
22050 print (vam->ofp, "No such msg / command '%s'", name);
22055 print (vam->ofp, "Help is available for the following:");
22058 hash_foreach_pair (p, vam->function_by_name,
22060 vec_add1 (cmds, (u8 *)(p->key));
22064 vec_sort_with_function (cmds, cmd_cmp);
22066 for (j = 0; j < vec_len (cmds); j++)
22067 print (vam->ofp, "%s", cmds[j]);
22074 set (vat_main_t * vam)
22076 u8 *name = 0, *value = 0;
22077 unformat_input_t *i = vam->input;
22079 if (unformat (i, "%s", &name))
22081 /* The input buffer is a vector, not a string. */
22082 value = vec_dup (i->buffer);
22083 vec_delete (value, i->index, 0);
22084 /* Almost certainly has a trailing newline */
22085 if (value[vec_len (value) - 1] == '\n')
22086 value[vec_len (value) - 1] = 0;
22087 /* Make sure it's a proper string, one way or the other */
22088 vec_add1 (value, 0);
22089 (void) clib_macro_set_value (&vam->macro_main,
22090 (char *) name, (char *) value);
22093 errmsg ("usage: set <name> <value>");
22101 unset (vat_main_t * vam)
22105 if (unformat (vam->input, "%s", &name))
22106 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22107 errmsg ("unset: %s wasn't set", name);
22120 macro_sort_cmp (void *a1, void *a2)
22122 macro_sort_t *s1 = a1;
22123 macro_sort_t *s2 = a2;
22125 return strcmp ((char *) (s1->name), (char *) (s2->name));
22129 dump_macro_table (vat_main_t * vam)
22131 macro_sort_t *sort_me = 0, *sm;
22136 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22138 vec_add2 (sort_me, sm, 1);
22139 sm->name = (u8 *)(p->key);
22140 sm->value = (u8 *) (p->value[0]);
22144 vec_sort_with_function (sort_me, macro_sort_cmp);
22146 if (vec_len (sort_me))
22147 print (vam->ofp, "%-15s%s", "Name", "Value");
22149 print (vam->ofp, "The macro table is empty...");
22151 for (i = 0; i < vec_len (sort_me); i++)
22152 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22157 dump_node_table (vat_main_t * vam)
22160 vlib_node_t *node, *next_node;
22162 if (vec_len (vam->graph_nodes) == 0)
22164 print (vam->ofp, "Node table empty, issue get_node_graph...");
22168 for (i = 0; i < vec_len (vam->graph_nodes); i++)
22170 node = vam->graph_nodes[i];
22171 print (vam->ofp, "[%d] %s", i, node->name);
22172 for (j = 0; j < vec_len (node->next_nodes); j++)
22174 if (node->next_nodes[j] != ~0)
22176 next_node = vam->graph_nodes[node->next_nodes[j]];
22177 print (vam->ofp, " [%d] %s", j, next_node->name);
22185 value_sort_cmp (void *a1, void *a2)
22187 name_sort_t *n1 = a1;
22188 name_sort_t *n2 = a2;
22190 if (n1->value < n2->value)
22192 if (n1->value > n2->value)
22199 dump_msg_api_table (vat_main_t * vam)
22201 api_main_t *am = &api_main;
22202 name_sort_t *nses = 0, *ns;
22207 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22209 vec_add2 (nses, ns, 1);
22210 ns->name = (u8 *)(hp->key);
22211 ns->value = (u32) hp->value[0];
22215 vec_sort_with_function (nses, value_sort_cmp);
22217 for (i = 0; i < vec_len (nses); i++)
22218 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22224 get_msg_id (vat_main_t * vam)
22229 if (unformat (vam->input, "%s", &name_and_crc))
22231 message_index = vl_api_get_msg_index (name_and_crc);
22232 if (message_index == ~0)
22234 print (vam->ofp, " '%s' not found", name_and_crc);
22237 print (vam->ofp, " '%s' has message index %d",
22238 name_and_crc, message_index);
22241 errmsg ("name_and_crc required...");
22246 search_node_table (vat_main_t * vam)
22248 unformat_input_t *line_input = vam->input;
22251 vlib_node_t *node, *next_node;
22254 if (vam->graph_node_index_by_name == 0)
22256 print (vam->ofp, "Node table empty, issue get_node_graph...");
22260 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22262 if (unformat (line_input, "%s", &node_to_find))
22264 vec_add1 (node_to_find, 0);
22265 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22268 print (vam->ofp, "%s not found...", node_to_find);
22271 node = vam->graph_nodes[p[0]];
22272 print (vam->ofp, "[%d] %s", p[0], node->name);
22273 for (j = 0; j < vec_len (node->next_nodes); j++)
22275 if (node->next_nodes[j] != ~0)
22277 next_node = vam->graph_nodes[node->next_nodes[j]];
22278 print (vam->ofp, " [%d] %s", j, next_node->name);
22285 clib_warning ("parse error '%U'", format_unformat_error,
22291 vec_free (node_to_find);
22300 script (vat_main_t * vam)
22302 #if (VPP_API_TEST_BUILTIN==0)
22304 char *save_current_file;
22305 unformat_input_t save_input;
22306 jmp_buf save_jump_buf;
22307 u32 save_line_number;
22309 FILE *new_fp, *save_ifp;
22311 if (unformat (vam->input, "%s", &s))
22313 new_fp = fopen ((char *) s, "r");
22316 errmsg ("Couldn't open script file %s", s);
22323 errmsg ("Missing script name");
22327 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22328 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22329 save_ifp = vam->ifp;
22330 save_line_number = vam->input_line_number;
22331 save_current_file = (char *) vam->current_file;
22333 vam->input_line_number = 0;
22335 vam->current_file = s;
22338 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
22339 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22340 vam->ifp = save_ifp;
22341 vam->input_line_number = save_line_number;
22342 vam->current_file = (u8 *) save_current_file;
22347 clib_warning ("use the exec command...");
22353 echo (vat_main_t * vam)
22355 print (vam->ofp, "%v", vam->input->buffer);
22359 /* List of API message constructors, CLI names map to api_xxx */
22360 #define foreach_vpe_api_msg \
22361 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22362 _(sw_interface_dump,"") \
22363 _(sw_interface_set_flags, \
22364 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22365 _(sw_interface_add_del_address, \
22366 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22367 _(sw_interface_set_rx_mode, \
22368 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22369 _(sw_interface_set_table, \
22370 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22371 _(sw_interface_set_mpls_enable, \
22372 "<intfc> | sw_if_index [disable | dis]") \
22373 _(sw_interface_set_vpath, \
22374 "<intfc> | sw_if_index <id> enable | disable") \
22375 _(sw_interface_set_vxlan_bypass, \
22376 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22377 _(sw_interface_set_geneve_bypass, \
22378 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22379 _(sw_interface_set_l2_xconnect, \
22380 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22381 "enable | disable") \
22382 _(sw_interface_set_l2_bridge, \
22383 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22384 "[shg <split-horizon-group>] [bvi]\n" \
22385 "enable | disable") \
22386 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22387 _(bridge_domain_add_del, \
22388 "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 <tag>] [del]\n") \
22389 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22391 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22392 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22393 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22395 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22397 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22399 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
22401 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
22403 "<vpp-if-name> | sw_if_index <id>") \
22404 _(sw_interface_tap_dump, "") \
22405 _(ip_table_add_del, \
22406 "table-id <n> [ipv6]\n") \
22407 _(ip_add_del_route, \
22408 "<addr>/<mask> via <addr> [table-id <n>]\n" \
22409 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22410 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22411 "[multipath] [count <n>]") \
22412 _(ip_mroute_add_del, \
22413 "<src> <grp>/<mask> [table-id <n>]\n" \
22414 "[<intfc> | sw_if_index <id>] [local] [del]") \
22415 _(mpls_table_add_del, \
22416 "table-id <n>\n") \
22417 _(mpls_route_add_del, \
22418 "<label> <eos> via <addr> [table-id <n>]\n" \
22419 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
22420 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
22421 "[multipath] [count <n>]") \
22422 _(mpls_ip_bind_unbind, \
22423 "<label> <addr/len>") \
22424 _(mpls_tunnel_add_del, \
22425 " via <addr> [table-id <n>]\n" \
22426 "sw_if_index <id>] [l2] [del]") \
22427 _(bier_table_add_del, \
22428 "<label> <sub-domain> <set> <bsl> [del]") \
22429 _(bier_route_add_del, \
22430 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22431 "[<intfc> | sw_if_index <id>]" \
22432 "[weight <n>] [del] [multipath]") \
22433 _(proxy_arp_add_del, \
22434 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22435 _(proxy_arp_intfc_enable_disable, \
22436 "<intfc> | sw_if_index <id> enable | disable") \
22437 _(sw_interface_set_unnumbered, \
22438 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22439 _(ip_neighbor_add_del, \
22440 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22441 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22442 _(reset_vrf, "vrf <id> [ipv6]") \
22443 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22444 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22445 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22446 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22447 "[outer_vlan_id_any][inner_vlan_id_any]") \
22448 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22449 _(reset_fib, "vrf <n> [ipv6]") \
22450 _(dhcp_proxy_config, \
22451 "svr <v46-address> src <v46-address>\n" \
22452 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22453 _(dhcp_proxy_set_vss, \
22454 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
22455 _(dhcp_proxy_dump, "ip6") \
22456 _(dhcp_client_config, \
22457 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22458 _(set_ip_flow_hash, \
22459 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22460 _(sw_interface_ip6_enable_disable, \
22461 "<intfc> | sw_if_index <id> enable | disable") \
22462 _(sw_interface_ip6_set_link_local_address, \
22463 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
22464 _(ip6nd_proxy_add_del, \
22465 "<intfc> | sw_if_index <id> <ip6-address>") \
22466 _(ip6nd_proxy_dump, "") \
22467 _(sw_interface_ip6nd_ra_prefix, \
22468 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22469 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22470 "[nolink] [isno]") \
22471 _(sw_interface_ip6nd_ra_config, \
22472 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22473 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22474 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22475 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22476 _(l2_patch_add_del, \
22477 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22478 "enable | disable") \
22479 _(sr_localsid_add_del, \
22480 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22481 "fib-table <num> (end.psp) sw_if_index <num>") \
22482 _(classify_add_del_table, \
22483 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22484 " [del] [del-chain] mask <mask-value>\n" \
22485 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22486 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22487 _(classify_add_del_session, \
22488 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22489 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22490 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22491 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22492 _(classify_set_interface_ip_table, \
22493 "<intfc> | sw_if_index <nn> table <nn>") \
22494 _(classify_set_interface_l2_tables, \
22495 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22496 " [other-table <nn>]") \
22497 _(get_node_index, "node <node-name") \
22498 _(add_node_next, "node <node-name> next <next-node-name>") \
22499 _(l2tpv3_create_tunnel, \
22500 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22501 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22502 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22503 _(l2tpv3_set_tunnel_cookies, \
22504 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22505 "[new_remote_cookie <nn>]\n") \
22506 _(l2tpv3_interface_enable_disable, \
22507 "<intfc> | sw_if_index <nn> enable | disable") \
22508 _(l2tpv3_set_lookup_key, \
22509 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22510 _(sw_if_l2tpv3_tunnel_dump, "") \
22511 _(vxlan_add_del_tunnel, \
22512 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22513 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22514 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22515 _(geneve_add_del_tunnel, \
22516 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22517 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22518 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22519 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22520 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22521 _(gre_add_del_tunnel, \
22522 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
22523 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22524 _(l2_fib_clear_table, "") \
22525 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22526 _(l2_interface_vlan_tag_rewrite, \
22527 "<intfc> | sw_if_index <nn> \n" \
22528 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22529 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22530 _(create_vhost_user_if, \
22531 "socket <filename> [server] [renumber <dev_instance>] " \
22532 "[mac <mac_address>]") \
22533 _(modify_vhost_user_if, \
22534 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22535 "[server] [renumber <dev_instance>]") \
22536 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22537 _(sw_interface_vhost_user_dump, "") \
22538 _(show_version, "") \
22539 _(vxlan_gpe_add_del_tunnel, \
22540 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22541 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22542 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22543 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22544 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22545 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22546 _(interface_name_renumber, \
22547 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22548 _(input_acl_set_interface, \
22549 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22550 " [l2-table <nn>] [del]") \
22551 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22552 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22553 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22554 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22555 _(ip_dump, "ipv4 | ipv6") \
22556 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22557 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22559 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22560 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22561 " integ_alg <alg> integ_key <hex>") \
22562 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
22563 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22564 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22565 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22566 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22567 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22568 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22569 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22570 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
22571 _(ipsec_sa_dump, "[sa_id <n>]") \
22572 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22573 " <alg> <hex>\n") \
22574 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22575 _(ikev2_profile_add_del, "name <profile_name> [del]") \
22576 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
22577 "(auth_data 0x<data> | auth_data <data>)") \
22578 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
22579 "(id_data 0x<data> | id_data <data>) (local|remote)") \
22580 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
22581 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
22582 "(local|remote)") \
22583 _(ikev2_set_local_key, "file <absolute_file_path>") \
22584 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
22585 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22586 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
22587 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
22588 _(ikev2_initiate_sa_init, "<profile_name>") \
22589 _(ikev2_initiate_del_ike_sa, "<ispi>") \
22590 _(ikev2_initiate_del_child_sa, "<ispi>") \
22591 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
22592 _(delete_loopback,"sw_if_index <nn>") \
22593 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22594 _(map_add_domain, \
22595 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
22596 "ip6-src <ip6addr> " \
22597 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
22598 _(map_del_domain, "index <n>") \
22599 _(map_add_del_rule, \
22600 "index <n> psid <n> dst <ip6addr> [del]") \
22601 _(map_domain_dump, "") \
22602 _(map_rule_dump, "index <map-domain>") \
22603 _(want_interface_events, "enable|disable") \
22604 _(want_stats,"enable|disable") \
22605 _(get_first_msg_id, "client <name>") \
22606 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22607 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22608 "fib-id <nn> [ip4][ip6][default]") \
22609 _(get_node_graph, " ") \
22610 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22611 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22612 _(ioam_disable, "") \
22613 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22614 " sw_if_index <sw_if_index> p <priority> " \
22615 "w <weight>] [del]") \
22616 _(one_add_del_locator, "locator-set <locator_name> " \
22617 "iface <intf> | sw_if_index <sw_if_index> " \
22618 "p <priority> w <weight> [del]") \
22619 _(one_add_del_local_eid,"vni <vni> eid " \
22620 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22621 "locator-set <locator_name> [del]" \
22622 "[key-id sha1|sha256 secret-key <secret-key>]")\
22623 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22624 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22625 _(one_enable_disable, "enable|disable") \
22626 _(one_map_register_enable_disable, "enable|disable") \
22627 _(one_map_register_fallback_threshold, "<value>") \
22628 _(one_rloc_probe_enable_disable, "enable|disable") \
22629 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22631 "rloc <locator> p <prio> " \
22632 "w <weight> [rloc <loc> ... ] " \
22633 "action <action> [del-all]") \
22634 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22636 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22637 _(one_use_petr, "ip-address> | disable") \
22638 _(one_map_request_mode, "src-dst|dst-only") \
22639 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22640 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22641 _(one_locator_set_dump, "[local | remote]") \
22642 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22643 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22644 "[local] | [remote]") \
22645 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22646 _(one_ndp_bd_get, "") \
22647 _(one_ndp_entries_get, "bd <bridge-domain>") \
22648 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22649 _(one_l2_arp_bd_get, "") \
22650 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22651 _(one_stats_enable_disable, "enable|disalbe") \
22652 _(show_one_stats_enable_disable, "") \
22653 _(one_eid_table_vni_dump, "") \
22654 _(one_eid_table_map_dump, "l2|l3") \
22655 _(one_map_resolver_dump, "") \
22656 _(one_map_server_dump, "") \
22657 _(one_adjacencies_get, "vni <vni>") \
22658 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22659 _(show_one_rloc_probe_state, "") \
22660 _(show_one_map_register_state, "") \
22661 _(show_one_status, "") \
22662 _(one_stats_dump, "") \
22663 _(one_stats_flush, "") \
22664 _(one_get_map_request_itr_rlocs, "") \
22665 _(one_map_register_set_ttl, "<ttl>") \
22666 _(one_set_transport_protocol, "udp|api") \
22667 _(one_get_transport_protocol, "") \
22668 _(one_enable_disable_xtr_mode, "enable|disable") \
22669 _(one_show_xtr_mode, "") \
22670 _(one_enable_disable_pitr_mode, "enable|disable") \
22671 _(one_show_pitr_mode, "") \
22672 _(one_enable_disable_petr_mode, "enable|disable") \
22673 _(one_show_petr_mode, "") \
22674 _(show_one_nsh_mapping, "") \
22675 _(show_one_pitr, "") \
22676 _(show_one_use_petr, "") \
22677 _(show_one_map_request_mode, "") \
22678 _(show_one_map_register_ttl, "") \
22679 _(show_one_map_register_fallback_threshold, "") \
22680 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22681 " sw_if_index <sw_if_index> p <priority> " \
22682 "w <weight>] [del]") \
22683 _(lisp_add_del_locator, "locator-set <locator_name> " \
22684 "iface <intf> | sw_if_index <sw_if_index> " \
22685 "p <priority> w <weight> [del]") \
22686 _(lisp_add_del_local_eid,"vni <vni> eid " \
22687 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22688 "locator-set <locator_name> [del]" \
22689 "[key-id sha1|sha256 secret-key <secret-key>]") \
22690 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22691 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22692 _(lisp_enable_disable, "enable|disable") \
22693 _(lisp_map_register_enable_disable, "enable|disable") \
22694 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22695 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22697 "rloc <locator> p <prio> " \
22698 "w <weight> [rloc <loc> ... ] " \
22699 "action <action> [del-all]") \
22700 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22702 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22703 _(lisp_use_petr, "<ip-address> | disable") \
22704 _(lisp_map_request_mode, "src-dst|dst-only") \
22705 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22706 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22707 _(lisp_locator_set_dump, "[local | remote]") \
22708 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22709 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22710 "[local] | [remote]") \
22711 _(lisp_eid_table_vni_dump, "") \
22712 _(lisp_eid_table_map_dump, "l2|l3") \
22713 _(lisp_map_resolver_dump, "") \
22714 _(lisp_map_server_dump, "") \
22715 _(lisp_adjacencies_get, "vni <vni>") \
22716 _(gpe_fwd_entry_vnis_get, "") \
22717 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22718 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22719 "[table <table-id>]") \
22720 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22721 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22722 _(gpe_set_encap_mode, "lisp|vxlan") \
22723 _(gpe_get_encap_mode, "") \
22724 _(lisp_gpe_add_del_iface, "up|down") \
22725 _(lisp_gpe_enable_disable, "enable|disable") \
22726 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22727 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22728 _(show_lisp_rloc_probe_state, "") \
22729 _(show_lisp_map_register_state, "") \
22730 _(show_lisp_status, "") \
22731 _(lisp_get_map_request_itr_rlocs, "") \
22732 _(show_lisp_pitr, "") \
22733 _(show_lisp_use_petr, "") \
22734 _(show_lisp_map_request_mode, "") \
22735 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22736 _(af_packet_delete, "name <host interface name>") \
22737 _(policer_add_del, "name <policer name> <params> [del]") \
22738 _(policer_dump, "[name <policer name>]") \
22739 _(policer_classify_set_interface, \
22740 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22741 " [l2-table <nn>] [del]") \
22742 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22743 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22744 "[master|slave]") \
22745 _(netmap_delete, "name <interface name>") \
22746 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22747 _(mpls_fib_dump, "") \
22748 _(classify_table_ids, "") \
22749 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22750 _(classify_table_info, "table_id <nn>") \
22751 _(classify_session_dump, "table_id <nn>") \
22752 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22753 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22754 "[template_interval <nn>] [udp_checksum]") \
22755 _(ipfix_exporter_dump, "") \
22756 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22757 _(ipfix_classify_stream_dump, "") \
22758 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22759 _(ipfix_classify_table_dump, "") \
22760 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22761 _(sw_interface_span_dump, "[l2]") \
22762 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22763 _(pg_create_interface, "if_id <nn>") \
22764 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22765 _(pg_enable_disable, "[stream <id>] disable") \
22766 _(ip_source_and_port_range_check_add_del, \
22767 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22768 _(ip_source_and_port_range_check_interface_add_del, \
22769 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22770 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22771 _(ipsec_gre_add_del_tunnel, \
22772 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22773 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22774 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22775 _(l2_interface_pbb_tag_rewrite, \
22776 "<intfc> | sw_if_index <nn> \n" \
22777 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22778 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22779 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22780 _(flow_classify_set_interface, \
22781 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22782 _(flow_classify_dump, "type [ip4|ip6]") \
22783 _(ip_fib_dump, "") \
22784 _(ip_mfib_dump, "") \
22785 _(ip6_fib_dump, "") \
22786 _(ip6_mfib_dump, "") \
22787 _(feature_enable_disable, "arc_name <arc_name> " \
22788 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22789 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22791 _(l2_xconnect_dump, "") \
22792 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
22793 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22794 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22795 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22796 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22797 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22798 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22799 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22800 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22801 _(memfd_segment_create,"size <nnn>") \
22802 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22803 _(dns_enable_disable, "[enable][disable]") \
22804 _(dns_name_server_add_del, "<ip-address> [del]") \
22805 _(dns_resolve_name, "<hostname>") \
22806 _(dns_resolve_ip, "<ip4|ip6>") \
22807 _(dns_name_server_add_del, "<ip-address> [del]") \
22808 _(dns_resolve_name, "<hostname>") \
22809 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22810 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22811 _(session_rules_dump, "") \
22812 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22814 /* List of command functions, CLI names map directly to functions */
22815 #define foreach_cli_function \
22816 _(comment, "usage: comment <ignore-rest-of-line>") \
22817 _(dump_interface_table, "usage: dump_interface_table") \
22818 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22819 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22820 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22821 _(dump_stats_table, "usage: dump_stats_table") \
22822 _(dump_macro_table, "usage: dump_macro_table ") \
22823 _(dump_node_table, "usage: dump_node_table") \
22824 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22825 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22826 _(echo, "usage: echo <message>") \
22827 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22828 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22829 _(help, "usage: help") \
22830 _(q, "usage: quit") \
22831 _(quit, "usage: quit") \
22832 _(search_node_table, "usage: search_node_table <name>...") \
22833 _(set, "usage: set <variable-name> <value>") \
22834 _(script, "usage: script <file-name>") \
22835 _(unset, "usage: unset <variable-name>")
22837 static void vl_api_##n##_t_handler_uni \
22838 (vl_api_##n##_t * mp) \
22840 vat_main_t * vam = &vat_main; \
22841 if (vam->json_output) { \
22842 vl_api_##n##_t_handler_json(mp); \
22844 vl_api_##n##_t_handler(mp); \
22847 foreach_vpe_api_reply_msg;
22848 #if VPP_API_TEST_BUILTIN == 0
22849 foreach_standalone_reply_msg;
22854 vat_api_hookup (vat_main_t * vam)
22857 vl_msg_api_set_handlers(VL_API_##N, #n, \
22858 vl_api_##n##_t_handler_uni, \
22860 vl_api_##n##_t_endian, \
22861 vl_api_##n##_t_print, \
22862 sizeof(vl_api_##n##_t), 1);
22863 foreach_vpe_api_reply_msg;
22864 #if VPP_API_TEST_BUILTIN == 0
22865 foreach_standalone_reply_msg;
22869 #if (VPP_API_TEST_BUILTIN==0)
22870 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22872 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22874 vam->function_by_name = hash_create_string (0, sizeof (uword));
22876 vam->help_by_name = hash_create_string (0, sizeof (uword));
22879 /* API messages we can send */
22880 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22881 foreach_vpe_api_msg;
22885 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22886 foreach_vpe_api_msg;
22889 /* CLI functions */
22890 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22891 foreach_cli_function;
22895 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22896 foreach_cli_function;
22900 #if VPP_API_TEST_BUILTIN
22901 static clib_error_t *
22902 vat_api_hookup_shim (vlib_main_t * vm)
22904 vat_api_hookup (&vat_main);
22908 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22912 * fd.io coding-style-patch-verification: ON
22915 * eval: (c-set-style "gnu")