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 (u64 * mac)
725 tmp = clib_net_to_host_u64 (tmp);
726 tmp += 1 << 16; /* skip unused (least significant) octets */
727 tmp = clib_host_to_net_u64 (tmp);
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 retval = memfd_slave_init (&memfd);
2142 clib_warning ("WARNING: segment map returned %d", retval);
2144 /* Pivot to the memory client segment that vpp just created */
2146 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2148 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2150 vl_client_install_client_message_handlers ();
2152 vl_client_connect_to_vlib_no_map ("pvt",
2154 32 /* input_queue_length */ );
2155 if (close (my_fd) < 0)
2156 clib_unix_warning ("close memfd fd pivot");
2157 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2159 vl_socket_client_enable_disable (&vam->socket_client_main,
2160 0 /* disable socket */ );
2164 if (vam->async_mode)
2166 vam->async_errors += (retval < 0);
2170 vam->retval = retval;
2171 vam->result_ready = 1;
2176 static void vl_api_memfd_segment_create_reply_t_handler_json
2177 (vl_api_memfd_segment_create_reply_t * mp)
2179 clib_warning ("no");
2182 static void vl_api_dns_resolve_name_reply_t_handler
2183 (vl_api_dns_resolve_name_reply_t * mp)
2185 vat_main_t *vam = &vat_main;
2186 i32 retval = ntohl (mp->retval);
2187 if (vam->async_mode)
2189 vam->async_errors += (retval < 0);
2193 vam->retval = retval;
2194 vam->result_ready = 1;
2199 clib_warning ("ip4 address %U", format_ip4_address,
2200 (ip4_address_t *) mp->ip4_address);
2202 clib_warning ("ip6 address %U", format_ip6_address,
2203 (ip6_address_t *) mp->ip6_address);
2206 clib_warning ("retval %d", retval);
2210 static void vl_api_dns_resolve_name_reply_t_handler_json
2211 (vl_api_dns_resolve_name_reply_t * mp)
2213 clib_warning ("no");
2216 static void vl_api_ip_address_details_t_handler
2217 (vl_api_ip_address_details_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 static ip_address_details_t empty_ip_address_details = { {0} };
2221 ip_address_details_t *address = NULL;
2222 ip_details_t *current_ip_details = NULL;
2223 ip_details_t *details = NULL;
2225 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2227 if (!details || vam->current_sw_if_index >= vec_len (details)
2228 || !details[vam->current_sw_if_index].present)
2230 errmsg ("ip address details arrived but not stored");
2231 errmsg ("ip_dump should be called first");
2235 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2237 #define addresses (current_ip_details->addr)
2239 vec_validate_init_empty (addresses, vec_len (addresses),
2240 empty_ip_address_details);
2242 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2244 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2245 address->prefix_length = mp->prefix_length;
2249 static void vl_api_ip_address_details_t_handler_json
2250 (vl_api_ip_address_details_t * mp)
2252 vat_main_t *vam = &vat_main;
2253 vat_json_node_t *node = NULL;
2254 struct in6_addr ip6;
2257 if (VAT_JSON_ARRAY != vam->json_tree.type)
2259 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2260 vat_json_init_array (&vam->json_tree);
2262 node = vat_json_array_add (&vam->json_tree);
2264 vat_json_init_object (node);
2267 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2268 vat_json_object_add_ip6 (node, "ip", ip6);
2272 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2273 vat_json_object_add_ip4 (node, "ip", ip4);
2275 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2279 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 static ip_details_t empty_ip_details = { 0 };
2283 ip_details_t *ip = NULL;
2284 u32 sw_if_index = ~0;
2286 sw_if_index = ntohl (mp->sw_if_index);
2288 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2289 sw_if_index, empty_ip_details);
2291 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2298 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2300 vat_main_t *vam = &vat_main;
2302 if (VAT_JSON_ARRAY != vam->json_tree.type)
2304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2305 vat_json_init_array (&vam->json_tree);
2307 vat_json_array_add_uint (&vam->json_tree,
2308 clib_net_to_host_u32 (mp->sw_if_index));
2311 static void vl_api_map_domain_details_t_handler_json
2312 (vl_api_map_domain_details_t * mp)
2314 vat_json_node_t *node = NULL;
2315 vat_main_t *vam = &vat_main;
2316 struct in6_addr ip6;
2319 if (VAT_JSON_ARRAY != vam->json_tree.type)
2321 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2322 vat_json_init_array (&vam->json_tree);
2325 node = vat_json_array_add (&vam->json_tree);
2326 vat_json_init_object (node);
2328 vat_json_object_add_uint (node, "domain_index",
2329 clib_net_to_host_u32 (mp->domain_index));
2330 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2331 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2332 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2333 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2334 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2335 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2336 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2337 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2338 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2339 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2340 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2341 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2342 vat_json_object_add_uint (node, "flags", mp->flags);
2343 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2344 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2347 static void vl_api_map_domain_details_t_handler
2348 (vl_api_map_domain_details_t * mp)
2350 vat_main_t *vam = &vat_main;
2352 if (mp->is_translation)
2355 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2356 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2357 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2358 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2359 clib_net_to_host_u32 (mp->domain_index));
2364 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2365 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2366 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2367 format_ip6_address, mp->ip6_src,
2368 clib_net_to_host_u32 (mp->domain_index));
2370 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2371 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2372 mp->is_translation ? "map-t" : "");
2375 static void vl_api_map_rule_details_t_handler_json
2376 (vl_api_map_rule_details_t * mp)
2378 struct in6_addr ip6;
2379 vat_json_node_t *node = NULL;
2380 vat_main_t *vam = &vat_main;
2382 if (VAT_JSON_ARRAY != vam->json_tree.type)
2384 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2385 vat_json_init_array (&vam->json_tree);
2388 node = vat_json_array_add (&vam->json_tree);
2389 vat_json_init_object (node);
2391 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2392 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2393 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2397 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2399 vat_main_t *vam = &vat_main;
2400 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2401 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2405 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2407 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2408 "router_addr %U host_mac %U",
2409 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2410 format_ip4_address, &mp->host_address,
2411 format_ip4_address, &mp->router_address,
2412 format_ethernet_address, mp->host_mac);
2415 static void vl_api_dhcp_compl_event_t_handler_json
2416 (vl_api_dhcp_compl_event_t * mp)
2418 /* JSON output not supported */
2422 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2425 vat_main_t *vam = &vat_main;
2426 static u64 default_counter = 0;
2428 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2430 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2431 sw_if_index, default_counter);
2432 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2436 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2437 interface_counter_t counter)
2439 vat_main_t *vam = &vat_main;
2440 static interface_counter_t default_counter = { 0, };
2442 vec_validate_init_empty (vam->combined_interface_counters,
2443 vnet_counter_type, NULL);
2444 vec_validate_init_empty (vam->combined_interface_counters
2445 [vnet_counter_type], sw_if_index, default_counter);
2446 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2449 static void vl_api_vnet_interface_simple_counters_t_handler
2450 (vl_api_vnet_interface_simple_counters_t * mp)
2455 static void vl_api_vnet_interface_combined_counters_t_handler
2456 (vl_api_vnet_interface_combined_counters_t * mp)
2461 static void vl_api_vnet_interface_simple_counters_t_handler_json
2462 (vl_api_vnet_interface_simple_counters_t * mp)
2467 u32 first_sw_if_index;
2470 count = ntohl (mp->count);
2471 first_sw_if_index = ntohl (mp->first_sw_if_index);
2473 v_packets = (u64 *) & mp->data;
2474 for (i = 0; i < count; i++)
2476 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2477 set_simple_interface_counter (mp->vnet_counter_type,
2478 first_sw_if_index + i, packets);
2483 static void vl_api_vnet_interface_combined_counters_t_handler_json
2484 (vl_api_vnet_interface_combined_counters_t * mp)
2486 interface_counter_t counter;
2488 u32 first_sw_if_index;
2492 count = ntohl (mp->count);
2493 first_sw_if_index = ntohl (mp->first_sw_if_index);
2495 v = (vlib_counter_t *) & mp->data;
2496 for (i = 0; i < count; i++)
2499 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2501 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2502 set_combined_interface_counter (mp->vnet_counter_type,
2503 first_sw_if_index + i, counter);
2509 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2511 vat_main_t *vam = &vat_main;
2514 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2516 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2525 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2527 vat_main_t *vam = &vat_main;
2530 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2532 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2540 static void vl_api_vnet_ip4_fib_counters_t_handler
2541 (vl_api_vnet_ip4_fib_counters_t * mp)
2546 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2547 (vl_api_vnet_ip4_fib_counters_t * mp)
2549 vat_main_t *vam = &vat_main;
2550 vl_api_ip4_fib_counter_t *v;
2551 ip4_fib_counter_t *counter;
2558 vrf_id = ntohl (mp->vrf_id);
2559 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2560 if (~0 == vrf_index)
2562 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2563 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2564 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2565 vec_validate (vam->ip4_fib_counters, vrf_index);
2566 vam->ip4_fib_counters[vrf_index] = NULL;
2569 vec_free (vam->ip4_fib_counters[vrf_index]);
2570 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2571 count = ntohl (mp->count);
2572 for (i = 0; i < count; i++)
2574 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2575 counter = &vam->ip4_fib_counters[vrf_index][i];
2576 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2577 counter->address = ip4;
2578 counter->address_length = v->address_length;
2579 counter->packets = clib_net_to_host_u64 (v->packets);
2580 counter->bytes = clib_net_to_host_u64 (v->bytes);
2585 static void vl_api_vnet_ip4_nbr_counters_t_handler
2586 (vl_api_vnet_ip4_nbr_counters_t * mp)
2591 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2592 (vl_api_vnet_ip4_nbr_counters_t * mp)
2594 vat_main_t *vam = &vat_main;
2595 vl_api_ip4_nbr_counter_t *v;
2596 ip4_nbr_counter_t *counter;
2601 sw_if_index = ntohl (mp->sw_if_index);
2602 count = ntohl (mp->count);
2603 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2606 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2608 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2609 for (i = 0; i < count; i++)
2611 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2612 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2613 counter->address.s_addr = v->address;
2614 counter->packets = clib_net_to_host_u64 (v->packets);
2615 counter->bytes = clib_net_to_host_u64 (v->bytes);
2616 counter->linkt = v->link_type;
2621 static void vl_api_vnet_ip6_fib_counters_t_handler
2622 (vl_api_vnet_ip6_fib_counters_t * mp)
2627 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2628 (vl_api_vnet_ip6_fib_counters_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vl_api_ip6_fib_counter_t *v;
2632 ip6_fib_counter_t *counter;
2633 struct in6_addr ip6;
2639 vrf_id = ntohl (mp->vrf_id);
2640 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2641 if (~0 == vrf_index)
2643 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2644 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2645 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2646 vec_validate (vam->ip6_fib_counters, vrf_index);
2647 vam->ip6_fib_counters[vrf_index] = NULL;
2650 vec_free (vam->ip6_fib_counters[vrf_index]);
2651 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2652 count = ntohl (mp->count);
2653 for (i = 0; i < count; i++)
2655 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2656 counter = &vam->ip6_fib_counters[vrf_index][i];
2657 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2658 counter->address = ip6;
2659 counter->address_length = v->address_length;
2660 counter->packets = clib_net_to_host_u64 (v->packets);
2661 counter->bytes = clib_net_to_host_u64 (v->bytes);
2666 static void vl_api_vnet_ip6_nbr_counters_t_handler
2667 (vl_api_vnet_ip6_nbr_counters_t * mp)
2672 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2673 (vl_api_vnet_ip6_nbr_counters_t * mp)
2675 vat_main_t *vam = &vat_main;
2676 vl_api_ip6_nbr_counter_t *v;
2677 ip6_nbr_counter_t *counter;
2678 struct in6_addr ip6;
2683 sw_if_index = ntohl (mp->sw_if_index);
2684 count = ntohl (mp->count);
2685 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2688 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2690 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2691 for (i = 0; i < count; i++)
2693 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2694 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2695 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2696 counter->address = ip6;
2697 counter->packets = clib_net_to_host_u64 (v->packets);
2698 counter->bytes = clib_net_to_host_u64 (v->bytes);
2703 static void vl_api_get_first_msg_id_reply_t_handler
2704 (vl_api_get_first_msg_id_reply_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 i32 retval = ntohl (mp->retval);
2709 if (vam->async_mode)
2711 vam->async_errors += (retval < 0);
2715 vam->retval = retval;
2716 vam->result_ready = 1;
2720 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2724 static void vl_api_get_first_msg_id_reply_t_handler_json
2725 (vl_api_get_first_msg_id_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t node;
2730 vat_json_init_object (&node);
2731 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2732 vat_json_object_add_uint (&node, "first_msg_id",
2733 (uint) ntohs (mp->first_msg_id));
2735 vat_json_print (vam->ofp, &node);
2736 vat_json_free (&node);
2738 vam->retval = ntohl (mp->retval);
2739 vam->result_ready = 1;
2742 static void vl_api_get_node_graph_reply_t_handler
2743 (vl_api_get_node_graph_reply_t * mp)
2745 vat_main_t *vam = &vat_main;
2746 api_main_t *am = &api_main;
2747 i32 retval = ntohl (mp->retval);
2748 u8 *pvt_copy, *reply;
2753 if (vam->async_mode)
2755 vam->async_errors += (retval < 0);
2759 vam->retval = retval;
2760 vam->result_ready = 1;
2763 /* "Should never happen..." */
2767 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2768 pvt_copy = vec_dup (reply);
2770 /* Toss the shared-memory original... */
2771 pthread_mutex_lock (&am->vlib_rp->mutex);
2772 oldheap = svm_push_data_heap (am->vlib_rp);
2776 svm_pop_heap (oldheap);
2777 pthread_mutex_unlock (&am->vlib_rp->mutex);
2779 if (vam->graph_nodes)
2781 hash_free (vam->graph_node_index_by_name);
2783 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2785 node = vam->graph_nodes[i];
2786 vec_free (node->name);
2787 vec_free (node->next_nodes);
2790 vec_free (vam->graph_nodes);
2793 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2794 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2795 vec_free (pvt_copy);
2797 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2799 node = vam->graph_nodes[i];
2800 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2804 static void vl_api_get_node_graph_reply_t_handler_json
2805 (vl_api_get_node_graph_reply_t * mp)
2807 vat_main_t *vam = &vat_main;
2808 api_main_t *am = &api_main;
2810 vat_json_node_t node;
2813 /* $$$$ make this real? */
2814 vat_json_init_object (&node);
2815 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2816 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2818 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2820 /* Toss the shared-memory original... */
2821 pthread_mutex_lock (&am->vlib_rp->mutex);
2822 oldheap = svm_push_data_heap (am->vlib_rp);
2826 svm_pop_heap (oldheap);
2827 pthread_mutex_unlock (&am->vlib_rp->mutex);
2829 vat_json_print (vam->ofp, &node);
2830 vat_json_free (&node);
2832 vam->retval = ntohl (mp->retval);
2833 vam->result_ready = 1;
2837 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2839 vat_main_t *vam = &vat_main;
2844 s = format (s, "%=16d%=16d%=16d",
2845 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2849 s = format (s, "%=16U%=16d%=16d",
2850 mp->is_ipv6 ? format_ip6_address :
2852 mp->ip_address, mp->priority, mp->weight);
2855 print (vam->ofp, "%v", s);
2860 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2862 vat_main_t *vam = &vat_main;
2863 vat_json_node_t *node = NULL;
2864 struct in6_addr ip6;
2867 if (VAT_JSON_ARRAY != vam->json_tree.type)
2869 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2870 vat_json_init_array (&vam->json_tree);
2872 node = vat_json_array_add (&vam->json_tree);
2873 vat_json_init_object (node);
2875 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2876 vat_json_object_add_uint (node, "priority", mp->priority);
2877 vat_json_object_add_uint (node, "weight", mp->weight);
2880 vat_json_object_add_uint (node, "sw_if_index",
2881 clib_net_to_host_u32 (mp->sw_if_index));
2886 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2887 vat_json_object_add_ip6 (node, "address", ip6);
2891 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2892 vat_json_object_add_ip4 (node, "address", ip4);
2898 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2901 vat_main_t *vam = &vat_main;
2904 ls_name = format (0, "%s", mp->ls_name);
2906 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2912 vl_api_one_locator_set_details_t_handler_json
2913 (vl_api_one_locator_set_details_t * mp)
2915 vat_main_t *vam = &vat_main;
2916 vat_json_node_t *node = 0;
2919 ls_name = format (0, "%s", mp->ls_name);
2920 vec_add1 (ls_name, 0);
2922 if (VAT_JSON_ARRAY != vam->json_tree.type)
2924 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2925 vat_json_init_array (&vam->json_tree);
2927 node = vat_json_array_add (&vam->json_tree);
2929 vat_json_init_object (node);
2930 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2931 vat_json_object_add_uint (node, "ls_index",
2932 clib_net_to_host_u32 (mp->ls_index));
2940 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2943 unformat_nsh_address (unformat_input_t * input, va_list * args)
2945 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2946 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2950 format_nsh_address_vat (u8 * s, va_list * args)
2952 nsh_t *a = va_arg (*args, nsh_t *);
2953 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2957 format_lisp_flat_eid (u8 * s, va_list * args)
2959 u32 type = va_arg (*args, u32);
2960 u8 *eid = va_arg (*args, u8 *);
2961 u32 eid_len = va_arg (*args, u32);
2966 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2968 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2970 return format (s, "%U", format_ethernet_address, eid);
2972 return format (s, "%U", format_nsh_address_vat, eid);
2978 format_lisp_eid_vat (u8 * s, va_list * args)
2980 u32 type = va_arg (*args, u32);
2981 u8 *eid = va_arg (*args, u8 *);
2982 u32 eid_len = va_arg (*args, u32);
2983 u8 *seid = va_arg (*args, u8 *);
2984 u32 seid_len = va_arg (*args, u32);
2985 u32 is_src_dst = va_arg (*args, u32);
2988 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2990 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2996 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2998 vat_main_t *vam = &vat_main;
2999 u8 *s = 0, *eid = 0;
3001 if (~0 == mp->locator_set_index)
3002 s = format (0, "action: %d", mp->action);
3004 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3006 eid = format (0, "%U", format_lisp_eid_vat,
3010 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3013 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3014 clib_net_to_host_u32 (mp->vni),
3016 mp->is_local ? "local" : "remote",
3017 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3018 clib_net_to_host_u16 (mp->key_id), mp->key);
3025 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3028 vat_main_t *vam = &vat_main;
3029 vat_json_node_t *node = 0;
3032 if (VAT_JSON_ARRAY != vam->json_tree.type)
3034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3035 vat_json_init_array (&vam->json_tree);
3037 node = vat_json_array_add (&vam->json_tree);
3039 vat_json_init_object (node);
3040 if (~0 == mp->locator_set_index)
3041 vat_json_object_add_uint (node, "action", mp->action);
3043 vat_json_object_add_uint (node, "locator_set_index",
3044 clib_net_to_host_u32 (mp->locator_set_index));
3046 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3047 if (mp->eid_type == 3)
3049 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3050 vat_json_init_object (nsh_json);
3051 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3052 vat_json_object_add_uint (nsh_json, "spi",
3053 clib_net_to_host_u32 (nsh->spi));
3054 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3058 eid = format (0, "%U", format_lisp_eid_vat,
3062 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3064 vat_json_object_add_string_copy (node, "eid", eid);
3067 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3068 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3069 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3073 vat_json_object_add_uint (node, "key_id",
3074 clib_net_to_host_u16 (mp->key_id));
3075 vat_json_object_add_string_copy (node, "key", mp->key);
3080 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3082 vat_main_t *vam = &vat_main;
3083 u8 *seid = 0, *deid = 0;
3084 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3086 deid = format (0, "%U", format_lisp_eid_vat,
3087 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3089 seid = format (0, "%U", format_lisp_eid_vat,
3090 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3096 format_ip_address_fcn = format_ip4_address;
3098 format_ip_address_fcn = format_ip6_address;
3101 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3102 clib_net_to_host_u32 (mp->vni),
3104 format_ip_address_fcn, mp->lloc,
3105 format_ip_address_fcn, mp->rloc,
3106 clib_net_to_host_u32 (mp->pkt_count),
3107 clib_net_to_host_u32 (mp->bytes));
3114 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3116 struct in6_addr ip6;
3118 vat_main_t *vam = &vat_main;
3119 vat_json_node_t *node = 0;
3120 u8 *deid = 0, *seid = 0;
3122 if (VAT_JSON_ARRAY != vam->json_tree.type)
3124 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3125 vat_json_init_array (&vam->json_tree);
3127 node = vat_json_array_add (&vam->json_tree);
3129 vat_json_init_object (node);
3130 deid = format (0, "%U", format_lisp_eid_vat,
3131 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3133 seid = format (0, "%U", format_lisp_eid_vat,
3134 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3139 vat_json_object_add_string_copy (node, "seid", seid);
3140 vat_json_object_add_string_copy (node, "deid", deid);
3141 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3145 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3146 vat_json_object_add_ip4 (node, "lloc", ip4);
3147 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3148 vat_json_object_add_ip4 (node, "rloc", ip4);
3152 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3153 vat_json_object_add_ip6 (node, "lloc", ip6);
3154 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3155 vat_json_object_add_ip6 (node, "rloc", ip6);
3157 vat_json_object_add_uint (node, "pkt_count",
3158 clib_net_to_host_u32 (mp->pkt_count));
3159 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3166 vl_api_one_eid_table_map_details_t_handler
3167 (vl_api_one_eid_table_map_details_t * mp)
3169 vat_main_t *vam = &vat_main;
3171 u8 *line = format (0, "%=10d%=10d",
3172 clib_net_to_host_u32 (mp->vni),
3173 clib_net_to_host_u32 (mp->dp_table));
3174 print (vam->ofp, "%v", line);
3179 vl_api_one_eid_table_map_details_t_handler_json
3180 (vl_api_one_eid_table_map_details_t * mp)
3182 vat_main_t *vam = &vat_main;
3183 vat_json_node_t *node = NULL;
3185 if (VAT_JSON_ARRAY != vam->json_tree.type)
3187 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3188 vat_json_init_array (&vam->json_tree);
3190 node = vat_json_array_add (&vam->json_tree);
3191 vat_json_init_object (node);
3192 vat_json_object_add_uint (node, "dp_table",
3193 clib_net_to_host_u32 (mp->dp_table));
3194 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3198 vl_api_one_eid_table_vni_details_t_handler
3199 (vl_api_one_eid_table_vni_details_t * mp)
3201 vat_main_t *vam = &vat_main;
3203 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3204 print (vam->ofp, "%v", line);
3209 vl_api_one_eid_table_vni_details_t_handler_json
3210 (vl_api_one_eid_table_vni_details_t * mp)
3212 vat_main_t *vam = &vat_main;
3213 vat_json_node_t *node = NULL;
3215 if (VAT_JSON_ARRAY != vam->json_tree.type)
3217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3218 vat_json_init_array (&vam->json_tree);
3220 node = vat_json_array_add (&vam->json_tree);
3221 vat_json_init_object (node);
3222 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3226 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3227 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3229 vat_main_t *vam = &vat_main;
3230 int retval = clib_net_to_host_u32 (mp->retval);
3232 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3233 print (vam->ofp, "fallback threshold value: %d", mp->value);
3235 vam->retval = retval;
3236 vam->result_ready = 1;
3240 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3241 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t _node, *node = &_node;
3245 int retval = clib_net_to_host_u32 (mp->retval);
3247 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3248 vat_json_init_object (node);
3249 vat_json_object_add_uint (node, "value", mp->value);
3251 vat_json_print (vam->ofp, node);
3252 vat_json_free (node);
3254 vam->retval = retval;
3255 vam->result_ready = 1;
3259 vl_api_show_one_map_register_state_reply_t_handler
3260 (vl_api_show_one_map_register_state_reply_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 int retval = clib_net_to_host_u32 (mp->retval);
3265 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3267 vam->retval = retval;
3268 vam->result_ready = 1;
3272 vl_api_show_one_map_register_state_reply_t_handler_json
3273 (vl_api_show_one_map_register_state_reply_t * mp)
3275 vat_main_t *vam = &vat_main;
3276 vat_json_node_t _node, *node = &_node;
3277 int retval = clib_net_to_host_u32 (mp->retval);
3279 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3281 vat_json_init_object (node);
3282 vat_json_object_add_string_copy (node, "state", s);
3284 vat_json_print (vam->ofp, node);
3285 vat_json_free (node);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3293 vl_api_show_one_rloc_probe_state_reply_t_handler
3294 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3304 vam->retval = retval;
3305 vam->result_ready = 1;
3309 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3310 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 vat_json_node_t _node, *node = &_node;
3314 int retval = clib_net_to_host_u32 (mp->retval);
3316 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3317 vat_json_init_object (node);
3318 vat_json_object_add_string_copy (node, "state", s);
3320 vat_json_print (vam->ofp, node);
3321 vat_json_free (node);
3323 vam->retval = retval;
3324 vam->result_ready = 1;
3329 vl_api_show_one_stats_enable_disable_reply_t_handler
3330 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3332 vat_main_t *vam = &vat_main;
3333 int retval = clib_net_to_host_u32 (mp->retval);
3338 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3340 vam->retval = retval;
3341 vam->result_ready = 1;
3345 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3346 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3348 vat_main_t *vam = &vat_main;
3349 vat_json_node_t _node, *node = &_node;
3350 int retval = clib_net_to_host_u32 (mp->retval);
3352 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3353 vat_json_init_object (node);
3354 vat_json_object_add_string_copy (node, "state", s);
3356 vat_json_print (vam->ofp, node);
3357 vat_json_free (node);
3359 vam->retval = retval;
3360 vam->result_ready = 1;
3365 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3367 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3368 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3369 e->vni = clib_net_to_host_u32 (e->vni);
3373 gpe_fwd_entries_get_reply_t_net_to_host
3374 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3378 mp->count = clib_net_to_host_u32 (mp->count);
3379 for (i = 0; i < mp->count; i++)
3381 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3386 format_gpe_encap_mode (u8 * s, va_list * args)
3388 u32 mode = va_arg (*args, u32);
3393 return format (s, "lisp");
3395 return format (s, "vxlan");
3401 vl_api_gpe_get_encap_mode_reply_t_handler
3402 (vl_api_gpe_get_encap_mode_reply_t * mp)
3404 vat_main_t *vam = &vat_main;
3406 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3407 vam->retval = ntohl (mp->retval);
3408 vam->result_ready = 1;
3412 vl_api_gpe_get_encap_mode_reply_t_handler_json
3413 (vl_api_gpe_get_encap_mode_reply_t * mp)
3415 vat_main_t *vam = &vat_main;
3416 vat_json_node_t node;
3418 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3419 vec_add1 (encap_mode, 0);
3421 vat_json_init_object (&node);
3422 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3424 vec_free (encap_mode);
3425 vat_json_print (vam->ofp, &node);
3426 vat_json_free (&node);
3428 vam->retval = ntohl (mp->retval);
3429 vam->result_ready = 1;
3433 vl_api_gpe_fwd_entry_path_details_t_handler
3434 (vl_api_gpe_fwd_entry_path_details_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3439 if (mp->lcl_loc.is_ip4)
3440 format_ip_address_fcn = format_ip4_address;
3442 format_ip_address_fcn = format_ip6_address;
3444 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3445 format_ip_address_fcn, &mp->lcl_loc,
3446 format_ip_address_fcn, &mp->rmt_loc);
3450 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3452 struct in6_addr ip6;
3457 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3458 vat_json_object_add_ip4 (n, "address", ip4);
3462 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3463 vat_json_object_add_ip6 (n, "address", ip6);
3465 vat_json_object_add_uint (n, "weight", loc->weight);
3469 vl_api_gpe_fwd_entry_path_details_t_handler_json
3470 (vl_api_gpe_fwd_entry_path_details_t * mp)
3472 vat_main_t *vam = &vat_main;
3473 vat_json_node_t *node = NULL;
3474 vat_json_node_t *loc_node;
3476 if (VAT_JSON_ARRAY != vam->json_tree.type)
3478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3479 vat_json_init_array (&vam->json_tree);
3481 node = vat_json_array_add (&vam->json_tree);
3482 vat_json_init_object (node);
3484 loc_node = vat_json_object_add (node, "local_locator");
3485 vat_json_init_object (loc_node);
3486 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3488 loc_node = vat_json_object_add (node, "remote_locator");
3489 vat_json_init_object (loc_node);
3490 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3494 vl_api_gpe_fwd_entries_get_reply_t_handler
3495 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3497 vat_main_t *vam = &vat_main;
3499 int retval = clib_net_to_host_u32 (mp->retval);
3500 vl_api_gpe_fwd_entry_t *e;
3505 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3507 for (i = 0; i < mp->count; i++)
3509 e = &mp->entries[i];
3510 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3511 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3512 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3516 vam->retval = retval;
3517 vam->result_ready = 1;
3521 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3522 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3525 vat_main_t *vam = &vat_main;
3526 vat_json_node_t *e = 0, root;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *fwd;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3535 vat_json_init_array (&root);
3537 for (i = 0; i < mp->count; i++)
3539 e = vat_json_array_add (&root);
3540 fwd = &mp->entries[i];
3542 vat_json_init_object (e);
3543 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3544 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3545 vat_json_object_add_int (e, "vni", fwd->vni);
3546 vat_json_object_add_int (e, "action", fwd->action);
3548 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3549 fwd->leid_prefix_len);
3551 vat_json_object_add_string_copy (e, "leid", s);
3554 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3555 fwd->reid_prefix_len);
3557 vat_json_object_add_string_copy (e, "reid", s);
3561 vat_json_print (vam->ofp, &root);
3562 vat_json_free (&root);
3565 vam->retval = retval;
3566 vam->result_ready = 1;
3570 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3571 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3573 vat_main_t *vam = &vat_main;
3575 int retval = clib_net_to_host_u32 (mp->retval);
3576 vl_api_gpe_native_fwd_rpath_t *r;
3581 n = clib_net_to_host_u32 (mp->count);
3583 for (i = 0; i < n; i++)
3585 r = &mp->entries[i];
3586 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3587 clib_net_to_host_u32 (r->fib_index),
3588 clib_net_to_host_u32 (r->nh_sw_if_index),
3589 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3593 vam->retval = retval;
3594 vam->result_ready = 1;
3598 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3599 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3601 vat_main_t *vam = &vat_main;
3602 vat_json_node_t root, *e;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3611 n = clib_net_to_host_u32 (mp->count);
3612 vat_json_init_array (&root);
3614 for (i = 0; i < n; i++)
3616 e = vat_json_array_add (&root);
3617 vat_json_init_object (e);
3618 r = &mp->entries[i];
3620 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3623 vat_json_object_add_string_copy (e, "ip4", s);
3626 vat_json_object_add_uint (e, "fib_index",
3627 clib_net_to_host_u32 (r->fib_index));
3628 vat_json_object_add_uint (e, "nh_sw_if_index",
3629 clib_net_to_host_u32 (r->nh_sw_if_index));
3632 vat_json_print (vam->ofp, &root);
3633 vat_json_free (&root);
3636 vam->retval = retval;
3637 vam->result_ready = 1;
3641 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3642 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3644 vat_main_t *vam = &vat_main;
3646 int retval = clib_net_to_host_u32 (mp->retval);
3651 n = clib_net_to_host_u32 (mp->count);
3653 for (i = 0; i < n; i++)
3654 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3657 vam->retval = retval;
3658 vam->result_ready = 1;
3662 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3663 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3665 vat_main_t *vam = &vat_main;
3666 vat_json_node_t root;
3668 int retval = clib_net_to_host_u32 (mp->retval);
3673 n = clib_net_to_host_u32 (mp->count);
3674 vat_json_init_array (&root);
3676 for (i = 0; i < n; i++)
3677 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3679 vat_json_print (vam->ofp, &root);
3680 vat_json_free (&root);
3683 vam->retval = retval;
3684 vam->result_ready = 1;
3688 vl_api_one_ndp_entries_get_reply_t_handler
3689 (vl_api_one_ndp_entries_get_reply_t * mp)
3691 vat_main_t *vam = &vat_main;
3693 int retval = clib_net_to_host_u32 (mp->retval);
3698 n = clib_net_to_host_u32 (mp->count);
3700 for (i = 0; i < n; i++)
3701 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3702 format_ethernet_address, mp->entries[i].mac);
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3710 vl_api_one_ndp_entries_get_reply_t_handler_json
3711 (vl_api_one_ndp_entries_get_reply_t * mp)
3714 vat_main_t *vam = &vat_main;
3715 vat_json_node_t *e = 0, root;
3717 int retval = clib_net_to_host_u32 (mp->retval);
3718 vl_api_one_ndp_entry_t *arp_entry;
3723 n = clib_net_to_host_u32 (mp->count);
3724 vat_json_init_array (&root);
3726 for (i = 0; i < n; i++)
3728 e = vat_json_array_add (&root);
3729 arp_entry = &mp->entries[i];
3731 vat_json_init_object (e);
3732 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3735 vat_json_object_add_string_copy (e, "mac", s);
3738 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3740 vat_json_object_add_string_copy (e, "ip6", s);
3744 vat_json_print (vam->ofp, &root);
3745 vat_json_free (&root);
3748 vam->retval = retval;
3749 vam->result_ready = 1;
3753 vl_api_one_l2_arp_entries_get_reply_t_handler
3754 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3756 vat_main_t *vam = &vat_main;
3758 int retval = clib_net_to_host_u32 (mp->retval);
3763 n = clib_net_to_host_u32 (mp->count);
3765 for (i = 0; i < n; i++)
3766 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3767 format_ethernet_address, mp->entries[i].mac);
3770 vam->retval = retval;
3771 vam->result_ready = 1;
3775 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3776 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3779 vat_main_t *vam = &vat_main;
3780 vat_json_node_t *e = 0, root;
3782 int retval = clib_net_to_host_u32 (mp->retval);
3783 vl_api_one_l2_arp_entry_t *arp_entry;
3788 n = clib_net_to_host_u32 (mp->count);
3789 vat_json_init_array (&root);
3791 for (i = 0; i < n; i++)
3793 e = vat_json_array_add (&root);
3794 arp_entry = &mp->entries[i];
3796 vat_json_init_object (e);
3797 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3800 vat_json_object_add_string_copy (e, "mac", s);
3803 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3805 vat_json_object_add_string_copy (e, "ip4", s);
3809 vat_json_print (vam->ofp, &root);
3810 vat_json_free (&root);
3813 vam->retval = retval;
3814 vam->result_ready = 1;
3818 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3820 vat_main_t *vam = &vat_main;
3822 int retval = clib_net_to_host_u32 (mp->retval);
3827 n = clib_net_to_host_u32 (mp->count);
3829 for (i = 0; i < n; i++)
3831 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3835 vam->retval = retval;
3836 vam->result_ready = 1;
3840 vl_api_one_ndp_bd_get_reply_t_handler_json
3841 (vl_api_one_ndp_bd_get_reply_t * mp)
3843 vat_main_t *vam = &vat_main;
3844 vat_json_node_t root;
3846 int retval = clib_net_to_host_u32 (mp->retval);
3851 n = clib_net_to_host_u32 (mp->count);
3852 vat_json_init_array (&root);
3854 for (i = 0; i < n; i++)
3856 vat_json_array_add_uint (&root,
3857 clib_net_to_host_u32 (mp->bridge_domains[i]));
3860 vat_json_print (vam->ofp, &root);
3861 vat_json_free (&root);
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_l2_arp_bd_get_reply_t_handler
3870 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3874 int retval = clib_net_to_host_u32 (mp->retval);
3879 n = clib_net_to_host_u32 (mp->count);
3881 for (i = 0; i < n; i++)
3883 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3887 vam->retval = retval;
3888 vam->result_ready = 1;
3892 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3893 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3895 vat_main_t *vam = &vat_main;
3896 vat_json_node_t root;
3898 int retval = clib_net_to_host_u32 (mp->retval);
3903 n = clib_net_to_host_u32 (mp->count);
3904 vat_json_init_array (&root);
3906 for (i = 0; i < n; i++)
3908 vat_json_array_add_uint (&root,
3909 clib_net_to_host_u32 (mp->bridge_domains[i]));
3912 vat_json_print (vam->ofp, &root);
3913 vat_json_free (&root);
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_adjacencies_get_reply_t_handler
3922 (vl_api_one_adjacencies_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3926 int retval = clib_net_to_host_u32 (mp->retval);
3927 vl_api_one_adjacency_t *a;
3932 n = clib_net_to_host_u32 (mp->count);
3934 for (i = 0; i < n; i++)
3936 a = &mp->adjacencies[i];
3937 print (vam->ofp, "%U %40U",
3938 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3939 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3943 vam->retval = retval;
3944 vam->result_ready = 1;
3948 vl_api_one_adjacencies_get_reply_t_handler_json
3949 (vl_api_one_adjacencies_get_reply_t * mp)
3952 vat_main_t *vam = &vat_main;
3953 vat_json_node_t *e = 0, root;
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);
3962 vat_json_init_array (&root);
3964 for (i = 0; i < n; i++)
3966 e = vat_json_array_add (&root);
3967 a = &mp->adjacencies[i];
3969 vat_json_init_object (e);
3970 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3971 a->leid_prefix_len);
3973 vat_json_object_add_string_copy (e, "leid", s);
3976 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3977 a->reid_prefix_len);
3979 vat_json_object_add_string_copy (e, "reid", s);
3983 vat_json_print (vam->ofp, &root);
3984 vat_json_free (&root);
3987 vam->retval = retval;
3988 vam->result_ready = 1;
3992 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3994 vat_main_t *vam = &vat_main;
3996 print (vam->ofp, "%=20U",
3997 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4002 vl_api_one_map_server_details_t_handler_json
4003 (vl_api_one_map_server_details_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t *node = NULL;
4007 struct in6_addr ip6;
4010 if (VAT_JSON_ARRAY != vam->json_tree.type)
4012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4013 vat_json_init_array (&vam->json_tree);
4015 node = vat_json_array_add (&vam->json_tree);
4017 vat_json_init_object (node);
4020 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4021 vat_json_object_add_ip6 (node, "map-server", ip6);
4025 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4026 vat_json_object_add_ip4 (node, "map-server", ip4);
4031 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4034 vat_main_t *vam = &vat_main;
4036 print (vam->ofp, "%=20U",
4037 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4042 vl_api_one_map_resolver_details_t_handler_json
4043 (vl_api_one_map_resolver_details_t * mp)
4045 vat_main_t *vam = &vat_main;
4046 vat_json_node_t *node = NULL;
4047 struct in6_addr ip6;
4050 if (VAT_JSON_ARRAY != vam->json_tree.type)
4052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4053 vat_json_init_array (&vam->json_tree);
4055 node = vat_json_array_add (&vam->json_tree);
4057 vat_json_init_object (node);
4060 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4061 vat_json_object_add_ip6 (node, "map resolver", ip6);
4065 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4066 vat_json_object_add_ip4 (node, "map resolver", ip4);
4071 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4073 vat_main_t *vam = &vat_main;
4074 i32 retval = ntohl (mp->retval);
4078 print (vam->ofp, "feature: %s\ngpe: %s",
4079 mp->feature_status ? "enabled" : "disabled",
4080 mp->gpe_status ? "enabled" : "disabled");
4083 vam->retval = retval;
4084 vam->result_ready = 1;
4088 vl_api_show_one_status_reply_t_handler_json
4089 (vl_api_show_one_status_reply_t * mp)
4091 vat_main_t *vam = &vat_main;
4092 vat_json_node_t node;
4093 u8 *gpe_status = NULL;
4094 u8 *feature_status = NULL;
4096 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4097 feature_status = format (0, "%s",
4098 mp->feature_status ? "enabled" : "disabled");
4099 vec_add1 (gpe_status, 0);
4100 vec_add1 (feature_status, 0);
4102 vat_json_init_object (&node);
4103 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4104 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4106 vec_free (gpe_status);
4107 vec_free (feature_status);
4109 vat_json_print (vam->ofp, &node);
4110 vat_json_free (&node);
4112 vam->retval = ntohl (mp->retval);
4113 vam->result_ready = 1;
4117 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4118 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 i32 retval = ntohl (mp->retval);
4125 print (vam->ofp, "%=20s", mp->locator_set_name);
4128 vam->retval = retval;
4129 vam->result_ready = 1;
4133 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4134 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4136 vat_main_t *vam = &vat_main;
4137 vat_json_node_t *node = NULL;
4139 if (VAT_JSON_ARRAY != vam->json_tree.type)
4141 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4142 vat_json_init_array (&vam->json_tree);
4144 node = vat_json_array_add (&vam->json_tree);
4146 vat_json_init_object (node);
4147 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4149 vat_json_print (vam->ofp, node);
4150 vat_json_free (node);
4152 vam->retval = ntohl (mp->retval);
4153 vam->result_ready = 1;
4157 format_lisp_map_request_mode (u8 * s, va_list * args)
4159 u32 mode = va_arg (*args, u32);
4164 return format (0, "dst-only");
4166 return format (0, "src-dst");
4172 vl_api_show_one_map_request_mode_reply_t_handler
4173 (vl_api_show_one_map_request_mode_reply_t * mp)
4175 vat_main_t *vam = &vat_main;
4176 i32 retval = ntohl (mp->retval);
4180 u32 mode = mp->mode;
4181 print (vam->ofp, "map_request_mode: %U",
4182 format_lisp_map_request_mode, mode);
4185 vam->retval = retval;
4186 vam->result_ready = 1;
4190 vl_api_show_one_map_request_mode_reply_t_handler_json
4191 (vl_api_show_one_map_request_mode_reply_t * mp)
4193 vat_main_t *vam = &vat_main;
4194 vat_json_node_t node;
4199 s = format (0, "%U", format_lisp_map_request_mode, mode);
4202 vat_json_init_object (&node);
4203 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4204 vat_json_print (vam->ofp, &node);
4205 vat_json_free (&node);
4208 vam->retval = ntohl (mp->retval);
4209 vam->result_ready = 1;
4213 vl_api_show_one_use_petr_reply_t_handler
4214 (vl_api_show_one_use_petr_reply_t * mp)
4216 vat_main_t *vam = &vat_main;
4217 i32 retval = ntohl (mp->retval);
4221 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4224 print (vam->ofp, "Proxy-ETR address; %U",
4225 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4230 vam->retval = retval;
4231 vam->result_ready = 1;
4235 vl_api_show_one_use_petr_reply_t_handler_json
4236 (vl_api_show_one_use_petr_reply_t * mp)
4238 vat_main_t *vam = &vat_main;
4239 vat_json_node_t node;
4242 struct in6_addr ip6;
4244 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4245 vec_add1 (status, 0);
4247 vat_json_init_object (&node);
4248 vat_json_object_add_string_copy (&node, "status", status);
4253 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4254 vat_json_object_add_ip6 (&node, "address", ip6);
4258 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4259 vat_json_object_add_ip4 (&node, "address", ip4);
4265 vat_json_print (vam->ofp, &node);
4266 vat_json_free (&node);
4268 vam->retval = ntohl (mp->retval);
4269 vam->result_ready = 1;
4273 vl_api_show_one_nsh_mapping_reply_t_handler
4274 (vl_api_show_one_nsh_mapping_reply_t * mp)
4276 vat_main_t *vam = &vat_main;
4277 i32 retval = ntohl (mp->retval);
4281 print (vam->ofp, "%-20s%-16s",
4282 mp->is_set ? "set" : "not-set",
4283 mp->is_set ? (char *) mp->locator_set_name : "");
4286 vam->retval = retval;
4287 vam->result_ready = 1;
4291 vl_api_show_one_nsh_mapping_reply_t_handler_json
4292 (vl_api_show_one_nsh_mapping_reply_t * mp)
4294 vat_main_t *vam = &vat_main;
4295 vat_json_node_t node;
4298 status = format (0, "%s", mp->is_set ? "yes" : "no");
4299 vec_add1 (status, 0);
4301 vat_json_init_object (&node);
4302 vat_json_object_add_string_copy (&node, "is_set", status);
4305 vat_json_object_add_string_copy (&node, "locator_set",
4306 mp->locator_set_name);
4311 vat_json_print (vam->ofp, &node);
4312 vat_json_free (&node);
4314 vam->retval = ntohl (mp->retval);
4315 vam->result_ready = 1;
4319 vl_api_show_one_map_register_ttl_reply_t_handler
4320 (vl_api_show_one_map_register_ttl_reply_t * mp)
4322 vat_main_t *vam = &vat_main;
4323 i32 retval = ntohl (mp->retval);
4325 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4329 print (vam->ofp, "ttl: %u", mp->ttl);
4332 vam->retval = retval;
4333 vam->result_ready = 1;
4337 vl_api_show_one_map_register_ttl_reply_t_handler_json
4338 (vl_api_show_one_map_register_ttl_reply_t * mp)
4340 vat_main_t *vam = &vat_main;
4341 vat_json_node_t node;
4343 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4344 vat_json_init_object (&node);
4345 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4347 vat_json_print (vam->ofp, &node);
4348 vat_json_free (&node);
4350 vam->retval = ntohl (mp->retval);
4351 vam->result_ready = 1;
4355 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4357 vat_main_t *vam = &vat_main;
4358 i32 retval = ntohl (mp->retval);
4362 print (vam->ofp, "%-20s%-16s",
4363 mp->status ? "enabled" : "disabled",
4364 mp->status ? (char *) mp->locator_set_name : "");
4367 vam->retval = retval;
4368 vam->result_ready = 1;
4372 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4374 vat_main_t *vam = &vat_main;
4375 vat_json_node_t node;
4378 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4379 vec_add1 (status, 0);
4381 vat_json_init_object (&node);
4382 vat_json_object_add_string_copy (&node, "status", status);
4385 vat_json_object_add_string_copy (&node, "locator_set",
4386 mp->locator_set_name);
4391 vat_json_print (vam->ofp, &node);
4392 vat_json_free (&node);
4394 vam->retval = ntohl (mp->retval);
4395 vam->result_ready = 1;
4399 format_policer_type (u8 * s, va_list * va)
4401 u32 i = va_arg (*va, u32);
4403 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4404 s = format (s, "1r2c");
4405 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4406 s = format (s, "1r3c");
4407 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4408 s = format (s, "2r3c-2698");
4409 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4410 s = format (s, "2r3c-4115");
4411 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4412 s = format (s, "2r3c-mef5cf1");
4414 s = format (s, "ILLEGAL");
4419 format_policer_rate_type (u8 * s, va_list * va)
4421 u32 i = va_arg (*va, u32);
4423 if (i == SSE2_QOS_RATE_KBPS)
4424 s = format (s, "kbps");
4425 else if (i == SSE2_QOS_RATE_PPS)
4426 s = format (s, "pps");
4428 s = format (s, "ILLEGAL");
4433 format_policer_round_type (u8 * s, va_list * va)
4435 u32 i = va_arg (*va, u32);
4437 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4438 s = format (s, "closest");
4439 else if (i == SSE2_QOS_ROUND_TO_UP)
4440 s = format (s, "up");
4441 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4442 s = format (s, "down");
4444 s = format (s, "ILLEGAL");
4449 format_policer_action_type (u8 * s, va_list * va)
4451 u32 i = va_arg (*va, u32);
4453 if (i == SSE2_QOS_ACTION_DROP)
4454 s = format (s, "drop");
4455 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4456 s = format (s, "transmit");
4457 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4458 s = format (s, "mark-and-transmit");
4460 s = format (s, "ILLEGAL");
4465 format_dscp (u8 * s, va_list * va)
4467 u32 i = va_arg (*va, u32);
4472 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4476 return format (s, "ILLEGAL");
4478 s = format (s, "%s", t);
4483 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4485 vat_main_t *vam = &vat_main;
4486 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4488 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4489 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4491 conform_dscp_str = format (0, "");
4493 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4494 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4496 exceed_dscp_str = format (0, "");
4498 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4499 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4501 violate_dscp_str = format (0, "");
4503 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4504 "rate type %U, round type %U, %s rate, %s color-aware, "
4505 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4506 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4507 "conform action %U%s, exceed action %U%s, violate action %U%s",
4509 format_policer_type, mp->type,
4512 clib_net_to_host_u64 (mp->cb),
4513 clib_net_to_host_u64 (mp->eb),
4514 format_policer_rate_type, mp->rate_type,
4515 format_policer_round_type, mp->round_type,
4516 mp->single_rate ? "single" : "dual",
4517 mp->color_aware ? "is" : "not",
4518 ntohl (mp->cir_tokens_per_period),
4519 ntohl (mp->pir_tokens_per_period),
4521 ntohl (mp->current_limit),
4522 ntohl (mp->current_bucket),
4523 ntohl (mp->extended_limit),
4524 ntohl (mp->extended_bucket),
4525 clib_net_to_host_u64 (mp->last_update_time),
4526 format_policer_action_type, mp->conform_action_type,
4528 format_policer_action_type, mp->exceed_action_type,
4530 format_policer_action_type, mp->violate_action_type,
4533 vec_free (conform_dscp_str);
4534 vec_free (exceed_dscp_str);
4535 vec_free (violate_dscp_str);
4538 static void vl_api_policer_details_t_handler_json
4539 (vl_api_policer_details_t * mp)
4541 vat_main_t *vam = &vat_main;
4542 vat_json_node_t *node;
4543 u8 *rate_type_str, *round_type_str, *type_str;
4544 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4546 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4548 format (0, "%U", format_policer_round_type, mp->round_type);
4549 type_str = format (0, "%U", format_policer_type, mp->type);
4550 conform_action_str = format (0, "%U", format_policer_action_type,
4551 mp->conform_action_type);
4552 exceed_action_str = format (0, "%U", format_policer_action_type,
4553 mp->exceed_action_type);
4554 violate_action_str = format (0, "%U", format_policer_action_type,
4555 mp->violate_action_type);
4557 if (VAT_JSON_ARRAY != vam->json_tree.type)
4559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4560 vat_json_init_array (&vam->json_tree);
4562 node = vat_json_array_add (&vam->json_tree);
4564 vat_json_init_object (node);
4565 vat_json_object_add_string_copy (node, "name", mp->name);
4566 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4567 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4568 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4569 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4570 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4571 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4572 vat_json_object_add_string_copy (node, "type", type_str);
4573 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4574 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4575 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4576 vat_json_object_add_uint (node, "cir_tokens_per_period",
4577 ntohl (mp->cir_tokens_per_period));
4578 vat_json_object_add_uint (node, "eir_tokens_per_period",
4579 ntohl (mp->pir_tokens_per_period));
4580 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4581 vat_json_object_add_uint (node, "current_bucket",
4582 ntohl (mp->current_bucket));
4583 vat_json_object_add_uint (node, "extended_limit",
4584 ntohl (mp->extended_limit));
4585 vat_json_object_add_uint (node, "extended_bucket",
4586 ntohl (mp->extended_bucket));
4587 vat_json_object_add_uint (node, "last_update_time",
4588 ntohl (mp->last_update_time));
4589 vat_json_object_add_string_copy (node, "conform_action",
4590 conform_action_str);
4591 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4593 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4594 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4595 vec_free (dscp_str);
4597 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4598 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4600 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4601 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4602 vec_free (dscp_str);
4604 vat_json_object_add_string_copy (node, "violate_action",
4605 violate_action_str);
4606 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4608 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4609 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4610 vec_free (dscp_str);
4613 vec_free (rate_type_str);
4614 vec_free (round_type_str);
4615 vec_free (type_str);
4616 vec_free (conform_action_str);
4617 vec_free (exceed_action_str);
4618 vec_free (violate_action_str);
4622 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4625 vat_main_t *vam = &vat_main;
4626 int i, count = ntohl (mp->count);
4629 print (vam->ofp, "classify table ids (%d) : ", count);
4630 for (i = 0; i < count; i++)
4632 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4633 print (vam->ofp, (i < count - 1) ? "," : "");
4635 vam->retval = ntohl (mp->retval);
4636 vam->result_ready = 1;
4640 vl_api_classify_table_ids_reply_t_handler_json
4641 (vl_api_classify_table_ids_reply_t * mp)
4643 vat_main_t *vam = &vat_main;
4644 int i, count = ntohl (mp->count);
4648 vat_json_node_t node;
4650 vat_json_init_object (&node);
4651 for (i = 0; i < count; i++)
4653 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4655 vat_json_print (vam->ofp, &node);
4656 vat_json_free (&node);
4658 vam->retval = ntohl (mp->retval);
4659 vam->result_ready = 1;
4663 vl_api_classify_table_by_interface_reply_t_handler
4664 (vl_api_classify_table_by_interface_reply_t * mp)
4666 vat_main_t *vam = &vat_main;
4669 table_id = ntohl (mp->l2_table_id);
4671 print (vam->ofp, "l2 table id : %d", table_id);
4673 print (vam->ofp, "l2 table id : No input ACL tables configured");
4674 table_id = ntohl (mp->ip4_table_id);
4676 print (vam->ofp, "ip4 table id : %d", table_id);
4678 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4679 table_id = ntohl (mp->ip6_table_id);
4681 print (vam->ofp, "ip6 table id : %d", table_id);
4683 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4684 vam->retval = ntohl (mp->retval);
4685 vam->result_ready = 1;
4689 vl_api_classify_table_by_interface_reply_t_handler_json
4690 (vl_api_classify_table_by_interface_reply_t * mp)
4692 vat_main_t *vam = &vat_main;
4693 vat_json_node_t node;
4695 vat_json_init_object (&node);
4697 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4698 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4699 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4701 vat_json_print (vam->ofp, &node);
4702 vat_json_free (&node);
4704 vam->retval = ntohl (mp->retval);
4705 vam->result_ready = 1;
4708 static void vl_api_policer_add_del_reply_t_handler
4709 (vl_api_policer_add_del_reply_t * mp)
4711 vat_main_t *vam = &vat_main;
4712 i32 retval = ntohl (mp->retval);
4713 if (vam->async_mode)
4715 vam->async_errors += (retval < 0);
4719 vam->retval = retval;
4720 vam->result_ready = 1;
4721 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4723 * Note: this is just barely thread-safe, depends on
4724 * the main thread spinning waiting for an answer...
4726 errmsg ("policer index %d", ntohl (mp->policer_index));
4730 static void vl_api_policer_add_del_reply_t_handler_json
4731 (vl_api_policer_add_del_reply_t * mp)
4733 vat_main_t *vam = &vat_main;
4734 vat_json_node_t node;
4736 vat_json_init_object (&node);
4737 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4738 vat_json_object_add_uint (&node, "policer_index",
4739 ntohl (mp->policer_index));
4741 vat_json_print (vam->ofp, &node);
4742 vat_json_free (&node);
4744 vam->retval = ntohl (mp->retval);
4745 vam->result_ready = 1;
4748 /* Format hex dump. */
4750 format_hex_bytes (u8 * s, va_list * va)
4752 u8 *bytes = va_arg (*va, u8 *);
4753 int n_bytes = va_arg (*va, int);
4756 /* Print short or long form depending on byte count. */
4757 uword short_form = n_bytes <= 32;
4758 u32 indent = format_get_indent (s);
4763 for (i = 0; i < n_bytes; i++)
4765 if (!short_form && (i % 32) == 0)
4766 s = format (s, "%08x: ", i);
4767 s = format (s, "%02x", bytes[i]);
4768 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4769 s = format (s, "\n%U", format_white_space, indent);
4776 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4779 vat_main_t *vam = &vat_main;
4780 i32 retval = ntohl (mp->retval);
4783 print (vam->ofp, "classify table info :");
4784 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4785 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4786 ntohl (mp->miss_next_index));
4787 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4788 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4789 ntohl (mp->match_n_vectors));
4790 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4791 ntohl (mp->mask_length));
4793 vam->retval = retval;
4794 vam->result_ready = 1;
4798 vl_api_classify_table_info_reply_t_handler_json
4799 (vl_api_classify_table_info_reply_t * mp)
4801 vat_main_t *vam = &vat_main;
4802 vat_json_node_t node;
4804 i32 retval = ntohl (mp->retval);
4807 vat_json_init_object (&node);
4809 vat_json_object_add_int (&node, "sessions",
4810 ntohl (mp->active_sessions));
4811 vat_json_object_add_int (&node, "nexttbl",
4812 ntohl (mp->next_table_index));
4813 vat_json_object_add_int (&node, "nextnode",
4814 ntohl (mp->miss_next_index));
4815 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4816 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4817 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4818 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4819 ntohl (mp->mask_length), 0);
4820 vat_json_object_add_string_copy (&node, "mask", s);
4822 vat_json_print (vam->ofp, &node);
4823 vat_json_free (&node);
4825 vam->retval = ntohl (mp->retval);
4826 vam->result_ready = 1;
4830 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4833 vat_main_t *vam = &vat_main;
4835 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4836 ntohl (mp->hit_next_index), ntohl (mp->advance),
4837 ntohl (mp->opaque_index));
4838 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4839 ntohl (mp->match_length));
4843 vl_api_classify_session_details_t_handler_json
4844 (vl_api_classify_session_details_t * mp)
4846 vat_main_t *vam = &vat_main;
4847 vat_json_node_t *node = NULL;
4849 if (VAT_JSON_ARRAY != vam->json_tree.type)
4851 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4852 vat_json_init_array (&vam->json_tree);
4854 node = vat_json_array_add (&vam->json_tree);
4856 vat_json_init_object (node);
4857 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4858 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4859 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4861 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4863 vat_json_object_add_string_copy (node, "match", s);
4866 static void vl_api_pg_create_interface_reply_t_handler
4867 (vl_api_pg_create_interface_reply_t * mp)
4869 vat_main_t *vam = &vat_main;
4871 vam->retval = ntohl (mp->retval);
4872 vam->result_ready = 1;
4875 static void vl_api_pg_create_interface_reply_t_handler_json
4876 (vl_api_pg_create_interface_reply_t * mp)
4878 vat_main_t *vam = &vat_main;
4879 vat_json_node_t node;
4881 i32 retval = ntohl (mp->retval);
4884 vat_json_init_object (&node);
4886 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4888 vat_json_print (vam->ofp, &node);
4889 vat_json_free (&node);
4891 vam->retval = ntohl (mp->retval);
4892 vam->result_ready = 1;
4895 static void vl_api_policer_classify_details_t_handler
4896 (vl_api_policer_classify_details_t * mp)
4898 vat_main_t *vam = &vat_main;
4900 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4901 ntohl (mp->table_index));
4904 static void vl_api_policer_classify_details_t_handler_json
4905 (vl_api_policer_classify_details_t * mp)
4907 vat_main_t *vam = &vat_main;
4908 vat_json_node_t *node;
4910 if (VAT_JSON_ARRAY != vam->json_tree.type)
4912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4913 vat_json_init_array (&vam->json_tree);
4915 node = vat_json_array_add (&vam->json_tree);
4917 vat_json_init_object (node);
4918 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4919 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4922 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4923 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4925 vat_main_t *vam = &vat_main;
4926 i32 retval = ntohl (mp->retval);
4927 if (vam->async_mode)
4929 vam->async_errors += (retval < 0);
4933 vam->retval = retval;
4934 vam->sw_if_index = ntohl (mp->sw_if_index);
4935 vam->result_ready = 1;
4939 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4940 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4942 vat_main_t *vam = &vat_main;
4943 vat_json_node_t node;
4945 vat_json_init_object (&node);
4946 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4947 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4949 vat_json_print (vam->ofp, &node);
4950 vat_json_free (&node);
4952 vam->retval = ntohl (mp->retval);
4953 vam->result_ready = 1;
4956 static void vl_api_flow_classify_details_t_handler
4957 (vl_api_flow_classify_details_t * mp)
4959 vat_main_t *vam = &vat_main;
4961 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4962 ntohl (mp->table_index));
4965 static void vl_api_flow_classify_details_t_handler_json
4966 (vl_api_flow_classify_details_t * mp)
4968 vat_main_t *vam = &vat_main;
4969 vat_json_node_t *node;
4971 if (VAT_JSON_ARRAY != vam->json_tree.type)
4973 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4974 vat_json_init_array (&vam->json_tree);
4976 node = vat_json_array_add (&vam->json_tree);
4978 vat_json_init_object (node);
4979 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4980 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4983 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4984 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4985 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4986 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4987 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4988 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4989 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4990 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4991 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4992 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4993 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4994 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4995 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4996 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4997 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4998 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4999 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5000 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5001 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5002 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5003 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5004 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5007 * Generate boilerplate reply handlers, which
5008 * dig the return value out of the xxx_reply_t API message,
5009 * stick it into vam->retval, and set vam->result_ready
5011 * Could also do this by pointing N message decode slots at
5012 * a single function, but that could break in subtle ways.
5015 #define foreach_standard_reply_retval_handler \
5016 _(sw_interface_set_flags_reply) \
5017 _(sw_interface_add_del_address_reply) \
5018 _(sw_interface_set_table_reply) \
5019 _(sw_interface_set_mpls_enable_reply) \
5020 _(sw_interface_set_vpath_reply) \
5021 _(sw_interface_set_vxlan_bypass_reply) \
5022 _(sw_interface_set_geneve_bypass_reply) \
5023 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5024 _(sw_interface_set_l2_bridge_reply) \
5025 _(bridge_domain_add_del_reply) \
5026 _(sw_interface_set_l2_xconnect_reply) \
5027 _(l2fib_add_del_reply) \
5028 _(l2fib_flush_int_reply) \
5029 _(l2fib_flush_bd_reply) \
5030 _(ip_add_del_route_reply) \
5031 _(ip_table_add_del_reply) \
5032 _(ip_mroute_add_del_reply) \
5033 _(mpls_route_add_del_reply) \
5034 _(mpls_table_add_del_reply) \
5035 _(mpls_ip_bind_unbind_reply) \
5036 _(proxy_arp_add_del_reply) \
5037 _(proxy_arp_intfc_enable_disable_reply) \
5038 _(sw_interface_set_unnumbered_reply) \
5039 _(ip_neighbor_add_del_reply) \
5040 _(reset_vrf_reply) \
5041 _(oam_add_del_reply) \
5042 _(reset_fib_reply) \
5043 _(dhcp_proxy_config_reply) \
5044 _(dhcp_proxy_set_vss_reply) \
5045 _(dhcp_client_config_reply) \
5046 _(set_ip_flow_hash_reply) \
5047 _(sw_interface_ip6_enable_disable_reply) \
5048 _(sw_interface_ip6_set_link_local_address_reply) \
5049 _(ip6nd_proxy_add_del_reply) \
5050 _(sw_interface_ip6nd_ra_prefix_reply) \
5051 _(sw_interface_ip6nd_ra_config_reply) \
5052 _(set_arp_neighbor_limit_reply) \
5053 _(l2_patch_add_del_reply) \
5054 _(sr_policy_add_reply) \
5055 _(sr_policy_mod_reply) \
5056 _(sr_policy_del_reply) \
5057 _(sr_localsid_add_del_reply) \
5058 _(sr_steering_add_del_reply) \
5059 _(classify_add_del_session_reply) \
5060 _(classify_set_interface_ip_table_reply) \
5061 _(classify_set_interface_l2_tables_reply) \
5062 _(l2tpv3_set_tunnel_cookies_reply) \
5063 _(l2tpv3_interface_enable_disable_reply) \
5064 _(l2tpv3_set_lookup_key_reply) \
5065 _(l2_fib_clear_table_reply) \
5066 _(l2_interface_efp_filter_reply) \
5067 _(l2_interface_vlan_tag_rewrite_reply) \
5068 _(modify_vhost_user_if_reply) \
5069 _(delete_vhost_user_if_reply) \
5070 _(want_ip4_arp_events_reply) \
5071 _(want_ip6_nd_events_reply) \
5072 _(want_l2_macs_events_reply) \
5073 _(input_acl_set_interface_reply) \
5074 _(ipsec_spd_add_del_reply) \
5075 _(ipsec_interface_add_del_spd_reply) \
5076 _(ipsec_spd_add_del_entry_reply) \
5077 _(ipsec_sad_add_del_entry_reply) \
5078 _(ipsec_sa_set_key_reply) \
5079 _(ipsec_tunnel_if_add_del_reply) \
5080 _(ipsec_tunnel_if_set_key_reply) \
5081 _(ikev2_profile_add_del_reply) \
5082 _(ikev2_profile_set_auth_reply) \
5083 _(ikev2_profile_set_id_reply) \
5084 _(ikev2_profile_set_ts_reply) \
5085 _(ikev2_set_local_key_reply) \
5086 _(ikev2_set_responder_reply) \
5087 _(ikev2_set_ike_transforms_reply) \
5088 _(ikev2_set_esp_transforms_reply) \
5089 _(ikev2_set_sa_lifetime_reply) \
5090 _(ikev2_initiate_sa_init_reply) \
5091 _(ikev2_initiate_del_ike_sa_reply) \
5092 _(ikev2_initiate_del_child_sa_reply) \
5093 _(ikev2_initiate_rekey_child_sa_reply) \
5094 _(delete_loopback_reply) \
5095 _(bd_ip_mac_add_del_reply) \
5096 _(map_del_domain_reply) \
5097 _(map_add_del_rule_reply) \
5098 _(want_interface_events_reply) \
5099 _(want_stats_reply) \
5100 _(cop_interface_enable_disable_reply) \
5101 _(cop_whitelist_enable_disable_reply) \
5102 _(sw_interface_clear_stats_reply) \
5103 _(ioam_enable_reply) \
5104 _(ioam_disable_reply) \
5105 _(one_add_del_locator_reply) \
5106 _(one_add_del_local_eid_reply) \
5107 _(one_add_del_remote_mapping_reply) \
5108 _(one_add_del_adjacency_reply) \
5109 _(one_add_del_map_resolver_reply) \
5110 _(one_add_del_map_server_reply) \
5111 _(one_enable_disable_reply) \
5112 _(one_rloc_probe_enable_disable_reply) \
5113 _(one_map_register_enable_disable_reply) \
5114 _(one_map_register_set_ttl_reply) \
5115 _(one_set_transport_protocol_reply) \
5116 _(one_map_register_fallback_threshold_reply) \
5117 _(one_pitr_set_locator_set_reply) \
5118 _(one_map_request_mode_reply) \
5119 _(one_add_del_map_request_itr_rlocs_reply) \
5120 _(one_eid_table_add_del_map_reply) \
5121 _(one_use_petr_reply) \
5122 _(one_stats_enable_disable_reply) \
5123 _(one_add_del_l2_arp_entry_reply) \
5124 _(one_add_del_ndp_entry_reply) \
5125 _(one_stats_flush_reply) \
5126 _(gpe_enable_disable_reply) \
5127 _(gpe_set_encap_mode_reply) \
5128 _(gpe_add_del_iface_reply) \
5129 _(gpe_add_del_native_fwd_rpath_reply) \
5130 _(af_packet_delete_reply) \
5131 _(policer_classify_set_interface_reply) \
5132 _(netmap_create_reply) \
5133 _(netmap_delete_reply) \
5134 _(set_ipfix_exporter_reply) \
5135 _(set_ipfix_classify_stream_reply) \
5136 _(ipfix_classify_table_add_del_reply) \
5137 _(flow_classify_set_interface_reply) \
5138 _(sw_interface_span_enable_disable_reply) \
5139 _(pg_capture_reply) \
5140 _(pg_enable_disable_reply) \
5141 _(ip_source_and_port_range_check_add_del_reply) \
5142 _(ip_source_and_port_range_check_interface_add_del_reply)\
5143 _(delete_subif_reply) \
5144 _(l2_interface_pbb_tag_rewrite_reply) \
5146 _(feature_enable_disable_reply) \
5147 _(sw_interface_tag_add_del_reply) \
5148 _(sw_interface_set_mtu_reply) \
5149 _(p2p_ethernet_add_reply) \
5150 _(p2p_ethernet_del_reply) \
5151 _(lldp_config_reply) \
5152 _(sw_interface_set_lldp_reply) \
5153 _(tcp_configure_src_addresses_reply) \
5154 _(app_namespace_add_del_reply) \
5155 _(dns_enable_disable_reply) \
5156 _(dns_name_server_add_del_reply)
5159 static void vl_api_##n##_t_handler \
5160 (vl_api_##n##_t * mp) \
5162 vat_main_t * vam = &vat_main; \
5163 i32 retval = ntohl(mp->retval); \
5164 if (vam->async_mode) { \
5165 vam->async_errors += (retval < 0); \
5167 vam->retval = retval; \
5168 vam->result_ready = 1; \
5171 foreach_standard_reply_retval_handler;
5175 static void vl_api_##n##_t_handler_json \
5176 (vl_api_##n##_t * mp) \
5178 vat_main_t * vam = &vat_main; \
5179 vat_json_node_t node; \
5180 vat_json_init_object(&node); \
5181 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5182 vat_json_print(vam->ofp, &node); \
5183 vam->retval = ntohl(mp->retval); \
5184 vam->result_ready = 1; \
5186 foreach_standard_reply_retval_handler;
5190 * Table of message reply handlers, must include boilerplate handlers
5194 #define foreach_vpe_api_reply_msg \
5195 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5196 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5197 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5198 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5199 _(CONTROL_PING_REPLY, control_ping_reply) \
5200 _(CLI_REPLY, cli_reply) \
5201 _(CLI_INBAND_REPLY, cli_inband_reply) \
5202 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5203 sw_interface_add_del_address_reply) \
5204 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5205 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5206 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5207 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5208 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5209 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5210 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5211 sw_interface_set_l2_xconnect_reply) \
5212 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5213 sw_interface_set_l2_bridge_reply) \
5214 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5215 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5216 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5217 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5218 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5219 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5220 _(L2_FLAGS_REPLY, l2_flags_reply) \
5221 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5222 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5223 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5224 _(TAP_DELETE_REPLY, tap_delete_reply) \
5225 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5226 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5227 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5228 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5229 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5230 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5231 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5232 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5233 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5234 proxy_arp_intfc_enable_disable_reply) \
5235 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5236 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5237 sw_interface_set_unnumbered_reply) \
5238 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5239 _(RESET_VRF_REPLY, reset_vrf_reply) \
5240 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5241 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5242 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5243 _(RESET_FIB_REPLY, reset_fib_reply) \
5244 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5245 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5246 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5247 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5248 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5249 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5250 sw_interface_ip6_enable_disable_reply) \
5251 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5252 sw_interface_ip6_set_link_local_address_reply) \
5253 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5254 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5255 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5256 sw_interface_ip6nd_ra_prefix_reply) \
5257 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5258 sw_interface_ip6nd_ra_config_reply) \
5259 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5260 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5261 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5262 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5263 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5264 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5265 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5266 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5267 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5268 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5269 classify_set_interface_ip_table_reply) \
5270 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5271 classify_set_interface_l2_tables_reply) \
5272 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5273 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5274 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5275 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5276 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5277 l2tpv3_interface_enable_disable_reply) \
5278 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5279 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5280 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5281 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5282 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5283 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5284 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5285 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5286 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5287 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5288 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5289 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5290 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5291 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5292 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5293 _(SHOW_VERSION_REPLY, show_version_reply) \
5294 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5295 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5296 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5297 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5298 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5299 _(IP4_ARP_EVENT, ip4_arp_event) \
5300 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5301 _(IP6_ND_EVENT, ip6_nd_event) \
5302 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5303 _(L2_MACS_EVENT, l2_macs_event) \
5304 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5305 _(IP_ADDRESS_DETAILS, ip_address_details) \
5306 _(IP_DETAILS, ip_details) \
5307 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5308 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5309 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5310 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5311 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5312 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5313 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5314 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5315 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5316 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5317 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5318 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5319 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5320 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5321 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5322 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5323 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5324 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5325 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5326 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5327 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5328 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5329 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5330 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5331 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5332 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5333 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5334 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5335 _(MAP_RULE_DETAILS, map_rule_details) \
5336 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5337 _(WANT_STATS_REPLY, want_stats_reply) \
5338 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5339 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5340 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5341 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5342 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5343 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5344 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5345 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5346 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5347 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5348 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5349 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5350 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5351 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5352 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5353 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5354 one_map_register_enable_disable_reply) \
5355 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5356 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5357 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5358 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5359 one_map_register_fallback_threshold_reply) \
5360 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5361 one_rloc_probe_enable_disable_reply) \
5362 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5363 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5364 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5365 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5366 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5367 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5368 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5369 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5370 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5371 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5372 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5373 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5374 _(ONE_STATS_DETAILS, one_stats_details) \
5375 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5376 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5377 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5378 show_one_stats_enable_disable_reply) \
5379 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5380 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5381 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5382 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5383 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5384 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5385 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5386 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5387 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5388 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5389 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5390 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5391 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5392 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5393 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5394 gpe_add_del_native_fwd_rpath_reply) \
5395 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5396 gpe_fwd_entry_path_details) \
5397 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5398 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5399 one_add_del_map_request_itr_rlocs_reply) \
5400 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5401 one_get_map_request_itr_rlocs_reply) \
5402 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5403 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5404 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5405 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5406 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5407 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5408 show_one_map_register_state_reply) \
5409 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5410 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5411 show_one_map_register_fallback_threshold_reply) \
5412 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5413 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5414 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5415 _(POLICER_DETAILS, policer_details) \
5416 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5417 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5418 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5419 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5420 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5421 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5422 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5423 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5424 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5425 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5426 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5427 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5428 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5429 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5430 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5431 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5432 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5433 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5434 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5435 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5436 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5437 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5438 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5439 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5440 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5441 ip_source_and_port_range_check_add_del_reply) \
5442 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5443 ip_source_and_port_range_check_interface_add_del_reply) \
5444 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5445 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5446 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5447 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5448 _(PUNT_REPLY, punt_reply) \
5449 _(IP_FIB_DETAILS, ip_fib_details) \
5450 _(IP6_FIB_DETAILS, ip6_fib_details) \
5451 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5452 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5453 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5454 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5455 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5456 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5457 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5458 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5459 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5460 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5461 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5462 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5463 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5464 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5465 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)
5467 #define foreach_standalone_reply_msg \
5468 _(SW_INTERFACE_EVENT, sw_interface_event) \
5469 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5470 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5471 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5472 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5473 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5474 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5475 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5484 #define STR_VTR_OP_CASE(op) \
5485 case L2_VTR_ ## op: \
5489 str_vtr_op (u32 vtr_op)
5493 STR_VTR_OP_CASE (DISABLED);
5494 STR_VTR_OP_CASE (PUSH_1);
5495 STR_VTR_OP_CASE (PUSH_2);
5496 STR_VTR_OP_CASE (POP_1);
5497 STR_VTR_OP_CASE (POP_2);
5498 STR_VTR_OP_CASE (TRANSLATE_1_1);
5499 STR_VTR_OP_CASE (TRANSLATE_1_2);
5500 STR_VTR_OP_CASE (TRANSLATE_2_1);
5501 STR_VTR_OP_CASE (TRANSLATE_2_2);
5508 dump_sub_interface_table (vat_main_t * vam)
5510 const sw_interface_subif_t *sub = NULL;
5512 if (vam->json_output)
5515 ("JSON output supported only for VPE API calls and dump_stats_table");
5520 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5521 "Interface", "sw_if_index",
5522 "sub id", "dot1ad", "tags", "outer id",
5523 "inner id", "exact", "default", "outer any", "inner any");
5525 vec_foreach (sub, vam->sw_if_subif_table)
5528 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5529 sub->interface_name,
5531 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5532 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5533 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5534 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5535 if (sub->vtr_op != L2_VTR_DISABLED)
5538 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5539 "tag1: %d tag2: %d ]",
5540 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5541 sub->vtr_tag1, sub->vtr_tag2);
5549 name_sort_cmp (void *a1, void *a2)
5551 name_sort_t *n1 = a1;
5552 name_sort_t *n2 = a2;
5554 return strcmp ((char *) n1->name, (char *) n2->name);
5558 dump_interface_table (vat_main_t * vam)
5561 name_sort_t *nses = 0, *ns;
5563 if (vam->json_output)
5566 ("JSON output supported only for VPE API calls and dump_stats_table");
5571 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5573 vec_add2 (nses, ns, 1);
5574 ns->name = (u8 *)(p->key);
5575 ns->value = (u32) p->value[0];
5579 vec_sort_with_function (nses, name_sort_cmp);
5581 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5582 vec_foreach (ns, nses)
5584 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5591 dump_ip_table (vat_main_t * vam, int is_ipv6)
5593 const ip_details_t *det = NULL;
5594 const ip_address_details_t *address = NULL;
5597 print (vam->ofp, "%-12s", "sw_if_index");
5599 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5606 print (vam->ofp, "%-12d", i);
5607 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5612 vec_foreach (address, det->addr)
5616 is_ipv6 ? format_ip6_address : format_ip4_address,
5617 address->ip, address->prefix_length);
5625 dump_ipv4_table (vat_main_t * vam)
5627 if (vam->json_output)
5630 ("JSON output supported only for VPE API calls and dump_stats_table");
5634 return dump_ip_table (vam, 0);
5638 dump_ipv6_table (vat_main_t * vam)
5640 if (vam->json_output)
5643 ("JSON output supported only for VPE API calls and dump_stats_table");
5647 return dump_ip_table (vam, 1);
5651 counter_type_to_str (u8 counter_type, u8 is_combined)
5655 switch (counter_type)
5657 case VNET_INTERFACE_COUNTER_DROP:
5659 case VNET_INTERFACE_COUNTER_PUNT:
5661 case VNET_INTERFACE_COUNTER_IP4:
5663 case VNET_INTERFACE_COUNTER_IP6:
5665 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5667 case VNET_INTERFACE_COUNTER_RX_MISS:
5669 case VNET_INTERFACE_COUNTER_RX_ERROR:
5671 case VNET_INTERFACE_COUNTER_TX_ERROR:
5674 return "INVALID-COUNTER-TYPE";
5679 switch (counter_type)
5681 case VNET_INTERFACE_COUNTER_RX:
5683 case VNET_INTERFACE_COUNTER_TX:
5686 return "INVALID-COUNTER-TYPE";
5692 dump_stats_table (vat_main_t * vam)
5694 vat_json_node_t node;
5695 vat_json_node_t *msg_array;
5696 vat_json_node_t *msg;
5697 vat_json_node_t *counter_array;
5698 vat_json_node_t *counter;
5699 interface_counter_t c;
5701 ip4_fib_counter_t *c4;
5702 ip6_fib_counter_t *c6;
5703 ip4_nbr_counter_t *n4;
5704 ip6_nbr_counter_t *n6;
5707 if (!vam->json_output)
5709 clib_warning ("dump_stats_table supported only in JSON format");
5713 vat_json_init_object (&node);
5715 /* interface counters */
5716 msg_array = vat_json_object_add (&node, "interface_counters");
5717 vat_json_init_array (msg_array);
5718 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5720 msg = vat_json_array_add (msg_array);
5721 vat_json_init_object (msg);
5722 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5723 (u8 *) counter_type_to_str (i, 0));
5724 vat_json_object_add_int (msg, "is_combined", 0);
5725 counter_array = vat_json_object_add (msg, "data");
5726 vat_json_init_array (counter_array);
5727 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5729 packets = vam->simple_interface_counters[i][j];
5730 vat_json_array_add_uint (counter_array, packets);
5733 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5735 msg = vat_json_array_add (msg_array);
5736 vat_json_init_object (msg);
5737 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5738 (u8 *) counter_type_to_str (i, 1));
5739 vat_json_object_add_int (msg, "is_combined", 1);
5740 counter_array = vat_json_object_add (msg, "data");
5741 vat_json_init_array (counter_array);
5742 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5744 c = vam->combined_interface_counters[i][j];
5745 counter = vat_json_array_add (counter_array);
5746 vat_json_init_object (counter);
5747 vat_json_object_add_uint (counter, "packets", c.packets);
5748 vat_json_object_add_uint (counter, "bytes", c.bytes);
5752 /* ip4 fib counters */
5753 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5754 vat_json_init_array (msg_array);
5755 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5757 msg = vat_json_array_add (msg_array);
5758 vat_json_init_object (msg);
5759 vat_json_object_add_uint (msg, "vrf_id",
5760 vam->ip4_fib_counters_vrf_id_by_index[i]);
5761 counter_array = vat_json_object_add (msg, "c");
5762 vat_json_init_array (counter_array);
5763 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5765 counter = vat_json_array_add (counter_array);
5766 vat_json_init_object (counter);
5767 c4 = &vam->ip4_fib_counters[i][j];
5768 vat_json_object_add_ip4 (counter, "address", c4->address);
5769 vat_json_object_add_uint (counter, "address_length",
5770 c4->address_length);
5771 vat_json_object_add_uint (counter, "packets", c4->packets);
5772 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5776 /* ip6 fib counters */
5777 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5778 vat_json_init_array (msg_array);
5779 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5781 msg = vat_json_array_add (msg_array);
5782 vat_json_init_object (msg);
5783 vat_json_object_add_uint (msg, "vrf_id",
5784 vam->ip6_fib_counters_vrf_id_by_index[i]);
5785 counter_array = vat_json_object_add (msg, "c");
5786 vat_json_init_array (counter_array);
5787 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5789 counter = vat_json_array_add (counter_array);
5790 vat_json_init_object (counter);
5791 c6 = &vam->ip6_fib_counters[i][j];
5792 vat_json_object_add_ip6 (counter, "address", c6->address);
5793 vat_json_object_add_uint (counter, "address_length",
5794 c6->address_length);
5795 vat_json_object_add_uint (counter, "packets", c6->packets);
5796 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5800 /* ip4 nbr counters */
5801 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5802 vat_json_init_array (msg_array);
5803 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5805 msg = vat_json_array_add (msg_array);
5806 vat_json_init_object (msg);
5807 vat_json_object_add_uint (msg, "sw_if_index", i);
5808 counter_array = vat_json_object_add (msg, "c");
5809 vat_json_init_array (counter_array);
5810 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5812 counter = vat_json_array_add (counter_array);
5813 vat_json_init_object (counter);
5814 n4 = &vam->ip4_nbr_counters[i][j];
5815 vat_json_object_add_ip4 (counter, "address", n4->address);
5816 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5817 vat_json_object_add_uint (counter, "packets", n4->packets);
5818 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5822 /* ip6 nbr counters */
5823 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5824 vat_json_init_array (msg_array);
5825 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5827 msg = vat_json_array_add (msg_array);
5828 vat_json_init_object (msg);
5829 vat_json_object_add_uint (msg, "sw_if_index", i);
5830 counter_array = vat_json_object_add (msg, "c");
5831 vat_json_init_array (counter_array);
5832 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5834 counter = vat_json_array_add (counter_array);
5835 vat_json_init_object (counter);
5836 n6 = &vam->ip6_nbr_counters[i][j];
5837 vat_json_object_add_ip6 (counter, "address", n6->address);
5838 vat_json_object_add_uint (counter, "packets", n6->packets);
5839 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5843 vat_json_print (vam->ofp, &node);
5844 vat_json_free (&node);
5850 * Pass CLI buffers directly in the CLI_INBAND API message,
5851 * instead of an additional shared memory area.
5854 exec_inband (vat_main_t * vam)
5856 vl_api_cli_inband_t *mp;
5857 unformat_input_t *i = vam->input;
5860 if (vec_len (i->buffer) == 0)
5863 if (vam->exec_mode == 0 && unformat (i, "mode"))
5868 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5875 * In order for the CLI command to work, it
5876 * must be a vector ending in \n, not a C-string ending
5879 u32 len = vec_len (vam->input->buffer);
5880 M2 (CLI_INBAND, mp, len);
5881 clib_memcpy (mp->cmd, vam->input->buffer, len);
5882 mp->length = htonl (len);
5886 /* json responses may or may not include a useful reply... */
5887 if (vec_len (vam->cmd_reply))
5888 print (vam->ofp, (char *) (vam->cmd_reply));
5893 exec (vat_main_t * vam)
5895 return exec_inband (vam);
5899 api_create_loopback (vat_main_t * vam)
5901 unformat_input_t *i = vam->input;
5902 vl_api_create_loopback_t *mp;
5903 vl_api_create_loopback_instance_t *mp_lbi;
5906 u8 is_specified = 0;
5907 u32 user_instance = 0;
5910 memset (mac_address, 0, sizeof (mac_address));
5912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5914 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5916 if (unformat (i, "instance %d", &user_instance))
5924 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5925 mp_lbi->is_specified = is_specified;
5927 mp_lbi->user_instance = htonl (user_instance);
5929 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5934 /* Construct the API message */
5935 M (CREATE_LOOPBACK, mp);
5937 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5946 api_delete_loopback (vat_main_t * vam)
5948 unformat_input_t *i = vam->input;
5949 vl_api_delete_loopback_t *mp;
5950 u32 sw_if_index = ~0;
5953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5955 if (unformat (i, "sw_if_index %d", &sw_if_index))
5961 if (sw_if_index == ~0)
5963 errmsg ("missing sw_if_index");
5967 /* Construct the API message */
5968 M (DELETE_LOOPBACK, mp);
5969 mp->sw_if_index = ntohl (sw_if_index);
5977 api_want_stats (vat_main_t * vam)
5979 unformat_input_t *i = vam->input;
5980 vl_api_want_stats_t *mp;
5984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5986 if (unformat (i, "enable"))
5988 else if (unformat (i, "disable"))
5996 errmsg ("missing enable|disable");
6001 mp->enable_disable = enable;
6009 api_want_interface_events (vat_main_t * vam)
6011 unformat_input_t *i = vam->input;
6012 vl_api_want_interface_events_t *mp;
6016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6018 if (unformat (i, "enable"))
6020 else if (unformat (i, "disable"))
6028 errmsg ("missing enable|disable");
6032 M (WANT_INTERFACE_EVENTS, mp);
6033 mp->enable_disable = enable;
6035 vam->interface_event_display = enable;
6043 /* Note: non-static, called once to set up the initial intfc table */
6045 api_sw_interface_dump (vat_main_t * vam)
6047 vl_api_sw_interface_dump_t *mp;
6048 vl_api_control_ping_t *mp_ping;
6050 name_sort_t *nses = 0, *ns;
6051 sw_interface_subif_t *sub = NULL;
6054 /* Toss the old name table */
6056 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6058 vec_add2 (nses, ns, 1);
6059 ns->name = (u8 *)(p->key);
6060 ns->value = (u32) p->value[0];
6064 hash_free (vam->sw_if_index_by_interface_name);
6066 vec_foreach (ns, nses) vec_free (ns->name);
6070 vec_foreach (sub, vam->sw_if_subif_table)
6072 vec_free (sub->interface_name);
6074 vec_free (vam->sw_if_subif_table);
6076 /* recreate the interface name hash table */
6077 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6079 /* Get list of ethernets */
6080 M (SW_INTERFACE_DUMP, mp);
6081 mp->name_filter_valid = 1;
6082 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6085 /* and local / loopback interfaces */
6086 M (SW_INTERFACE_DUMP, mp);
6087 mp->name_filter_valid = 1;
6088 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6091 /* and packet-generator interfaces */
6092 M (SW_INTERFACE_DUMP, mp);
6093 mp->name_filter_valid = 1;
6094 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6097 /* and vxlan-gpe tunnel interfaces */
6098 M (SW_INTERFACE_DUMP, mp);
6099 mp->name_filter_valid = 1;
6100 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6101 sizeof (mp->name_filter) - 1);
6104 /* and vxlan tunnel interfaces */
6105 M (SW_INTERFACE_DUMP, mp);
6106 mp->name_filter_valid = 1;
6107 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6110 /* and geneve tunnel interfaces */
6111 M (SW_INTERFACE_DUMP, mp);
6112 mp->name_filter_valid = 1;
6113 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6116 /* and host (af_packet) interfaces */
6117 M (SW_INTERFACE_DUMP, mp);
6118 mp->name_filter_valid = 1;
6119 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6122 /* and l2tpv3 tunnel interfaces */
6123 M (SW_INTERFACE_DUMP, mp);
6124 mp->name_filter_valid = 1;
6125 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6126 sizeof (mp->name_filter) - 1);
6129 /* and GRE tunnel interfaces */
6130 M (SW_INTERFACE_DUMP, mp);
6131 mp->name_filter_valid = 1;
6132 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6135 /* and LISP-GPE interfaces */
6136 M (SW_INTERFACE_DUMP, mp);
6137 mp->name_filter_valid = 1;
6138 strncpy ((char *) mp->name_filter, "lisp_gpe",
6139 sizeof (mp->name_filter) - 1);
6142 /* and IPSEC tunnel interfaces */
6143 M (SW_INTERFACE_DUMP, mp);
6144 mp->name_filter_valid = 1;
6145 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6148 /* Use a control ping for synchronization */
6149 MPING (CONTROL_PING, mp_ping);
6157 api_sw_interface_set_flags (vat_main_t * vam)
6159 unformat_input_t *i = vam->input;
6160 vl_api_sw_interface_set_flags_t *mp;
6162 u8 sw_if_index_set = 0;
6166 /* Parse args required to build the message */
6167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6169 if (unformat (i, "admin-up"))
6171 else if (unformat (i, "admin-down"))
6174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6175 sw_if_index_set = 1;
6176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6177 sw_if_index_set = 1;
6182 if (sw_if_index_set == 0)
6184 errmsg ("missing interface name or sw_if_index");
6188 /* Construct the API message */
6189 M (SW_INTERFACE_SET_FLAGS, mp);
6190 mp->sw_if_index = ntohl (sw_if_index);
6191 mp->admin_up_down = admin_up;
6196 /* Wait for a reply, return the good/bad news... */
6202 api_sw_interface_clear_stats (vat_main_t * vam)
6204 unformat_input_t *i = vam->input;
6205 vl_api_sw_interface_clear_stats_t *mp;
6207 u8 sw_if_index_set = 0;
6210 /* Parse args required to build the message */
6211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6213 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6214 sw_if_index_set = 1;
6215 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6216 sw_if_index_set = 1;
6221 /* Construct the API message */
6222 M (SW_INTERFACE_CLEAR_STATS, mp);
6224 if (sw_if_index_set == 1)
6225 mp->sw_if_index = ntohl (sw_if_index);
6227 mp->sw_if_index = ~0;
6232 /* Wait for a reply, return the good/bad news... */
6238 api_sw_interface_add_del_address (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_sw_interface_add_del_address_t *mp;
6243 u8 sw_if_index_set = 0;
6244 u8 is_add = 1, del_all = 0;
6245 u32 address_length = 0;
6246 u8 v4_address_set = 0;
6247 u8 v6_address_set = 0;
6248 ip4_address_t v4address;
6249 ip6_address_t v6address;
6252 /* Parse args required to build the message */
6253 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6255 if (unformat (i, "del-all"))
6257 else if (unformat (i, "del"))
6260 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6261 sw_if_index_set = 1;
6262 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6263 sw_if_index_set = 1;
6264 else if (unformat (i, "%U/%d",
6265 unformat_ip4_address, &v4address, &address_length))
6267 else if (unformat (i, "%U/%d",
6268 unformat_ip6_address, &v6address, &address_length))
6274 if (sw_if_index_set == 0)
6276 errmsg ("missing interface name or sw_if_index");
6279 if (v4_address_set && v6_address_set)
6281 errmsg ("both v4 and v6 addresses set");
6284 if (!v4_address_set && !v6_address_set && !del_all)
6286 errmsg ("no addresses set");
6290 /* Construct the API message */
6291 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6293 mp->sw_if_index = ntohl (sw_if_index);
6294 mp->is_add = is_add;
6295 mp->del_all = del_all;
6299 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6303 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6305 mp->address_length = address_length;
6310 /* Wait for a reply, return good/bad news */
6316 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6318 unformat_input_t *i = vam->input;
6319 vl_api_sw_interface_set_mpls_enable_t *mp;
6321 u8 sw_if_index_set = 0;
6325 /* Parse args required to build the message */
6326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6328 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6331 sw_if_index_set = 1;
6332 else if (unformat (i, "disable"))
6334 else if (unformat (i, "dis"))
6340 if (sw_if_index_set == 0)
6342 errmsg ("missing interface name or sw_if_index");
6346 /* Construct the API message */
6347 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6349 mp->sw_if_index = ntohl (sw_if_index);
6350 mp->enable = enable;
6355 /* Wait for a reply... */
6361 api_sw_interface_set_table (vat_main_t * vam)
6363 unformat_input_t *i = vam->input;
6364 vl_api_sw_interface_set_table_t *mp;
6365 u32 sw_if_index, vrf_id = 0;
6366 u8 sw_if_index_set = 0;
6370 /* Parse args required to build the message */
6371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6373 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6376 sw_if_index_set = 1;
6377 else if (unformat (i, "vrf %d", &vrf_id))
6379 else if (unformat (i, "ipv6"))
6385 if (sw_if_index_set == 0)
6387 errmsg ("missing interface name or sw_if_index");
6391 /* Construct the API message */
6392 M (SW_INTERFACE_SET_TABLE, mp);
6394 mp->sw_if_index = ntohl (sw_if_index);
6395 mp->is_ipv6 = is_ipv6;
6396 mp->vrf_id = ntohl (vrf_id);
6401 /* Wait for a reply... */
6406 static void vl_api_sw_interface_get_table_reply_t_handler
6407 (vl_api_sw_interface_get_table_reply_t * mp)
6409 vat_main_t *vam = &vat_main;
6411 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6413 vam->retval = ntohl (mp->retval);
6414 vam->result_ready = 1;
6418 static void vl_api_sw_interface_get_table_reply_t_handler_json
6419 (vl_api_sw_interface_get_table_reply_t * mp)
6421 vat_main_t *vam = &vat_main;
6422 vat_json_node_t node;
6424 vat_json_init_object (&node);
6425 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6426 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6428 vat_json_print (vam->ofp, &node);
6429 vat_json_free (&node);
6431 vam->retval = ntohl (mp->retval);
6432 vam->result_ready = 1;
6436 api_sw_interface_get_table (vat_main_t * vam)
6438 unformat_input_t *i = vam->input;
6439 vl_api_sw_interface_get_table_t *mp;
6441 u8 sw_if_index_set = 0;
6445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6447 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6450 sw_if_index_set = 1;
6451 else if (unformat (i, "ipv6"))
6457 if (sw_if_index_set == 0)
6459 errmsg ("missing interface name or sw_if_index");
6463 M (SW_INTERFACE_GET_TABLE, mp);
6464 mp->sw_if_index = htonl (sw_if_index);
6465 mp->is_ipv6 = is_ipv6;
6473 api_sw_interface_set_vpath (vat_main_t * vam)
6475 unformat_input_t *i = vam->input;
6476 vl_api_sw_interface_set_vpath_t *mp;
6477 u32 sw_if_index = 0;
6478 u8 sw_if_index_set = 0;
6482 /* Parse args required to build the message */
6483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6488 sw_if_index_set = 1;
6489 else if (unformat (i, "enable"))
6491 else if (unformat (i, "disable"))
6497 if (sw_if_index_set == 0)
6499 errmsg ("missing interface name or sw_if_index");
6503 /* Construct the API message */
6504 M (SW_INTERFACE_SET_VPATH, mp);
6506 mp->sw_if_index = ntohl (sw_if_index);
6507 mp->enable = is_enable;
6512 /* Wait for a reply... */
6518 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6520 unformat_input_t *i = vam->input;
6521 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6522 u32 sw_if_index = 0;
6523 u8 sw_if_index_set = 0;
6528 /* Parse args required to build the message */
6529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6534 sw_if_index_set = 1;
6535 else if (unformat (i, "enable"))
6537 else if (unformat (i, "disable"))
6539 else if (unformat (i, "ip4"))
6541 else if (unformat (i, "ip6"))
6547 if (sw_if_index_set == 0)
6549 errmsg ("missing interface name or sw_if_index");
6553 /* Construct the API message */
6554 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6556 mp->sw_if_index = ntohl (sw_if_index);
6557 mp->enable = is_enable;
6558 mp->is_ipv6 = is_ipv6;
6563 /* Wait for a reply... */
6569 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6571 unformat_input_t *i = vam->input;
6572 vl_api_sw_interface_set_geneve_bypass_t *mp;
6573 u32 sw_if_index = 0;
6574 u8 sw_if_index_set = 0;
6579 /* Parse args required to build the message */
6580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6582 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6585 sw_if_index_set = 1;
6586 else if (unformat (i, "enable"))
6588 else if (unformat (i, "disable"))
6590 else if (unformat (i, "ip4"))
6592 else if (unformat (i, "ip6"))
6598 if (sw_if_index_set == 0)
6600 errmsg ("missing interface name or sw_if_index");
6604 /* Construct the API message */
6605 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6607 mp->sw_if_index = ntohl (sw_if_index);
6608 mp->enable = is_enable;
6609 mp->is_ipv6 = is_ipv6;
6614 /* Wait for a reply... */
6620 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6622 unformat_input_t *i = vam->input;
6623 vl_api_sw_interface_set_l2_xconnect_t *mp;
6625 u8 rx_sw_if_index_set = 0;
6627 u8 tx_sw_if_index_set = 0;
6631 /* Parse args required to build the message */
6632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6634 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6635 rx_sw_if_index_set = 1;
6636 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6637 tx_sw_if_index_set = 1;
6638 else if (unformat (i, "rx"))
6640 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6642 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6644 rx_sw_if_index_set = 1;
6649 else if (unformat (i, "tx"))
6651 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6653 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6655 tx_sw_if_index_set = 1;
6660 else if (unformat (i, "enable"))
6662 else if (unformat (i, "disable"))
6668 if (rx_sw_if_index_set == 0)
6670 errmsg ("missing rx interface name or rx_sw_if_index");
6674 if (enable && (tx_sw_if_index_set == 0))
6676 errmsg ("missing tx interface name or tx_sw_if_index");
6680 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6682 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6683 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6684 mp->enable = enable;
6692 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6694 unformat_input_t *i = vam->input;
6695 vl_api_sw_interface_set_l2_bridge_t *mp;
6697 u8 rx_sw_if_index_set = 0;
6705 /* Parse args required to build the message */
6706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6708 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6709 rx_sw_if_index_set = 1;
6710 else if (unformat (i, "bd_id %d", &bd_id))
6714 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6715 rx_sw_if_index_set = 1;
6716 else if (unformat (i, "shg %d", &shg))
6718 else if (unformat (i, "bvi"))
6720 else if (unformat (i, "enable"))
6722 else if (unformat (i, "disable"))
6728 if (rx_sw_if_index_set == 0)
6730 errmsg ("missing rx interface name or sw_if_index");
6734 if (enable && (bd_id_set == 0))
6736 errmsg ("missing bridge domain");
6740 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6742 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6743 mp->bd_id = ntohl (bd_id);
6746 mp->enable = enable;
6754 api_bridge_domain_dump (vat_main_t * vam)
6756 unformat_input_t *i = vam->input;
6757 vl_api_bridge_domain_dump_t *mp;
6758 vl_api_control_ping_t *mp_ping;
6762 /* Parse args required to build the message */
6763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6765 if (unformat (i, "bd_id %d", &bd_id))
6771 M (BRIDGE_DOMAIN_DUMP, mp);
6772 mp->bd_id = ntohl (bd_id);
6775 /* Use a control ping for synchronization */
6776 MPING (CONTROL_PING, mp_ping);
6784 api_bridge_domain_add_del (vat_main_t * vam)
6786 unformat_input_t *i = vam->input;
6787 vl_api_bridge_domain_add_del_t *mp;
6790 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6795 /* Parse args required to build the message */
6796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6798 if (unformat (i, "bd_id %d", &bd_id))
6800 else if (unformat (i, "flood %d", &flood))
6802 else if (unformat (i, "uu-flood %d", &uu_flood))
6804 else if (unformat (i, "forward %d", &forward))
6806 else if (unformat (i, "learn %d", &learn))
6808 else if (unformat (i, "arp-term %d", &arp_term))
6810 else if (unformat (i, "mac-age %d", &mac_age))
6812 else if (unformat (i, "bd-tag %s", &bd_tag))
6814 else if (unformat (i, "del"))
6817 flood = uu_flood = forward = learn = 0;
6825 errmsg ("missing bridge domain");
6832 errmsg ("mac age must be less than 256 ");
6837 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6839 errmsg ("bd-tag cannot be longer than 63");
6844 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6846 mp->bd_id = ntohl (bd_id);
6848 mp->uu_flood = uu_flood;
6849 mp->forward = forward;
6851 mp->arp_term = arp_term;
6852 mp->is_add = is_add;
6853 mp->mac_age = (u8) mac_age;
6855 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6866 api_l2fib_flush_bd (vat_main_t * vam)
6868 unformat_input_t *i = vam->input;
6869 vl_api_l2fib_flush_bd_t *mp;
6873 /* Parse args required to build the message */
6874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6876 if (unformat (i, "bd_id %d", &bd_id));
6883 errmsg ("missing bridge domain");
6887 M (L2FIB_FLUSH_BD, mp);
6889 mp->bd_id = htonl (bd_id);
6897 api_l2fib_flush_int (vat_main_t * vam)
6899 unformat_input_t *i = vam->input;
6900 vl_api_l2fib_flush_int_t *mp;
6901 u32 sw_if_index = ~0;
6904 /* Parse args required to build the message */
6905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6907 if (unformat (i, "sw_if_index %d", &sw_if_index));
6909 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6914 if (sw_if_index == ~0)
6916 errmsg ("missing interface name or sw_if_index");
6920 M (L2FIB_FLUSH_INT, mp);
6922 mp->sw_if_index = ntohl (sw_if_index);
6930 api_l2fib_add_del (vat_main_t * vam)
6932 unformat_input_t *i = vam->input;
6933 vl_api_l2fib_add_del_t *mp;
6939 u32 sw_if_index = ~0;
6940 u8 sw_if_index_set = 0;
6949 /* Parse args required to build the message */
6950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6952 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6954 else if (unformat (i, "bd_id %d", &bd_id))
6956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6957 sw_if_index_set = 1;
6958 else if (unformat (i, "sw_if"))
6960 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6963 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6964 sw_if_index_set = 1;
6969 else if (unformat (i, "static"))
6971 else if (unformat (i, "filter"))
6976 else if (unformat (i, "bvi"))
6981 else if (unformat (i, "del"))
6983 else if (unformat (i, "count %d", &count))
6991 errmsg ("missing mac address");
6997 errmsg ("missing bridge domain");
7001 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7003 errmsg ("missing interface name or sw_if_index");
7009 /* Turn on async mode */
7010 vam->async_mode = 1;
7011 vam->async_errors = 0;
7012 before = vat_time_now (vam);
7015 for (j = 0; j < count; j++)
7017 M (L2FIB_ADD_DEL, mp);
7020 mp->bd_id = ntohl (bd_id);
7021 mp->is_add = is_add;
7025 mp->sw_if_index = ntohl (sw_if_index);
7026 mp->static_mac = static_mac;
7027 mp->filter_mac = filter_mac;
7028 mp->bvi_mac = bvi_mac;
7030 increment_mac_address (&mac);
7037 vl_api_control_ping_t *mp_ping;
7040 /* Shut off async mode */
7041 vam->async_mode = 0;
7043 MPING (CONTROL_PING, mp_ping);
7046 timeout = vat_time_now (vam) + 1.0;
7047 while (vat_time_now (vam) < timeout)
7048 if (vam->result_ready == 1)
7053 if (vam->retval == -99)
7056 if (vam->async_errors > 0)
7058 errmsg ("%d asynchronous errors", vam->async_errors);
7061 vam->async_errors = 0;
7062 after = vat_time_now (vam);
7064 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7065 count, after - before, count / (after - before));
7071 /* Wait for a reply... */
7075 /* Return the good/bad news */
7076 return (vam->retval);
7080 api_bridge_domain_set_mac_age (vat_main_t * vam)
7082 unformat_input_t *i = vam->input;
7083 vl_api_bridge_domain_set_mac_age_t *mp;
7088 /* Parse args required to build the message */
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "bd_id %d", &bd_id));
7092 else if (unformat (i, "mac-age %d", &mac_age));
7099 errmsg ("missing bridge domain");
7105 errmsg ("mac age must be less than 256 ");
7109 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7111 mp->bd_id = htonl (bd_id);
7112 mp->mac_age = (u8) mac_age;
7120 api_l2_flags (vat_main_t * vam)
7122 unformat_input_t *i = vam->input;
7123 vl_api_l2_flags_t *mp;
7126 u8 sw_if_index_set = 0;
7130 /* Parse args required to build the message */
7131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7133 if (unformat (i, "sw_if_index %d", &sw_if_index))
7134 sw_if_index_set = 1;
7135 else if (unformat (i, "sw_if"))
7137 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7140 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7141 sw_if_index_set = 1;
7146 else if (unformat (i, "learn"))
7148 else if (unformat (i, "forward"))
7150 else if (unformat (i, "flood"))
7152 else if (unformat (i, "uu-flood"))
7153 flags |= L2_UU_FLOOD;
7154 else if (unformat (i, "arp-term"))
7155 flags |= L2_ARP_TERM;
7156 else if (unformat (i, "off"))
7158 else if (unformat (i, "disable"))
7164 if (sw_if_index_set == 0)
7166 errmsg ("missing interface name or sw_if_index");
7172 mp->sw_if_index = ntohl (sw_if_index);
7173 mp->feature_bitmap = ntohl (flags);
7174 mp->is_set = is_set;
7182 api_bridge_flags (vat_main_t * vam)
7184 unformat_input_t *i = vam->input;
7185 vl_api_bridge_flags_t *mp;
7192 /* Parse args required to build the message */
7193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7195 if (unformat (i, "bd_id %d", &bd_id))
7197 else if (unformat (i, "learn"))
7199 else if (unformat (i, "forward"))
7201 else if (unformat (i, "flood"))
7203 else if (unformat (i, "uu-flood"))
7204 flags |= L2_UU_FLOOD;
7205 else if (unformat (i, "arp-term"))
7206 flags |= L2_ARP_TERM;
7207 else if (unformat (i, "off"))
7209 else if (unformat (i, "disable"))
7217 errmsg ("missing bridge domain");
7221 M (BRIDGE_FLAGS, mp);
7223 mp->bd_id = ntohl (bd_id);
7224 mp->feature_bitmap = ntohl (flags);
7225 mp->is_set = is_set;
7233 api_bd_ip_mac_add_del (vat_main_t * vam)
7235 unformat_input_t *i = vam->input;
7236 vl_api_bd_ip_mac_add_del_t *mp;
7243 ip4_address_t v4addr;
7244 ip6_address_t v6addr;
7249 /* Parse args required to build the message */
7250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7252 if (unformat (i, "bd_id %d", &bd_id))
7256 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7260 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7265 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7269 else if (unformat (i, "del"))
7277 errmsg ("missing bridge domain");
7280 else if (ip_set == 0)
7282 errmsg ("missing IP address");
7285 else if (mac_set == 0)
7287 errmsg ("missing MAC address");
7291 M (BD_IP_MAC_ADD_DEL, mp);
7293 mp->bd_id = ntohl (bd_id);
7294 mp->is_ipv6 = is_ipv6;
7295 mp->is_add = is_add;
7297 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7299 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7300 clib_memcpy (mp->mac_address, macaddr, 6);
7307 api_tap_connect (vat_main_t * vam)
7309 unformat_input_t *i = vam->input;
7310 vl_api_tap_connect_t *mp;
7316 ip4_address_t ip4_address;
7318 int ip4_address_set = 0;
7319 ip6_address_t ip6_address;
7321 int ip6_address_set = 0;
7324 memset (mac_address, 0, sizeof (mac_address));
7326 /* Parse args required to build the message */
7327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7329 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7333 else if (unformat (i, "random-mac"))
7335 else if (unformat (i, "tapname %s", &tap_name))
7337 else if (unformat (i, "tag %s", &tag))
7339 else if (unformat (i, "address %U/%d",
7340 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7341 ip4_address_set = 1;
7342 else if (unformat (i, "address %U/%d",
7343 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7344 ip6_address_set = 1;
7351 errmsg ("missing tap name");
7354 if (vec_len (tap_name) > 63)
7356 errmsg ("tap name too long");
7359 vec_add1 (tap_name, 0);
7361 if (vec_len (tag) > 63)
7363 errmsg ("tag too long");
7367 /* Construct the API message */
7368 M (TAP_CONNECT, mp);
7370 mp->use_random_mac = random_mac;
7371 clib_memcpy (mp->mac_address, mac_address, 6);
7372 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7374 clib_memcpy (mp->tag, tag, vec_len (tag));
7376 if (ip4_address_set)
7378 mp->ip4_address_set = 1;
7379 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7380 mp->ip4_mask_width = ip4_mask_width;
7382 if (ip6_address_set)
7384 mp->ip6_address_set = 1;
7385 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7386 mp->ip6_mask_width = ip6_mask_width;
7389 vec_free (tap_name);
7395 /* Wait for a reply... */
7401 api_tap_modify (vat_main_t * vam)
7403 unformat_input_t *i = vam->input;
7404 vl_api_tap_modify_t *mp;
7409 u32 sw_if_index = ~0;
7410 u8 sw_if_index_set = 0;
7413 memset (mac_address, 0, sizeof (mac_address));
7415 /* Parse args required to build the message */
7416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7418 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7419 sw_if_index_set = 1;
7420 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7421 sw_if_index_set = 1;
7422 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7426 else if (unformat (i, "random-mac"))
7428 else if (unformat (i, "tapname %s", &tap_name))
7434 if (sw_if_index_set == 0)
7436 errmsg ("missing vpp interface name");
7441 errmsg ("missing tap name");
7444 if (vec_len (tap_name) > 63)
7446 errmsg ("tap name too long");
7448 vec_add1 (tap_name, 0);
7450 /* Construct the API message */
7453 mp->use_random_mac = random_mac;
7454 mp->sw_if_index = ntohl (sw_if_index);
7455 clib_memcpy (mp->mac_address, mac_address, 6);
7456 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7457 vec_free (tap_name);
7462 /* Wait for a reply... */
7468 api_tap_delete (vat_main_t * vam)
7470 unformat_input_t *i = vam->input;
7471 vl_api_tap_delete_t *mp;
7472 u32 sw_if_index = ~0;
7473 u8 sw_if_index_set = 0;
7476 /* Parse args required to build the message */
7477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7480 sw_if_index_set = 1;
7481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7482 sw_if_index_set = 1;
7487 if (sw_if_index_set == 0)
7489 errmsg ("missing vpp interface name");
7493 /* Construct the API message */
7496 mp->sw_if_index = ntohl (sw_if_index);
7501 /* Wait for a reply... */
7507 api_ip_table_add_del (vat_main_t * vam)
7509 unformat_input_t *i = vam->input;
7510 vl_api_ip_table_add_del_t *mp;
7516 /* Parse args required to build the message */
7517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7519 if (unformat (i, "ipv6"))
7521 else if (unformat (i, "del"))
7523 else if (unformat (i, "add"))
7525 else if (unformat (i, "table %d", &table_id))
7529 clib_warning ("parse error '%U'", format_unformat_error, i);
7536 errmsg ("missing table-ID");
7540 /* Construct the API message */
7541 M (IP_TABLE_ADD_DEL, mp);
7543 mp->table_id = ntohl (table_id);
7544 mp->is_ipv6 = is_ipv6;
7545 mp->is_add = is_add;
7550 /* Wait for a reply... */
7557 api_ip_add_del_route (vat_main_t * vam)
7559 unformat_input_t *i = vam->input;
7560 vl_api_ip_add_del_route_t *mp;
7561 u32 sw_if_index = ~0, vrf_id = 0;
7563 u8 is_local = 0, is_drop = 0;
7564 u8 is_unreach = 0, is_prohibit = 0;
7566 u32 next_hop_weight = 1;
7568 u8 is_multipath = 0;
7570 u8 address_length_set = 0;
7571 u32 next_hop_table_id = 0;
7572 u32 resolve_attempts = 0;
7573 u32 dst_address_length = 0;
7574 u8 next_hop_set = 0;
7575 ip4_address_t v4_dst_address, v4_next_hop_address;
7576 ip6_address_t v6_dst_address, v6_next_hop_address;
7580 u32 random_add_del = 0;
7581 u32 *random_vector = 0;
7583 u32 random_seed = 0xdeaddabe;
7584 u32 classify_table_index = ~0;
7586 u8 resolve_host = 0, resolve_attached = 0;
7587 mpls_label_t *next_hop_out_label_stack = NULL;
7588 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7589 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7591 /* Parse args required to build the message */
7592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7596 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7598 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7603 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7608 else if (unformat (i, "/%d", &dst_address_length))
7610 address_length_set = 1;
7613 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7614 &v4_next_hop_address))
7618 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7619 &v6_next_hop_address))
7623 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7625 else if (unformat (i, "weight %d", &next_hop_weight))
7627 else if (unformat (i, "drop"))
7631 else if (unformat (i, "null-send-unreach"))
7635 else if (unformat (i, "null-send-prohibit"))
7639 else if (unformat (i, "local"))
7643 else if (unformat (i, "classify %d", &classify_table_index))
7647 else if (unformat (i, "del"))
7649 else if (unformat (i, "add"))
7651 else if (unformat (i, "not-last"))
7653 else if (unformat (i, "resolve-via-host"))
7655 else if (unformat (i, "resolve-via-attached"))
7656 resolve_attached = 1;
7657 else if (unformat (i, "multipath"))
7659 else if (unformat (i, "vrf %d", &vrf_id))
7661 else if (unformat (i, "count %d", &count))
7663 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7665 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7667 else if (unformat (i, "out-label %d", &next_hop_out_label))
7668 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7669 else if (unformat (i, "via-label %d", &next_hop_via_label))
7671 else if (unformat (i, "random"))
7673 else if (unformat (i, "seed %d", &random_seed))
7677 clib_warning ("parse error '%U'", format_unformat_error, i);
7682 if (!next_hop_set && !is_drop && !is_local &&
7683 !is_classify && !is_unreach && !is_prohibit &&
7684 MPLS_LABEL_INVALID == next_hop_via_label)
7687 ("next hop / local / drop / unreach / prohibit / classify not set");
7691 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7693 errmsg ("next hop and next-hop via label set");
7696 if (address_set == 0)
7698 errmsg ("missing addresses");
7702 if (address_length_set == 0)
7704 errmsg ("missing address length");
7708 /* Generate a pile of unique, random routes */
7711 u32 this_random_address;
7712 random_hash = hash_create (count, sizeof (uword));
7714 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7715 for (j = 0; j <= count; j++)
7719 this_random_address = random_u32 (&random_seed);
7720 this_random_address =
7721 clib_host_to_net_u32 (this_random_address);
7723 while (hash_get (random_hash, this_random_address));
7724 vec_add1 (random_vector, this_random_address);
7725 hash_set (random_hash, this_random_address, 1);
7727 hash_free (random_hash);
7728 v4_dst_address.as_u32 = random_vector[0];
7733 /* Turn on async mode */
7734 vam->async_mode = 1;
7735 vam->async_errors = 0;
7736 before = vat_time_now (vam);
7739 for (j = 0; j < count; j++)
7741 /* Construct the API message */
7742 M2 (IP_ADD_DEL_ROUTE, mp,
7743 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7745 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7746 mp->table_id = ntohl (vrf_id);
7748 mp->is_add = is_add;
7749 mp->is_drop = is_drop;
7750 mp->is_unreach = is_unreach;
7751 mp->is_prohibit = is_prohibit;
7752 mp->is_ipv6 = is_ipv6;
7753 mp->is_local = is_local;
7754 mp->is_classify = is_classify;
7755 mp->is_multipath = is_multipath;
7756 mp->is_resolve_host = resolve_host;
7757 mp->is_resolve_attached = resolve_attached;
7758 mp->not_last = not_last;
7759 mp->next_hop_weight = next_hop_weight;
7760 mp->dst_address_length = dst_address_length;
7761 mp->next_hop_table_id = ntohl (next_hop_table_id);
7762 mp->classify_table_index = ntohl (classify_table_index);
7763 mp->next_hop_via_label = ntohl (next_hop_via_label);
7764 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7765 if (0 != mp->next_hop_n_out_labels)
7767 memcpy (mp->next_hop_out_label_stack,
7768 next_hop_out_label_stack,
7769 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7770 vec_free (next_hop_out_label_stack);
7775 clib_memcpy (mp->dst_address, &v6_dst_address,
7776 sizeof (v6_dst_address));
7778 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7779 sizeof (v6_next_hop_address));
7780 increment_v6_address (&v6_dst_address);
7784 clib_memcpy (mp->dst_address, &v4_dst_address,
7785 sizeof (v4_dst_address));
7787 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7788 sizeof (v4_next_hop_address));
7790 v4_dst_address.as_u32 = random_vector[j + 1];
7792 increment_v4_address (&v4_dst_address);
7796 /* If we receive SIGTERM, stop now... */
7801 /* When testing multiple add/del ops, use a control-ping to sync */
7804 vl_api_control_ping_t *mp_ping;
7808 /* Shut off async mode */
7809 vam->async_mode = 0;
7811 MPING (CONTROL_PING, mp_ping);
7814 timeout = vat_time_now (vam) + 1.0;
7815 while (vat_time_now (vam) < timeout)
7816 if (vam->result_ready == 1)
7821 if (vam->retval == -99)
7824 if (vam->async_errors > 0)
7826 errmsg ("%d asynchronous errors", vam->async_errors);
7829 vam->async_errors = 0;
7830 after = vat_time_now (vam);
7832 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7836 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7837 count, after - before, count / (after - before));
7843 /* Wait for a reply... */
7848 /* Return the good/bad news */
7849 return (vam->retval);
7853 api_ip_mroute_add_del (vat_main_t * vam)
7855 unformat_input_t *i = vam->input;
7856 vl_api_ip_mroute_add_del_t *mp;
7857 u32 sw_if_index = ~0, vrf_id = 0;
7862 u32 grp_address_length = 0;
7863 ip4_address_t v4_grp_address, v4_src_address;
7864 ip6_address_t v6_grp_address, v6_src_address;
7865 mfib_itf_flags_t iflags = 0;
7866 mfib_entry_flags_t eflags = 0;
7869 /* Parse args required to build the message */
7870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7872 if (unformat (i, "sw_if_index %d", &sw_if_index))
7874 else if (unformat (i, "%U %U",
7875 unformat_ip4_address, &v4_src_address,
7876 unformat_ip4_address, &v4_grp_address))
7878 grp_address_length = 64;
7882 else if (unformat (i, "%U %U",
7883 unformat_ip6_address, &v6_src_address,
7884 unformat_ip6_address, &v6_grp_address))
7886 grp_address_length = 256;
7890 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7892 memset (&v4_src_address, 0, sizeof (v4_src_address));
7893 grp_address_length = 32;
7897 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7899 memset (&v6_src_address, 0, sizeof (v6_src_address));
7900 grp_address_length = 128;
7904 else if (unformat (i, "/%d", &grp_address_length))
7906 else if (unformat (i, "local"))
7910 else if (unformat (i, "del"))
7912 else if (unformat (i, "add"))
7914 else if (unformat (i, "vrf %d", &vrf_id))
7916 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7918 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7922 clib_warning ("parse error '%U'", format_unformat_error, i);
7927 if (address_set == 0)
7929 errmsg ("missing addresses\n");
7933 /* Construct the API message */
7934 M (IP_MROUTE_ADD_DEL, mp);
7936 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7937 mp->table_id = ntohl (vrf_id);
7939 mp->is_add = is_add;
7940 mp->is_ipv6 = is_ipv6;
7941 mp->is_local = is_local;
7942 mp->itf_flags = ntohl (iflags);
7943 mp->entry_flags = ntohl (eflags);
7944 mp->grp_address_length = grp_address_length;
7945 mp->grp_address_length = ntohs (mp->grp_address_length);
7949 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7950 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7954 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7955 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7961 /* Wait for a reply... */
7967 api_mpls_table_add_del (vat_main_t * vam)
7969 unformat_input_t *i = vam->input;
7970 vl_api_mpls_table_add_del_t *mp;
7975 /* Parse args required to build the message */
7976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7978 if (unformat (i, "del"))
7980 else if (unformat (i, "add"))
7982 else if (unformat (i, "table-id %d", &table_id))
7986 clib_warning ("parse error '%U'", format_unformat_error, i);
7993 errmsg ("missing table-ID");
7997 /* Construct the API message */
7998 M (MPLS_TABLE_ADD_DEL, mp);
8000 mp->mt_table_id = ntohl (table_id);
8001 mp->mt_is_add = is_add;
8006 /* Wait for a reply... */
8013 api_mpls_route_add_del (vat_main_t * vam)
8015 unformat_input_t *i = vam->input;
8016 vl_api_mpls_route_add_del_t *mp;
8017 u32 sw_if_index = ~0, table_id = 0;
8019 u32 next_hop_weight = 1;
8020 u8 is_multipath = 0;
8021 u32 next_hop_table_id = 0;
8022 u8 next_hop_set = 0;
8023 ip4_address_t v4_next_hop_address = {
8026 ip6_address_t v6_next_hop_address = { {0} };
8030 u32 classify_table_index = ~0;
8032 u8 resolve_host = 0, resolve_attached = 0;
8033 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8034 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8035 mpls_label_t *next_hop_out_label_stack = NULL;
8036 mpls_label_t local_label = MPLS_LABEL_INVALID;
8038 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8040 /* Parse args required to build the message */
8041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8043 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8045 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8047 else if (unformat (i, "%d", &local_label))
8049 else if (unformat (i, "eos"))
8051 else if (unformat (i, "non-eos"))
8053 else if (unformat (i, "via %U", unformat_ip4_address,
8054 &v4_next_hop_address))
8057 next_hop_proto = DPO_PROTO_IP4;
8059 else if (unformat (i, "via %U", unformat_ip6_address,
8060 &v6_next_hop_address))
8063 next_hop_proto = DPO_PROTO_IP6;
8065 else if (unformat (i, "weight %d", &next_hop_weight))
8067 else if (unformat (i, "classify %d", &classify_table_index))
8071 else if (unformat (i, "del"))
8073 else if (unformat (i, "add"))
8075 else if (unformat (i, "resolve-via-host"))
8077 else if (unformat (i, "resolve-via-attached"))
8078 resolve_attached = 1;
8079 else if (unformat (i, "multipath"))
8081 else if (unformat (i, "count %d", &count))
8083 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8086 next_hop_proto = DPO_PROTO_IP4;
8088 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8091 next_hop_proto = DPO_PROTO_IP6;
8093 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8095 else if (unformat (i, "via-label %d", &next_hop_via_label))
8097 else if (unformat (i, "out-label %d", &next_hop_out_label))
8098 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8101 clib_warning ("parse error '%U'", format_unformat_error, i);
8106 if (!next_hop_set && !is_classify)
8108 errmsg ("next hop / classify not set");
8112 if (MPLS_LABEL_INVALID == local_label)
8114 errmsg ("missing label");
8120 /* Turn on async mode */
8121 vam->async_mode = 1;
8122 vam->async_errors = 0;
8123 before = vat_time_now (vam);
8126 for (j = 0; j < count; j++)
8128 /* Construct the API message */
8129 M2 (MPLS_ROUTE_ADD_DEL, mp,
8130 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8132 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8133 mp->mr_table_id = ntohl (table_id);
8135 mp->mr_is_add = is_add;
8136 mp->mr_next_hop_proto = next_hop_proto;
8137 mp->mr_is_classify = is_classify;
8138 mp->mr_is_multipath = is_multipath;
8139 mp->mr_is_resolve_host = resolve_host;
8140 mp->mr_is_resolve_attached = resolve_attached;
8141 mp->mr_next_hop_weight = next_hop_weight;
8142 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8143 mp->mr_classify_table_index = ntohl (classify_table_index);
8144 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8145 mp->mr_label = ntohl (local_label);
8146 mp->mr_eos = is_eos;
8148 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8149 if (0 != mp->mr_next_hop_n_out_labels)
8151 memcpy (mp->mr_next_hop_out_label_stack,
8152 next_hop_out_label_stack,
8153 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8154 vec_free (next_hop_out_label_stack);
8159 if (DPO_PROTO_IP4 == next_hop_proto)
8161 clib_memcpy (mp->mr_next_hop,
8162 &v4_next_hop_address,
8163 sizeof (v4_next_hop_address));
8165 else if (DPO_PROTO_IP6 == next_hop_proto)
8168 clib_memcpy (mp->mr_next_hop,
8169 &v6_next_hop_address,
8170 sizeof (v6_next_hop_address));
8177 /* If we receive SIGTERM, stop now... */
8182 /* When testing multiple add/del ops, use a control-ping to sync */
8185 vl_api_control_ping_t *mp_ping;
8189 /* Shut off async mode */
8190 vam->async_mode = 0;
8192 MPING (CONTROL_PING, mp_ping);
8195 timeout = vat_time_now (vam) + 1.0;
8196 while (vat_time_now (vam) < timeout)
8197 if (vam->result_ready == 1)
8202 if (vam->retval == -99)
8205 if (vam->async_errors > 0)
8207 errmsg ("%d asynchronous errors", vam->async_errors);
8210 vam->async_errors = 0;
8211 after = vat_time_now (vam);
8213 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8217 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8218 count, after - before, count / (after - before));
8224 /* Wait for a reply... */
8229 /* Return the good/bad news */
8230 return (vam->retval);
8234 api_mpls_ip_bind_unbind (vat_main_t * vam)
8236 unformat_input_t *i = vam->input;
8237 vl_api_mpls_ip_bind_unbind_t *mp;
8238 u32 ip_table_id = 0;
8241 ip4_address_t v4_address;
8242 ip6_address_t v6_address;
8245 mpls_label_t local_label = MPLS_LABEL_INVALID;
8248 /* Parse args required to build the message */
8249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8251 if (unformat (i, "%U/%d", unformat_ip4_address,
8252 &v4_address, &address_length))
8257 else if (unformat (i, "%U/%d", unformat_ip6_address,
8258 &v6_address, &address_length))
8263 else if (unformat (i, "%d", &local_label))
8265 else if (unformat (i, "table-id %d", &ip_table_id))
8267 else if (unformat (i, "unbind"))
8269 else if (unformat (i, "bind"))
8273 clib_warning ("parse error '%U'", format_unformat_error, i);
8280 errmsg ("IP addres not set");
8284 if (MPLS_LABEL_INVALID == local_label)
8286 errmsg ("missing label");
8290 /* Construct the API message */
8291 M (MPLS_IP_BIND_UNBIND, mp);
8293 mp->mb_is_bind = is_bind;
8294 mp->mb_is_ip4 = is_ip4;
8295 mp->mb_ip_table_id = ntohl (ip_table_id);
8296 mp->mb_mpls_table_id = 0;
8297 mp->mb_label = ntohl (local_label);
8298 mp->mb_address_length = address_length;
8301 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8303 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8308 /* Wait for a reply... */
8314 api_proxy_arp_add_del (vat_main_t * vam)
8316 unformat_input_t *i = vam->input;
8317 vl_api_proxy_arp_add_del_t *mp;
8320 ip4_address_t lo, hi;
8324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8326 if (unformat (i, "vrf %d", &vrf_id))
8328 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8329 unformat_ip4_address, &hi))
8331 else if (unformat (i, "del"))
8335 clib_warning ("parse error '%U'", format_unformat_error, i);
8342 errmsg ("address range not set");
8346 M (PROXY_ARP_ADD_DEL, mp);
8348 mp->vrf_id = ntohl (vrf_id);
8349 mp->is_add = is_add;
8350 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8351 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8359 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8361 unformat_input_t *i = vam->input;
8362 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8365 u8 sw_if_index_set = 0;
8368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8370 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8371 sw_if_index_set = 1;
8372 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8373 sw_if_index_set = 1;
8374 else if (unformat (i, "enable"))
8376 else if (unformat (i, "disable"))
8380 clib_warning ("parse error '%U'", format_unformat_error, i);
8385 if (sw_if_index_set == 0)
8387 errmsg ("missing interface name or sw_if_index");
8391 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8393 mp->sw_if_index = ntohl (sw_if_index);
8394 mp->enable_disable = enable;
8402 api_mpls_tunnel_add_del (vat_main_t * vam)
8404 unformat_input_t *i = vam->input;
8405 vl_api_mpls_tunnel_add_del_t *mp;
8409 u32 sw_if_index = ~0;
8410 u32 next_hop_sw_if_index = ~0;
8411 u32 next_hop_proto_is_ip4 = 1;
8413 u32 next_hop_table_id = 0;
8414 ip4_address_t v4_next_hop_address = {
8417 ip6_address_t v6_next_hop_address = { {0} };
8418 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8421 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8423 if (unformat (i, "add"))
8425 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8427 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8429 else if (unformat (i, "via %U",
8430 unformat_ip4_address, &v4_next_hop_address))
8432 next_hop_proto_is_ip4 = 1;
8434 else if (unformat (i, "via %U",
8435 unformat_ip6_address, &v6_next_hop_address))
8437 next_hop_proto_is_ip4 = 0;
8439 else if (unformat (i, "l2-only"))
8441 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8443 else if (unformat (i, "out-label %d", &next_hop_out_label))
8444 vec_add1 (labels, ntohl (next_hop_out_label));
8447 clib_warning ("parse error '%U'", format_unformat_error, i);
8452 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8454 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8455 mp->mt_sw_if_index = ntohl (sw_if_index);
8456 mp->mt_is_add = is_add;
8457 mp->mt_l2_only = l2_only;
8458 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8459 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8461 mp->mt_next_hop_n_out_labels = vec_len (labels);
8463 if (0 != mp->mt_next_hop_n_out_labels)
8465 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8466 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8470 if (next_hop_proto_is_ip4)
8472 clib_memcpy (mp->mt_next_hop,
8473 &v4_next_hop_address, sizeof (v4_next_hop_address));
8477 clib_memcpy (mp->mt_next_hop,
8478 &v6_next_hop_address, sizeof (v6_next_hop_address));
8487 api_sw_interface_set_unnumbered (vat_main_t * vam)
8489 unformat_input_t *i = vam->input;
8490 vl_api_sw_interface_set_unnumbered_t *mp;
8492 u32 unnum_sw_index = ~0;
8494 u8 sw_if_index_set = 0;
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8500 sw_if_index_set = 1;
8501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8502 sw_if_index_set = 1;
8503 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8505 else if (unformat (i, "del"))
8509 clib_warning ("parse error '%U'", format_unformat_error, i);
8514 if (sw_if_index_set == 0)
8516 errmsg ("missing interface name or sw_if_index");
8520 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8522 mp->sw_if_index = ntohl (sw_if_index);
8523 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8524 mp->is_add = is_add;
8532 api_ip_neighbor_add_del (vat_main_t * vam)
8534 unformat_input_t *i = vam->input;
8535 vl_api_ip_neighbor_add_del_t *mp;
8537 u8 sw_if_index_set = 0;
8540 u8 is_no_fib_entry = 0;
8543 u8 v4_address_set = 0;
8544 u8 v6_address_set = 0;
8545 ip4_address_t v4address;
8546 ip6_address_t v6address;
8549 memset (mac_address, 0, sizeof (mac_address));
8551 /* Parse args required to build the message */
8552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8554 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8558 else if (unformat (i, "del"))
8561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8562 sw_if_index_set = 1;
8563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8564 sw_if_index_set = 1;
8565 else if (unformat (i, "is_static"))
8567 else if (unformat (i, "no-fib-entry"))
8568 is_no_fib_entry = 1;
8569 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8571 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8575 clib_warning ("parse error '%U'", format_unformat_error, i);
8580 if (sw_if_index_set == 0)
8582 errmsg ("missing interface name or sw_if_index");
8585 if (v4_address_set && v6_address_set)
8587 errmsg ("both v4 and v6 addresses set");
8590 if (!v4_address_set && !v6_address_set)
8592 errmsg ("no address set");
8596 /* Construct the API message */
8597 M (IP_NEIGHBOR_ADD_DEL, mp);
8599 mp->sw_if_index = ntohl (sw_if_index);
8600 mp->is_add = is_add;
8601 mp->is_static = is_static;
8602 mp->is_no_adj_fib = is_no_fib_entry;
8604 clib_memcpy (mp->mac_address, mac_address, 6);
8608 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8612 /* mp->is_ipv6 = 0; via memset in M macro above */
8613 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8619 /* Wait for a reply, return good/bad news */
8625 api_reset_vrf (vat_main_t * vam)
8627 unformat_input_t *i = vam->input;
8628 vl_api_reset_vrf_t *mp;
8634 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8636 if (unformat (i, "vrf %d", &vrf_id))
8638 else if (unformat (i, "ipv6"))
8642 clib_warning ("parse error '%U'", format_unformat_error, i);
8647 if (vrf_id_set == 0)
8649 errmsg ("missing vrf id");
8655 mp->vrf_id = ntohl (vrf_id);
8656 mp->is_ipv6 = is_ipv6;
8664 api_create_vlan_subif (vat_main_t * vam)
8666 unformat_input_t *i = vam->input;
8667 vl_api_create_vlan_subif_t *mp;
8669 u8 sw_if_index_set = 0;
8674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8676 if (unformat (i, "sw_if_index %d", &sw_if_index))
8677 sw_if_index_set = 1;
8679 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8680 sw_if_index_set = 1;
8681 else if (unformat (i, "vlan %d", &vlan_id))
8685 clib_warning ("parse error '%U'", format_unformat_error, i);
8690 if (sw_if_index_set == 0)
8692 errmsg ("missing interface name or sw_if_index");
8696 if (vlan_id_set == 0)
8698 errmsg ("missing vlan_id");
8701 M (CREATE_VLAN_SUBIF, mp);
8703 mp->sw_if_index = ntohl (sw_if_index);
8704 mp->vlan_id = ntohl (vlan_id);
8711 #define foreach_create_subif_bit \
8718 _(outer_vlan_id_any) \
8719 _(inner_vlan_id_any)
8722 api_create_subif (vat_main_t * vam)
8724 unformat_input_t *i = vam->input;
8725 vl_api_create_subif_t *mp;
8727 u8 sw_if_index_set = 0;
8734 u32 exact_match = 0;
8735 u32 default_sub = 0;
8736 u32 outer_vlan_id_any = 0;
8737 u32 inner_vlan_id_any = 0;
8739 u16 outer_vlan_id = 0;
8740 u16 inner_vlan_id = 0;
8743 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8745 if (unformat (i, "sw_if_index %d", &sw_if_index))
8746 sw_if_index_set = 1;
8748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8749 sw_if_index_set = 1;
8750 else if (unformat (i, "sub_id %d", &sub_id))
8752 else if (unformat (i, "outer_vlan_id %d", &tmp))
8753 outer_vlan_id = tmp;
8754 else if (unformat (i, "inner_vlan_id %d", &tmp))
8755 inner_vlan_id = tmp;
8757 #define _(a) else if (unformat (i, #a)) a = 1 ;
8758 foreach_create_subif_bit
8762 clib_warning ("parse error '%U'", format_unformat_error, i);
8767 if (sw_if_index_set == 0)
8769 errmsg ("missing interface name or sw_if_index");
8773 if (sub_id_set == 0)
8775 errmsg ("missing sub_id");
8778 M (CREATE_SUBIF, mp);
8780 mp->sw_if_index = ntohl (sw_if_index);
8781 mp->sub_id = ntohl (sub_id);
8783 #define _(a) mp->a = a;
8784 foreach_create_subif_bit;
8787 mp->outer_vlan_id = ntohs (outer_vlan_id);
8788 mp->inner_vlan_id = ntohs (inner_vlan_id);
8796 api_oam_add_del (vat_main_t * vam)
8798 unformat_input_t *i = vam->input;
8799 vl_api_oam_add_del_t *mp;
8802 ip4_address_t src, dst;
8807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8809 if (unformat (i, "vrf %d", &vrf_id))
8811 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8813 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8815 else if (unformat (i, "del"))
8819 clib_warning ("parse error '%U'", format_unformat_error, i);
8826 errmsg ("missing src addr");
8832 errmsg ("missing dst addr");
8836 M (OAM_ADD_DEL, mp);
8838 mp->vrf_id = ntohl (vrf_id);
8839 mp->is_add = is_add;
8840 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8841 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8849 api_reset_fib (vat_main_t * vam)
8851 unformat_input_t *i = vam->input;
8852 vl_api_reset_fib_t *mp;
8858 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8860 if (unformat (i, "vrf %d", &vrf_id))
8862 else if (unformat (i, "ipv6"))
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8871 if (vrf_id_set == 0)
8873 errmsg ("missing vrf id");
8879 mp->vrf_id = ntohl (vrf_id);
8880 mp->is_ipv6 = is_ipv6;
8888 api_dhcp_proxy_config (vat_main_t * vam)
8890 unformat_input_t *i = vam->input;
8891 vl_api_dhcp_proxy_config_t *mp;
8893 u32 server_vrf_id = 0;
8895 u8 v4_address_set = 0;
8896 u8 v6_address_set = 0;
8897 ip4_address_t v4address;
8898 ip6_address_t v6address;
8899 u8 v4_src_address_set = 0;
8900 u8 v6_src_address_set = 0;
8901 ip4_address_t v4srcaddress;
8902 ip6_address_t v6srcaddress;
8905 /* Parse args required to build the message */
8906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8908 if (unformat (i, "del"))
8910 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8912 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8914 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8916 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8918 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8919 v4_src_address_set = 1;
8920 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8921 v6_src_address_set = 1;
8926 if (v4_address_set && v6_address_set)
8928 errmsg ("both v4 and v6 server addresses set");
8931 if (!v4_address_set && !v6_address_set)
8933 errmsg ("no server addresses set");
8937 if (v4_src_address_set && v6_src_address_set)
8939 errmsg ("both v4 and v6 src addresses set");
8942 if (!v4_src_address_set && !v6_src_address_set)
8944 errmsg ("no src addresses set");
8948 if (!(v4_src_address_set && v4_address_set) &&
8949 !(v6_src_address_set && v6_address_set))
8951 errmsg ("no matching server and src addresses set");
8955 /* Construct the API message */
8956 M (DHCP_PROXY_CONFIG, mp);
8958 mp->is_add = is_add;
8959 mp->rx_vrf_id = ntohl (rx_vrf_id);
8960 mp->server_vrf_id = ntohl (server_vrf_id);
8964 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8965 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8969 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8970 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8976 /* Wait for a reply, return good/bad news */
8981 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8982 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8985 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8987 vat_main_t *vam = &vat_main;
8988 u32 i, count = mp->count;
8989 vl_api_dhcp_server_t *s;
8993 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8994 ntohl (mp->rx_vrf_id),
8995 format_ip6_address, mp->dhcp_src_address,
8996 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8999 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9000 ntohl (mp->rx_vrf_id),
9001 format_ip4_address, mp->dhcp_src_address,
9002 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9004 for (i = 0; i < count; i++)
9006 s = &mp->servers[i];
9010 " Server Table-ID %d, Server Address %U",
9011 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9014 " Server Table-ID %d, Server Address %U",
9015 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9019 static void vl_api_dhcp_proxy_details_t_handler_json
9020 (vl_api_dhcp_proxy_details_t * mp)
9022 vat_main_t *vam = &vat_main;
9023 vat_json_node_t *node = NULL;
9024 u32 i, count = mp->count;
9026 struct in6_addr ip6;
9027 vl_api_dhcp_server_t *s;
9029 if (VAT_JSON_ARRAY != vam->json_tree.type)
9031 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9032 vat_json_init_array (&vam->json_tree);
9034 node = vat_json_array_add (&vam->json_tree);
9036 vat_json_init_object (node);
9037 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9038 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9039 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9043 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9044 vat_json_object_add_ip6 (node, "src_address", ip6);
9048 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9049 vat_json_object_add_ip4 (node, "src_address", ip4);
9052 for (i = 0; i < count; i++)
9054 s = &mp->servers[i];
9056 vat_json_object_add_uint (node, "server-table-id",
9057 ntohl (s->server_vrf_id));
9061 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9062 vat_json_object_add_ip4 (node, "src_address", ip4);
9066 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9067 vat_json_object_add_ip6 (node, "server_address", ip6);
9073 api_dhcp_proxy_dump (vat_main_t * vam)
9075 unformat_input_t *i = vam->input;
9076 vl_api_control_ping_t *mp_ping;
9077 vl_api_dhcp_proxy_dump_t *mp;
9081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9083 if (unformat (i, "ipv6"))
9087 clib_warning ("parse error '%U'", format_unformat_error, i);
9092 M (DHCP_PROXY_DUMP, mp);
9094 mp->is_ip6 = is_ipv6;
9097 /* Use a control ping for synchronization */
9098 MPING (CONTROL_PING, mp_ping);
9106 api_dhcp_proxy_set_vss (vat_main_t * vam)
9108 unformat_input_t *i = vam->input;
9109 vl_api_dhcp_proxy_set_vss_t *mp;
9120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9122 if (unformat (i, "tbl_id %d", &tbl_id))
9124 if (unformat (i, "fib_id %d", &fib_id))
9126 if (unformat (i, "oui %d", &oui))
9128 else if (unformat (i, "ipv6"))
9130 else if (unformat (i, "del"))
9134 clib_warning ("parse error '%U'", format_unformat_error, i);
9139 if (tbl_id_set == 0)
9141 errmsg ("missing tbl id");
9145 if (fib_id_set == 0)
9147 errmsg ("missing fib id");
9152 errmsg ("missing oui");
9156 M (DHCP_PROXY_SET_VSS, mp);
9157 mp->tbl_id = ntohl (tbl_id);
9158 mp->fib_id = ntohl (fib_id);
9159 mp->oui = ntohl (oui);
9160 mp->is_ipv6 = is_ipv6;
9161 mp->is_add = is_add;
9169 api_dhcp_client_config (vat_main_t * vam)
9171 unformat_input_t *i = vam->input;
9172 vl_api_dhcp_client_config_t *mp;
9174 u8 sw_if_index_set = 0;
9177 u8 disable_event = 0;
9180 /* Parse args required to build the message */
9181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9183 if (unformat (i, "del"))
9186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9187 sw_if_index_set = 1;
9188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9189 sw_if_index_set = 1;
9190 else if (unformat (i, "hostname %s", &hostname))
9192 else if (unformat (i, "disable_event"))
9198 if (sw_if_index_set == 0)
9200 errmsg ("missing interface name or sw_if_index");
9204 if (vec_len (hostname) > 63)
9206 errmsg ("hostname too long");
9208 vec_add1 (hostname, 0);
9210 /* Construct the API message */
9211 M (DHCP_CLIENT_CONFIG, mp);
9213 mp->sw_if_index = htonl (sw_if_index);
9214 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9215 vec_free (hostname);
9216 mp->is_add = is_add;
9217 mp->want_dhcp_event = disable_event ? 0 : 1;
9218 mp->pid = htonl (getpid ());
9223 /* Wait for a reply, return good/bad news */
9229 api_set_ip_flow_hash (vat_main_t * vam)
9231 unformat_input_t *i = vam->input;
9232 vl_api_set_ip_flow_hash_t *mp;
9244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9246 if (unformat (i, "vrf %d", &vrf_id))
9248 else if (unformat (i, "ipv6"))
9250 else if (unformat (i, "src"))
9252 else if (unformat (i, "dst"))
9254 else if (unformat (i, "sport"))
9256 else if (unformat (i, "dport"))
9258 else if (unformat (i, "proto"))
9260 else if (unformat (i, "reverse"))
9265 clib_warning ("parse error '%U'", format_unformat_error, i);
9270 if (vrf_id_set == 0)
9272 errmsg ("missing vrf id");
9276 M (SET_IP_FLOW_HASH, mp);
9282 mp->reverse = reverse;
9283 mp->vrf_id = ntohl (vrf_id);
9284 mp->is_ipv6 = is_ipv6;
9292 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9294 unformat_input_t *i = vam->input;
9295 vl_api_sw_interface_ip6_enable_disable_t *mp;
9297 u8 sw_if_index_set = 0;
9301 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9303 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9304 sw_if_index_set = 1;
9305 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9306 sw_if_index_set = 1;
9307 else if (unformat (i, "enable"))
9309 else if (unformat (i, "disable"))
9313 clib_warning ("parse error '%U'", format_unformat_error, i);
9318 if (sw_if_index_set == 0)
9320 errmsg ("missing interface name or sw_if_index");
9324 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9326 mp->sw_if_index = ntohl (sw_if_index);
9327 mp->enable = enable;
9335 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9337 unformat_input_t *i = vam->input;
9338 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9340 u8 sw_if_index_set = 0;
9341 u8 v6_address_set = 0;
9342 ip6_address_t v6address;
9345 /* Parse args required to build the message */
9346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9349 sw_if_index_set = 1;
9350 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9351 sw_if_index_set = 1;
9352 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9358 if (sw_if_index_set == 0)
9360 errmsg ("missing interface name or sw_if_index");
9363 if (!v6_address_set)
9365 errmsg ("no address set");
9369 /* Construct the API message */
9370 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9372 mp->sw_if_index = ntohl (sw_if_index);
9373 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9378 /* Wait for a reply, return good/bad news */
9384 api_ip6nd_proxy_add_del (vat_main_t * vam)
9386 unformat_input_t *i = vam->input;
9387 vl_api_ip6nd_proxy_add_del_t *mp;
9388 u32 sw_if_index = ~0;
9389 u8 v6_address_set = 0;
9390 ip6_address_t v6address;
9394 /* Parse args required to build the message */
9395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9399 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9401 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9403 if (unformat (i, "del"))
9407 clib_warning ("parse error '%U'", format_unformat_error, i);
9412 if (sw_if_index == ~0)
9414 errmsg ("missing interface name or sw_if_index");
9417 if (!v6_address_set)
9419 errmsg ("no address set");
9423 /* Construct the API message */
9424 M (IP6ND_PROXY_ADD_DEL, mp);
9426 mp->is_del = is_del;
9427 mp->sw_if_index = ntohl (sw_if_index);
9428 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9433 /* Wait for a reply, return good/bad news */
9439 api_ip6nd_proxy_dump (vat_main_t * vam)
9441 vl_api_ip6nd_proxy_dump_t *mp;
9442 vl_api_control_ping_t *mp_ping;
9445 M (IP6ND_PROXY_DUMP, mp);
9449 /* Use a control ping for synchronization */
9450 MPING (CONTROL_PING, mp_ping);
9457 static void vl_api_ip6nd_proxy_details_t_handler
9458 (vl_api_ip6nd_proxy_details_t * mp)
9460 vat_main_t *vam = &vat_main;
9462 print (vam->ofp, "host %U sw_if_index %d",
9463 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9466 static void vl_api_ip6nd_proxy_details_t_handler_json
9467 (vl_api_ip6nd_proxy_details_t * mp)
9469 vat_main_t *vam = &vat_main;
9470 struct in6_addr ip6;
9471 vat_json_node_t *node = NULL;
9473 if (VAT_JSON_ARRAY != vam->json_tree.type)
9475 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9476 vat_json_init_array (&vam->json_tree);
9478 node = vat_json_array_add (&vam->json_tree);
9480 vat_json_init_object (node);
9481 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9483 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9484 vat_json_object_add_ip6 (node, "host", ip6);
9488 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9490 unformat_input_t *i = vam->input;
9491 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9493 u8 sw_if_index_set = 0;
9494 u32 address_length = 0;
9495 u8 v6_address_set = 0;
9496 ip6_address_t v6address;
9498 u8 no_advertise = 0;
9500 u8 no_autoconfig = 0;
9503 u32 val_lifetime = 0;
9504 u32 pref_lifetime = 0;
9507 /* Parse args required to build the message */
9508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9511 sw_if_index_set = 1;
9512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9513 sw_if_index_set = 1;
9514 else if (unformat (i, "%U/%d",
9515 unformat_ip6_address, &v6address, &address_length))
9517 else if (unformat (i, "val_life %d", &val_lifetime))
9519 else if (unformat (i, "pref_life %d", &pref_lifetime))
9521 else if (unformat (i, "def"))
9523 else if (unformat (i, "noadv"))
9525 else if (unformat (i, "offl"))
9527 else if (unformat (i, "noauto"))
9529 else if (unformat (i, "nolink"))
9531 else if (unformat (i, "isno"))
9535 clib_warning ("parse error '%U'", format_unformat_error, i);
9540 if (sw_if_index_set == 0)
9542 errmsg ("missing interface name or sw_if_index");
9545 if (!v6_address_set)
9547 errmsg ("no address set");
9551 /* Construct the API message */
9552 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9554 mp->sw_if_index = ntohl (sw_if_index);
9555 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9556 mp->address_length = address_length;
9557 mp->use_default = use_default;
9558 mp->no_advertise = no_advertise;
9559 mp->off_link = off_link;
9560 mp->no_autoconfig = no_autoconfig;
9561 mp->no_onlink = no_onlink;
9563 mp->val_lifetime = ntohl (val_lifetime);
9564 mp->pref_lifetime = ntohl (pref_lifetime);
9569 /* Wait for a reply, return good/bad news */
9575 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9577 unformat_input_t *i = vam->input;
9578 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9580 u8 sw_if_index_set = 0;
9585 u8 send_unicast = 0;
9588 u8 default_router = 0;
9589 u32 max_interval = 0;
9590 u32 min_interval = 0;
9592 u32 initial_count = 0;
9593 u32 initial_interval = 0;
9597 /* Parse args required to build the message */
9598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9601 sw_if_index_set = 1;
9602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9603 sw_if_index_set = 1;
9604 else if (unformat (i, "maxint %d", &max_interval))
9606 else if (unformat (i, "minint %d", &min_interval))
9608 else if (unformat (i, "life %d", &lifetime))
9610 else if (unformat (i, "count %d", &initial_count))
9612 else if (unformat (i, "interval %d", &initial_interval))
9614 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9616 else if (unformat (i, "managed"))
9618 else if (unformat (i, "other"))
9620 else if (unformat (i, "ll"))
9622 else if (unformat (i, "send"))
9624 else if (unformat (i, "cease"))
9626 else if (unformat (i, "isno"))
9628 else if (unformat (i, "def"))
9632 clib_warning ("parse error '%U'", format_unformat_error, i);
9637 if (sw_if_index_set == 0)
9639 errmsg ("missing interface name or sw_if_index");
9643 /* Construct the API message */
9644 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9646 mp->sw_if_index = ntohl (sw_if_index);
9647 mp->max_interval = ntohl (max_interval);
9648 mp->min_interval = ntohl (min_interval);
9649 mp->lifetime = ntohl (lifetime);
9650 mp->initial_count = ntohl (initial_count);
9651 mp->initial_interval = ntohl (initial_interval);
9652 mp->suppress = suppress;
9653 mp->managed = managed;
9655 mp->ll_option = ll_option;
9656 mp->send_unicast = send_unicast;
9659 mp->default_router = default_router;
9664 /* Wait for a reply, return good/bad news */
9670 api_set_arp_neighbor_limit (vat_main_t * vam)
9672 unformat_input_t *i = vam->input;
9673 vl_api_set_arp_neighbor_limit_t *mp;
9679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9681 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9683 else if (unformat (i, "ipv6"))
9687 clib_warning ("parse error '%U'", format_unformat_error, i);
9694 errmsg ("missing limit value");
9698 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9700 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9701 mp->is_ipv6 = is_ipv6;
9709 api_l2_patch_add_del (vat_main_t * vam)
9711 unformat_input_t *i = vam->input;
9712 vl_api_l2_patch_add_del_t *mp;
9714 u8 rx_sw_if_index_set = 0;
9716 u8 tx_sw_if_index_set = 0;
9720 /* Parse args required to build the message */
9721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9723 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9724 rx_sw_if_index_set = 1;
9725 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9726 tx_sw_if_index_set = 1;
9727 else if (unformat (i, "rx"))
9729 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9731 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9733 rx_sw_if_index_set = 1;
9738 else if (unformat (i, "tx"))
9740 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9742 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9744 tx_sw_if_index_set = 1;
9749 else if (unformat (i, "del"))
9755 if (rx_sw_if_index_set == 0)
9757 errmsg ("missing rx interface name or rx_sw_if_index");
9761 if (tx_sw_if_index_set == 0)
9763 errmsg ("missing tx interface name or tx_sw_if_index");
9767 M (L2_PATCH_ADD_DEL, mp);
9769 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9770 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9771 mp->is_add = is_add;
9779 u8 localsid_addr[16];
9788 api_sr_localsid_add_del (vat_main_t * vam)
9790 unformat_input_t *i = vam->input;
9791 vl_api_sr_localsid_add_del_t *mp;
9794 ip6_address_t localsid;
9798 u32 fib_table = ~(u32) 0;
9799 ip6_address_t next_hop;
9801 bool nexthop_set = 0;
9805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9807 if (unformat (i, "del"))
9809 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9810 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9812 else if (unformat (i, "behavior %u", &behavior));
9813 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9814 else if (unformat (i, "fib-table %u", &fib_table));
9815 else if (unformat (i, "end.psp %u", &behavior));
9820 M (SR_LOCALSID_ADD_DEL, mp);
9822 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9824 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9825 mp->behavior = behavior;
9826 mp->sw_if_index = ntohl (sw_if_index);
9827 mp->fib_table = ntohl (fib_table);
9828 mp->end_psp = end_psp;
9829 mp->is_del = is_del;
9837 api_ioam_enable (vat_main_t * vam)
9839 unformat_input_t *input = vam->input;
9840 vl_api_ioam_enable_t *mp;
9842 int has_trace_option = 0;
9843 int has_pot_option = 0;
9844 int has_seqno_option = 0;
9845 int has_analyse_option = 0;
9848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9850 if (unformat (input, "trace"))
9851 has_trace_option = 1;
9852 else if (unformat (input, "pot"))
9854 else if (unformat (input, "seqno"))
9855 has_seqno_option = 1;
9856 else if (unformat (input, "analyse"))
9857 has_analyse_option = 1;
9861 M (IOAM_ENABLE, mp);
9862 mp->id = htons (id);
9863 mp->seqno = has_seqno_option;
9864 mp->analyse = has_analyse_option;
9865 mp->pot_enable = has_pot_option;
9866 mp->trace_enable = has_trace_option;
9875 api_ioam_disable (vat_main_t * vam)
9877 vl_api_ioam_disable_t *mp;
9880 M (IOAM_DISABLE, mp);
9886 #define foreach_tcp_proto_field \
9890 #define foreach_udp_proto_field \
9894 #define foreach_ip4_proto_field \
9906 u16 src_port, dst_port;
9909 #if VPP_API_TEST_BUILTIN == 0
9911 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9913 u8 **maskp = va_arg (*args, u8 **);
9915 u8 found_something = 0;
9918 #define _(a) u8 a=0;
9919 foreach_tcp_proto_field;
9922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9925 #define _(a) else if (unformat (input, #a)) a=1;
9926 foreach_tcp_proto_field
9932 #define _(a) found_something += a;
9933 foreach_tcp_proto_field;
9936 if (found_something == 0)
9939 vec_validate (mask, sizeof (*tcp) - 1);
9941 tcp = (tcp_header_t *) mask;
9943 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9944 foreach_tcp_proto_field;
9952 unformat_udp_mask (unformat_input_t * input, va_list * args)
9954 u8 **maskp = va_arg (*args, u8 **);
9956 u8 found_something = 0;
9959 #define _(a) u8 a=0;
9960 foreach_udp_proto_field;
9963 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9966 #define _(a) else if (unformat (input, #a)) a=1;
9967 foreach_udp_proto_field
9973 #define _(a) found_something += a;
9974 foreach_udp_proto_field;
9977 if (found_something == 0)
9980 vec_validate (mask, sizeof (*udp) - 1);
9982 udp = (udp_header_t *) mask;
9984 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9985 foreach_udp_proto_field;
9993 unformat_l4_mask (unformat_input_t * input, va_list * args)
9995 u8 **maskp = va_arg (*args, u8 **);
9996 u16 src_port = 0, dst_port = 0;
9997 tcpudp_header_t *tcpudp;
9999 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10001 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10003 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10005 else if (unformat (input, "src_port"))
10007 else if (unformat (input, "dst_port"))
10013 if (!src_port && !dst_port)
10017 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10019 tcpudp = (tcpudp_header_t *) mask;
10020 tcpudp->src_port = src_port;
10021 tcpudp->dst_port = dst_port;
10029 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10031 u8 **maskp = va_arg (*args, u8 **);
10033 u8 found_something = 0;
10036 #define _(a) u8 a=0;
10037 foreach_ip4_proto_field;
10043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10045 if (unformat (input, "version"))
10047 else if (unformat (input, "hdr_length"))
10049 else if (unformat (input, "src"))
10051 else if (unformat (input, "dst"))
10053 else if (unformat (input, "proto"))
10056 #define _(a) else if (unformat (input, #a)) a=1;
10057 foreach_ip4_proto_field
10063 #define _(a) found_something += a;
10064 foreach_ip4_proto_field;
10067 if (found_something == 0)
10070 vec_validate (mask, sizeof (*ip) - 1);
10072 ip = (ip4_header_t *) mask;
10074 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10075 foreach_ip4_proto_field;
10078 ip->ip_version_and_header_length = 0;
10081 ip->ip_version_and_header_length |= 0xF0;
10084 ip->ip_version_and_header_length |= 0x0F;
10090 #define foreach_ip6_proto_field \
10093 _(payload_length) \
10098 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10100 u8 **maskp = va_arg (*args, u8 **);
10102 u8 found_something = 0;
10104 u32 ip_version_traffic_class_and_flow_label;
10106 #define _(a) u8 a=0;
10107 foreach_ip6_proto_field;
10110 u8 traffic_class = 0;
10113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10115 if (unformat (input, "version"))
10117 else if (unformat (input, "traffic-class"))
10119 else if (unformat (input, "flow-label"))
10121 else if (unformat (input, "src"))
10123 else if (unformat (input, "dst"))
10125 else if (unformat (input, "proto"))
10128 #define _(a) else if (unformat (input, #a)) a=1;
10129 foreach_ip6_proto_field
10135 #define _(a) found_something += a;
10136 foreach_ip6_proto_field;
10139 if (found_something == 0)
10142 vec_validate (mask, sizeof (*ip) - 1);
10144 ip = (ip6_header_t *) mask;
10146 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10147 foreach_ip6_proto_field;
10150 ip_version_traffic_class_and_flow_label = 0;
10153 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10156 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10159 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10161 ip->ip_version_traffic_class_and_flow_label =
10162 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10169 unformat_l3_mask (unformat_input_t * input, va_list * args)
10171 u8 **maskp = va_arg (*args, u8 **);
10173 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10175 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10177 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10186 unformat_l2_mask (unformat_input_t * input, va_list * args)
10188 u8 **maskp = va_arg (*args, u8 **);
10195 u8 ignore_tag1 = 0;
10196 u8 ignore_tag2 = 0;
10203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10205 if (unformat (input, "src"))
10207 else if (unformat (input, "dst"))
10209 else if (unformat (input, "proto"))
10211 else if (unformat (input, "tag1"))
10213 else if (unformat (input, "tag2"))
10215 else if (unformat (input, "ignore-tag1"))
10217 else if (unformat (input, "ignore-tag2"))
10219 else if (unformat (input, "cos1"))
10221 else if (unformat (input, "cos2"))
10223 else if (unformat (input, "dot1q"))
10225 else if (unformat (input, "dot1ad"))
10230 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10231 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10234 if (tag1 || ignore_tag1 || cos1 || dot1q)
10236 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10239 vec_validate (mask, len - 1);
10242 memset (mask, 0xff, 6);
10245 memset (mask + 6, 0xff, 6);
10247 if (tag2 || dot1ad)
10249 /* inner vlan tag */
10258 mask[21] = mask[20] = 0xff;
10279 mask[16] = mask[17] = 0xff;
10289 mask[12] = mask[13] = 0xff;
10296 unformat_classify_mask (unformat_input_t * input, va_list * args)
10298 u8 **maskp = va_arg (*args, u8 **);
10299 u32 *skipp = va_arg (*args, u32 *);
10300 u32 *matchp = va_arg (*args, u32 *);
10308 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10310 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10312 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10314 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10316 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10330 if (mask || l2 || l3 || l4)
10332 if (l2 || l3 || l4)
10334 /* "With a free Ethernet header in every package" */
10336 vec_validate (l2, 13);
10340 vec_append (mask, l3);
10345 vec_append (mask, l4);
10350 /* Scan forward looking for the first significant mask octet */
10351 for (i = 0; i < vec_len (mask); i++)
10355 /* compute (skip, match) params */
10356 *skipp = i / sizeof (u32x4);
10357 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10359 /* Pad mask to an even multiple of the vector size */
10360 while (vec_len (mask) % sizeof (u32x4))
10361 vec_add1 (mask, 0);
10363 match = vec_len (mask) / sizeof (u32x4);
10365 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10367 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10368 if (*tmp || *(tmp + 1))
10373 clib_warning ("BUG: match 0");
10375 _vec_len (mask) = match * sizeof (u32x4);
10385 #endif /* VPP_API_TEST_BUILTIN */
10387 #define foreach_l2_next \
10389 _(ethernet, ETHERNET_INPUT) \
10390 _(ip4, IP4_INPUT) \
10394 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10396 u32 *miss_next_indexp = va_arg (*args, u32 *);
10397 u32 next_index = 0;
10401 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10405 if (unformat (input, "%d", &tmp))
10414 *miss_next_indexp = next_index;
10418 #define foreach_ip_next \
10421 _(rewrite, REWRITE)
10424 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10426 u32 *miss_next_indexp = va_arg (*args, u32 *);
10427 u32 next_index = 0;
10431 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10435 if (unformat (input, "%d", &tmp))
10444 *miss_next_indexp = next_index;
10448 #define foreach_acl_next \
10452 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10454 u32 *miss_next_indexp = va_arg (*args, u32 *);
10455 u32 next_index = 0;
10459 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10463 if (unformat (input, "permit"))
10468 else if (unformat (input, "%d", &tmp))
10477 *miss_next_indexp = next_index;
10482 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10484 u32 *r = va_arg (*args, u32 *);
10486 if (unformat (input, "conform-color"))
10487 *r = POLICE_CONFORM;
10488 else if (unformat (input, "exceed-color"))
10489 *r = POLICE_EXCEED;
10497 api_classify_add_del_table (vat_main_t * vam)
10499 unformat_input_t *i = vam->input;
10500 vl_api_classify_add_del_table_t *mp;
10507 u32 table_index = ~0;
10508 u32 next_table_index = ~0;
10509 u32 miss_next_index = ~0;
10510 u32 memory_size = 32 << 20;
10512 u32 current_data_flag = 0;
10513 int current_data_offset = 0;
10516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10518 if (unformat (i, "del"))
10520 else if (unformat (i, "del-chain"))
10525 else if (unformat (i, "buckets %d", &nbuckets))
10527 else if (unformat (i, "memory_size %d", &memory_size))
10529 else if (unformat (i, "skip %d", &skip))
10531 else if (unformat (i, "match %d", &match))
10533 else if (unformat (i, "table %d", &table_index))
10535 else if (unformat (i, "mask %U", unformat_classify_mask,
10536 &mask, &skip, &match))
10538 else if (unformat (i, "next-table %d", &next_table_index))
10540 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10543 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10546 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10549 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10551 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10557 if (is_add && mask == 0)
10559 errmsg ("Mask required");
10563 if (is_add && skip == ~0)
10565 errmsg ("skip count required");
10569 if (is_add && match == ~0)
10571 errmsg ("match count required");
10575 if (!is_add && table_index == ~0)
10577 errmsg ("table index required for delete");
10581 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10583 mp->is_add = is_add;
10584 mp->del_chain = del_chain;
10585 mp->table_index = ntohl (table_index);
10586 mp->nbuckets = ntohl (nbuckets);
10587 mp->memory_size = ntohl (memory_size);
10588 mp->skip_n_vectors = ntohl (skip);
10589 mp->match_n_vectors = ntohl (match);
10590 mp->next_table_index = ntohl (next_table_index);
10591 mp->miss_next_index = ntohl (miss_next_index);
10592 mp->current_data_flag = ntohl (current_data_flag);
10593 mp->current_data_offset = ntohl (current_data_offset);
10594 clib_memcpy (mp->mask, mask, vec_len (mask));
10603 #if VPP_API_TEST_BUILTIN == 0
10605 unformat_l4_match (unformat_input_t * input, va_list * args)
10607 u8 **matchp = va_arg (*args, u8 **);
10609 u8 *proto_header = 0;
10615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10617 if (unformat (input, "src_port %d", &src_port))
10619 else if (unformat (input, "dst_port %d", &dst_port))
10625 h.src_port = clib_host_to_net_u16 (src_port);
10626 h.dst_port = clib_host_to_net_u16 (dst_port);
10627 vec_validate (proto_header, sizeof (h) - 1);
10628 memcpy (proto_header, &h, sizeof (h));
10630 *matchp = proto_header;
10636 unformat_ip4_match (unformat_input_t * input, va_list * args)
10638 u8 **matchp = va_arg (*args, u8 **);
10643 int hdr_length = 0;
10644 u32 hdr_length_val;
10645 int src = 0, dst = 0;
10646 ip4_address_t src_val, dst_val;
10653 int fragment_id = 0;
10654 u32 fragment_id_val;
10660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10662 if (unformat (input, "version %d", &version_val))
10664 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10666 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10668 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10670 else if (unformat (input, "proto %d", &proto_val))
10672 else if (unformat (input, "tos %d", &tos_val))
10674 else if (unformat (input, "length %d", &length_val))
10676 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10678 else if (unformat (input, "ttl %d", &ttl_val))
10680 else if (unformat (input, "checksum %d", &checksum_val))
10686 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10687 + ttl + checksum == 0)
10691 * Aligned because we use the real comparison functions
10693 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10695 ip = (ip4_header_t *) match;
10697 /* These are realistically matched in practice */
10699 ip->src_address.as_u32 = src_val.as_u32;
10702 ip->dst_address.as_u32 = dst_val.as_u32;
10705 ip->protocol = proto_val;
10708 /* These are not, but they're included for completeness */
10710 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10713 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10719 ip->length = clib_host_to_net_u16 (length_val);
10725 ip->checksum = clib_host_to_net_u16 (checksum_val);
10732 unformat_ip6_match (unformat_input_t * input, va_list * args)
10734 u8 **matchp = va_arg (*args, u8 **);
10739 u8 traffic_class = 0;
10740 u32 traffic_class_val = 0;
10743 int src = 0, dst = 0;
10744 ip6_address_t src_val, dst_val;
10747 int payload_length = 0;
10748 u32 payload_length_val;
10751 u32 ip_version_traffic_class_and_flow_label;
10753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10755 if (unformat (input, "version %d", &version_val))
10757 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10759 else if (unformat (input, "flow_label %d", &flow_label_val))
10761 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10763 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10765 else if (unformat (input, "proto %d", &proto_val))
10767 else if (unformat (input, "payload_length %d", &payload_length_val))
10768 payload_length = 1;
10769 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10775 if (version + traffic_class + flow_label + src + dst + proto +
10776 payload_length + hop_limit == 0)
10780 * Aligned because we use the real comparison functions
10782 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10784 ip = (ip6_header_t *) match;
10787 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10790 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10793 ip->protocol = proto_val;
10795 ip_version_traffic_class_and_flow_label = 0;
10798 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10801 ip_version_traffic_class_and_flow_label |=
10802 (traffic_class_val & 0xFF) << 20;
10805 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10807 ip->ip_version_traffic_class_and_flow_label =
10808 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10810 if (payload_length)
10811 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10814 ip->hop_limit = hop_limit_val;
10821 unformat_l3_match (unformat_input_t * input, va_list * args)
10823 u8 **matchp = va_arg (*args, u8 **);
10825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10827 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10829 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10838 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10840 u8 *tagp = va_arg (*args, u8 *);
10843 if (unformat (input, "%d", &tag))
10845 tagp[0] = (tag >> 8) & 0x0F;
10846 tagp[1] = tag & 0xFF;
10854 unformat_l2_match (unformat_input_t * input, va_list * args)
10856 u8 **matchp = va_arg (*args, u8 **);
10869 u8 ignore_tag1 = 0;
10870 u8 ignore_tag2 = 0;
10876 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10878 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10881 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10883 else if (unformat (input, "proto %U",
10884 unformat_ethernet_type_host_byte_order, &proto_val))
10886 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10888 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10890 else if (unformat (input, "ignore-tag1"))
10892 else if (unformat (input, "ignore-tag2"))
10894 else if (unformat (input, "cos1 %d", &cos1_val))
10896 else if (unformat (input, "cos2 %d", &cos2_val))
10901 if ((src + dst + proto + tag1 + tag2 +
10902 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10905 if (tag1 || ignore_tag1 || cos1)
10907 if (tag2 || ignore_tag2 || cos2)
10910 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10913 clib_memcpy (match, dst_val, 6);
10916 clib_memcpy (match + 6, src_val, 6);
10920 /* inner vlan tag */
10921 match[19] = tag2_val[1];
10922 match[18] = tag2_val[0];
10924 match[18] |= (cos2_val & 0x7) << 5;
10927 match[21] = proto_val & 0xff;
10928 match[20] = proto_val >> 8;
10932 match[15] = tag1_val[1];
10933 match[14] = tag1_val[0];
10936 match[14] |= (cos1_val & 0x7) << 5;
10942 match[15] = tag1_val[1];
10943 match[14] = tag1_val[0];
10946 match[17] = proto_val & 0xff;
10947 match[16] = proto_val >> 8;
10950 match[14] |= (cos1_val & 0x7) << 5;
10956 match[18] |= (cos2_val & 0x7) << 5;
10958 match[14] |= (cos1_val & 0x7) << 5;
10961 match[13] = proto_val & 0xff;
10962 match[12] = proto_val >> 8;
10971 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10973 u8 **matchp = va_arg (*args, u8 **);
10974 u32 skip_n_vectors = va_arg (*args, u32);
10975 u32 match_n_vectors = va_arg (*args, u32);
10982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10984 if (unformat (input, "hex %U", unformat_hex_string, &match))
10986 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10988 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10990 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11004 if (match || l2 || l3 || l4)
11006 if (l2 || l3 || l4)
11008 /* "Win a free Ethernet header in every packet" */
11010 vec_validate_aligned (l2, 13, sizeof (u32x4));
11014 vec_append_aligned (match, l3, sizeof (u32x4));
11019 vec_append_aligned (match, l4, sizeof (u32x4));
11024 /* Make sure the vector is big enough even if key is all 0's */
11025 vec_validate_aligned
11026 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11029 /* Set size, include skipped vectors */
11030 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11041 api_classify_add_del_session (vat_main_t * vam)
11043 unformat_input_t *i = vam->input;
11044 vl_api_classify_add_del_session_t *mp;
11046 u32 table_index = ~0;
11047 u32 hit_next_index = ~0;
11048 u32 opaque_index = ~0;
11051 u32 skip_n_vectors = 0;
11052 u32 match_n_vectors = 0;
11058 * Warning: you have to supply skip_n and match_n
11059 * because the API client cant simply look at the classify
11063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11065 if (unformat (i, "del"))
11067 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11070 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11073 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11076 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11078 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11080 else if (unformat (i, "opaque-index %d", &opaque_index))
11082 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11084 else if (unformat (i, "match_n %d", &match_n_vectors))
11086 else if (unformat (i, "match %U", api_unformat_classify_match,
11087 &match, skip_n_vectors, match_n_vectors))
11089 else if (unformat (i, "advance %d", &advance))
11091 else if (unformat (i, "table-index %d", &table_index))
11093 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11095 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11097 else if (unformat (i, "action %d", &action))
11099 else if (unformat (i, "metadata %d", &metadata))
11105 if (table_index == ~0)
11107 errmsg ("Table index required");
11111 if (is_add && match == 0)
11113 errmsg ("Match value required");
11117 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11119 mp->is_add = is_add;
11120 mp->table_index = ntohl (table_index);
11121 mp->hit_next_index = ntohl (hit_next_index);
11122 mp->opaque_index = ntohl (opaque_index);
11123 mp->advance = ntohl (advance);
11124 mp->action = action;
11125 mp->metadata = ntohl (metadata);
11126 clib_memcpy (mp->match, match, vec_len (match));
11135 api_classify_set_interface_ip_table (vat_main_t * vam)
11137 unformat_input_t *i = vam->input;
11138 vl_api_classify_set_interface_ip_table_t *mp;
11140 int sw_if_index_set;
11141 u32 table_index = ~0;
11145 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11147 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11148 sw_if_index_set = 1;
11149 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11150 sw_if_index_set = 1;
11151 else if (unformat (i, "table %d", &table_index))
11155 clib_warning ("parse error '%U'", format_unformat_error, i);
11160 if (sw_if_index_set == 0)
11162 errmsg ("missing interface name or sw_if_index");
11167 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11169 mp->sw_if_index = ntohl (sw_if_index);
11170 mp->table_index = ntohl (table_index);
11171 mp->is_ipv6 = is_ipv6;
11179 api_classify_set_interface_l2_tables (vat_main_t * vam)
11181 unformat_input_t *i = vam->input;
11182 vl_api_classify_set_interface_l2_tables_t *mp;
11184 int sw_if_index_set;
11185 u32 ip4_table_index = ~0;
11186 u32 ip6_table_index = ~0;
11187 u32 other_table_index = ~0;
11191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11193 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11196 sw_if_index_set = 1;
11197 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11199 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11201 else if (unformat (i, "other-table %d", &other_table_index))
11203 else if (unformat (i, "is-input %d", &is_input))
11207 clib_warning ("parse error '%U'", format_unformat_error, i);
11212 if (sw_if_index_set == 0)
11214 errmsg ("missing interface name or sw_if_index");
11219 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11221 mp->sw_if_index = ntohl (sw_if_index);
11222 mp->ip4_table_index = ntohl (ip4_table_index);
11223 mp->ip6_table_index = ntohl (ip6_table_index);
11224 mp->other_table_index = ntohl (other_table_index);
11225 mp->is_input = (u8) is_input;
11233 api_set_ipfix_exporter (vat_main_t * vam)
11235 unformat_input_t *i = vam->input;
11236 vl_api_set_ipfix_exporter_t *mp;
11237 ip4_address_t collector_address;
11238 u8 collector_address_set = 0;
11239 u32 collector_port = ~0;
11240 ip4_address_t src_address;
11241 u8 src_address_set = 0;
11244 u32 template_interval = ~0;
11245 u8 udp_checksum = 0;
11248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11250 if (unformat (i, "collector_address %U", unformat_ip4_address,
11251 &collector_address))
11252 collector_address_set = 1;
11253 else if (unformat (i, "collector_port %d", &collector_port))
11255 else if (unformat (i, "src_address %U", unformat_ip4_address,
11257 src_address_set = 1;
11258 else if (unformat (i, "vrf_id %d", &vrf_id))
11260 else if (unformat (i, "path_mtu %d", &path_mtu))
11262 else if (unformat (i, "template_interval %d", &template_interval))
11264 else if (unformat (i, "udp_checksum"))
11270 if (collector_address_set == 0)
11272 errmsg ("collector_address required");
11276 if (src_address_set == 0)
11278 errmsg ("src_address required");
11282 M (SET_IPFIX_EXPORTER, mp);
11284 memcpy (mp->collector_address, collector_address.data,
11285 sizeof (collector_address.data));
11286 mp->collector_port = htons ((u16) collector_port);
11287 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11288 mp->vrf_id = htonl (vrf_id);
11289 mp->path_mtu = htonl (path_mtu);
11290 mp->template_interval = htonl (template_interval);
11291 mp->udp_checksum = udp_checksum;
11299 api_set_ipfix_classify_stream (vat_main_t * vam)
11301 unformat_input_t *i = vam->input;
11302 vl_api_set_ipfix_classify_stream_t *mp;
11304 u32 src_port = UDP_DST_PORT_ipfix;
11307 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11309 if (unformat (i, "domain %d", &domain_id))
11311 else if (unformat (i, "src_port %d", &src_port))
11315 errmsg ("unknown input `%U'", format_unformat_error, i);
11320 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11322 mp->domain_id = htonl (domain_id);
11323 mp->src_port = htons ((u16) src_port);
11331 api_ipfix_classify_table_add_del (vat_main_t * vam)
11333 unformat_input_t *i = vam->input;
11334 vl_api_ipfix_classify_table_add_del_t *mp;
11336 u32 classify_table_index = ~0;
11338 u8 transport_protocol = 255;
11341 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11343 if (unformat (i, "add"))
11345 else if (unformat (i, "del"))
11347 else if (unformat (i, "table %d", &classify_table_index))
11349 else if (unformat (i, "ip4"))
11351 else if (unformat (i, "ip6"))
11353 else if (unformat (i, "tcp"))
11354 transport_protocol = 6;
11355 else if (unformat (i, "udp"))
11356 transport_protocol = 17;
11359 errmsg ("unknown input `%U'", format_unformat_error, i);
11366 errmsg ("expecting: add|del");
11369 if (classify_table_index == ~0)
11371 errmsg ("classifier table not specified");
11374 if (ip_version == 0)
11376 errmsg ("IP version not specified");
11380 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11382 mp->is_add = is_add;
11383 mp->table_id = htonl (classify_table_index);
11384 mp->ip_version = ip_version;
11385 mp->transport_protocol = transport_protocol;
11393 api_get_node_index (vat_main_t * vam)
11395 unformat_input_t *i = vam->input;
11396 vl_api_get_node_index_t *mp;
11400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11402 if (unformat (i, "node %s", &name))
11409 errmsg ("node name required");
11412 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11414 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11418 M (GET_NODE_INDEX, mp);
11419 clib_memcpy (mp->node_name, name, vec_len (name));
11428 api_get_next_index (vat_main_t * vam)
11430 unformat_input_t *i = vam->input;
11431 vl_api_get_next_index_t *mp;
11432 u8 *node_name = 0, *next_node_name = 0;
11435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11437 if (unformat (i, "node-name %s", &node_name))
11439 else if (unformat (i, "next-node-name %s", &next_node_name))
11443 if (node_name == 0)
11445 errmsg ("node name required");
11448 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11450 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11454 if (next_node_name == 0)
11456 errmsg ("next node name required");
11459 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11461 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11465 M (GET_NEXT_INDEX, mp);
11466 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11467 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11468 vec_free (node_name);
11469 vec_free (next_node_name);
11477 api_add_node_next (vat_main_t * vam)
11479 unformat_input_t *i = vam->input;
11480 vl_api_add_node_next_t *mp;
11485 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11487 if (unformat (i, "node %s", &name))
11489 else if (unformat (i, "next %s", &next))
11496 errmsg ("node name required");
11499 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11501 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11506 errmsg ("next node required");
11509 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11511 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11515 M (ADD_NODE_NEXT, mp);
11516 clib_memcpy (mp->node_name, name, vec_len (name));
11517 clib_memcpy (mp->next_name, next, vec_len (next));
11527 api_l2tpv3_create_tunnel (vat_main_t * vam)
11529 unformat_input_t *i = vam->input;
11530 ip6_address_t client_address, our_address;
11531 int client_address_set = 0;
11532 int our_address_set = 0;
11533 u32 local_session_id = 0;
11534 u32 remote_session_id = 0;
11535 u64 local_cookie = 0;
11536 u64 remote_cookie = 0;
11537 u8 l2_sublayer_present = 0;
11538 vl_api_l2tpv3_create_tunnel_t *mp;
11541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11543 if (unformat (i, "client_address %U", unformat_ip6_address,
11545 client_address_set = 1;
11546 else if (unformat (i, "our_address %U", unformat_ip6_address,
11548 our_address_set = 1;
11549 else if (unformat (i, "local_session_id %d", &local_session_id))
11551 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11553 else if (unformat (i, "local_cookie %lld", &local_cookie))
11555 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11557 else if (unformat (i, "l2-sublayer-present"))
11558 l2_sublayer_present = 1;
11563 if (client_address_set == 0)
11565 errmsg ("client_address required");
11569 if (our_address_set == 0)
11571 errmsg ("our_address required");
11575 M (L2TPV3_CREATE_TUNNEL, mp);
11577 clib_memcpy (mp->client_address, client_address.as_u8,
11578 sizeof (mp->client_address));
11580 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11582 mp->local_session_id = ntohl (local_session_id);
11583 mp->remote_session_id = ntohl (remote_session_id);
11584 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11585 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11586 mp->l2_sublayer_present = l2_sublayer_present;
11595 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11597 unformat_input_t *i = vam->input;
11599 u8 sw_if_index_set = 0;
11600 u64 new_local_cookie = 0;
11601 u64 new_remote_cookie = 0;
11602 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11605 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11607 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11608 sw_if_index_set = 1;
11609 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11610 sw_if_index_set = 1;
11611 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11613 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11619 if (sw_if_index_set == 0)
11621 errmsg ("missing interface name or sw_if_index");
11625 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11627 mp->sw_if_index = ntohl (sw_if_index);
11628 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11629 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11637 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11639 unformat_input_t *i = vam->input;
11640 vl_api_l2tpv3_interface_enable_disable_t *mp;
11642 u8 sw_if_index_set = 0;
11643 u8 enable_disable = 1;
11646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11649 sw_if_index_set = 1;
11650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11651 sw_if_index_set = 1;
11652 else if (unformat (i, "enable"))
11653 enable_disable = 1;
11654 else if (unformat (i, "disable"))
11655 enable_disable = 0;
11660 if (sw_if_index_set == 0)
11662 errmsg ("missing interface name or sw_if_index");
11666 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11668 mp->sw_if_index = ntohl (sw_if_index);
11669 mp->enable_disable = enable_disable;
11677 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11679 unformat_input_t *i = vam->input;
11680 vl_api_l2tpv3_set_lookup_key_t *mp;
11684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11686 if (unformat (i, "lookup_v6_src"))
11687 key = L2T_LOOKUP_SRC_ADDRESS;
11688 else if (unformat (i, "lookup_v6_dst"))
11689 key = L2T_LOOKUP_DST_ADDRESS;
11690 else if (unformat (i, "lookup_session_id"))
11691 key = L2T_LOOKUP_SESSION_ID;
11696 if (key == (u8) ~ 0)
11698 errmsg ("l2tp session lookup key unset");
11702 M (L2TPV3_SET_LOOKUP_KEY, mp);
11711 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11712 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11714 vat_main_t *vam = &vat_main;
11716 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11717 format_ip6_address, mp->our_address,
11718 format_ip6_address, mp->client_address,
11719 clib_net_to_host_u32 (mp->sw_if_index));
11722 " local cookies %016llx %016llx remote cookie %016llx",
11723 clib_net_to_host_u64 (mp->local_cookie[0]),
11724 clib_net_to_host_u64 (mp->local_cookie[1]),
11725 clib_net_to_host_u64 (mp->remote_cookie));
11727 print (vam->ofp, " local session-id %d remote session-id %d",
11728 clib_net_to_host_u32 (mp->local_session_id),
11729 clib_net_to_host_u32 (mp->remote_session_id));
11731 print (vam->ofp, " l2 specific sublayer %s\n",
11732 mp->l2_sublayer_present ? "preset" : "absent");
11736 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11737 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11739 vat_main_t *vam = &vat_main;
11740 vat_json_node_t *node = NULL;
11741 struct in6_addr addr;
11743 if (VAT_JSON_ARRAY != vam->json_tree.type)
11745 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11746 vat_json_init_array (&vam->json_tree);
11748 node = vat_json_array_add (&vam->json_tree);
11750 vat_json_init_object (node);
11752 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11753 vat_json_object_add_ip6 (node, "our_address", addr);
11754 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11755 vat_json_object_add_ip6 (node, "client_address", addr);
11757 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11758 vat_json_init_array (lc);
11759 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11760 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11761 vat_json_object_add_uint (node, "remote_cookie",
11762 clib_net_to_host_u64 (mp->remote_cookie));
11764 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11765 vat_json_object_add_uint (node, "local_session_id",
11766 clib_net_to_host_u32 (mp->local_session_id));
11767 vat_json_object_add_uint (node, "remote_session_id",
11768 clib_net_to_host_u32 (mp->remote_session_id));
11769 vat_json_object_add_string_copy (node, "l2_sublayer",
11770 mp->l2_sublayer_present ? (u8 *) "present"
11771 : (u8 *) "absent");
11775 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11777 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11778 vl_api_control_ping_t *mp_ping;
11781 /* Get list of l2tpv3-tunnel interfaces */
11782 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11785 /* Use a control ping for synchronization */
11786 MPING (CONTROL_PING, mp_ping);
11794 static void vl_api_sw_interface_tap_details_t_handler
11795 (vl_api_sw_interface_tap_details_t * mp)
11797 vat_main_t *vam = &vat_main;
11799 print (vam->ofp, "%-16s %d",
11800 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11803 static void vl_api_sw_interface_tap_details_t_handler_json
11804 (vl_api_sw_interface_tap_details_t * mp)
11806 vat_main_t *vam = &vat_main;
11807 vat_json_node_t *node = NULL;
11809 if (VAT_JSON_ARRAY != vam->json_tree.type)
11811 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11812 vat_json_init_array (&vam->json_tree);
11814 node = vat_json_array_add (&vam->json_tree);
11816 vat_json_init_object (node);
11817 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11818 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11822 api_sw_interface_tap_dump (vat_main_t * vam)
11824 vl_api_sw_interface_tap_dump_t *mp;
11825 vl_api_control_ping_t *mp_ping;
11828 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11829 /* Get list of tap interfaces */
11830 M (SW_INTERFACE_TAP_DUMP, mp);
11833 /* Use a control ping for synchronization */
11834 MPING (CONTROL_PING, mp_ping);
11841 static uword unformat_vxlan_decap_next
11842 (unformat_input_t * input, va_list * args)
11844 u32 *result = va_arg (*args, u32 *);
11847 if (unformat (input, "l2"))
11848 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11849 else if (unformat (input, "%d", &tmp))
11857 api_vxlan_add_del_tunnel (vat_main_t * vam)
11859 unformat_input_t *line_input = vam->input;
11860 vl_api_vxlan_add_del_tunnel_t *mp;
11861 ip46_address_t src, dst;
11863 u8 ipv4_set = 0, ipv6_set = 0;
11867 u32 mcast_sw_if_index = ~0;
11868 u32 encap_vrf_id = 0;
11869 u32 decap_next_index = ~0;
11873 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11874 memset (&src, 0, sizeof src);
11875 memset (&dst, 0, sizeof dst);
11877 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11879 if (unformat (line_input, "del"))
11882 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11888 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11894 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11900 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11905 else if (unformat (line_input, "group %U %U",
11906 unformat_ip4_address, &dst.ip4,
11907 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11909 grp_set = dst_set = 1;
11912 else if (unformat (line_input, "group %U",
11913 unformat_ip4_address, &dst.ip4))
11915 grp_set = dst_set = 1;
11918 else if (unformat (line_input, "group %U %U",
11919 unformat_ip6_address, &dst.ip6,
11920 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11922 grp_set = dst_set = 1;
11925 else if (unformat (line_input, "group %U",
11926 unformat_ip6_address, &dst.ip6))
11928 grp_set = dst_set = 1;
11932 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11934 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11936 else if (unformat (line_input, "decap-next %U",
11937 unformat_vxlan_decap_next, &decap_next_index))
11939 else if (unformat (line_input, "vni %d", &vni))
11943 errmsg ("parse error '%U'", format_unformat_error, line_input);
11950 errmsg ("tunnel src address not specified");
11955 errmsg ("tunnel dst address not specified");
11959 if (grp_set && !ip46_address_is_multicast (&dst))
11961 errmsg ("tunnel group address not multicast");
11964 if (grp_set && mcast_sw_if_index == ~0)
11966 errmsg ("tunnel nonexistent multicast device");
11969 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11971 errmsg ("tunnel dst address must be unicast");
11976 if (ipv4_set && ipv6_set)
11978 errmsg ("both IPv4 and IPv6 addresses specified");
11982 if ((vni == 0) || (vni >> 24))
11984 errmsg ("vni not specified or out of range");
11988 M (VXLAN_ADD_DEL_TUNNEL, mp);
11992 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11993 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11997 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11998 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12000 mp->encap_vrf_id = ntohl (encap_vrf_id);
12001 mp->decap_next_index = ntohl (decap_next_index);
12002 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12003 mp->vni = ntohl (vni);
12004 mp->is_add = is_add;
12005 mp->is_ipv6 = ipv6_set;
12012 static void vl_api_vxlan_tunnel_details_t_handler
12013 (vl_api_vxlan_tunnel_details_t * mp)
12015 vat_main_t *vam = &vat_main;
12016 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12017 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12019 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12020 ntohl (mp->sw_if_index),
12021 format_ip46_address, &src, IP46_TYPE_ANY,
12022 format_ip46_address, &dst, IP46_TYPE_ANY,
12023 ntohl (mp->encap_vrf_id),
12024 ntohl (mp->decap_next_index), ntohl (mp->vni),
12025 ntohl (mp->mcast_sw_if_index));
12028 static void vl_api_vxlan_tunnel_details_t_handler_json
12029 (vl_api_vxlan_tunnel_details_t * mp)
12031 vat_main_t *vam = &vat_main;
12032 vat_json_node_t *node = NULL;
12034 if (VAT_JSON_ARRAY != vam->json_tree.type)
12036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12037 vat_json_init_array (&vam->json_tree);
12039 node = vat_json_array_add (&vam->json_tree);
12041 vat_json_init_object (node);
12042 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12045 struct in6_addr ip6;
12047 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12048 vat_json_object_add_ip6 (node, "src_address", ip6);
12049 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12050 vat_json_object_add_ip6 (node, "dst_address", ip6);
12054 struct in_addr ip4;
12056 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12057 vat_json_object_add_ip4 (node, "src_address", ip4);
12058 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12059 vat_json_object_add_ip4 (node, "dst_address", ip4);
12061 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12062 vat_json_object_add_uint (node, "decap_next_index",
12063 ntohl (mp->decap_next_index));
12064 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12065 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12066 vat_json_object_add_uint (node, "mcast_sw_if_index",
12067 ntohl (mp->mcast_sw_if_index));
12071 api_vxlan_tunnel_dump (vat_main_t * vam)
12073 unformat_input_t *i = vam->input;
12074 vl_api_vxlan_tunnel_dump_t *mp;
12075 vl_api_control_ping_t *mp_ping;
12077 u8 sw_if_index_set = 0;
12080 /* Parse args required to build the message */
12081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12083 if (unformat (i, "sw_if_index %d", &sw_if_index))
12084 sw_if_index_set = 1;
12089 if (sw_if_index_set == 0)
12094 if (!vam->json_output)
12096 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12097 "sw_if_index", "src_address", "dst_address",
12098 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12101 /* Get list of vxlan-tunnel interfaces */
12102 M (VXLAN_TUNNEL_DUMP, mp);
12104 mp->sw_if_index = htonl (sw_if_index);
12108 /* Use a control ping for synchronization */
12109 MPING (CONTROL_PING, mp_ping);
12116 static uword unformat_geneve_decap_next
12117 (unformat_input_t * input, va_list * args)
12119 u32 *result = va_arg (*args, u32 *);
12122 if (unformat (input, "l2"))
12123 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12124 else if (unformat (input, "%d", &tmp))
12132 api_geneve_add_del_tunnel (vat_main_t * vam)
12134 unformat_input_t *line_input = vam->input;
12135 vl_api_geneve_add_del_tunnel_t *mp;
12136 ip46_address_t src, dst;
12138 u8 ipv4_set = 0, ipv6_set = 0;
12142 u32 mcast_sw_if_index = ~0;
12143 u32 encap_vrf_id = 0;
12144 u32 decap_next_index = ~0;
12148 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12149 memset (&src, 0, sizeof src);
12150 memset (&dst, 0, sizeof dst);
12152 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12154 if (unformat (line_input, "del"))
12157 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12163 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12169 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12175 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12180 else if (unformat (line_input, "group %U %U",
12181 unformat_ip4_address, &dst.ip4,
12182 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12184 grp_set = dst_set = 1;
12187 else if (unformat (line_input, "group %U",
12188 unformat_ip4_address, &dst.ip4))
12190 grp_set = dst_set = 1;
12193 else if (unformat (line_input, "group %U %U",
12194 unformat_ip6_address, &dst.ip6,
12195 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12197 grp_set = dst_set = 1;
12200 else if (unformat (line_input, "group %U",
12201 unformat_ip6_address, &dst.ip6))
12203 grp_set = dst_set = 1;
12207 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12209 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12211 else if (unformat (line_input, "decap-next %U",
12212 unformat_geneve_decap_next, &decap_next_index))
12214 else if (unformat (line_input, "vni %d", &vni))
12218 errmsg ("parse error '%U'", format_unformat_error, line_input);
12225 errmsg ("tunnel src address not specified");
12230 errmsg ("tunnel dst address not specified");
12234 if (grp_set && !ip46_address_is_multicast (&dst))
12236 errmsg ("tunnel group address not multicast");
12239 if (grp_set && mcast_sw_if_index == ~0)
12241 errmsg ("tunnel nonexistent multicast device");
12244 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12246 errmsg ("tunnel dst address must be unicast");
12251 if (ipv4_set && ipv6_set)
12253 errmsg ("both IPv4 and IPv6 addresses specified");
12257 if ((vni == 0) || (vni >> 24))
12259 errmsg ("vni not specified or out of range");
12263 M (GENEVE_ADD_DEL_TUNNEL, mp);
12267 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12268 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12272 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12273 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12275 mp->encap_vrf_id = ntohl (encap_vrf_id);
12276 mp->decap_next_index = ntohl (decap_next_index);
12277 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12278 mp->vni = ntohl (vni);
12279 mp->is_add = is_add;
12280 mp->is_ipv6 = ipv6_set;
12287 static void vl_api_geneve_tunnel_details_t_handler
12288 (vl_api_geneve_tunnel_details_t * mp)
12290 vat_main_t *vam = &vat_main;
12291 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12292 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12294 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12295 ntohl (mp->sw_if_index),
12296 format_ip46_address, &src, IP46_TYPE_ANY,
12297 format_ip46_address, &dst, IP46_TYPE_ANY,
12298 ntohl (mp->encap_vrf_id),
12299 ntohl (mp->decap_next_index), ntohl (mp->vni),
12300 ntohl (mp->mcast_sw_if_index));
12303 static void vl_api_geneve_tunnel_details_t_handler_json
12304 (vl_api_geneve_tunnel_details_t * mp)
12306 vat_main_t *vam = &vat_main;
12307 vat_json_node_t *node = NULL;
12309 if (VAT_JSON_ARRAY != vam->json_tree.type)
12311 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12312 vat_json_init_array (&vam->json_tree);
12314 node = vat_json_array_add (&vam->json_tree);
12316 vat_json_init_object (node);
12317 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12320 struct in6_addr ip6;
12322 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12323 vat_json_object_add_ip6 (node, "src_address", ip6);
12324 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12325 vat_json_object_add_ip6 (node, "dst_address", ip6);
12329 struct in_addr ip4;
12331 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12332 vat_json_object_add_ip4 (node, "src_address", ip4);
12333 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12334 vat_json_object_add_ip4 (node, "dst_address", ip4);
12336 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12337 vat_json_object_add_uint (node, "decap_next_index",
12338 ntohl (mp->decap_next_index));
12339 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12340 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12341 vat_json_object_add_uint (node, "mcast_sw_if_index",
12342 ntohl (mp->mcast_sw_if_index));
12346 api_geneve_tunnel_dump (vat_main_t * vam)
12348 unformat_input_t *i = vam->input;
12349 vl_api_geneve_tunnel_dump_t *mp;
12350 vl_api_control_ping_t *mp_ping;
12352 u8 sw_if_index_set = 0;
12355 /* Parse args required to build the message */
12356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12358 if (unformat (i, "sw_if_index %d", &sw_if_index))
12359 sw_if_index_set = 1;
12364 if (sw_if_index_set == 0)
12369 if (!vam->json_output)
12371 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12372 "sw_if_index", "local_address", "remote_address",
12373 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12376 /* Get list of geneve-tunnel interfaces */
12377 M (GENEVE_TUNNEL_DUMP, mp);
12379 mp->sw_if_index = htonl (sw_if_index);
12383 /* Use a control ping for synchronization */
12384 M (CONTROL_PING, mp_ping);
12392 api_gre_add_del_tunnel (vat_main_t * vam)
12394 unformat_input_t *line_input = vam->input;
12395 vl_api_gre_add_del_tunnel_t *mp;
12396 ip4_address_t src4, dst4;
12397 ip6_address_t src6, dst6;
12404 u32 outer_fib_id = 0;
12407 memset (&src4, 0, sizeof src4);
12408 memset (&dst4, 0, sizeof dst4);
12409 memset (&src6, 0, sizeof src6);
12410 memset (&dst6, 0, sizeof dst6);
12412 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12414 if (unformat (line_input, "del"))
12416 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12421 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12426 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12431 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12436 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12438 else if (unformat (line_input, "teb"))
12442 errmsg ("parse error '%U'", format_unformat_error, line_input);
12449 errmsg ("tunnel src address not specified");
12454 errmsg ("tunnel dst address not specified");
12457 if (ipv4_set && ipv6_set)
12459 errmsg ("both IPv4 and IPv6 addresses specified");
12464 M (GRE_ADD_DEL_TUNNEL, mp);
12468 clib_memcpy (&mp->src_address, &src4, 4);
12469 clib_memcpy (&mp->dst_address, &dst4, 4);
12473 clib_memcpy (&mp->src_address, &src6, 16);
12474 clib_memcpy (&mp->dst_address, &dst6, 16);
12476 mp->outer_fib_id = ntohl (outer_fib_id);
12477 mp->is_add = is_add;
12479 mp->is_ipv6 = ipv6_set;
12486 static void vl_api_gre_tunnel_details_t_handler
12487 (vl_api_gre_tunnel_details_t * mp)
12489 vat_main_t *vam = &vat_main;
12490 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12491 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12493 print (vam->ofp, "%11d%24U%24U%6d%14d",
12494 ntohl (mp->sw_if_index),
12495 format_ip46_address, &src, IP46_TYPE_ANY,
12496 format_ip46_address, &dst, IP46_TYPE_ANY,
12497 mp->teb, ntohl (mp->outer_fib_id));
12500 static void vl_api_gre_tunnel_details_t_handler_json
12501 (vl_api_gre_tunnel_details_t * mp)
12503 vat_main_t *vam = &vat_main;
12504 vat_json_node_t *node = NULL;
12505 struct in_addr ip4;
12506 struct in6_addr ip6;
12508 if (VAT_JSON_ARRAY != vam->json_tree.type)
12510 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12511 vat_json_init_array (&vam->json_tree);
12513 node = vat_json_array_add (&vam->json_tree);
12515 vat_json_init_object (node);
12516 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12519 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12520 vat_json_object_add_ip4 (node, "src_address", ip4);
12521 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12522 vat_json_object_add_ip4 (node, "dst_address", ip4);
12526 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12527 vat_json_object_add_ip6 (node, "src_address", ip6);
12528 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12529 vat_json_object_add_ip6 (node, "dst_address", ip6);
12531 vat_json_object_add_uint (node, "teb", mp->teb);
12532 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12533 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12537 api_gre_tunnel_dump (vat_main_t * vam)
12539 unformat_input_t *i = vam->input;
12540 vl_api_gre_tunnel_dump_t *mp;
12541 vl_api_control_ping_t *mp_ping;
12543 u8 sw_if_index_set = 0;
12546 /* Parse args required to build the message */
12547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12549 if (unformat (i, "sw_if_index %d", &sw_if_index))
12550 sw_if_index_set = 1;
12555 if (sw_if_index_set == 0)
12560 if (!vam->json_output)
12562 print (vam->ofp, "%11s%24s%24s%6s%14s",
12563 "sw_if_index", "src_address", "dst_address", "teb",
12567 /* Get list of gre-tunnel interfaces */
12568 M (GRE_TUNNEL_DUMP, mp);
12570 mp->sw_if_index = htonl (sw_if_index);
12574 /* Use a control ping for synchronization */
12575 MPING (CONTROL_PING, mp_ping);
12583 api_l2_fib_clear_table (vat_main_t * vam)
12585 // unformat_input_t * i = vam->input;
12586 vl_api_l2_fib_clear_table_t *mp;
12589 M (L2_FIB_CLEAR_TABLE, mp);
12597 api_l2_interface_efp_filter (vat_main_t * vam)
12599 unformat_input_t *i = vam->input;
12600 vl_api_l2_interface_efp_filter_t *mp;
12603 u8 sw_if_index_set = 0;
12606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12608 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12609 sw_if_index_set = 1;
12610 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12611 sw_if_index_set = 1;
12612 else if (unformat (i, "enable"))
12614 else if (unformat (i, "disable"))
12618 clib_warning ("parse error '%U'", format_unformat_error, i);
12623 if (sw_if_index_set == 0)
12625 errmsg ("missing sw_if_index");
12629 M (L2_INTERFACE_EFP_FILTER, mp);
12631 mp->sw_if_index = ntohl (sw_if_index);
12632 mp->enable_disable = enable;
12639 #define foreach_vtr_op \
12640 _("disable", L2_VTR_DISABLED) \
12641 _("push-1", L2_VTR_PUSH_1) \
12642 _("push-2", L2_VTR_PUSH_2) \
12643 _("pop-1", L2_VTR_POP_1) \
12644 _("pop-2", L2_VTR_POP_2) \
12645 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12646 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12647 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12648 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12651 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12653 unformat_input_t *i = vam->input;
12654 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12656 u8 sw_if_index_set = 0;
12659 u32 push_dot1q = 1;
12664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12666 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12667 sw_if_index_set = 1;
12668 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12669 sw_if_index_set = 1;
12670 else if (unformat (i, "vtr_op %d", &vtr_op))
12672 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12675 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12677 else if (unformat (i, "tag1 %d", &tag1))
12679 else if (unformat (i, "tag2 %d", &tag2))
12683 clib_warning ("parse error '%U'", format_unformat_error, i);
12688 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12690 errmsg ("missing vtr operation or sw_if_index");
12694 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12695 mp->sw_if_index = ntohl (sw_if_index);
12696 mp->vtr_op = ntohl (vtr_op);
12697 mp->push_dot1q = ntohl (push_dot1q);
12698 mp->tag1 = ntohl (tag1);
12699 mp->tag2 = ntohl (tag2);
12707 api_create_vhost_user_if (vat_main_t * vam)
12709 unformat_input_t *i = vam->input;
12710 vl_api_create_vhost_user_if_t *mp;
12713 u8 file_name_set = 0;
12714 u32 custom_dev_instance = ~0;
12716 u8 use_custom_mac = 0;
12720 /* Shut up coverity */
12721 memset (hwaddr, 0, sizeof (hwaddr));
12723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12725 if (unformat (i, "socket %s", &file_name))
12729 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12731 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12732 use_custom_mac = 1;
12733 else if (unformat (i, "server"))
12735 else if (unformat (i, "tag %s", &tag))
12741 if (file_name_set == 0)
12743 errmsg ("missing socket file name");
12747 if (vec_len (file_name) > 255)
12749 errmsg ("socket file name too long");
12752 vec_add1 (file_name, 0);
12754 M (CREATE_VHOST_USER_IF, mp);
12756 mp->is_server = is_server;
12757 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12758 vec_free (file_name);
12759 if (custom_dev_instance != ~0)
12762 mp->custom_dev_instance = ntohl (custom_dev_instance);
12764 mp->use_custom_mac = use_custom_mac;
12765 clib_memcpy (mp->mac_address, hwaddr, 6);
12767 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12776 api_modify_vhost_user_if (vat_main_t * vam)
12778 unformat_input_t *i = vam->input;
12779 vl_api_modify_vhost_user_if_t *mp;
12782 u8 file_name_set = 0;
12783 u32 custom_dev_instance = ~0;
12784 u8 sw_if_index_set = 0;
12785 u32 sw_if_index = (u32) ~ 0;
12788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12791 sw_if_index_set = 1;
12792 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12793 sw_if_index_set = 1;
12794 else if (unformat (i, "socket %s", &file_name))
12798 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12800 else if (unformat (i, "server"))
12806 if (sw_if_index_set == 0)
12808 errmsg ("missing sw_if_index or interface name");
12812 if (file_name_set == 0)
12814 errmsg ("missing socket file name");
12818 if (vec_len (file_name) > 255)
12820 errmsg ("socket file name too long");
12823 vec_add1 (file_name, 0);
12825 M (MODIFY_VHOST_USER_IF, mp);
12827 mp->sw_if_index = ntohl (sw_if_index);
12828 mp->is_server = is_server;
12829 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12830 vec_free (file_name);
12831 if (custom_dev_instance != ~0)
12834 mp->custom_dev_instance = ntohl (custom_dev_instance);
12843 api_delete_vhost_user_if (vat_main_t * vam)
12845 unformat_input_t *i = vam->input;
12846 vl_api_delete_vhost_user_if_t *mp;
12847 u32 sw_if_index = ~0;
12848 u8 sw_if_index_set = 0;
12851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12853 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12854 sw_if_index_set = 1;
12855 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12856 sw_if_index_set = 1;
12861 if (sw_if_index_set == 0)
12863 errmsg ("missing sw_if_index or interface name");
12868 M (DELETE_VHOST_USER_IF, mp);
12870 mp->sw_if_index = ntohl (sw_if_index);
12877 static void vl_api_sw_interface_vhost_user_details_t_handler
12878 (vl_api_sw_interface_vhost_user_details_t * mp)
12880 vat_main_t *vam = &vat_main;
12882 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12883 (char *) mp->interface_name,
12884 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12885 clib_net_to_host_u64 (mp->features), mp->is_server,
12886 ntohl (mp->num_regions), (char *) mp->sock_filename);
12887 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12890 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12891 (vl_api_sw_interface_vhost_user_details_t * mp)
12893 vat_main_t *vam = &vat_main;
12894 vat_json_node_t *node = NULL;
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));
12905 vat_json_object_add_string_copy (node, "interface_name",
12906 mp->interface_name);
12907 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12908 ntohl (mp->virtio_net_hdr_sz));
12909 vat_json_object_add_uint (node, "features",
12910 clib_net_to_host_u64 (mp->features));
12911 vat_json_object_add_uint (node, "is_server", mp->is_server);
12912 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12913 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12914 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12918 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12920 vl_api_sw_interface_vhost_user_dump_t *mp;
12921 vl_api_control_ping_t *mp_ping;
12924 "Interface name idx hdr_sz features server regions filename");
12926 /* Get list of vhost-user interfaces */
12927 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12930 /* Use a control ping for synchronization */
12931 MPING (CONTROL_PING, mp_ping);
12939 api_show_version (vat_main_t * vam)
12941 vl_api_show_version_t *mp;
12944 M (SHOW_VERSION, mp);
12953 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12955 unformat_input_t *line_input = vam->input;
12956 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12957 ip4_address_t local4, remote4;
12958 ip6_address_t local6, remote6;
12960 u8 ipv4_set = 0, ipv6_set = 0;
12964 u32 mcast_sw_if_index = ~0;
12965 u32 encap_vrf_id = 0;
12966 u32 decap_vrf_id = 0;
12972 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12973 memset (&local4, 0, sizeof local4);
12974 memset (&remote4, 0, sizeof remote4);
12975 memset (&local6, 0, sizeof local6);
12976 memset (&remote6, 0, sizeof remote6);
12978 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12980 if (unformat (line_input, "del"))
12982 else if (unformat (line_input, "local %U",
12983 unformat_ip4_address, &local4))
12988 else if (unformat (line_input, "remote %U",
12989 unformat_ip4_address, &remote4))
12994 else if (unformat (line_input, "local %U",
12995 unformat_ip6_address, &local6))
13000 else if (unformat (line_input, "remote %U",
13001 unformat_ip6_address, &remote6))
13006 else if (unformat (line_input, "group %U %U",
13007 unformat_ip4_address, &remote4,
13008 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13010 grp_set = remote_set = 1;
13013 else if (unformat (line_input, "group %U",
13014 unformat_ip4_address, &remote4))
13016 grp_set = remote_set = 1;
13019 else if (unformat (line_input, "group %U %U",
13020 unformat_ip6_address, &remote6,
13021 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13023 grp_set = remote_set = 1;
13026 else if (unformat (line_input, "group %U",
13027 unformat_ip6_address, &remote6))
13029 grp_set = remote_set = 1;
13033 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13035 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13037 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13039 else if (unformat (line_input, "vni %d", &vni))
13041 else if (unformat (line_input, "next-ip4"))
13043 else if (unformat (line_input, "next-ip6"))
13045 else if (unformat (line_input, "next-ethernet"))
13047 else if (unformat (line_input, "next-nsh"))
13051 errmsg ("parse error '%U'", format_unformat_error, line_input);
13056 if (local_set == 0)
13058 errmsg ("tunnel local address not specified");
13061 if (remote_set == 0)
13063 errmsg ("tunnel remote address not specified");
13066 if (grp_set && mcast_sw_if_index == ~0)
13068 errmsg ("tunnel nonexistent multicast device");
13071 if (ipv4_set && ipv6_set)
13073 errmsg ("both IPv4 and IPv6 addresses specified");
13079 errmsg ("vni not specified");
13083 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13088 clib_memcpy (&mp->local, &local6, sizeof (local6));
13089 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13093 clib_memcpy (&mp->local, &local4, sizeof (local4));
13094 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13097 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13098 mp->encap_vrf_id = ntohl (encap_vrf_id);
13099 mp->decap_vrf_id = ntohl (decap_vrf_id);
13100 mp->protocol = protocol;
13101 mp->vni = ntohl (vni);
13102 mp->is_add = is_add;
13103 mp->is_ipv6 = ipv6_set;
13110 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13111 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13113 vat_main_t *vam = &vat_main;
13114 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13115 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13117 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13118 ntohl (mp->sw_if_index),
13119 format_ip46_address, &local, IP46_TYPE_ANY,
13120 format_ip46_address, &remote, IP46_TYPE_ANY,
13121 ntohl (mp->vni), mp->protocol,
13122 ntohl (mp->mcast_sw_if_index),
13123 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13127 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13128 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13130 vat_main_t *vam = &vat_main;
13131 vat_json_node_t *node = NULL;
13132 struct in_addr ip4;
13133 struct in6_addr ip6;
13135 if (VAT_JSON_ARRAY != vam->json_tree.type)
13137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13138 vat_json_init_array (&vam->json_tree);
13140 node = vat_json_array_add (&vam->json_tree);
13142 vat_json_init_object (node);
13143 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13146 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13147 vat_json_object_add_ip6 (node, "local", ip6);
13148 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13149 vat_json_object_add_ip6 (node, "remote", ip6);
13153 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13154 vat_json_object_add_ip4 (node, "local", ip4);
13155 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13156 vat_json_object_add_ip4 (node, "remote", ip4);
13158 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13159 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13160 vat_json_object_add_uint (node, "mcast_sw_if_index",
13161 ntohl (mp->mcast_sw_if_index));
13162 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13163 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13164 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13168 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13170 unformat_input_t *i = vam->input;
13171 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13172 vl_api_control_ping_t *mp_ping;
13174 u8 sw_if_index_set = 0;
13177 /* Parse args required to build the message */
13178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13180 if (unformat (i, "sw_if_index %d", &sw_if_index))
13181 sw_if_index_set = 1;
13186 if (sw_if_index_set == 0)
13191 if (!vam->json_output)
13193 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13194 "sw_if_index", "local", "remote", "vni",
13195 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13198 /* Get list of vxlan-tunnel interfaces */
13199 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13201 mp->sw_if_index = htonl (sw_if_index);
13205 /* Use a control ping for synchronization */
13206 MPING (CONTROL_PING, mp_ping);
13215 format_l2_fib_mac_address (u8 * s, va_list * args)
13217 u8 *a = va_arg (*args, u8 *);
13219 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13220 a[2], a[3], a[4], a[5], a[6], a[7]);
13223 static void vl_api_l2_fib_table_details_t_handler
13224 (vl_api_l2_fib_table_details_t * mp)
13226 vat_main_t *vam = &vat_main;
13228 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13230 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13231 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13235 static void vl_api_l2_fib_table_details_t_handler_json
13236 (vl_api_l2_fib_table_details_t * mp)
13238 vat_main_t *vam = &vat_main;
13239 vat_json_node_t *node = NULL;
13241 if (VAT_JSON_ARRAY != vam->json_tree.type)
13243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13244 vat_json_init_array (&vam->json_tree);
13246 node = vat_json_array_add (&vam->json_tree);
13248 vat_json_init_object (node);
13249 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13250 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13251 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13252 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13253 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13254 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13258 api_l2_fib_table_dump (vat_main_t * vam)
13260 unformat_input_t *i = vam->input;
13261 vl_api_l2_fib_table_dump_t *mp;
13262 vl_api_control_ping_t *mp_ping;
13267 /* Parse args required to build the message */
13268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13270 if (unformat (i, "bd_id %d", &bd_id))
13276 if (bd_id_set == 0)
13278 errmsg ("missing bridge domain");
13282 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13284 /* Get list of l2 fib entries */
13285 M (L2_FIB_TABLE_DUMP, mp);
13287 mp->bd_id = ntohl (bd_id);
13290 /* Use a control ping for synchronization */
13291 MPING (CONTROL_PING, mp_ping);
13300 api_interface_name_renumber (vat_main_t * vam)
13302 unformat_input_t *line_input = vam->input;
13303 vl_api_interface_name_renumber_t *mp;
13304 u32 sw_if_index = ~0;
13305 u32 new_show_dev_instance = ~0;
13308 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13310 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13313 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13315 else if (unformat (line_input, "new_show_dev_instance %d",
13316 &new_show_dev_instance))
13322 if (sw_if_index == ~0)
13324 errmsg ("missing interface name or sw_if_index");
13328 if (new_show_dev_instance == ~0)
13330 errmsg ("missing new_show_dev_instance");
13334 M (INTERFACE_NAME_RENUMBER, mp);
13336 mp->sw_if_index = ntohl (sw_if_index);
13337 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13345 api_want_ip4_arp_events (vat_main_t * vam)
13347 unformat_input_t *line_input = vam->input;
13348 vl_api_want_ip4_arp_events_t *mp;
13349 ip4_address_t address;
13350 int address_set = 0;
13351 u32 enable_disable = 1;
13354 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13356 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13358 else if (unformat (line_input, "del"))
13359 enable_disable = 0;
13364 if (address_set == 0)
13366 errmsg ("missing addresses");
13370 M (WANT_IP4_ARP_EVENTS, mp);
13371 mp->enable_disable = enable_disable;
13372 mp->pid = htonl (getpid ());
13373 mp->address = address.as_u32;
13381 api_want_ip6_nd_events (vat_main_t * vam)
13383 unformat_input_t *line_input = vam->input;
13384 vl_api_want_ip6_nd_events_t *mp;
13385 ip6_address_t address;
13386 int address_set = 0;
13387 u32 enable_disable = 1;
13390 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13392 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13394 else if (unformat (line_input, "del"))
13395 enable_disable = 0;
13400 if (address_set == 0)
13402 errmsg ("missing addresses");
13406 M (WANT_IP6_ND_EVENTS, mp);
13407 mp->enable_disable = enable_disable;
13408 mp->pid = htonl (getpid ());
13409 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13417 api_want_l2_macs_events (vat_main_t * vam)
13419 unformat_input_t *line_input = vam->input;
13420 vl_api_want_l2_macs_events_t *mp;
13421 u8 enable_disable = 1;
13422 u32 scan_delay = 0;
13423 u32 max_macs_in_event = 0;
13424 u32 learn_limit = 0;
13427 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13429 if (unformat (line_input, "learn-limit %d", &learn_limit))
13431 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13433 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13435 else if (unformat (line_input, "disable"))
13436 enable_disable = 0;
13441 M (WANT_L2_MACS_EVENTS, mp);
13442 mp->enable_disable = enable_disable;
13443 mp->pid = htonl (getpid ());
13444 mp->learn_limit = htonl (learn_limit);
13445 mp->scan_delay = (u8) scan_delay;
13446 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13453 api_input_acl_set_interface (vat_main_t * vam)
13455 unformat_input_t *i = vam->input;
13456 vl_api_input_acl_set_interface_t *mp;
13458 int sw_if_index_set;
13459 u32 ip4_table_index = ~0;
13460 u32 ip6_table_index = ~0;
13461 u32 l2_table_index = ~0;
13465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13467 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13468 sw_if_index_set = 1;
13469 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13470 sw_if_index_set = 1;
13471 else if (unformat (i, "del"))
13473 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13475 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13477 else if (unformat (i, "l2-table %d", &l2_table_index))
13481 clib_warning ("parse error '%U'", format_unformat_error, i);
13486 if (sw_if_index_set == 0)
13488 errmsg ("missing interface name or sw_if_index");
13492 M (INPUT_ACL_SET_INTERFACE, mp);
13494 mp->sw_if_index = ntohl (sw_if_index);
13495 mp->ip4_table_index = ntohl (ip4_table_index);
13496 mp->ip6_table_index = ntohl (ip6_table_index);
13497 mp->l2_table_index = ntohl (l2_table_index);
13498 mp->is_add = is_add;
13506 api_ip_address_dump (vat_main_t * vam)
13508 unformat_input_t *i = vam->input;
13509 vl_api_ip_address_dump_t *mp;
13510 vl_api_control_ping_t *mp_ping;
13511 u32 sw_if_index = ~0;
13512 u8 sw_if_index_set = 0;
13517 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13519 if (unformat (i, "sw_if_index %d", &sw_if_index))
13520 sw_if_index_set = 1;
13522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13523 sw_if_index_set = 1;
13524 else if (unformat (i, "ipv4"))
13526 else if (unformat (i, "ipv6"))
13532 if (ipv4_set && ipv6_set)
13534 errmsg ("ipv4 and ipv6 flags cannot be both set");
13538 if ((!ipv4_set) && (!ipv6_set))
13540 errmsg ("no ipv4 nor ipv6 flag set");
13544 if (sw_if_index_set == 0)
13546 errmsg ("missing interface name or sw_if_index");
13550 vam->current_sw_if_index = sw_if_index;
13551 vam->is_ipv6 = ipv6_set;
13553 M (IP_ADDRESS_DUMP, mp);
13554 mp->sw_if_index = ntohl (sw_if_index);
13555 mp->is_ipv6 = ipv6_set;
13558 /* Use a control ping for synchronization */
13559 MPING (CONTROL_PING, mp_ping);
13567 api_ip_dump (vat_main_t * vam)
13569 vl_api_ip_dump_t *mp;
13570 vl_api_control_ping_t *mp_ping;
13571 unformat_input_t *in = vam->input;
13578 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13580 if (unformat (in, "ipv4"))
13582 else if (unformat (in, "ipv6"))
13588 if (ipv4_set && ipv6_set)
13590 errmsg ("ipv4 and ipv6 flags cannot be both set");
13594 if ((!ipv4_set) && (!ipv6_set))
13596 errmsg ("no ipv4 nor ipv6 flag set");
13600 is_ipv6 = ipv6_set;
13601 vam->is_ipv6 = is_ipv6;
13603 /* free old data */
13604 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13606 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13608 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13611 mp->is_ipv6 = ipv6_set;
13614 /* Use a control ping for synchronization */
13615 MPING (CONTROL_PING, mp_ping);
13623 api_ipsec_spd_add_del (vat_main_t * vam)
13625 unformat_input_t *i = vam->input;
13626 vl_api_ipsec_spd_add_del_t *mp;
13631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13633 if (unformat (i, "spd_id %d", &spd_id))
13635 else if (unformat (i, "del"))
13639 clib_warning ("parse error '%U'", format_unformat_error, i);
13645 errmsg ("spd_id must be set");
13649 M (IPSEC_SPD_ADD_DEL, mp);
13651 mp->spd_id = ntohl (spd_id);
13652 mp->is_add = is_add;
13660 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13662 unformat_input_t *i = vam->input;
13663 vl_api_ipsec_interface_add_del_spd_t *mp;
13665 u8 sw_if_index_set = 0;
13666 u32 spd_id = (u32) ~ 0;
13670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13672 if (unformat (i, "del"))
13674 else if (unformat (i, "spd_id %d", &spd_id))
13677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13678 sw_if_index_set = 1;
13679 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13680 sw_if_index_set = 1;
13683 clib_warning ("parse error '%U'", format_unformat_error, i);
13689 if (spd_id == (u32) ~ 0)
13691 errmsg ("spd_id must be set");
13695 if (sw_if_index_set == 0)
13697 errmsg ("missing interface name or sw_if_index");
13701 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13703 mp->spd_id = ntohl (spd_id);
13704 mp->sw_if_index = ntohl (sw_if_index);
13705 mp->is_add = is_add;
13713 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13715 unformat_input_t *i = vam->input;
13716 vl_api_ipsec_spd_add_del_entry_t *mp;
13717 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13718 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13720 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13721 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13722 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13723 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13726 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13727 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13728 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13729 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13730 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13731 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13735 if (unformat (i, "del"))
13737 if (unformat (i, "outbound"))
13739 if (unformat (i, "inbound"))
13741 else if (unformat (i, "spd_id %d", &spd_id))
13743 else if (unformat (i, "sa_id %d", &sa_id))
13745 else if (unformat (i, "priority %d", &priority))
13747 else if (unformat (i, "protocol %d", &protocol))
13749 else if (unformat (i, "lport_start %d", &lport_start))
13751 else if (unformat (i, "lport_stop %d", &lport_stop))
13753 else if (unformat (i, "rport_start %d", &rport_start))
13755 else if (unformat (i, "rport_stop %d", &rport_stop))
13759 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13765 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13772 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13778 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13785 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13791 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13798 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13804 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13810 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13812 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13814 clib_warning ("unsupported action: 'resolve'");
13820 clib_warning ("parse error '%U'", format_unformat_error, i);
13826 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13828 mp->spd_id = ntohl (spd_id);
13829 mp->priority = ntohl (priority);
13830 mp->is_outbound = is_outbound;
13832 mp->is_ipv6 = is_ipv6;
13833 if (is_ipv6 || is_ip_any)
13835 clib_memcpy (mp->remote_address_start, &raddr6_start,
13836 sizeof (ip6_address_t));
13837 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13838 sizeof (ip6_address_t));
13839 clib_memcpy (mp->local_address_start, &laddr6_start,
13840 sizeof (ip6_address_t));
13841 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13842 sizeof (ip6_address_t));
13846 clib_memcpy (mp->remote_address_start, &raddr4_start,
13847 sizeof (ip4_address_t));
13848 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13849 sizeof (ip4_address_t));
13850 clib_memcpy (mp->local_address_start, &laddr4_start,
13851 sizeof (ip4_address_t));
13852 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13853 sizeof (ip4_address_t));
13855 mp->protocol = (u8) protocol;
13856 mp->local_port_start = ntohs ((u16) lport_start);
13857 mp->local_port_stop = ntohs ((u16) lport_stop);
13858 mp->remote_port_start = ntohs ((u16) rport_start);
13859 mp->remote_port_stop = ntohs ((u16) rport_stop);
13860 mp->policy = (u8) policy;
13861 mp->sa_id = ntohl (sa_id);
13862 mp->is_add = is_add;
13863 mp->is_ip_any = is_ip_any;
13870 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13872 unformat_input_t *i = vam->input;
13873 vl_api_ipsec_sad_add_del_entry_t *mp;
13874 u32 sad_id = 0, spi = 0;
13875 u8 *ck = 0, *ik = 0;
13878 u8 protocol = IPSEC_PROTOCOL_AH;
13879 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13880 u32 crypto_alg = 0, integ_alg = 0;
13881 ip4_address_t tun_src4;
13882 ip4_address_t tun_dst4;
13883 ip6_address_t tun_src6;
13884 ip6_address_t tun_dst6;
13887 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13889 if (unformat (i, "del"))
13891 else if (unformat (i, "sad_id %d", &sad_id))
13893 else if (unformat (i, "spi %d", &spi))
13895 else if (unformat (i, "esp"))
13896 protocol = IPSEC_PROTOCOL_ESP;
13897 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13900 is_tunnel_ipv6 = 0;
13902 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13905 is_tunnel_ipv6 = 0;
13907 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13910 is_tunnel_ipv6 = 1;
13912 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13915 is_tunnel_ipv6 = 1;
13919 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13921 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13922 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13924 clib_warning ("unsupported crypto-alg: '%U'",
13925 format_ipsec_crypto_alg, crypto_alg);
13929 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13933 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13935 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13936 integ_alg >= IPSEC_INTEG_N_ALG)
13938 clib_warning ("unsupported integ-alg: '%U'",
13939 format_ipsec_integ_alg, integ_alg);
13943 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13947 clib_warning ("parse error '%U'", format_unformat_error, i);
13953 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13955 mp->sad_id = ntohl (sad_id);
13956 mp->is_add = is_add;
13957 mp->protocol = protocol;
13958 mp->spi = ntohl (spi);
13959 mp->is_tunnel = is_tunnel;
13960 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13961 mp->crypto_algorithm = crypto_alg;
13962 mp->integrity_algorithm = integ_alg;
13963 mp->crypto_key_length = vec_len (ck);
13964 mp->integrity_key_length = vec_len (ik);
13966 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13967 mp->crypto_key_length = sizeof (mp->crypto_key);
13969 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13970 mp->integrity_key_length = sizeof (mp->integrity_key);
13973 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13975 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13979 if (is_tunnel_ipv6)
13981 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13982 sizeof (ip6_address_t));
13983 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13984 sizeof (ip6_address_t));
13988 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13989 sizeof (ip4_address_t));
13990 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13991 sizeof (ip4_address_t));
14001 api_ipsec_sa_set_key (vat_main_t * vam)
14003 unformat_input_t *i = vam->input;
14004 vl_api_ipsec_sa_set_key_t *mp;
14006 u8 *ck = 0, *ik = 0;
14009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14011 if (unformat (i, "sa_id %d", &sa_id))
14013 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14015 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14019 clib_warning ("parse error '%U'", format_unformat_error, i);
14024 M (IPSEC_SA_SET_KEY, mp);
14026 mp->sa_id = ntohl (sa_id);
14027 mp->crypto_key_length = vec_len (ck);
14028 mp->integrity_key_length = vec_len (ik);
14030 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14031 mp->crypto_key_length = sizeof (mp->crypto_key);
14033 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14034 mp->integrity_key_length = sizeof (mp->integrity_key);
14037 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14039 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14047 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14049 unformat_input_t *i = vam->input;
14050 vl_api_ipsec_tunnel_if_add_del_t *mp;
14051 u32 local_spi = 0, remote_spi = 0;
14052 u32 crypto_alg = 0, integ_alg = 0;
14053 u8 *lck = NULL, *rck = NULL;
14054 u8 *lik = NULL, *rik = NULL;
14055 ip4_address_t local_ip = { {0} };
14056 ip4_address_t remote_ip = { {0} };
14059 u8 anti_replay = 0;
14062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14064 if (unformat (i, "del"))
14066 else if (unformat (i, "esn"))
14068 else if (unformat (i, "anti_replay"))
14070 else if (unformat (i, "local_spi %d", &local_spi))
14072 else if (unformat (i, "remote_spi %d", &remote_spi))
14074 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14076 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14078 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14081 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14083 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14085 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14089 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14091 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14092 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14094 errmsg ("unsupported crypto-alg: '%U'\n",
14095 format_ipsec_crypto_alg, crypto_alg);
14101 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14103 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14104 integ_alg >= IPSEC_INTEG_N_ALG)
14106 errmsg ("unsupported integ-alg: '%U'\n",
14107 format_ipsec_integ_alg, integ_alg);
14113 errmsg ("parse error '%U'\n", format_unformat_error, i);
14118 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14120 mp->is_add = is_add;
14122 mp->anti_replay = anti_replay;
14124 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14125 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14127 mp->local_spi = htonl (local_spi);
14128 mp->remote_spi = htonl (remote_spi);
14129 mp->crypto_alg = (u8) crypto_alg;
14131 mp->local_crypto_key_len = 0;
14134 mp->local_crypto_key_len = vec_len (lck);
14135 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14136 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14137 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14140 mp->remote_crypto_key_len = 0;
14143 mp->remote_crypto_key_len = vec_len (rck);
14144 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14145 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14146 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14149 mp->integ_alg = (u8) integ_alg;
14151 mp->local_integ_key_len = 0;
14154 mp->local_integ_key_len = vec_len (lik);
14155 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14156 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14157 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14160 mp->remote_integ_key_len = 0;
14163 mp->remote_integ_key_len = vec_len (rik);
14164 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14165 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14166 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14175 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14177 vat_main_t *vam = &vat_main;
14179 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14180 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14181 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14182 "tunnel_src_addr %U tunnel_dst_addr %U "
14183 "salt %u seq_outbound %lu last_seq_inbound %lu "
14184 "replay_window %lu total_data_size %lu\n",
14185 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14187 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14188 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14189 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14190 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14191 mp->tunnel_src_addr,
14192 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14193 mp->tunnel_dst_addr,
14195 clib_net_to_host_u64 (mp->seq_outbound),
14196 clib_net_to_host_u64 (mp->last_seq_inbound),
14197 clib_net_to_host_u64 (mp->replay_window),
14198 clib_net_to_host_u64 (mp->total_data_size));
14201 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14202 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14204 static void vl_api_ipsec_sa_details_t_handler_json
14205 (vl_api_ipsec_sa_details_t * mp)
14207 vat_main_t *vam = &vat_main;
14208 vat_json_node_t *node = NULL;
14209 struct in_addr src_ip4, dst_ip4;
14210 struct in6_addr src_ip6, dst_ip6;
14212 if (VAT_JSON_ARRAY != vam->json_tree.type)
14214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14215 vat_json_init_array (&vam->json_tree);
14217 node = vat_json_array_add (&vam->json_tree);
14219 vat_json_init_object (node);
14220 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14221 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14222 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14223 vat_json_object_add_uint (node, "proto", mp->protocol);
14224 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14225 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14226 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14227 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14228 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14229 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14230 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14231 mp->crypto_key_len);
14232 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14233 mp->integ_key_len);
14234 if (mp->is_tunnel_ip6)
14236 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14237 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14238 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14239 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14243 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14244 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14245 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14246 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14248 vat_json_object_add_uint (node, "replay_window",
14249 clib_net_to_host_u64 (mp->replay_window));
14250 vat_json_object_add_uint (node, "total_data_size",
14251 clib_net_to_host_u64 (mp->total_data_size));
14256 api_ipsec_sa_dump (vat_main_t * vam)
14258 unformat_input_t *i = vam->input;
14259 vl_api_ipsec_sa_dump_t *mp;
14260 vl_api_control_ping_t *mp_ping;
14264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14266 if (unformat (i, "sa_id %d", &sa_id))
14270 clib_warning ("parse error '%U'", format_unformat_error, i);
14275 M (IPSEC_SA_DUMP, mp);
14277 mp->sa_id = ntohl (sa_id);
14281 /* Use a control ping for synchronization */
14282 M (CONTROL_PING, mp_ping);
14290 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14292 unformat_input_t *i = vam->input;
14293 vl_api_ipsec_tunnel_if_set_key_t *mp;
14294 u32 sw_if_index = ~0;
14295 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14302 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14305 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14306 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14308 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14309 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14310 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14311 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14313 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14314 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14315 else if (unformat (i, "%U", unformat_hex_string, &key))
14319 clib_warning ("parse error '%U'", format_unformat_error, i);
14324 if (sw_if_index == ~0)
14326 errmsg ("interface must be specified");
14330 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14332 errmsg ("key type must be specified");
14338 errmsg ("algorithm must be specified");
14342 if (vec_len (key) == 0)
14344 errmsg ("key must be specified");
14348 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14350 mp->sw_if_index = htonl (sw_if_index);
14352 mp->key_type = key_type;
14353 mp->key_len = vec_len (key);
14354 clib_memcpy (mp->key, key, vec_len (key));
14363 api_ikev2_profile_add_del (vat_main_t * vam)
14365 unformat_input_t *i = vam->input;
14366 vl_api_ikev2_profile_add_del_t *mp;
14371 const char *valid_chars = "a-zA-Z0-9_";
14373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14375 if (unformat (i, "del"))
14377 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14378 vec_add1 (name, 0);
14381 errmsg ("parse error '%U'", format_unformat_error, i);
14386 if (!vec_len (name))
14388 errmsg ("profile name must be specified");
14392 if (vec_len (name) > 64)
14394 errmsg ("profile name too long");
14398 M (IKEV2_PROFILE_ADD_DEL, mp);
14400 clib_memcpy (mp->name, name, vec_len (name));
14401 mp->is_add = is_add;
14410 api_ikev2_profile_set_auth (vat_main_t * vam)
14412 unformat_input_t *i = vam->input;
14413 vl_api_ikev2_profile_set_auth_t *mp;
14416 u32 auth_method = 0;
14420 const char *valid_chars = "a-zA-Z0-9_";
14422 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14424 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14425 vec_add1 (name, 0);
14426 else if (unformat (i, "auth_method %U",
14427 unformat_ikev2_auth_method, &auth_method))
14429 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14431 else if (unformat (i, "auth_data %v", &data))
14435 errmsg ("parse error '%U'", format_unformat_error, i);
14440 if (!vec_len (name))
14442 errmsg ("profile name must be specified");
14446 if (vec_len (name) > 64)
14448 errmsg ("profile name too long");
14452 if (!vec_len (data))
14454 errmsg ("auth_data must be specified");
14460 errmsg ("auth_method must be specified");
14464 M (IKEV2_PROFILE_SET_AUTH, mp);
14466 mp->is_hex = is_hex;
14467 mp->auth_method = (u8) auth_method;
14468 mp->data_len = vec_len (data);
14469 clib_memcpy (mp->name, name, vec_len (name));
14470 clib_memcpy (mp->data, data, vec_len (data));
14480 api_ikev2_profile_set_id (vat_main_t * vam)
14482 unformat_input_t *i = vam->input;
14483 vl_api_ikev2_profile_set_id_t *mp;
14491 const char *valid_chars = "a-zA-Z0-9_";
14493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14495 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14496 vec_add1 (name, 0);
14497 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14499 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14501 data = vec_new (u8, 4);
14502 clib_memcpy (data, ip4.as_u8, 4);
14504 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14506 else if (unformat (i, "id_data %v", &data))
14508 else if (unformat (i, "local"))
14510 else if (unformat (i, "remote"))
14514 errmsg ("parse error '%U'", format_unformat_error, i);
14519 if (!vec_len (name))
14521 errmsg ("profile name must be specified");
14525 if (vec_len (name) > 64)
14527 errmsg ("profile name too long");
14531 if (!vec_len (data))
14533 errmsg ("id_data must be specified");
14539 errmsg ("id_type must be specified");
14543 M (IKEV2_PROFILE_SET_ID, mp);
14545 mp->is_local = is_local;
14546 mp->id_type = (u8) id_type;
14547 mp->data_len = vec_len (data);
14548 clib_memcpy (mp->name, name, vec_len (name));
14549 clib_memcpy (mp->data, data, vec_len (data));
14559 api_ikev2_profile_set_ts (vat_main_t * vam)
14561 unformat_input_t *i = vam->input;
14562 vl_api_ikev2_profile_set_ts_t *mp;
14565 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14566 ip4_address_t start_addr, end_addr;
14568 const char *valid_chars = "a-zA-Z0-9_";
14571 start_addr.as_u32 = 0;
14572 end_addr.as_u32 = (u32) ~ 0;
14574 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14576 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14577 vec_add1 (name, 0);
14578 else if (unformat (i, "protocol %d", &proto))
14580 else if (unformat (i, "start_port %d", &start_port))
14582 else if (unformat (i, "end_port %d", &end_port))
14585 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14587 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14589 else if (unformat (i, "local"))
14591 else if (unformat (i, "remote"))
14595 errmsg ("parse error '%U'", format_unformat_error, i);
14600 if (!vec_len (name))
14602 errmsg ("profile name must be specified");
14606 if (vec_len (name) > 64)
14608 errmsg ("profile name too long");
14612 M (IKEV2_PROFILE_SET_TS, mp);
14614 mp->is_local = is_local;
14615 mp->proto = (u8) proto;
14616 mp->start_port = (u16) start_port;
14617 mp->end_port = (u16) end_port;
14618 mp->start_addr = start_addr.as_u32;
14619 mp->end_addr = end_addr.as_u32;
14620 clib_memcpy (mp->name, name, vec_len (name));
14629 api_ikev2_set_local_key (vat_main_t * vam)
14631 unformat_input_t *i = vam->input;
14632 vl_api_ikev2_set_local_key_t *mp;
14636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14638 if (unformat (i, "file %v", &file))
14639 vec_add1 (file, 0);
14642 errmsg ("parse error '%U'", format_unformat_error, i);
14647 if (!vec_len (file))
14649 errmsg ("RSA key file must be specified");
14653 if (vec_len (file) > 256)
14655 errmsg ("file name too long");
14659 M (IKEV2_SET_LOCAL_KEY, mp);
14661 clib_memcpy (mp->key_file, file, vec_len (file));
14670 api_ikev2_set_responder (vat_main_t * vam)
14672 unformat_input_t *i = vam->input;
14673 vl_api_ikev2_set_responder_t *mp;
14676 u32 sw_if_index = ~0;
14677 ip4_address_t address;
14679 const char *valid_chars = "a-zA-Z0-9_";
14681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14684 (i, "%U interface %d address %U", unformat_token, valid_chars,
14685 &name, &sw_if_index, unformat_ip4_address, &address))
14686 vec_add1 (name, 0);
14689 errmsg ("parse error '%U'", format_unformat_error, i);
14694 if (!vec_len (name))
14696 errmsg ("profile name must be specified");
14700 if (vec_len (name) > 64)
14702 errmsg ("profile name too long");
14706 M (IKEV2_SET_RESPONDER, mp);
14708 clib_memcpy (mp->name, name, vec_len (name));
14711 mp->sw_if_index = sw_if_index;
14712 clib_memcpy (mp->address, &address, sizeof (address));
14720 api_ikev2_set_ike_transforms (vat_main_t * vam)
14722 unformat_input_t *i = vam->input;
14723 vl_api_ikev2_set_ike_transforms_t *mp;
14726 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14728 const char *valid_chars = "a-zA-Z0-9_";
14730 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14732 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14733 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14734 vec_add1 (name, 0);
14737 errmsg ("parse error '%U'", format_unformat_error, i);
14742 if (!vec_len (name))
14744 errmsg ("profile name must be specified");
14748 if (vec_len (name) > 64)
14750 errmsg ("profile name too long");
14754 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14756 clib_memcpy (mp->name, name, vec_len (name));
14758 mp->crypto_alg = crypto_alg;
14759 mp->crypto_key_size = crypto_key_size;
14760 mp->integ_alg = integ_alg;
14761 mp->dh_group = dh_group;
14770 api_ikev2_set_esp_transforms (vat_main_t * vam)
14772 unformat_input_t *i = vam->input;
14773 vl_api_ikev2_set_esp_transforms_t *mp;
14776 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14778 const char *valid_chars = "a-zA-Z0-9_";
14780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14782 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14783 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14784 vec_add1 (name, 0);
14787 errmsg ("parse error '%U'", format_unformat_error, i);
14792 if (!vec_len (name))
14794 errmsg ("profile name must be specified");
14798 if (vec_len (name) > 64)
14800 errmsg ("profile name too long");
14804 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14806 clib_memcpy (mp->name, name, vec_len (name));
14808 mp->crypto_alg = crypto_alg;
14809 mp->crypto_key_size = crypto_key_size;
14810 mp->integ_alg = integ_alg;
14811 mp->dh_group = dh_group;
14819 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14821 unformat_input_t *i = vam->input;
14822 vl_api_ikev2_set_sa_lifetime_t *mp;
14825 u64 lifetime, lifetime_maxdata;
14826 u32 lifetime_jitter, handover;
14828 const char *valid_chars = "a-zA-Z0-9_";
14830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14832 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14833 &lifetime, &lifetime_jitter, &handover,
14834 &lifetime_maxdata))
14835 vec_add1 (name, 0);
14838 errmsg ("parse error '%U'", format_unformat_error, i);
14843 if (!vec_len (name))
14845 errmsg ("profile name must be specified");
14849 if (vec_len (name) > 64)
14851 errmsg ("profile name too long");
14855 M (IKEV2_SET_SA_LIFETIME, mp);
14857 clib_memcpy (mp->name, name, vec_len (name));
14859 mp->lifetime = lifetime;
14860 mp->lifetime_jitter = lifetime_jitter;
14861 mp->handover = handover;
14862 mp->lifetime_maxdata = lifetime_maxdata;
14870 api_ikev2_initiate_sa_init (vat_main_t * vam)
14872 unformat_input_t *i = vam->input;
14873 vl_api_ikev2_initiate_sa_init_t *mp;
14877 const char *valid_chars = "a-zA-Z0-9_";
14879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14881 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14882 vec_add1 (name, 0);
14885 errmsg ("parse error '%U'", format_unformat_error, i);
14890 if (!vec_len (name))
14892 errmsg ("profile name must be specified");
14896 if (vec_len (name) > 64)
14898 errmsg ("profile name too long");
14902 M (IKEV2_INITIATE_SA_INIT, mp);
14904 clib_memcpy (mp->name, name, vec_len (name));
14913 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14915 unformat_input_t *i = vam->input;
14916 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14923 if (unformat (i, "%lx", &ispi))
14927 errmsg ("parse error '%U'", format_unformat_error, i);
14932 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14942 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14944 unformat_input_t *i = vam->input;
14945 vl_api_ikev2_initiate_del_child_sa_t *mp;
14950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14952 if (unformat (i, "%x", &ispi))
14956 errmsg ("parse error '%U'", format_unformat_error, i);
14961 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14971 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14973 unformat_input_t *i = vam->input;
14974 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14981 if (unformat (i, "%x", &ispi))
14985 errmsg ("parse error '%U'", format_unformat_error, i);
14990 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15003 api_map_add_domain (vat_main_t * vam)
15005 unformat_input_t *i = vam->input;
15006 vl_api_map_add_domain_t *mp;
15008 ip4_address_t ip4_prefix;
15009 ip6_address_t ip6_prefix;
15010 ip6_address_t ip6_src;
15011 u32 num_m_args = 0;
15012 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15013 0, psid_length = 0;
15014 u8 is_translation = 0;
15016 u32 ip6_src_len = 128;
15019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15021 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15022 &ip4_prefix, &ip4_prefix_len))
15024 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15025 &ip6_prefix, &ip6_prefix_len))
15029 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15032 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15034 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15036 else if (unformat (i, "psid-offset %d", &psid_offset))
15038 else if (unformat (i, "psid-len %d", &psid_length))
15040 else if (unformat (i, "mtu %d", &mtu))
15042 else if (unformat (i, "map-t"))
15043 is_translation = 1;
15046 clib_warning ("parse error '%U'", format_unformat_error, i);
15051 if (num_m_args < 3)
15053 errmsg ("mandatory argument(s) missing");
15057 /* Construct the API message */
15058 M (MAP_ADD_DOMAIN, mp);
15060 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15061 mp->ip4_prefix_len = ip4_prefix_len;
15063 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15064 mp->ip6_prefix_len = ip6_prefix_len;
15066 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15067 mp->ip6_src_prefix_len = ip6_src_len;
15069 mp->ea_bits_len = ea_bits_len;
15070 mp->psid_offset = psid_offset;
15071 mp->psid_length = psid_length;
15072 mp->is_translation = is_translation;
15073 mp->mtu = htons (mtu);
15078 /* Wait for a reply, return good/bad news */
15084 api_map_del_domain (vat_main_t * vam)
15086 unformat_input_t *i = vam->input;
15087 vl_api_map_del_domain_t *mp;
15089 u32 num_m_args = 0;
15093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15095 if (unformat (i, "index %d", &index))
15099 clib_warning ("parse error '%U'", format_unformat_error, i);
15104 if (num_m_args != 1)
15106 errmsg ("mandatory argument(s) missing");
15110 /* Construct the API message */
15111 M (MAP_DEL_DOMAIN, mp);
15113 mp->index = ntohl (index);
15118 /* Wait for a reply, return good/bad news */
15124 api_map_add_del_rule (vat_main_t * vam)
15126 unformat_input_t *i = vam->input;
15127 vl_api_map_add_del_rule_t *mp;
15129 ip6_address_t ip6_dst;
15130 u32 num_m_args = 0, index, psid = 0;
15133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15135 if (unformat (i, "index %d", &index))
15137 else if (unformat (i, "psid %d", &psid))
15139 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15141 else if (unformat (i, "del"))
15147 clib_warning ("parse error '%U'", format_unformat_error, i);
15152 /* Construct the API message */
15153 M (MAP_ADD_DEL_RULE, mp);
15155 mp->index = ntohl (index);
15156 mp->is_add = is_add;
15157 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15158 mp->psid = ntohs (psid);
15163 /* Wait for a reply, return good/bad news */
15169 api_map_domain_dump (vat_main_t * vam)
15171 vl_api_map_domain_dump_t *mp;
15172 vl_api_control_ping_t *mp_ping;
15175 /* Construct the API message */
15176 M (MAP_DOMAIN_DUMP, mp);
15181 /* Use a control ping for synchronization */
15182 MPING (CONTROL_PING, mp_ping);
15190 api_map_rule_dump (vat_main_t * vam)
15192 unformat_input_t *i = vam->input;
15193 vl_api_map_rule_dump_t *mp;
15194 vl_api_control_ping_t *mp_ping;
15195 u32 domain_index = ~0;
15198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15200 if (unformat (i, "index %u", &domain_index))
15206 if (domain_index == ~0)
15208 clib_warning ("parse error: domain index expected");
15212 /* Construct the API message */
15213 M (MAP_RULE_DUMP, mp);
15215 mp->domain_index = htonl (domain_index);
15220 /* Use a control ping for synchronization */
15221 MPING (CONTROL_PING, mp_ping);
15228 static void vl_api_map_add_domain_reply_t_handler
15229 (vl_api_map_add_domain_reply_t * mp)
15231 vat_main_t *vam = &vat_main;
15232 i32 retval = ntohl (mp->retval);
15234 if (vam->async_mode)
15236 vam->async_errors += (retval < 0);
15240 vam->retval = retval;
15241 vam->result_ready = 1;
15245 static void vl_api_map_add_domain_reply_t_handler_json
15246 (vl_api_map_add_domain_reply_t * mp)
15248 vat_main_t *vam = &vat_main;
15249 vat_json_node_t node;
15251 vat_json_init_object (&node);
15252 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15253 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15255 vat_json_print (vam->ofp, &node);
15256 vat_json_free (&node);
15258 vam->retval = ntohl (mp->retval);
15259 vam->result_ready = 1;
15263 api_get_first_msg_id (vat_main_t * vam)
15265 vl_api_get_first_msg_id_t *mp;
15266 unformat_input_t *i = vam->input;
15271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15273 if (unformat (i, "client %s", &name))
15281 errmsg ("missing client name");
15284 vec_add1 (name, 0);
15286 if (vec_len (name) > 63)
15288 errmsg ("client name too long");
15292 M (GET_FIRST_MSG_ID, mp);
15293 clib_memcpy (mp->name, name, vec_len (name));
15300 api_cop_interface_enable_disable (vat_main_t * vam)
15302 unformat_input_t *line_input = vam->input;
15303 vl_api_cop_interface_enable_disable_t *mp;
15304 u32 sw_if_index = ~0;
15305 u8 enable_disable = 1;
15308 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15310 if (unformat (line_input, "disable"))
15311 enable_disable = 0;
15312 if (unformat (line_input, "enable"))
15313 enable_disable = 1;
15314 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15315 vam, &sw_if_index))
15317 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15323 if (sw_if_index == ~0)
15325 errmsg ("missing interface name or sw_if_index");
15329 /* Construct the API message */
15330 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15331 mp->sw_if_index = ntohl (sw_if_index);
15332 mp->enable_disable = enable_disable;
15336 /* Wait for the reply */
15342 api_cop_whitelist_enable_disable (vat_main_t * vam)
15344 unformat_input_t *line_input = vam->input;
15345 vl_api_cop_whitelist_enable_disable_t *mp;
15346 u32 sw_if_index = ~0;
15347 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15351 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15353 if (unformat (line_input, "ip4"))
15355 else if (unformat (line_input, "ip6"))
15357 else if (unformat (line_input, "default"))
15359 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15360 vam, &sw_if_index))
15362 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15364 else if (unformat (line_input, "fib-id %d", &fib_id))
15370 if (sw_if_index == ~0)
15372 errmsg ("missing interface name or sw_if_index");
15376 /* Construct the API message */
15377 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15378 mp->sw_if_index = ntohl (sw_if_index);
15379 mp->fib_id = ntohl (fib_id);
15382 mp->default_cop = default_cop;
15386 /* Wait for the reply */
15392 api_get_node_graph (vat_main_t * vam)
15394 vl_api_get_node_graph_t *mp;
15397 M (GET_NODE_GRAPH, mp);
15401 /* Wait for the reply */
15407 /** Used for parsing LISP eids */
15408 typedef CLIB_PACKED(struct{
15409 u8 addr[16]; /**< eid address */
15410 u32 len; /**< prefix length if IP */
15411 u8 type; /**< type of eid */
15416 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15418 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15420 memset (a, 0, sizeof (a[0]));
15422 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15424 a->type = 0; /* ipv4 type */
15426 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15428 a->type = 1; /* ipv6 type */
15430 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15432 a->type = 2; /* mac type */
15434 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15436 a->type = 3; /* NSH type */
15437 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15438 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15445 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15454 lisp_eid_size_vat (u8 type)
15471 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15473 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15477 api_one_add_del_locator_set (vat_main_t * vam)
15479 unformat_input_t *input = vam->input;
15480 vl_api_one_add_del_locator_set_t *mp;
15482 u8 *locator_set_name = NULL;
15483 u8 locator_set_name_set = 0;
15484 vl_api_local_locator_t locator, *locators = 0;
15485 u32 sw_if_index, priority, weight;
15489 /* Parse args required to build the message */
15490 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15492 if (unformat (input, "del"))
15496 else if (unformat (input, "locator-set %s", &locator_set_name))
15498 locator_set_name_set = 1;
15500 else if (unformat (input, "sw_if_index %u p %u w %u",
15501 &sw_if_index, &priority, &weight))
15503 locator.sw_if_index = htonl (sw_if_index);
15504 locator.priority = priority;
15505 locator.weight = weight;
15506 vec_add1 (locators, locator);
15510 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15511 &sw_if_index, &priority, &weight))
15513 locator.sw_if_index = htonl (sw_if_index);
15514 locator.priority = priority;
15515 locator.weight = weight;
15516 vec_add1 (locators, locator);
15522 if (locator_set_name_set == 0)
15524 errmsg ("missing locator-set name");
15525 vec_free (locators);
15529 if (vec_len (locator_set_name) > 64)
15531 errmsg ("locator-set name too long");
15532 vec_free (locator_set_name);
15533 vec_free (locators);
15536 vec_add1 (locator_set_name, 0);
15538 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15540 /* Construct the API message */
15541 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15543 mp->is_add = is_add;
15544 clib_memcpy (mp->locator_set_name, locator_set_name,
15545 vec_len (locator_set_name));
15546 vec_free (locator_set_name);
15548 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15550 clib_memcpy (mp->locators, locators, data_len);
15551 vec_free (locators);
15556 /* Wait for a reply... */
15561 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15564 api_one_add_del_locator (vat_main_t * vam)
15566 unformat_input_t *input = vam->input;
15567 vl_api_one_add_del_locator_t *mp;
15568 u32 tmp_if_index = ~0;
15569 u32 sw_if_index = ~0;
15570 u8 sw_if_index_set = 0;
15571 u8 sw_if_index_if_name_set = 0;
15573 u8 priority_set = 0;
15577 u8 *locator_set_name = NULL;
15578 u8 locator_set_name_set = 0;
15581 /* Parse args required to build the message */
15582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15584 if (unformat (input, "del"))
15588 else if (unformat (input, "locator-set %s", &locator_set_name))
15590 locator_set_name_set = 1;
15592 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15595 sw_if_index_if_name_set = 1;
15596 sw_if_index = tmp_if_index;
15598 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15600 sw_if_index_set = 1;
15601 sw_if_index = tmp_if_index;
15603 else if (unformat (input, "p %d", &priority))
15607 else if (unformat (input, "w %d", &weight))
15615 if (locator_set_name_set == 0)
15617 errmsg ("missing locator-set name");
15621 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15623 errmsg ("missing sw_if_index");
15624 vec_free (locator_set_name);
15628 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15630 errmsg ("cannot use both params interface name and sw_if_index");
15631 vec_free (locator_set_name);
15635 if (priority_set == 0)
15637 errmsg ("missing locator-set priority");
15638 vec_free (locator_set_name);
15642 if (weight_set == 0)
15644 errmsg ("missing locator-set weight");
15645 vec_free (locator_set_name);
15649 if (vec_len (locator_set_name) > 64)
15651 errmsg ("locator-set name too long");
15652 vec_free (locator_set_name);
15655 vec_add1 (locator_set_name, 0);
15657 /* Construct the API message */
15658 M (ONE_ADD_DEL_LOCATOR, mp);
15660 mp->is_add = is_add;
15661 mp->sw_if_index = ntohl (sw_if_index);
15662 mp->priority = priority;
15663 mp->weight = weight;
15664 clib_memcpy (mp->locator_set_name, locator_set_name,
15665 vec_len (locator_set_name));
15666 vec_free (locator_set_name);
15671 /* Wait for a reply... */
15676 #define api_lisp_add_del_locator api_one_add_del_locator
15679 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15681 u32 *key_id = va_arg (*args, u32 *);
15684 if (unformat (input, "%s", &s))
15686 if (!strcmp ((char *) s, "sha1"))
15687 key_id[0] = HMAC_SHA_1_96;
15688 else if (!strcmp ((char *) s, "sha256"))
15689 key_id[0] = HMAC_SHA_256_128;
15692 clib_warning ("invalid key_id: '%s'", s);
15693 key_id[0] = HMAC_NO_KEY;
15704 api_one_add_del_local_eid (vat_main_t * vam)
15706 unformat_input_t *input = vam->input;
15707 vl_api_one_add_del_local_eid_t *mp;
15710 lisp_eid_vat_t _eid, *eid = &_eid;
15711 u8 *locator_set_name = 0;
15712 u8 locator_set_name_set = 0;
15718 /* Parse args required to build the message */
15719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15721 if (unformat (input, "del"))
15725 else if (unformat (input, "vni %d", &vni))
15729 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15733 else if (unformat (input, "locator-set %s", &locator_set_name))
15735 locator_set_name_set = 1;
15737 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15739 else if (unformat (input, "secret-key %_%v%_", &key))
15745 if (locator_set_name_set == 0)
15747 errmsg ("missing locator-set name");
15753 errmsg ("EID address not set!");
15754 vec_free (locator_set_name);
15758 if (key && (0 == key_id))
15760 errmsg ("invalid key_id!");
15764 if (vec_len (key) > 64)
15766 errmsg ("key too long");
15771 if (vec_len (locator_set_name) > 64)
15773 errmsg ("locator-set name too long");
15774 vec_free (locator_set_name);
15777 vec_add1 (locator_set_name, 0);
15779 /* Construct the API message */
15780 M (ONE_ADD_DEL_LOCAL_EID, mp);
15782 mp->is_add = is_add;
15783 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15784 mp->eid_type = eid->type;
15785 mp->prefix_len = eid->len;
15786 mp->vni = clib_host_to_net_u32 (vni);
15787 mp->key_id = clib_host_to_net_u16 (key_id);
15788 clib_memcpy (mp->locator_set_name, locator_set_name,
15789 vec_len (locator_set_name));
15790 clib_memcpy (mp->key, key, vec_len (key));
15792 vec_free (locator_set_name);
15798 /* Wait for a reply... */
15803 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15806 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15808 u32 dp_table = 0, vni = 0;;
15809 unformat_input_t *input = vam->input;
15810 vl_api_gpe_add_del_fwd_entry_t *mp;
15812 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15813 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15814 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15815 u32 action = ~0, w;
15816 ip4_address_t rmt_rloc4, lcl_rloc4;
15817 ip6_address_t rmt_rloc6, lcl_rloc6;
15818 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15821 memset (&rloc, 0, sizeof (rloc));
15823 /* Parse args required to build the message */
15824 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15826 if (unformat (input, "del"))
15828 else if (unformat (input, "add"))
15830 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15834 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15838 else if (unformat (input, "vrf %d", &dp_table))
15840 else if (unformat (input, "bd %d", &dp_table))
15842 else if (unformat (input, "vni %d", &vni))
15844 else if (unformat (input, "w %d", &w))
15848 errmsg ("No RLOC configured for setting priority/weight!");
15851 curr_rloc->weight = w;
15853 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15854 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15858 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15860 vec_add1 (lcl_locs, rloc);
15862 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15863 vec_add1 (rmt_locs, rloc);
15864 /* weight saved in rmt loc */
15865 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15867 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15868 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15871 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15873 vec_add1 (lcl_locs, rloc);
15875 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15876 vec_add1 (rmt_locs, rloc);
15877 /* weight saved in rmt loc */
15878 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15880 else if (unformat (input, "action %d", &action))
15886 clib_warning ("parse error '%U'", format_unformat_error, input);
15893 errmsg ("remote eid addresses not set");
15897 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15899 errmsg ("eid types don't match");
15903 if (0 == rmt_locs && (u32) ~ 0 == action)
15905 errmsg ("action not set for negative mapping");
15909 /* Construct the API message */
15910 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15911 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15913 mp->is_add = is_add;
15914 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15915 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15916 mp->eid_type = rmt_eid->type;
15917 mp->dp_table = clib_host_to_net_u32 (dp_table);
15918 mp->vni = clib_host_to_net_u32 (vni);
15919 mp->rmt_len = rmt_eid->len;
15920 mp->lcl_len = lcl_eid->len;
15921 mp->action = action;
15923 if (0 != rmt_locs && 0 != lcl_locs)
15925 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15926 clib_memcpy (mp->locs, lcl_locs,
15927 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15929 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15930 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15931 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15933 vec_free (lcl_locs);
15934 vec_free (rmt_locs);
15939 /* Wait for a reply... */
15945 api_one_add_del_map_server (vat_main_t * vam)
15947 unformat_input_t *input = vam->input;
15948 vl_api_one_add_del_map_server_t *mp;
15952 ip4_address_t ipv4;
15953 ip6_address_t ipv6;
15956 /* Parse args required to build the message */
15957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15959 if (unformat (input, "del"))
15963 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15967 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15975 if (ipv4_set && ipv6_set)
15977 errmsg ("both eid v4 and v6 addresses set");
15981 if (!ipv4_set && !ipv6_set)
15983 errmsg ("eid addresses not set");
15987 /* Construct the API message */
15988 M (ONE_ADD_DEL_MAP_SERVER, mp);
15990 mp->is_add = is_add;
15994 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15999 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16005 /* Wait for a reply... */
16010 #define api_lisp_add_del_map_server api_one_add_del_map_server
16013 api_one_add_del_map_resolver (vat_main_t * vam)
16015 unformat_input_t *input = vam->input;
16016 vl_api_one_add_del_map_resolver_t *mp;
16020 ip4_address_t ipv4;
16021 ip6_address_t ipv6;
16024 /* Parse args required to build the message */
16025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16027 if (unformat (input, "del"))
16031 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16035 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16043 if (ipv4_set && ipv6_set)
16045 errmsg ("both eid v4 and v6 addresses set");
16049 if (!ipv4_set && !ipv6_set)
16051 errmsg ("eid addresses not set");
16055 /* Construct the API message */
16056 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16058 mp->is_add = is_add;
16062 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16067 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16073 /* Wait for a reply... */
16078 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16081 api_lisp_gpe_enable_disable (vat_main_t * vam)
16083 unformat_input_t *input = vam->input;
16084 vl_api_gpe_enable_disable_t *mp;
16089 /* Parse args required to build the message */
16090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16092 if (unformat (input, "enable"))
16097 else if (unformat (input, "disable"))
16108 errmsg ("Value not set");
16112 /* Construct the API message */
16113 M (GPE_ENABLE_DISABLE, mp);
16120 /* Wait for a reply... */
16126 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16128 unformat_input_t *input = vam->input;
16129 vl_api_one_rloc_probe_enable_disable_t *mp;
16134 /* Parse args required to build the message */
16135 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16137 if (unformat (input, "enable"))
16142 else if (unformat (input, "disable"))
16150 errmsg ("Value not set");
16154 /* Construct the API message */
16155 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16157 mp->is_enabled = is_en;
16162 /* Wait for a reply... */
16167 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16170 api_one_map_register_enable_disable (vat_main_t * vam)
16172 unformat_input_t *input = vam->input;
16173 vl_api_one_map_register_enable_disable_t *mp;
16178 /* Parse args required to build the message */
16179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16181 if (unformat (input, "enable"))
16186 else if (unformat (input, "disable"))
16194 errmsg ("Value not set");
16198 /* Construct the API message */
16199 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16201 mp->is_enabled = is_en;
16206 /* Wait for a reply... */
16211 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16214 api_one_enable_disable (vat_main_t * vam)
16216 unformat_input_t *input = vam->input;
16217 vl_api_one_enable_disable_t *mp;
16222 /* Parse args required to build the message */
16223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16225 if (unformat (input, "enable"))
16230 else if (unformat (input, "disable"))
16240 errmsg ("Value not set");
16244 /* Construct the API message */
16245 M (ONE_ENABLE_DISABLE, mp);
16252 /* Wait for a reply... */
16257 #define api_lisp_enable_disable api_one_enable_disable
16260 api_show_one_map_register_state (vat_main_t * vam)
16262 vl_api_show_one_map_register_state_t *mp;
16265 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16270 /* wait for reply */
16275 #define api_show_lisp_map_register_state api_show_one_map_register_state
16278 api_show_one_rloc_probe_state (vat_main_t * vam)
16280 vl_api_show_one_rloc_probe_state_t *mp;
16283 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16288 /* wait for reply */
16293 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16296 api_one_add_del_ndp_entry (vat_main_t * vam)
16298 vl_api_one_add_del_ndp_entry_t *mp;
16299 unformat_input_t *input = vam->input;
16304 u8 mac[6] = { 0, };
16305 u8 ip6[16] = { 0, };
16309 /* Parse args required to build the message */
16310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16312 if (unformat (input, "del"))
16314 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16316 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16318 else if (unformat (input, "bd %d", &bd))
16322 errmsg ("parse error '%U'", format_unformat_error, input);
16327 if (!bd_set || !ip_set || (!mac_set && is_add))
16329 errmsg ("Missing BD, IP or MAC!");
16333 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16334 mp->is_add = is_add;
16335 clib_memcpy (mp->mac, mac, 6);
16336 mp->bd = clib_host_to_net_u32 (bd);
16337 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16342 /* wait for reply */
16348 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16350 vl_api_one_add_del_l2_arp_entry_t *mp;
16351 unformat_input_t *input = vam->input;
16356 u8 mac[6] = { 0, };
16357 u32 ip4 = 0, bd = ~0;
16360 /* Parse args required to build the message */
16361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16363 if (unformat (input, "del"))
16365 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16367 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16369 else if (unformat (input, "bd %d", &bd))
16373 errmsg ("parse error '%U'", format_unformat_error, input);
16378 if (!bd_set || !ip_set || (!mac_set && is_add))
16380 errmsg ("Missing BD, IP or MAC!");
16384 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16385 mp->is_add = is_add;
16386 clib_memcpy (mp->mac, mac, 6);
16387 mp->bd = clib_host_to_net_u32 (bd);
16393 /* wait for reply */
16399 api_one_ndp_bd_get (vat_main_t * vam)
16401 vl_api_one_ndp_bd_get_t *mp;
16404 M (ONE_NDP_BD_GET, mp);
16409 /* wait for reply */
16415 api_one_ndp_entries_get (vat_main_t * vam)
16417 vl_api_one_ndp_entries_get_t *mp;
16418 unformat_input_t *input = vam->input;
16423 /* Parse args required to build the message */
16424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16426 if (unformat (input, "bd %d", &bd))
16430 errmsg ("parse error '%U'", format_unformat_error, input);
16437 errmsg ("Expected bridge domain!");
16441 M (ONE_NDP_ENTRIES_GET, mp);
16442 mp->bd = clib_host_to_net_u32 (bd);
16447 /* wait for reply */
16453 api_one_l2_arp_bd_get (vat_main_t * vam)
16455 vl_api_one_l2_arp_bd_get_t *mp;
16458 M (ONE_L2_ARP_BD_GET, mp);
16463 /* wait for reply */
16469 api_one_l2_arp_entries_get (vat_main_t * vam)
16471 vl_api_one_l2_arp_entries_get_t *mp;
16472 unformat_input_t *input = vam->input;
16477 /* Parse args required to build the message */
16478 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16480 if (unformat (input, "bd %d", &bd))
16484 errmsg ("parse error '%U'", format_unformat_error, input);
16491 errmsg ("Expected bridge domain!");
16495 M (ONE_L2_ARP_ENTRIES_GET, mp);
16496 mp->bd = clib_host_to_net_u32 (bd);
16501 /* wait for reply */
16507 api_one_stats_enable_disable (vat_main_t * vam)
16509 vl_api_one_stats_enable_disable_t *mp;
16510 unformat_input_t *input = vam->input;
16515 /* Parse args required to build the message */
16516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16518 if (unformat (input, "enable"))
16523 else if (unformat (input, "disable"))
16533 errmsg ("Value not set");
16537 M (ONE_STATS_ENABLE_DISABLE, mp);
16543 /* wait for reply */
16549 api_show_one_stats_enable_disable (vat_main_t * vam)
16551 vl_api_show_one_stats_enable_disable_t *mp;
16554 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16559 /* wait for reply */
16565 api_show_one_map_request_mode (vat_main_t * vam)
16567 vl_api_show_one_map_request_mode_t *mp;
16570 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16575 /* wait for reply */
16580 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16583 api_one_map_request_mode (vat_main_t * vam)
16585 unformat_input_t *input = vam->input;
16586 vl_api_one_map_request_mode_t *mp;
16590 /* Parse args required to build the message */
16591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16593 if (unformat (input, "dst-only"))
16595 else if (unformat (input, "src-dst"))
16599 errmsg ("parse error '%U'", format_unformat_error, input);
16604 M (ONE_MAP_REQUEST_MODE, mp);
16611 /* wait for reply */
16616 #define api_lisp_map_request_mode api_one_map_request_mode
16619 * Enable/disable ONE proxy ITR.
16621 * @param vam vpp API test context
16622 * @return return code
16625 api_one_pitr_set_locator_set (vat_main_t * vam)
16627 u8 ls_name_set = 0;
16628 unformat_input_t *input = vam->input;
16629 vl_api_one_pitr_set_locator_set_t *mp;
16634 /* Parse args required to build the message */
16635 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16637 if (unformat (input, "del"))
16639 else if (unformat (input, "locator-set %s", &ls_name))
16643 errmsg ("parse error '%U'", format_unformat_error, input);
16650 errmsg ("locator-set name not set!");
16654 M (ONE_PITR_SET_LOCATOR_SET, mp);
16656 mp->is_add = is_add;
16657 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16658 vec_free (ls_name);
16663 /* wait for reply */
16668 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16671 api_one_nsh_set_locator_set (vat_main_t * vam)
16673 u8 ls_name_set = 0;
16674 unformat_input_t *input = vam->input;
16675 vl_api_one_nsh_set_locator_set_t *mp;
16680 /* Parse args required to build the message */
16681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16683 if (unformat (input, "del"))
16685 else if (unformat (input, "ls %s", &ls_name))
16689 errmsg ("parse error '%U'", format_unformat_error, input);
16694 if (!ls_name_set && is_add)
16696 errmsg ("locator-set name not set!");
16700 M (ONE_NSH_SET_LOCATOR_SET, mp);
16702 mp->is_add = is_add;
16703 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16704 vec_free (ls_name);
16709 /* wait for reply */
16715 api_show_one_pitr (vat_main_t * vam)
16717 vl_api_show_one_pitr_t *mp;
16720 if (!vam->json_output)
16722 print (vam->ofp, "%=20s", "lisp status:");
16725 M (SHOW_ONE_PITR, mp);
16729 /* Wait for a reply... */
16734 #define api_show_lisp_pitr api_show_one_pitr
16737 api_one_use_petr (vat_main_t * vam)
16739 unformat_input_t *input = vam->input;
16740 vl_api_one_use_petr_t *mp;
16745 memset (&ip, 0, sizeof (ip));
16747 /* Parse args required to build the message */
16748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16750 if (unformat (input, "disable"))
16753 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16756 ip_addr_version (&ip) = IP4;
16759 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16762 ip_addr_version (&ip) = IP6;
16766 errmsg ("parse error '%U'", format_unformat_error, input);
16771 M (ONE_USE_PETR, mp);
16773 mp->is_add = is_add;
16776 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16778 clib_memcpy (mp->address, &ip, 4);
16780 clib_memcpy (mp->address, &ip, 16);
16786 /* wait for reply */
16791 #define api_lisp_use_petr api_one_use_petr
16794 api_show_one_nsh_mapping (vat_main_t * vam)
16796 vl_api_show_one_use_petr_t *mp;
16799 if (!vam->json_output)
16801 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16804 M (SHOW_ONE_NSH_MAPPING, mp);
16808 /* Wait for a reply... */
16814 api_show_one_use_petr (vat_main_t * vam)
16816 vl_api_show_one_use_petr_t *mp;
16819 if (!vam->json_output)
16821 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16824 M (SHOW_ONE_USE_PETR, mp);
16828 /* Wait for a reply... */
16833 #define api_show_lisp_use_petr api_show_one_use_petr
16836 * Add/delete mapping between vni and vrf
16839 api_one_eid_table_add_del_map (vat_main_t * vam)
16841 unformat_input_t *input = vam->input;
16842 vl_api_one_eid_table_add_del_map_t *mp;
16843 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16844 u32 vni, vrf, bd_index;
16847 /* Parse args required to build the message */
16848 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16850 if (unformat (input, "del"))
16852 else if (unformat (input, "vrf %d", &vrf))
16854 else if (unformat (input, "bd_index %d", &bd_index))
16856 else if (unformat (input, "vni %d", &vni))
16862 if (!vni_set || (!vrf_set && !bd_index_set))
16864 errmsg ("missing arguments!");
16868 if (vrf_set && bd_index_set)
16870 errmsg ("error: both vrf and bd entered!");
16874 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16876 mp->is_add = is_add;
16877 mp->vni = htonl (vni);
16878 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16879 mp->is_l2 = bd_index_set;
16884 /* wait for reply */
16889 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16892 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16894 u32 *action = va_arg (*args, u32 *);
16897 if (unformat (input, "%s", &s))
16899 if (!strcmp ((char *) s, "no-action"))
16901 else if (!strcmp ((char *) s, "natively-forward"))
16903 else if (!strcmp ((char *) s, "send-map-request"))
16905 else if (!strcmp ((char *) s, "drop"))
16909 clib_warning ("invalid action: '%s'", s);
16921 * Add/del remote mapping to/from ONE control plane
16923 * @param vam vpp API test context
16924 * @return return code
16927 api_one_add_del_remote_mapping (vat_main_t * vam)
16929 unformat_input_t *input = vam->input;
16930 vl_api_one_add_del_remote_mapping_t *mp;
16932 lisp_eid_vat_t _eid, *eid = &_eid;
16933 lisp_eid_vat_t _seid, *seid = &_seid;
16934 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16935 u32 action = ~0, p, w, data_len;
16936 ip4_address_t rloc4;
16937 ip6_address_t rloc6;
16938 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16941 memset (&rloc, 0, sizeof (rloc));
16943 /* Parse args required to build the message */
16944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16946 if (unformat (input, "del-all"))
16950 else if (unformat (input, "del"))
16954 else if (unformat (input, "add"))
16958 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16962 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16966 else if (unformat (input, "vni %d", &vni))
16970 else if (unformat (input, "p %d w %d", &p, &w))
16974 errmsg ("No RLOC configured for setting priority/weight!");
16977 curr_rloc->priority = p;
16978 curr_rloc->weight = w;
16980 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16983 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16984 vec_add1 (rlocs, rloc);
16985 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16987 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16990 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16991 vec_add1 (rlocs, rloc);
16992 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16994 else if (unformat (input, "action %U",
16995 unformat_negative_mapping_action, &action))
17001 clib_warning ("parse error '%U'", format_unformat_error, input);
17008 errmsg ("missing params!");
17012 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17014 errmsg ("no action set for negative map-reply!");
17018 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17020 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17021 mp->is_add = is_add;
17022 mp->vni = htonl (vni);
17023 mp->action = (u8) action;
17024 mp->is_src_dst = seid_set;
17025 mp->eid_len = eid->len;
17026 mp->seid_len = seid->len;
17027 mp->del_all = del_all;
17028 mp->eid_type = eid->type;
17029 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17030 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17032 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17033 clib_memcpy (mp->rlocs, rlocs, data_len);
17039 /* Wait for a reply... */
17044 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17047 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17048 * forwarding entries in data-plane accordingly.
17050 * @param vam vpp API test context
17051 * @return return code
17054 api_one_add_del_adjacency (vat_main_t * vam)
17056 unformat_input_t *input = vam->input;
17057 vl_api_one_add_del_adjacency_t *mp;
17059 ip4_address_t leid4, reid4;
17060 ip6_address_t leid6, reid6;
17061 u8 reid_mac[6] = { 0 };
17062 u8 leid_mac[6] = { 0 };
17063 u8 reid_type, leid_type;
17064 u32 leid_len = 0, reid_len = 0, len;
17068 leid_type = reid_type = (u8) ~ 0;
17070 /* Parse args required to build the message */
17071 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17073 if (unformat (input, "del"))
17077 else if (unformat (input, "add"))
17081 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17084 reid_type = 0; /* ipv4 */
17087 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17090 reid_type = 1; /* ipv6 */
17093 else if (unformat (input, "reid %U", unformat_ethernet_address,
17096 reid_type = 2; /* mac */
17098 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17101 leid_type = 0; /* ipv4 */
17104 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17107 leid_type = 1; /* ipv6 */
17110 else if (unformat (input, "leid %U", unformat_ethernet_address,
17113 leid_type = 2; /* mac */
17115 else if (unformat (input, "vni %d", &vni))
17121 errmsg ("parse error '%U'", format_unformat_error, input);
17126 if ((u8) ~ 0 == reid_type)
17128 errmsg ("missing params!");
17132 if (leid_type != reid_type)
17134 errmsg ("remote and local EIDs are of different types!");
17138 M (ONE_ADD_DEL_ADJACENCY, mp);
17139 mp->is_add = is_add;
17140 mp->vni = htonl (vni);
17141 mp->leid_len = leid_len;
17142 mp->reid_len = reid_len;
17143 mp->eid_type = reid_type;
17145 switch (mp->eid_type)
17148 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17149 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17152 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17153 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17156 clib_memcpy (mp->leid, leid_mac, 6);
17157 clib_memcpy (mp->reid, reid_mac, 6);
17160 errmsg ("unknown EID type %d!", mp->eid_type);
17167 /* Wait for a reply... */
17172 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17175 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17177 u32 *mode = va_arg (*args, u32 *);
17179 if (unformat (input, "lisp"))
17181 else if (unformat (input, "vxlan"))
17190 api_gpe_get_encap_mode (vat_main_t * vam)
17192 vl_api_gpe_get_encap_mode_t *mp;
17195 /* Construct the API message */
17196 M (GPE_GET_ENCAP_MODE, mp);
17201 /* Wait for a reply... */
17207 api_gpe_set_encap_mode (vat_main_t * vam)
17209 unformat_input_t *input = vam->input;
17210 vl_api_gpe_set_encap_mode_t *mp;
17214 /* Parse args required to build the message */
17215 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17217 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17223 /* Construct the API message */
17224 M (GPE_SET_ENCAP_MODE, mp);
17231 /* Wait for a reply... */
17237 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17239 unformat_input_t *input = vam->input;
17240 vl_api_gpe_add_del_iface_t *mp;
17241 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17242 u32 dp_table = 0, vni = 0;
17245 /* Parse args required to build the message */
17246 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17248 if (unformat (input, "up"))
17253 else if (unformat (input, "down"))
17258 else if (unformat (input, "table_id %d", &dp_table))
17262 else if (unformat (input, "bd_id %d", &dp_table))
17267 else if (unformat (input, "vni %d", &vni))
17275 if (action_set == 0)
17277 errmsg ("Action not set");
17280 if (dp_table_set == 0 || vni_set == 0)
17282 errmsg ("vni and dp_table must be set");
17286 /* Construct the API message */
17287 M (GPE_ADD_DEL_IFACE, mp);
17289 mp->is_add = is_add;
17290 mp->dp_table = clib_host_to_net_u32 (dp_table);
17292 mp->vni = clib_host_to_net_u32 (vni);
17297 /* Wait for a reply... */
17303 api_one_map_register_fallback_threshold (vat_main_t * vam)
17305 unformat_input_t *input = vam->input;
17306 vl_api_one_map_register_fallback_threshold_t *mp;
17311 /* Parse args required to build the message */
17312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17314 if (unformat (input, "%u", &value))
17318 clib_warning ("parse error '%U'", format_unformat_error, input);
17325 errmsg ("fallback threshold value is missing!");
17329 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17330 mp->value = clib_host_to_net_u32 (value);
17335 /* Wait for a reply... */
17341 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17343 vl_api_show_one_map_register_fallback_threshold_t *mp;
17346 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17351 /* Wait for a reply... */
17357 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17359 u32 *proto = va_arg (*args, u32 *);
17361 if (unformat (input, "udp"))
17363 else if (unformat (input, "api"))
17372 api_one_set_transport_protocol (vat_main_t * vam)
17374 unformat_input_t *input = vam->input;
17375 vl_api_one_set_transport_protocol_t *mp;
17380 /* Parse args required to build the message */
17381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17383 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17387 clib_warning ("parse error '%U'", format_unformat_error, input);
17394 errmsg ("Transport protocol missing!");
17398 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17399 mp->protocol = (u8) protocol;
17404 /* Wait for a reply... */
17410 api_one_get_transport_protocol (vat_main_t * vam)
17412 vl_api_one_get_transport_protocol_t *mp;
17415 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17420 /* Wait for a reply... */
17426 api_one_map_register_set_ttl (vat_main_t * vam)
17428 unformat_input_t *input = vam->input;
17429 vl_api_one_map_register_set_ttl_t *mp;
17434 /* Parse args required to build the message */
17435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17437 if (unformat (input, "%u", &ttl))
17441 clib_warning ("parse error '%U'", format_unformat_error, input);
17448 errmsg ("TTL value missing!");
17452 M (ONE_MAP_REGISTER_SET_TTL, mp);
17453 mp->ttl = clib_host_to_net_u32 (ttl);
17458 /* Wait for a reply... */
17464 api_show_one_map_register_ttl (vat_main_t * vam)
17466 vl_api_show_one_map_register_ttl_t *mp;
17469 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17474 /* Wait for a reply... */
17480 * Add/del map request itr rlocs from ONE control plane and updates
17482 * @param vam vpp API test context
17483 * @return return code
17486 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17488 unformat_input_t *input = vam->input;
17489 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17490 u8 *locator_set_name = 0;
17491 u8 locator_set_name_set = 0;
17495 /* Parse args required to build the message */
17496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17498 if (unformat (input, "del"))
17502 else if (unformat (input, "%_%v%_", &locator_set_name))
17504 locator_set_name_set = 1;
17508 clib_warning ("parse error '%U'", format_unformat_error, input);
17513 if (is_add && !locator_set_name_set)
17515 errmsg ("itr-rloc is not set!");
17519 if (is_add && vec_len (locator_set_name) > 64)
17521 errmsg ("itr-rloc locator-set name too long");
17522 vec_free (locator_set_name);
17526 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17527 mp->is_add = is_add;
17530 clib_memcpy (mp->locator_set_name, locator_set_name,
17531 vec_len (locator_set_name));
17535 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17537 vec_free (locator_set_name);
17542 /* Wait for a reply... */
17547 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17550 api_one_locator_dump (vat_main_t * vam)
17552 unformat_input_t *input = vam->input;
17553 vl_api_one_locator_dump_t *mp;
17554 vl_api_control_ping_t *mp_ping;
17555 u8 is_index_set = 0, is_name_set = 0;
17560 /* Parse args required to build the message */
17561 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17563 if (unformat (input, "ls_name %_%v%_", &ls_name))
17567 else if (unformat (input, "ls_index %d", &ls_index))
17573 errmsg ("parse error '%U'", format_unformat_error, input);
17578 if (!is_index_set && !is_name_set)
17580 errmsg ("error: expected one of index or name!");
17584 if (is_index_set && is_name_set)
17586 errmsg ("error: only one param expected!");
17590 if (vec_len (ls_name) > 62)
17592 errmsg ("error: locator set name too long!");
17596 if (!vam->json_output)
17598 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17601 M (ONE_LOCATOR_DUMP, mp);
17602 mp->is_index_set = is_index_set;
17605 mp->ls_index = clib_host_to_net_u32 (ls_index);
17608 vec_add1 (ls_name, 0);
17609 strncpy ((char *) mp->ls_name, (char *) ls_name,
17610 sizeof (mp->ls_name) - 1);
17616 /* Use a control ping for synchronization */
17617 MPING (CONTROL_PING, mp_ping);
17620 /* Wait for a reply... */
17625 #define api_lisp_locator_dump api_one_locator_dump
17628 api_one_locator_set_dump (vat_main_t * vam)
17630 vl_api_one_locator_set_dump_t *mp;
17631 vl_api_control_ping_t *mp_ping;
17632 unformat_input_t *input = vam->input;
17636 /* Parse args required to build the message */
17637 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17639 if (unformat (input, "local"))
17643 else if (unformat (input, "remote"))
17649 errmsg ("parse error '%U'", format_unformat_error, input);
17654 if (!vam->json_output)
17656 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17659 M (ONE_LOCATOR_SET_DUMP, mp);
17661 mp->filter = filter;
17666 /* Use a control ping for synchronization */
17667 MPING (CONTROL_PING, mp_ping);
17670 /* Wait for a reply... */
17675 #define api_lisp_locator_set_dump api_one_locator_set_dump
17678 api_one_eid_table_map_dump (vat_main_t * vam)
17682 unformat_input_t *input = vam->input;
17683 vl_api_one_eid_table_map_dump_t *mp;
17684 vl_api_control_ping_t *mp_ping;
17687 /* Parse args required to build the message */
17688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17690 if (unformat (input, "l2"))
17695 else if (unformat (input, "l3"))
17702 errmsg ("parse error '%U'", format_unformat_error, input);
17709 errmsg ("expected one of 'l2' or 'l3' parameter!");
17713 if (!vam->json_output)
17715 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17718 M (ONE_EID_TABLE_MAP_DUMP, mp);
17724 /* Use a control ping for synchronization */
17725 MPING (CONTROL_PING, mp_ping);
17728 /* Wait for a reply... */
17733 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17736 api_one_eid_table_vni_dump (vat_main_t * vam)
17738 vl_api_one_eid_table_vni_dump_t *mp;
17739 vl_api_control_ping_t *mp_ping;
17742 if (!vam->json_output)
17744 print (vam->ofp, "VNI");
17747 M (ONE_EID_TABLE_VNI_DUMP, mp);
17752 /* Use a control ping for synchronization */
17753 MPING (CONTROL_PING, mp_ping);
17756 /* Wait for a reply... */
17761 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17764 api_one_eid_table_dump (vat_main_t * vam)
17766 unformat_input_t *i = vam->input;
17767 vl_api_one_eid_table_dump_t *mp;
17768 vl_api_control_ping_t *mp_ping;
17769 struct in_addr ip4;
17770 struct in6_addr ip6;
17772 u8 eid_type = ~0, eid_set = 0;
17773 u32 prefix_length = ~0, t, vni = 0;
17776 lisp_nsh_api_t nsh;
17778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17780 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17786 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17792 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17797 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17802 else if (unformat (i, "vni %d", &t))
17806 else if (unformat (i, "local"))
17810 else if (unformat (i, "remote"))
17816 errmsg ("parse error '%U'", format_unformat_error, i);
17821 if (!vam->json_output)
17823 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17824 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17827 M (ONE_EID_TABLE_DUMP, mp);
17829 mp->filter = filter;
17833 mp->vni = htonl (vni);
17834 mp->eid_type = eid_type;
17838 mp->prefix_length = prefix_length;
17839 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17842 mp->prefix_length = prefix_length;
17843 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17846 clib_memcpy (mp->eid, mac, sizeof (mac));
17849 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17852 errmsg ("unknown EID type %d!", eid_type);
17860 /* Use a control ping for synchronization */
17861 MPING (CONTROL_PING, mp_ping);
17864 /* Wait for a reply... */
17869 #define api_lisp_eid_table_dump api_one_eid_table_dump
17872 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17874 unformat_input_t *i = vam->input;
17875 vl_api_gpe_fwd_entries_get_t *mp;
17880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17882 if (unformat (i, "vni %d", &vni))
17888 errmsg ("parse error '%U'", format_unformat_error, i);
17895 errmsg ("vni not set!");
17899 if (!vam->json_output)
17901 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17905 M (GPE_FWD_ENTRIES_GET, mp);
17906 mp->vni = clib_host_to_net_u32 (vni);
17911 /* Wait for a reply... */
17916 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17917 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17918 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17919 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17920 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17921 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17922 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17923 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17926 api_one_adjacencies_get (vat_main_t * vam)
17928 unformat_input_t *i = vam->input;
17929 vl_api_one_adjacencies_get_t *mp;
17934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17936 if (unformat (i, "vni %d", &vni))
17942 errmsg ("parse error '%U'", format_unformat_error, i);
17949 errmsg ("vni not set!");
17953 if (!vam->json_output)
17955 print (vam->ofp, "%s %40s", "leid", "reid");
17958 M (ONE_ADJACENCIES_GET, mp);
17959 mp->vni = clib_host_to_net_u32 (vni);
17964 /* Wait for a reply... */
17969 #define api_lisp_adjacencies_get api_one_adjacencies_get
17972 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17974 unformat_input_t *i = vam->input;
17975 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17977 u8 ip_family_set = 0, is_ip4 = 1;
17979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17981 if (unformat (i, "ip4"))
17986 else if (unformat (i, "ip6"))
17993 errmsg ("parse error '%U'", format_unformat_error, i);
17998 if (!ip_family_set)
18000 errmsg ("ip family not set!");
18004 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18005 mp->is_ip4 = is_ip4;
18010 /* Wait for a reply... */
18016 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18018 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18021 if (!vam->json_output)
18023 print (vam->ofp, "VNIs");
18026 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18031 /* Wait for a reply... */
18037 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18039 unformat_input_t *i = vam->input;
18040 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18042 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18043 struct in_addr ip4;
18044 struct in6_addr ip6;
18045 u32 table_id = 0, nh_sw_if_index = ~0;
18047 memset (&ip4, 0, sizeof (ip4));
18048 memset (&ip6, 0, sizeof (ip6));
18050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18052 if (unformat (i, "del"))
18054 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18055 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18060 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18061 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18066 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18070 nh_sw_if_index = ~0;
18072 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18076 nh_sw_if_index = ~0;
18078 else if (unformat (i, "table %d", &table_id))
18082 errmsg ("parse error '%U'", format_unformat_error, i);
18089 errmsg ("nh addr not set!");
18093 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18094 mp->is_add = is_add;
18095 mp->table_id = clib_host_to_net_u32 (table_id);
18096 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18097 mp->is_ip4 = is_ip4;
18099 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18101 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18106 /* Wait for a reply... */
18112 api_one_map_server_dump (vat_main_t * vam)
18114 vl_api_one_map_server_dump_t *mp;
18115 vl_api_control_ping_t *mp_ping;
18118 if (!vam->json_output)
18120 print (vam->ofp, "%=20s", "Map server");
18123 M (ONE_MAP_SERVER_DUMP, mp);
18127 /* Use a control ping for synchronization */
18128 MPING (CONTROL_PING, mp_ping);
18131 /* Wait for a reply... */
18136 #define api_lisp_map_server_dump api_one_map_server_dump
18139 api_one_map_resolver_dump (vat_main_t * vam)
18141 vl_api_one_map_resolver_dump_t *mp;
18142 vl_api_control_ping_t *mp_ping;
18145 if (!vam->json_output)
18147 print (vam->ofp, "%=20s", "Map resolver");
18150 M (ONE_MAP_RESOLVER_DUMP, mp);
18154 /* Use a control ping for synchronization */
18155 MPING (CONTROL_PING, mp_ping);
18158 /* Wait for a reply... */
18163 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18166 api_one_stats_flush (vat_main_t * vam)
18168 vl_api_one_stats_flush_t *mp;
18171 M (ONE_STATS_FLUSH, mp);
18178 api_one_stats_dump (vat_main_t * vam)
18180 vl_api_one_stats_dump_t *mp;
18181 vl_api_control_ping_t *mp_ping;
18184 M (ONE_STATS_DUMP, mp);
18188 /* Use a control ping for synchronization */
18189 MPING (CONTROL_PING, mp_ping);
18192 /* Wait for a reply... */
18198 api_show_one_status (vat_main_t * vam)
18200 vl_api_show_one_status_t *mp;
18203 if (!vam->json_output)
18205 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18208 M (SHOW_ONE_STATUS, mp);
18211 /* Wait for a reply... */
18216 #define api_show_lisp_status api_show_one_status
18219 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18221 vl_api_gpe_fwd_entry_path_dump_t *mp;
18222 vl_api_control_ping_t *mp_ping;
18223 unformat_input_t *i = vam->input;
18224 u32 fwd_entry_index = ~0;
18227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18229 if (unformat (i, "index %d", &fwd_entry_index))
18235 if (~0 == fwd_entry_index)
18237 errmsg ("no index specified!");
18241 if (!vam->json_output)
18243 print (vam->ofp, "first line");
18246 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18250 /* Use a control ping for synchronization */
18251 MPING (CONTROL_PING, mp_ping);
18254 /* Wait for a reply... */
18260 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18262 vl_api_one_get_map_request_itr_rlocs_t *mp;
18265 if (!vam->json_output)
18267 print (vam->ofp, "%=20s", "itr-rlocs:");
18270 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18273 /* Wait for a reply... */
18278 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18281 api_af_packet_create (vat_main_t * vam)
18283 unformat_input_t *i = vam->input;
18284 vl_api_af_packet_create_t *mp;
18285 u8 *host_if_name = 0;
18287 u8 random_hw_addr = 1;
18290 memset (hw_addr, 0, sizeof (hw_addr));
18292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18294 if (unformat (i, "name %s", &host_if_name))
18295 vec_add1 (host_if_name, 0);
18296 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18297 random_hw_addr = 0;
18302 if (!vec_len (host_if_name))
18304 errmsg ("host-interface name must be specified");
18308 if (vec_len (host_if_name) > 64)
18310 errmsg ("host-interface name too long");
18314 M (AF_PACKET_CREATE, mp);
18316 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18317 clib_memcpy (mp->hw_addr, hw_addr, 6);
18318 mp->use_random_hw_addr = random_hw_addr;
18319 vec_free (host_if_name);
18327 fprintf (vam->ofp ? vam->ofp : stderr,
18328 " new sw_if_index = %d\n", vam->sw_if_index);
18335 api_af_packet_delete (vat_main_t * vam)
18337 unformat_input_t *i = vam->input;
18338 vl_api_af_packet_delete_t *mp;
18339 u8 *host_if_name = 0;
18342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18344 if (unformat (i, "name %s", &host_if_name))
18345 vec_add1 (host_if_name, 0);
18350 if (!vec_len (host_if_name))
18352 errmsg ("host-interface name must be specified");
18356 if (vec_len (host_if_name) > 64)
18358 errmsg ("host-interface name too long");
18362 M (AF_PACKET_DELETE, mp);
18364 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18365 vec_free (host_if_name);
18373 api_policer_add_del (vat_main_t * vam)
18375 unformat_input_t *i = vam->input;
18376 vl_api_policer_add_del_t *mp;
18386 u8 color_aware = 0;
18387 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18390 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18391 conform_action.dscp = 0;
18392 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18393 exceed_action.dscp = 0;
18394 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18395 violate_action.dscp = 0;
18397 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18399 if (unformat (i, "del"))
18401 else if (unformat (i, "name %s", &name))
18402 vec_add1 (name, 0);
18403 else if (unformat (i, "cir %u", &cir))
18405 else if (unformat (i, "eir %u", &eir))
18407 else if (unformat (i, "cb %u", &cb))
18409 else if (unformat (i, "eb %u", &eb))
18411 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18414 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18417 else if (unformat (i, "type %U", unformat_policer_type, &type))
18419 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18422 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18425 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18428 else if (unformat (i, "color-aware"))
18434 if (!vec_len (name))
18436 errmsg ("policer name must be specified");
18440 if (vec_len (name) > 64)
18442 errmsg ("policer name too long");
18446 M (POLICER_ADD_DEL, mp);
18448 clib_memcpy (mp->name, name, vec_len (name));
18450 mp->is_add = is_add;
18451 mp->cir = ntohl (cir);
18452 mp->eir = ntohl (eir);
18453 mp->cb = clib_net_to_host_u64 (cb);
18454 mp->eb = clib_net_to_host_u64 (eb);
18455 mp->rate_type = rate_type;
18456 mp->round_type = round_type;
18458 mp->conform_action_type = conform_action.action_type;
18459 mp->conform_dscp = conform_action.dscp;
18460 mp->exceed_action_type = exceed_action.action_type;
18461 mp->exceed_dscp = exceed_action.dscp;
18462 mp->violate_action_type = violate_action.action_type;
18463 mp->violate_dscp = violate_action.dscp;
18464 mp->color_aware = color_aware;
18472 api_policer_dump (vat_main_t * vam)
18474 unformat_input_t *i = vam->input;
18475 vl_api_policer_dump_t *mp;
18476 vl_api_control_ping_t *mp_ping;
18477 u8 *match_name = 0;
18478 u8 match_name_valid = 0;
18481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18483 if (unformat (i, "name %s", &match_name))
18485 vec_add1 (match_name, 0);
18486 match_name_valid = 1;
18492 M (POLICER_DUMP, mp);
18493 mp->match_name_valid = match_name_valid;
18494 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18495 vec_free (match_name);
18499 /* Use a control ping for synchronization */
18500 MPING (CONTROL_PING, mp_ping);
18503 /* Wait for a reply... */
18509 api_policer_classify_set_interface (vat_main_t * vam)
18511 unformat_input_t *i = vam->input;
18512 vl_api_policer_classify_set_interface_t *mp;
18514 int sw_if_index_set;
18515 u32 ip4_table_index = ~0;
18516 u32 ip6_table_index = ~0;
18517 u32 l2_table_index = ~0;
18521 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18523 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18524 sw_if_index_set = 1;
18525 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18526 sw_if_index_set = 1;
18527 else if (unformat (i, "del"))
18529 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18531 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18533 else if (unformat (i, "l2-table %d", &l2_table_index))
18537 clib_warning ("parse error '%U'", format_unformat_error, i);
18542 if (sw_if_index_set == 0)
18544 errmsg ("missing interface name or sw_if_index");
18548 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18550 mp->sw_if_index = ntohl (sw_if_index);
18551 mp->ip4_table_index = ntohl (ip4_table_index);
18552 mp->ip6_table_index = ntohl (ip6_table_index);
18553 mp->l2_table_index = ntohl (l2_table_index);
18554 mp->is_add = is_add;
18562 api_policer_classify_dump (vat_main_t * vam)
18564 unformat_input_t *i = vam->input;
18565 vl_api_policer_classify_dump_t *mp;
18566 vl_api_control_ping_t *mp_ping;
18567 u8 type = POLICER_CLASSIFY_N_TABLES;
18570 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18574 errmsg ("classify table type must be specified");
18578 if (!vam->json_output)
18580 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18583 M (POLICER_CLASSIFY_DUMP, mp);
18588 /* Use a control ping for synchronization */
18589 MPING (CONTROL_PING, mp_ping);
18592 /* Wait for a reply... */
18598 api_netmap_create (vat_main_t * vam)
18600 unformat_input_t *i = vam->input;
18601 vl_api_netmap_create_t *mp;
18604 u8 random_hw_addr = 1;
18609 memset (hw_addr, 0, sizeof (hw_addr));
18611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18613 if (unformat (i, "name %s", &if_name))
18614 vec_add1 (if_name, 0);
18615 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18616 random_hw_addr = 0;
18617 else if (unformat (i, "pipe"))
18619 else if (unformat (i, "master"))
18621 else if (unformat (i, "slave"))
18627 if (!vec_len (if_name))
18629 errmsg ("interface name must be specified");
18633 if (vec_len (if_name) > 64)
18635 errmsg ("interface name too long");
18639 M (NETMAP_CREATE, mp);
18641 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18642 clib_memcpy (mp->hw_addr, hw_addr, 6);
18643 mp->use_random_hw_addr = random_hw_addr;
18644 mp->is_pipe = is_pipe;
18645 mp->is_master = is_master;
18646 vec_free (if_name);
18654 api_netmap_delete (vat_main_t * vam)
18656 unformat_input_t *i = vam->input;
18657 vl_api_netmap_delete_t *mp;
18661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18663 if (unformat (i, "name %s", &if_name))
18664 vec_add1 (if_name, 0);
18669 if (!vec_len (if_name))
18671 errmsg ("interface name must be specified");
18675 if (vec_len (if_name) > 64)
18677 errmsg ("interface name too long");
18681 M (NETMAP_DELETE, mp);
18683 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18684 vec_free (if_name);
18692 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18694 if (fp->afi == IP46_TYPE_IP6)
18696 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18697 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18698 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18699 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18700 format_ip6_address, fp->next_hop);
18701 else if (fp->afi == IP46_TYPE_IP4)
18703 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18704 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18705 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18706 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18707 format_ip4_address, fp->next_hop);
18711 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18712 vl_api_fib_path2_t * fp)
18714 struct in_addr ip4;
18715 struct in6_addr ip6;
18717 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18718 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18719 vat_json_object_add_uint (node, "is_local", fp->is_local);
18720 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18721 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18722 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18723 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18724 if (fp->afi == IP46_TYPE_IP4)
18726 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18727 vat_json_object_add_ip4 (node, "next_hop", ip4);
18729 else if (fp->afi == IP46_TYPE_IP6)
18731 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18732 vat_json_object_add_ip6 (node, "next_hop", ip6);
18737 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18739 vat_main_t *vam = &vat_main;
18740 int count = ntohl (mp->mt_count);
18741 vl_api_fib_path2_t *fp;
18744 print (vam->ofp, "[%d]: sw_if_index %d via:",
18745 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18747 for (i = 0; i < count; i++)
18749 vl_api_mpls_fib_path_print (vam, fp);
18753 print (vam->ofp, "");
18756 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18757 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18760 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18762 vat_main_t *vam = &vat_main;
18763 vat_json_node_t *node = NULL;
18764 int count = ntohl (mp->mt_count);
18765 vl_api_fib_path2_t *fp;
18768 if (VAT_JSON_ARRAY != vam->json_tree.type)
18770 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18771 vat_json_init_array (&vam->json_tree);
18773 node = vat_json_array_add (&vam->json_tree);
18775 vat_json_init_object (node);
18776 vat_json_object_add_uint (node, "tunnel_index",
18777 ntohl (mp->mt_tunnel_index));
18778 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18780 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18783 for (i = 0; i < count; i++)
18785 vl_api_mpls_fib_path_json_print (node, fp);
18791 api_mpls_tunnel_dump (vat_main_t * vam)
18793 vl_api_mpls_tunnel_dump_t *mp;
18794 vl_api_control_ping_t *mp_ping;
18798 /* Parse args required to build the message */
18799 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18801 if (!unformat (vam->input, "tunnel_index %d", &index))
18808 print (vam->ofp, " tunnel_index %d", index);
18810 M (MPLS_TUNNEL_DUMP, mp);
18811 mp->tunnel_index = htonl (index);
18814 /* Use a control ping for synchronization */
18815 MPING (CONTROL_PING, mp_ping);
18822 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18823 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18827 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18829 vat_main_t *vam = &vat_main;
18830 int count = ntohl (mp->count);
18831 vl_api_fib_path2_t *fp;
18835 "table-id %d, label %u, ess_bit %u",
18836 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18838 for (i = 0; i < count; i++)
18840 vl_api_mpls_fib_path_print (vam, fp);
18845 static void vl_api_mpls_fib_details_t_handler_json
18846 (vl_api_mpls_fib_details_t * mp)
18848 vat_main_t *vam = &vat_main;
18849 int count = ntohl (mp->count);
18850 vat_json_node_t *node = NULL;
18851 vl_api_fib_path2_t *fp;
18854 if (VAT_JSON_ARRAY != vam->json_tree.type)
18856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18857 vat_json_init_array (&vam->json_tree);
18859 node = vat_json_array_add (&vam->json_tree);
18861 vat_json_init_object (node);
18862 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18863 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18864 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18865 vat_json_object_add_uint (node, "path_count", count);
18867 for (i = 0; i < count; i++)
18869 vl_api_mpls_fib_path_json_print (node, fp);
18875 api_mpls_fib_dump (vat_main_t * vam)
18877 vl_api_mpls_fib_dump_t *mp;
18878 vl_api_control_ping_t *mp_ping;
18881 M (MPLS_FIB_DUMP, mp);
18884 /* Use a control ping for synchronization */
18885 MPING (CONTROL_PING, mp_ping);
18892 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18893 #define vl_api_ip_fib_details_t_print vl_noop_handler
18896 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18898 vat_main_t *vam = &vat_main;
18899 int count = ntohl (mp->count);
18900 vl_api_fib_path_t *fp;
18904 "table-id %d, prefix %U/%d",
18905 ntohl (mp->table_id), format_ip4_address, mp->address,
18906 mp->address_length);
18908 for (i = 0; i < count; i++)
18910 if (fp->afi == IP46_TYPE_IP6)
18912 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18913 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18914 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18915 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18916 format_ip6_address, fp->next_hop);
18917 else if (fp->afi == IP46_TYPE_IP4)
18919 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18920 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18921 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18922 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18923 format_ip4_address, fp->next_hop);
18928 static void vl_api_ip_fib_details_t_handler_json
18929 (vl_api_ip_fib_details_t * mp)
18931 vat_main_t *vam = &vat_main;
18932 int count = ntohl (mp->count);
18933 vat_json_node_t *node = NULL;
18934 struct in_addr ip4;
18935 struct in6_addr ip6;
18936 vl_api_fib_path_t *fp;
18939 if (VAT_JSON_ARRAY != vam->json_tree.type)
18941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18942 vat_json_init_array (&vam->json_tree);
18944 node = vat_json_array_add (&vam->json_tree);
18946 vat_json_init_object (node);
18947 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18948 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18949 vat_json_object_add_ip4 (node, "prefix", ip4);
18950 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18951 vat_json_object_add_uint (node, "path_count", count);
18953 for (i = 0; i < count; i++)
18955 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18956 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18957 vat_json_object_add_uint (node, "is_local", fp->is_local);
18958 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18959 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18960 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18961 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18962 if (fp->afi == IP46_TYPE_IP4)
18964 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18965 vat_json_object_add_ip4 (node, "next_hop", ip4);
18967 else if (fp->afi == IP46_TYPE_IP6)
18969 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18970 vat_json_object_add_ip6 (node, "next_hop", ip6);
18976 api_ip_fib_dump (vat_main_t * vam)
18978 vl_api_ip_fib_dump_t *mp;
18979 vl_api_control_ping_t *mp_ping;
18982 M (IP_FIB_DUMP, mp);
18985 /* Use a control ping for synchronization */
18986 MPING (CONTROL_PING, mp_ping);
18994 api_ip_mfib_dump (vat_main_t * vam)
18996 vl_api_ip_mfib_dump_t *mp;
18997 vl_api_control_ping_t *mp_ping;
19000 M (IP_MFIB_DUMP, mp);
19003 /* Use a control ping for synchronization */
19004 MPING (CONTROL_PING, mp_ping);
19011 static void vl_api_ip_neighbor_details_t_handler
19012 (vl_api_ip_neighbor_details_t * mp)
19014 vat_main_t *vam = &vat_main;
19016 print (vam->ofp, "%c %U %U",
19017 (mp->is_static) ? 'S' : 'D',
19018 format_ethernet_address, &mp->mac_address,
19019 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19023 static void vl_api_ip_neighbor_details_t_handler_json
19024 (vl_api_ip_neighbor_details_t * mp)
19027 vat_main_t *vam = &vat_main;
19028 vat_json_node_t *node;
19029 struct in_addr ip4;
19030 struct in6_addr ip6;
19032 if (VAT_JSON_ARRAY != vam->json_tree.type)
19034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19035 vat_json_init_array (&vam->json_tree);
19037 node = vat_json_array_add (&vam->json_tree);
19039 vat_json_init_object (node);
19040 vat_json_object_add_string_copy (node, "flag",
19041 (mp->is_static) ? (u8 *) "static" : (u8 *)
19044 vat_json_object_add_string_copy (node, "link_layer",
19045 format (0, "%U", format_ethernet_address,
19046 &mp->mac_address));
19050 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19051 vat_json_object_add_ip6 (node, "ip_address", ip6);
19055 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19056 vat_json_object_add_ip4 (node, "ip_address", ip4);
19061 api_ip_neighbor_dump (vat_main_t * vam)
19063 unformat_input_t *i = vam->input;
19064 vl_api_ip_neighbor_dump_t *mp;
19065 vl_api_control_ping_t *mp_ping;
19067 u32 sw_if_index = ~0;
19070 /* Parse args required to build the message */
19071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19073 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19075 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19077 else if (unformat (i, "ip6"))
19083 if (sw_if_index == ~0)
19085 errmsg ("missing interface name or sw_if_index");
19089 M (IP_NEIGHBOR_DUMP, mp);
19090 mp->is_ipv6 = (u8) is_ipv6;
19091 mp->sw_if_index = ntohl (sw_if_index);
19094 /* Use a control ping for synchronization */
19095 MPING (CONTROL_PING, mp_ping);
19102 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19103 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19106 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19108 vat_main_t *vam = &vat_main;
19109 int count = ntohl (mp->count);
19110 vl_api_fib_path_t *fp;
19114 "table-id %d, prefix %U/%d",
19115 ntohl (mp->table_id), format_ip6_address, mp->address,
19116 mp->address_length);
19118 for (i = 0; i < count; i++)
19120 if (fp->afi == IP46_TYPE_IP6)
19122 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19123 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19124 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19125 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19126 format_ip6_address, fp->next_hop);
19127 else if (fp->afi == IP46_TYPE_IP4)
19129 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19130 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19131 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19132 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19133 format_ip4_address, fp->next_hop);
19138 static void vl_api_ip6_fib_details_t_handler_json
19139 (vl_api_ip6_fib_details_t * mp)
19141 vat_main_t *vam = &vat_main;
19142 int count = ntohl (mp->count);
19143 vat_json_node_t *node = NULL;
19144 struct in_addr ip4;
19145 struct in6_addr ip6;
19146 vl_api_fib_path_t *fp;
19149 if (VAT_JSON_ARRAY != vam->json_tree.type)
19151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19152 vat_json_init_array (&vam->json_tree);
19154 node = vat_json_array_add (&vam->json_tree);
19156 vat_json_init_object (node);
19157 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19158 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19159 vat_json_object_add_ip6 (node, "prefix", ip6);
19160 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19161 vat_json_object_add_uint (node, "path_count", count);
19163 for (i = 0; i < count; i++)
19165 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19166 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19167 vat_json_object_add_uint (node, "is_local", fp->is_local);
19168 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19169 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19170 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19171 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19172 if (fp->afi == IP46_TYPE_IP4)
19174 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19175 vat_json_object_add_ip4 (node, "next_hop", ip4);
19177 else if (fp->afi == IP46_TYPE_IP6)
19179 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19180 vat_json_object_add_ip6 (node, "next_hop", ip6);
19186 api_ip6_fib_dump (vat_main_t * vam)
19188 vl_api_ip6_fib_dump_t *mp;
19189 vl_api_control_ping_t *mp_ping;
19192 M (IP6_FIB_DUMP, mp);
19195 /* Use a control ping for synchronization */
19196 MPING (CONTROL_PING, mp_ping);
19204 api_ip6_mfib_dump (vat_main_t * vam)
19206 vl_api_ip6_mfib_dump_t *mp;
19207 vl_api_control_ping_t *mp_ping;
19210 M (IP6_MFIB_DUMP, mp);
19213 /* Use a control ping for synchronization */
19214 MPING (CONTROL_PING, mp_ping);
19222 api_classify_table_ids (vat_main_t * vam)
19224 vl_api_classify_table_ids_t *mp;
19227 /* Construct the API message */
19228 M (CLASSIFY_TABLE_IDS, mp);
19237 api_classify_table_by_interface (vat_main_t * vam)
19239 unformat_input_t *input = vam->input;
19240 vl_api_classify_table_by_interface_t *mp;
19242 u32 sw_if_index = ~0;
19244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19246 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19248 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19253 if (sw_if_index == ~0)
19255 errmsg ("missing interface name or sw_if_index");
19259 /* Construct the API message */
19260 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19262 mp->sw_if_index = ntohl (sw_if_index);
19270 api_classify_table_info (vat_main_t * vam)
19272 unformat_input_t *input = vam->input;
19273 vl_api_classify_table_info_t *mp;
19277 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19279 if (unformat (input, "table_id %d", &table_id))
19284 if (table_id == ~0)
19286 errmsg ("missing table id");
19290 /* Construct the API message */
19291 M (CLASSIFY_TABLE_INFO, mp);
19293 mp->table_id = ntohl (table_id);
19301 api_classify_session_dump (vat_main_t * vam)
19303 unformat_input_t *input = vam->input;
19304 vl_api_classify_session_dump_t *mp;
19305 vl_api_control_ping_t *mp_ping;
19309 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19311 if (unformat (input, "table_id %d", &table_id))
19316 if (table_id == ~0)
19318 errmsg ("missing table id");
19322 /* Construct the API message */
19323 M (CLASSIFY_SESSION_DUMP, mp);
19325 mp->table_id = ntohl (table_id);
19328 /* Use a control ping for synchronization */
19329 MPING (CONTROL_PING, mp_ping);
19337 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19339 vat_main_t *vam = &vat_main;
19341 print (vam->ofp, "collector_address %U, collector_port %d, "
19342 "src_address %U, vrf_id %d, path_mtu %u, "
19343 "template_interval %u, udp_checksum %d",
19344 format_ip4_address, mp->collector_address,
19345 ntohs (mp->collector_port),
19346 format_ip4_address, mp->src_address,
19347 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19348 ntohl (mp->template_interval), mp->udp_checksum);
19351 vam->result_ready = 1;
19355 vl_api_ipfix_exporter_details_t_handler_json
19356 (vl_api_ipfix_exporter_details_t * mp)
19358 vat_main_t *vam = &vat_main;
19359 vat_json_node_t node;
19360 struct in_addr collector_address;
19361 struct in_addr src_address;
19363 vat_json_init_object (&node);
19364 clib_memcpy (&collector_address, &mp->collector_address,
19365 sizeof (collector_address));
19366 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19367 vat_json_object_add_uint (&node, "collector_port",
19368 ntohs (mp->collector_port));
19369 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19370 vat_json_object_add_ip4 (&node, "src_address", src_address);
19371 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19372 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19373 vat_json_object_add_uint (&node, "template_interval",
19374 ntohl (mp->template_interval));
19375 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19377 vat_json_print (vam->ofp, &node);
19378 vat_json_free (&node);
19380 vam->result_ready = 1;
19384 api_ipfix_exporter_dump (vat_main_t * vam)
19386 vl_api_ipfix_exporter_dump_t *mp;
19389 /* Construct the API message */
19390 M (IPFIX_EXPORTER_DUMP, mp);
19399 api_ipfix_classify_stream_dump (vat_main_t * vam)
19401 vl_api_ipfix_classify_stream_dump_t *mp;
19404 /* Construct the API message */
19405 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19416 vl_api_ipfix_classify_stream_details_t_handler
19417 (vl_api_ipfix_classify_stream_details_t * mp)
19419 vat_main_t *vam = &vat_main;
19420 print (vam->ofp, "domain_id %d, src_port %d",
19421 ntohl (mp->domain_id), ntohs (mp->src_port));
19423 vam->result_ready = 1;
19427 vl_api_ipfix_classify_stream_details_t_handler_json
19428 (vl_api_ipfix_classify_stream_details_t * mp)
19430 vat_main_t *vam = &vat_main;
19431 vat_json_node_t node;
19433 vat_json_init_object (&node);
19434 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19435 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19437 vat_json_print (vam->ofp, &node);
19438 vat_json_free (&node);
19440 vam->result_ready = 1;
19444 api_ipfix_classify_table_dump (vat_main_t * vam)
19446 vl_api_ipfix_classify_table_dump_t *mp;
19447 vl_api_control_ping_t *mp_ping;
19450 if (!vam->json_output)
19452 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19453 "transport_protocol");
19456 /* Construct the API message */
19457 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19462 /* Use a control ping for synchronization */
19463 MPING (CONTROL_PING, mp_ping);
19471 vl_api_ipfix_classify_table_details_t_handler
19472 (vl_api_ipfix_classify_table_details_t * mp)
19474 vat_main_t *vam = &vat_main;
19475 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19476 mp->transport_protocol);
19480 vl_api_ipfix_classify_table_details_t_handler_json
19481 (vl_api_ipfix_classify_table_details_t * mp)
19483 vat_json_node_t *node = NULL;
19484 vat_main_t *vam = &vat_main;
19486 if (VAT_JSON_ARRAY != vam->json_tree.type)
19488 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19489 vat_json_init_array (&vam->json_tree);
19492 node = vat_json_array_add (&vam->json_tree);
19493 vat_json_init_object (node);
19495 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19496 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19497 vat_json_object_add_uint (node, "transport_protocol",
19498 mp->transport_protocol);
19502 api_sw_interface_span_enable_disable (vat_main_t * vam)
19504 unformat_input_t *i = vam->input;
19505 vl_api_sw_interface_span_enable_disable_t *mp;
19506 u32 src_sw_if_index = ~0;
19507 u32 dst_sw_if_index = ~0;
19512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19515 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19517 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19521 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19523 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19525 else if (unformat (i, "disable"))
19527 else if (unformat (i, "rx"))
19529 else if (unformat (i, "tx"))
19531 else if (unformat (i, "both"))
19533 else if (unformat (i, "l2"))
19539 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19541 mp->sw_if_index_from = htonl (src_sw_if_index);
19542 mp->sw_if_index_to = htonl (dst_sw_if_index);
19552 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19555 vat_main_t *vam = &vat_main;
19556 u8 *sw_if_from_name = 0;
19557 u8 *sw_if_to_name = 0;
19558 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19559 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19560 char *states[] = { "none", "rx", "tx", "both" };
19564 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19566 if ((u32) p->value[0] == sw_if_index_from)
19568 sw_if_from_name = (u8 *)(p->key);
19572 if ((u32) p->value[0] == sw_if_index_to)
19574 sw_if_to_name = (u8 *)(p->key);
19575 if (sw_if_from_name)
19580 print (vam->ofp, "%20s => %20s (%s)",
19581 sw_if_from_name, sw_if_to_name, states[mp->state]);
19585 vl_api_sw_interface_span_details_t_handler_json
19586 (vl_api_sw_interface_span_details_t * mp)
19588 vat_main_t *vam = &vat_main;
19589 vat_json_node_t *node = NULL;
19590 u8 *sw_if_from_name = 0;
19591 u8 *sw_if_to_name = 0;
19592 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19593 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19597 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19599 if ((u32) p->value[0] == sw_if_index_from)
19601 sw_if_from_name = (u8 *)(p->key);
19605 if ((u32) p->value[0] == sw_if_index_to)
19607 sw_if_to_name = (u8 *)(p->key);
19608 if (sw_if_from_name)
19614 if (VAT_JSON_ARRAY != vam->json_tree.type)
19616 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19617 vat_json_init_array (&vam->json_tree);
19619 node = vat_json_array_add (&vam->json_tree);
19621 vat_json_init_object (node);
19622 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19623 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19624 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19625 if (0 != sw_if_to_name)
19627 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19629 vat_json_object_add_uint (node, "state", mp->state);
19633 api_sw_interface_span_dump (vat_main_t * vam)
19635 unformat_input_t *input = vam->input;
19636 vl_api_sw_interface_span_dump_t *mp;
19637 vl_api_control_ping_t *mp_ping;
19641 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19643 if (unformat (input, "l2"))
19649 M (SW_INTERFACE_SPAN_DUMP, mp);
19653 /* Use a control ping for synchronization */
19654 MPING (CONTROL_PING, mp_ping);
19662 api_pg_create_interface (vat_main_t * vam)
19664 unformat_input_t *input = vam->input;
19665 vl_api_pg_create_interface_t *mp;
19669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19671 if (unformat (input, "if_id %d", &if_id))
19678 errmsg ("missing pg interface index");
19682 /* Construct the API message */
19683 M (PG_CREATE_INTERFACE, mp);
19685 mp->interface_id = ntohl (if_id);
19693 api_pg_capture (vat_main_t * vam)
19695 unformat_input_t *input = vam->input;
19696 vl_api_pg_capture_t *mp;
19701 u8 pcap_file_set = 0;
19704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19706 if (unformat (input, "if_id %d", &if_id))
19708 else if (unformat (input, "pcap %s", &pcap_file))
19710 else if (unformat (input, "count %d", &count))
19712 else if (unformat (input, "disable"))
19719 errmsg ("missing pg interface index");
19722 if (pcap_file_set > 0)
19724 if (vec_len (pcap_file) > 255)
19726 errmsg ("pcap file name is too long");
19731 u32 name_len = vec_len (pcap_file);
19732 /* Construct the API message */
19733 M (PG_CAPTURE, mp);
19735 mp->interface_id = ntohl (if_id);
19736 mp->is_enabled = enable;
19737 mp->count = ntohl (count);
19738 mp->pcap_name_length = ntohl (name_len);
19739 if (pcap_file_set != 0)
19741 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19743 vec_free (pcap_file);
19751 api_pg_enable_disable (vat_main_t * vam)
19753 unformat_input_t *input = vam->input;
19754 vl_api_pg_enable_disable_t *mp;
19757 u8 stream_name_set = 0;
19758 u8 *stream_name = 0;
19760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19762 if (unformat (input, "stream %s", &stream_name))
19763 stream_name_set = 1;
19764 else if (unformat (input, "disable"))
19770 if (stream_name_set > 0)
19772 if (vec_len (stream_name) > 255)
19774 errmsg ("stream name too long");
19779 u32 name_len = vec_len (stream_name);
19780 /* Construct the API message */
19781 M (PG_ENABLE_DISABLE, mp);
19783 mp->is_enabled = enable;
19784 if (stream_name_set != 0)
19786 mp->stream_name_length = ntohl (name_len);
19787 clib_memcpy (mp->stream_name, stream_name, name_len);
19789 vec_free (stream_name);
19797 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19799 unformat_input_t *input = vam->input;
19800 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19802 u16 *low_ports = 0;
19803 u16 *high_ports = 0;
19806 ip4_address_t ip4_addr;
19807 ip6_address_t ip6_addr;
19816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19818 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19824 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19829 else if (unformat (input, "vrf %d", &vrf_id))
19831 else if (unformat (input, "del"))
19833 else if (unformat (input, "port %d", &tmp))
19835 if (tmp == 0 || tmp > 65535)
19837 errmsg ("port %d out of range", tmp);
19841 this_hi = this_low + 1;
19842 vec_add1 (low_ports, this_low);
19843 vec_add1 (high_ports, this_hi);
19845 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19847 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19849 errmsg ("incorrect range parameters");
19853 /* Note: in debug CLI +1 is added to high before
19854 passing to real fn that does "the work"
19855 (ip_source_and_port_range_check_add_del).
19856 This fn is a wrapper around the binary API fn a
19857 control plane will call, which expects this increment
19858 to have occurred. Hence letting the binary API control
19859 plane fn do the increment for consistency between VAT
19860 and other control planes.
19863 vec_add1 (low_ports, this_low);
19864 vec_add1 (high_ports, this_hi);
19870 if (prefix_set == 0)
19872 errmsg ("<address>/<mask> not specified");
19878 errmsg ("VRF ID required, not specified");
19885 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19889 if (vec_len (low_ports) == 0)
19891 errmsg ("At least one port or port range required");
19895 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19897 mp->is_add = is_add;
19902 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19907 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19910 mp->mask_length = length;
19911 mp->number_of_ranges = vec_len (low_ports);
19913 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19914 vec_free (low_ports);
19916 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19917 vec_free (high_ports);
19919 mp->vrf_id = ntohl (vrf_id);
19927 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19929 unformat_input_t *input = vam->input;
19930 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19931 u32 sw_if_index = ~0;
19933 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19934 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19940 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19942 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19944 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19946 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19948 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19950 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19952 else if (unformat (input, "del"))
19958 if (sw_if_index == ~0)
19960 errmsg ("Interface required but not specified");
19966 errmsg ("VRF ID required but not specified");
19970 if (tcp_out_vrf_id == 0
19971 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19974 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19978 /* Construct the API message */
19979 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19981 mp->sw_if_index = ntohl (sw_if_index);
19982 mp->is_add = is_add;
19983 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19984 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19985 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19986 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19991 /* Wait for a reply... */
19997 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19999 unformat_input_t *i = vam->input;
20000 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20001 u32 local_sa_id = 0;
20002 u32 remote_sa_id = 0;
20003 ip4_address_t src_address;
20004 ip4_address_t dst_address;
20008 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20010 if (unformat (i, "local_sa %d", &local_sa_id))
20012 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20014 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20016 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20018 else if (unformat (i, "del"))
20022 clib_warning ("parse error '%U'", format_unformat_error, i);
20027 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20029 mp->local_sa_id = ntohl (local_sa_id);
20030 mp->remote_sa_id = ntohl (remote_sa_id);
20031 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20032 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20033 mp->is_add = is_add;
20041 api_punt (vat_main_t * vam)
20043 unformat_input_t *i = vam->input;
20051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20053 if (unformat (i, "ip %d", &ipv))
20055 else if (unformat (i, "protocol %d", &protocol))
20057 else if (unformat (i, "port %d", &port))
20059 else if (unformat (i, "del"))
20063 clib_warning ("parse error '%U'", format_unformat_error, i);
20070 mp->is_add = (u8) is_add;
20071 mp->ipv = (u8) ipv;
20072 mp->l4_protocol = (u8) protocol;
20073 mp->l4_port = htons ((u16) port);
20080 static void vl_api_ipsec_gre_tunnel_details_t_handler
20081 (vl_api_ipsec_gre_tunnel_details_t * mp)
20083 vat_main_t *vam = &vat_main;
20085 print (vam->ofp, "%11d%15U%15U%14d%14d",
20086 ntohl (mp->sw_if_index),
20087 format_ip4_address, &mp->src_address,
20088 format_ip4_address, &mp->dst_address,
20089 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20092 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20093 (vl_api_ipsec_gre_tunnel_details_t * mp)
20095 vat_main_t *vam = &vat_main;
20096 vat_json_node_t *node = NULL;
20097 struct in_addr ip4;
20099 if (VAT_JSON_ARRAY != vam->json_tree.type)
20101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20102 vat_json_init_array (&vam->json_tree);
20104 node = vat_json_array_add (&vam->json_tree);
20106 vat_json_init_object (node);
20107 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20108 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20109 vat_json_object_add_ip4 (node, "src_address", ip4);
20110 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20111 vat_json_object_add_ip4 (node, "dst_address", ip4);
20112 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20113 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20117 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20119 unformat_input_t *i = vam->input;
20120 vl_api_ipsec_gre_tunnel_dump_t *mp;
20121 vl_api_control_ping_t *mp_ping;
20123 u8 sw_if_index_set = 0;
20126 /* Parse args required to build the message */
20127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20129 if (unformat (i, "sw_if_index %d", &sw_if_index))
20130 sw_if_index_set = 1;
20135 if (sw_if_index_set == 0)
20140 if (!vam->json_output)
20142 print (vam->ofp, "%11s%15s%15s%14s%14s",
20143 "sw_if_index", "src_address", "dst_address",
20144 "local_sa_id", "remote_sa_id");
20147 /* Get list of gre-tunnel interfaces */
20148 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20150 mp->sw_if_index = htonl (sw_if_index);
20154 /* Use a control ping for synchronization */
20155 MPING (CONTROL_PING, mp_ping);
20163 api_delete_subif (vat_main_t * vam)
20165 unformat_input_t *i = vam->input;
20166 vl_api_delete_subif_t *mp;
20167 u32 sw_if_index = ~0;
20170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20174 if (unformat (i, "sw_if_index %d", &sw_if_index))
20180 if (sw_if_index == ~0)
20182 errmsg ("missing sw_if_index");
20186 /* Construct the API message */
20187 M (DELETE_SUBIF, mp);
20188 mp->sw_if_index = ntohl (sw_if_index);
20195 #define foreach_pbb_vtr_op \
20196 _("disable", L2_VTR_DISABLED) \
20197 _("pop", L2_VTR_POP_2) \
20198 _("push", L2_VTR_PUSH_2)
20201 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20203 unformat_input_t *i = vam->input;
20204 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20205 u32 sw_if_index = ~0, vtr_op = ~0;
20206 u16 outer_tag = ~0;
20207 u8 dmac[6], smac[6];
20208 u8 dmac_set = 0, smac_set = 0;
20214 /* Shut up coverity */
20215 memset (dmac, 0, sizeof (dmac));
20216 memset (smac, 0, sizeof (smac));
20218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20220 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20222 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20224 else if (unformat (i, "vtr_op %d", &vtr_op))
20226 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20229 else if (unformat (i, "translate_pbb_stag"))
20231 if (unformat (i, "%d", &tmp))
20233 vtr_op = L2_VTR_TRANSLATE_2_1;
20239 ("translate_pbb_stag operation requires outer tag definition");
20243 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20245 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20247 else if (unformat (i, "sid %d", &sid))
20249 else if (unformat (i, "vlanid %d", &tmp))
20253 clib_warning ("parse error '%U'", format_unformat_error, i);
20258 if ((sw_if_index == ~0) || (vtr_op == ~0))
20260 errmsg ("missing sw_if_index or vtr operation");
20263 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20264 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20267 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20271 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20272 mp->sw_if_index = ntohl (sw_if_index);
20273 mp->vtr_op = ntohl (vtr_op);
20274 mp->outer_tag = ntohs (outer_tag);
20275 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20276 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20277 mp->b_vlanid = ntohs (vlanid);
20278 mp->i_sid = ntohl (sid);
20286 api_flow_classify_set_interface (vat_main_t * vam)
20288 unformat_input_t *i = vam->input;
20289 vl_api_flow_classify_set_interface_t *mp;
20291 int sw_if_index_set;
20292 u32 ip4_table_index = ~0;
20293 u32 ip6_table_index = ~0;
20297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20300 sw_if_index_set = 1;
20301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20302 sw_if_index_set = 1;
20303 else if (unformat (i, "del"))
20305 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20307 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20311 clib_warning ("parse error '%U'", format_unformat_error, i);
20316 if (sw_if_index_set == 0)
20318 errmsg ("missing interface name or sw_if_index");
20322 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20324 mp->sw_if_index = ntohl (sw_if_index);
20325 mp->ip4_table_index = ntohl (ip4_table_index);
20326 mp->ip6_table_index = ntohl (ip6_table_index);
20327 mp->is_add = is_add;
20335 api_flow_classify_dump (vat_main_t * vam)
20337 unformat_input_t *i = vam->input;
20338 vl_api_flow_classify_dump_t *mp;
20339 vl_api_control_ping_t *mp_ping;
20340 u8 type = FLOW_CLASSIFY_N_TABLES;
20343 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20347 errmsg ("classify table type must be specified");
20351 if (!vam->json_output)
20353 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20356 M (FLOW_CLASSIFY_DUMP, mp);
20361 /* Use a control ping for synchronization */
20362 MPING (CONTROL_PING, mp_ping);
20365 /* Wait for a reply... */
20371 api_feature_enable_disable (vat_main_t * vam)
20373 unformat_input_t *i = vam->input;
20374 vl_api_feature_enable_disable_t *mp;
20376 u8 *feature_name = 0;
20377 u32 sw_if_index = ~0;
20381 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20383 if (unformat (i, "arc_name %s", &arc_name))
20385 else if (unformat (i, "feature_name %s", &feature_name))
20388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20390 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20392 else if (unformat (i, "disable"))
20400 errmsg ("missing arc name");
20403 if (vec_len (arc_name) > 63)
20405 errmsg ("arc name too long");
20408 if (feature_name == 0)
20410 errmsg ("missing feature name");
20413 if (vec_len (feature_name) > 63)
20415 errmsg ("feature name too long");
20418 if (sw_if_index == ~0)
20420 errmsg ("missing interface name or sw_if_index");
20424 /* Construct the API message */
20425 M (FEATURE_ENABLE_DISABLE, mp);
20426 mp->sw_if_index = ntohl (sw_if_index);
20427 mp->enable = enable;
20428 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20429 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20430 vec_free (arc_name);
20431 vec_free (feature_name);
20439 api_sw_interface_tag_add_del (vat_main_t * vam)
20441 unformat_input_t *i = vam->input;
20442 vl_api_sw_interface_tag_add_del_t *mp;
20443 u32 sw_if_index = ~0;
20448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20450 if (unformat (i, "tag %s", &tag))
20452 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20454 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20456 else if (unformat (i, "del"))
20462 if (sw_if_index == ~0)
20464 errmsg ("missing interface name or sw_if_index");
20468 if (enable && (tag == 0))
20470 errmsg ("no tag specified");
20474 /* Construct the API message */
20475 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20476 mp->sw_if_index = ntohl (sw_if_index);
20477 mp->is_add = enable;
20479 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20487 static void vl_api_l2_xconnect_details_t_handler
20488 (vl_api_l2_xconnect_details_t * mp)
20490 vat_main_t *vam = &vat_main;
20492 print (vam->ofp, "%15d%15d",
20493 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20496 static void vl_api_l2_xconnect_details_t_handler_json
20497 (vl_api_l2_xconnect_details_t * mp)
20499 vat_main_t *vam = &vat_main;
20500 vat_json_node_t *node = NULL;
20502 if (VAT_JSON_ARRAY != vam->json_tree.type)
20504 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20505 vat_json_init_array (&vam->json_tree);
20507 node = vat_json_array_add (&vam->json_tree);
20509 vat_json_init_object (node);
20510 vat_json_object_add_uint (node, "rx_sw_if_index",
20511 ntohl (mp->rx_sw_if_index));
20512 vat_json_object_add_uint (node, "tx_sw_if_index",
20513 ntohl (mp->tx_sw_if_index));
20517 api_l2_xconnect_dump (vat_main_t * vam)
20519 vl_api_l2_xconnect_dump_t *mp;
20520 vl_api_control_ping_t *mp_ping;
20523 if (!vam->json_output)
20525 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20528 M (L2_XCONNECT_DUMP, mp);
20532 /* Use a control ping for synchronization */
20533 MPING (CONTROL_PING, mp_ping);
20541 api_sw_interface_set_mtu (vat_main_t * vam)
20543 unformat_input_t *i = vam->input;
20544 vl_api_sw_interface_set_mtu_t *mp;
20545 u32 sw_if_index = ~0;
20549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20551 if (unformat (i, "mtu %d", &mtu))
20553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20555 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20561 if (sw_if_index == ~0)
20563 errmsg ("missing interface name or sw_if_index");
20569 errmsg ("no mtu specified");
20573 /* Construct the API message */
20574 M (SW_INTERFACE_SET_MTU, mp);
20575 mp->sw_if_index = ntohl (sw_if_index);
20576 mp->mtu = ntohs ((u16) mtu);
20584 api_p2p_ethernet_add (vat_main_t * vam)
20586 unformat_input_t *i = vam->input;
20587 vl_api_p2p_ethernet_add_t *mp;
20588 u32 parent_if_index = ~0;
20594 memset (remote_mac, 0, sizeof (remote_mac));
20595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20597 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20599 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20603 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20605 else if (unformat (i, "sub_id %d", &sub_id))
20609 clib_warning ("parse error '%U'", format_unformat_error, i);
20614 if (parent_if_index == ~0)
20616 errmsg ("missing interface name or sw_if_index");
20621 errmsg ("missing remote mac address");
20626 errmsg ("missing sub-interface id");
20630 M (P2P_ETHERNET_ADD, mp);
20631 mp->parent_if_index = ntohl (parent_if_index);
20632 mp->subif_id = ntohl (sub_id);
20633 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20641 api_p2p_ethernet_del (vat_main_t * vam)
20643 unformat_input_t *i = vam->input;
20644 vl_api_p2p_ethernet_del_t *mp;
20645 u32 parent_if_index = ~0;
20650 memset (remote_mac, 0, sizeof (remote_mac));
20651 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20653 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20655 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20659 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20663 clib_warning ("parse error '%U'", format_unformat_error, i);
20668 if (parent_if_index == ~0)
20670 errmsg ("missing interface name or sw_if_index");
20675 errmsg ("missing remote mac address");
20679 M (P2P_ETHERNET_DEL, mp);
20680 mp->parent_if_index = ntohl (parent_if_index);
20681 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20689 api_lldp_config (vat_main_t * vam)
20691 unformat_input_t *i = vam->input;
20692 vl_api_lldp_config_t *mp;
20694 int tx_interval = 0;
20695 u8 *sys_name = NULL;
20698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20700 if (unformat (i, "system-name %s", &sys_name))
20702 else if (unformat (i, "tx-hold %d", &tx_hold))
20704 else if (unformat (i, "tx-interval %d", &tx_interval))
20708 clib_warning ("parse error '%U'", format_unformat_error, i);
20713 vec_add1 (sys_name, 0);
20715 M (LLDP_CONFIG, mp);
20716 mp->tx_hold = htonl (tx_hold);
20717 mp->tx_interval = htonl (tx_interval);
20718 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20719 vec_free (sys_name);
20727 api_sw_interface_set_lldp (vat_main_t * vam)
20729 unformat_input_t *i = vam->input;
20730 vl_api_sw_interface_set_lldp_t *mp;
20731 u32 sw_if_index = ~0;
20733 u8 *port_desc = NULL, *mgmt_oid = NULL;
20734 ip4_address_t ip4_addr;
20735 ip6_address_t ip6_addr;
20738 memset (&ip4_addr, 0, sizeof (ip4_addr));
20739 memset (&ip6_addr, 0, sizeof (ip6_addr));
20741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20743 if (unformat (i, "disable"))
20746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20750 else if (unformat (i, "port-desc %s", &port_desc))
20752 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20754 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20756 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20762 if (sw_if_index == ~0)
20764 errmsg ("missing interface name or sw_if_index");
20768 /* Construct the API message */
20769 vec_add1 (port_desc, 0);
20770 vec_add1 (mgmt_oid, 0);
20771 M (SW_INTERFACE_SET_LLDP, mp);
20772 mp->sw_if_index = ntohl (sw_if_index);
20773 mp->enable = enable;
20774 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20775 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20776 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20777 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20778 vec_free (port_desc);
20779 vec_free (mgmt_oid);
20787 api_tcp_configure_src_addresses (vat_main_t * vam)
20789 vl_api_tcp_configure_src_addresses_t *mp;
20790 unformat_input_t *i = vam->input;
20791 ip4_address_t v4first, v4last;
20792 ip6_address_t v6first, v6last;
20797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20799 if (unformat (i, "%U - %U",
20800 unformat_ip4_address, &v4first,
20801 unformat_ip4_address, &v4last))
20805 errmsg ("one range per message (range already set)");
20810 else if (unformat (i, "%U - %U",
20811 unformat_ip6_address, &v6first,
20812 unformat_ip6_address, &v6last))
20816 errmsg ("one range per message (range already set)");
20821 else if (unformat (i, "vrf %d", &vrf_id))
20827 if (range_set == 0)
20829 errmsg ("address range not set");
20833 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20834 mp->vrf_id = ntohl (vrf_id);
20836 if (range_set == 2)
20839 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20840 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20845 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20846 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20854 api_app_namespace_add_del (vat_main_t * vam)
20856 vl_api_app_namespace_add_del_t *mp;
20857 unformat_input_t *i = vam->input;
20858 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20859 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20865 if (unformat (i, "id %_%v%_", &ns_id))
20867 else if (unformat (i, "secret %lu", &secret))
20869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20870 sw_if_index_set = 1;
20871 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20873 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20878 if (!ns_id || !secret_set || !sw_if_index_set)
20880 errmsg ("namespace id, secret and sw_if_index must be set");
20883 if (vec_len (ns_id) > 64)
20885 errmsg ("namespace id too long");
20888 M (APP_NAMESPACE_ADD_DEL, mp);
20890 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20891 mp->namespace_id_len = vec_len (ns_id);
20892 mp->secret = secret;
20893 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20894 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20895 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20903 api_memfd_segment_create (vat_main_t * vam)
20905 unformat_input_t *i = vam->input;
20906 vl_api_memfd_segment_create_t *mp;
20907 u64 size = 64 << 20;
20910 #if VPP_API_TEST_BUILTIN == 1
20911 errmsg ("memfd_segment_create (builtin) not supported");
20915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20917 if (unformat (i, "size %U", unformat_memory_size, &size))
20923 M (MEMFD_SEGMENT_CREATE, mp);
20924 mp->requested_size = size;
20931 api_dns_enable_disable (vat_main_t * vam)
20933 unformat_input_t *line_input = vam->input;
20934 vl_api_dns_enable_disable_t *mp;
20935 u8 enable_disable = 1;
20938 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20940 if (unformat (line_input, "disable"))
20941 enable_disable = 0;
20942 if (unformat (line_input, "enable"))
20943 enable_disable = 1;
20948 /* Construct the API message */
20949 M (DNS_ENABLE_DISABLE, mp);
20950 mp->enable = enable_disable;
20954 /* Wait for the reply */
20960 api_dns_resolve_name (vat_main_t * vam)
20962 unformat_input_t *line_input = vam->input;
20963 vl_api_dns_resolve_name_t *mp;
20967 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20969 if (unformat (line_input, "%s", &name))
20975 if (vec_len (name) > 127)
20977 errmsg ("name too long");
20981 /* Construct the API message */
20982 M (DNS_RESOLVE_NAME, mp);
20983 memcpy (mp->name, name, vec_len (name));
20988 /* Wait for the reply */
20994 api_dns_name_server_add_del (vat_main_t * vam)
20996 unformat_input_t *i = vam->input;
20997 vl_api_dns_name_server_add_del_t *mp;
20999 ip6_address_t ip6_server;
21000 ip4_address_t ip4_server;
21005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21007 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21009 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21011 else if (unformat (i, "del"))
21015 clib_warning ("parse error '%U'", format_unformat_error, i);
21020 if (ip4_set && ip6_set)
21022 errmsg ("Only one server address allowed per message");
21025 if ((ip4_set + ip6_set) == 0)
21027 errmsg ("Server address required");
21031 /* Construct the API message */
21032 M (DNS_NAME_SERVER_ADD_DEL, mp);
21036 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21041 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21045 mp->is_add = is_add;
21050 /* Wait for a reply, return good/bad news */
21057 q_or_quit (vat_main_t * vam)
21059 #if VPP_API_TEST_BUILTIN == 0
21060 longjmp (vam->jump_buf, 1);
21062 return 0; /* not so much */
21066 q (vat_main_t * vam)
21068 return q_or_quit (vam);
21072 quit (vat_main_t * vam)
21074 return q_or_quit (vam);
21078 comment (vat_main_t * vam)
21084 cmd_cmp (void *a1, void *a2)
21089 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21093 help (vat_main_t * vam)
21098 unformat_input_t *i = vam->input;
21101 if (unformat (i, "%s", &name))
21105 vec_add1 (name, 0);
21107 hs = hash_get_mem (vam->help_by_name, name);
21109 print (vam->ofp, "usage: %s %s", name, hs[0]);
21111 print (vam->ofp, "No such msg / command '%s'", name);
21116 print (vam->ofp, "Help is available for the following:");
21119 hash_foreach_pair (p, vam->function_by_name,
21121 vec_add1 (cmds, (u8 *)(p->key));
21125 vec_sort_with_function (cmds, cmd_cmp);
21127 for (j = 0; j < vec_len (cmds); j++)
21128 print (vam->ofp, "%s", cmds[j]);
21135 set (vat_main_t * vam)
21137 u8 *name = 0, *value = 0;
21138 unformat_input_t *i = vam->input;
21140 if (unformat (i, "%s", &name))
21142 /* The input buffer is a vector, not a string. */
21143 value = vec_dup (i->buffer);
21144 vec_delete (value, i->index, 0);
21145 /* Almost certainly has a trailing newline */
21146 if (value[vec_len (value) - 1] == '\n')
21147 value[vec_len (value) - 1] = 0;
21148 /* Make sure it's a proper string, one way or the other */
21149 vec_add1 (value, 0);
21150 (void) clib_macro_set_value (&vam->macro_main,
21151 (char *) name, (char *) value);
21154 errmsg ("usage: set <name> <value>");
21162 unset (vat_main_t * vam)
21166 if (unformat (vam->input, "%s", &name))
21167 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21168 errmsg ("unset: %s wasn't set", name);
21181 macro_sort_cmp (void *a1, void *a2)
21183 macro_sort_t *s1 = a1;
21184 macro_sort_t *s2 = a2;
21186 return strcmp ((char *) (s1->name), (char *) (s2->name));
21190 dump_macro_table (vat_main_t * vam)
21192 macro_sort_t *sort_me = 0, *sm;
21197 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21199 vec_add2 (sort_me, sm, 1);
21200 sm->name = (u8 *)(p->key);
21201 sm->value = (u8 *) (p->value[0]);
21205 vec_sort_with_function (sort_me, macro_sort_cmp);
21207 if (vec_len (sort_me))
21208 print (vam->ofp, "%-15s%s", "Name", "Value");
21210 print (vam->ofp, "The macro table is empty...");
21212 for (i = 0; i < vec_len (sort_me); i++)
21213 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21218 dump_node_table (vat_main_t * vam)
21221 vlib_node_t *node, *next_node;
21223 if (vec_len (vam->graph_nodes) == 0)
21225 print (vam->ofp, "Node table empty, issue get_node_graph...");
21229 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21231 node = vam->graph_nodes[i];
21232 print (vam->ofp, "[%d] %s", i, node->name);
21233 for (j = 0; j < vec_len (node->next_nodes); j++)
21235 if (node->next_nodes[j] != ~0)
21237 next_node = vam->graph_nodes[node->next_nodes[j]];
21238 print (vam->ofp, " [%d] %s", j, next_node->name);
21246 value_sort_cmp (void *a1, void *a2)
21248 name_sort_t *n1 = a1;
21249 name_sort_t *n2 = a2;
21251 if (n1->value < n2->value)
21253 if (n1->value > n2->value)
21260 dump_msg_api_table (vat_main_t * vam)
21262 api_main_t *am = &api_main;
21263 name_sort_t *nses = 0, *ns;
21268 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21270 vec_add2 (nses, ns, 1);
21271 ns->name = (u8 *)(hp->key);
21272 ns->value = (u32) hp->value[0];
21276 vec_sort_with_function (nses, value_sort_cmp);
21278 for (i = 0; i < vec_len (nses); i++)
21279 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21285 get_msg_id (vat_main_t * vam)
21290 if (unformat (vam->input, "%s", &name_and_crc))
21292 message_index = vl_api_get_msg_index (name_and_crc);
21293 if (message_index == ~0)
21295 print (vam->ofp, " '%s' not found", name_and_crc);
21298 print (vam->ofp, " '%s' has message index %d",
21299 name_and_crc, message_index);
21302 errmsg ("name_and_crc required...");
21307 search_node_table (vat_main_t * vam)
21309 unformat_input_t *line_input = vam->input;
21312 vlib_node_t *node, *next_node;
21315 if (vam->graph_node_index_by_name == 0)
21317 print (vam->ofp, "Node table empty, issue get_node_graph...");
21321 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21323 if (unformat (line_input, "%s", &node_to_find))
21325 vec_add1 (node_to_find, 0);
21326 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21329 print (vam->ofp, "%s not found...", node_to_find);
21332 node = vam->graph_nodes[p[0]];
21333 print (vam->ofp, "[%d] %s", p[0], node->name);
21334 for (j = 0; j < vec_len (node->next_nodes); j++)
21336 if (node->next_nodes[j] != ~0)
21338 next_node = vam->graph_nodes[node->next_nodes[j]];
21339 print (vam->ofp, " [%d] %s", j, next_node->name);
21346 clib_warning ("parse error '%U'", format_unformat_error,
21352 vec_free (node_to_find);
21361 script (vat_main_t * vam)
21363 #if (VPP_API_TEST_BUILTIN==0)
21365 char *save_current_file;
21366 unformat_input_t save_input;
21367 jmp_buf save_jump_buf;
21368 u32 save_line_number;
21370 FILE *new_fp, *save_ifp;
21372 if (unformat (vam->input, "%s", &s))
21374 new_fp = fopen ((char *) s, "r");
21377 errmsg ("Couldn't open script file %s", s);
21384 errmsg ("Missing script name");
21388 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21389 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21390 save_ifp = vam->ifp;
21391 save_line_number = vam->input_line_number;
21392 save_current_file = (char *) vam->current_file;
21394 vam->input_line_number = 0;
21396 vam->current_file = s;
21399 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21400 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21401 vam->ifp = save_ifp;
21402 vam->input_line_number = save_line_number;
21403 vam->current_file = (u8 *) save_current_file;
21408 clib_warning ("use the exec command...");
21414 echo (vat_main_t * vam)
21416 print (vam->ofp, "%v", vam->input->buffer);
21420 /* List of API message constructors, CLI names map to api_xxx */
21421 #define foreach_vpe_api_msg \
21422 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21423 _(sw_interface_dump,"") \
21424 _(sw_interface_set_flags, \
21425 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21426 _(sw_interface_add_del_address, \
21427 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21428 _(sw_interface_set_table, \
21429 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21430 _(sw_interface_set_mpls_enable, \
21431 "<intfc> | sw_if_index [disable | dis]") \
21432 _(sw_interface_set_vpath, \
21433 "<intfc> | sw_if_index <id> enable | disable") \
21434 _(sw_interface_set_vxlan_bypass, \
21435 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21436 _(sw_interface_set_geneve_bypass, \
21437 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21438 _(sw_interface_set_l2_xconnect, \
21439 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21440 "enable | disable") \
21441 _(sw_interface_set_l2_bridge, \
21442 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21443 "[shg <split-horizon-group>] [bvi]\n" \
21444 "enable | disable") \
21445 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21446 _(bridge_domain_add_del, \
21447 "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") \
21448 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21450 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21451 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21452 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21454 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21456 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21458 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21460 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21462 "<vpp-if-name> | sw_if_index <id>") \
21463 _(sw_interface_tap_dump, "") \
21464 _(ip_table_add_del, \
21465 "table-id <n> [ipv6]\n") \
21466 _(ip_add_del_route, \
21467 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21468 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21469 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21470 "[multipath] [count <n>]") \
21471 _(ip_mroute_add_del, \
21472 "<src> <grp>/<mask> [table-id <n>]\n" \
21473 "[<intfc> | sw_if_index <id>] [local] [del]") \
21474 _(mpls_table_add_del, \
21475 "table-id <n>\n") \
21476 _(mpls_route_add_del, \
21477 "<label> <eos> via <addr> [table-id <n>]\n" \
21478 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21479 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21480 "[multipath] [count <n>]") \
21481 _(mpls_ip_bind_unbind, \
21482 "<label> <addr/len>") \
21483 _(mpls_tunnel_add_del, \
21484 " via <addr> [table-id <n>]\n" \
21485 "sw_if_index <id>] [l2] [del]") \
21486 _(proxy_arp_add_del, \
21487 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21488 _(proxy_arp_intfc_enable_disable, \
21489 "<intfc> | sw_if_index <id> enable | disable") \
21490 _(sw_interface_set_unnumbered, \
21491 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21492 _(ip_neighbor_add_del, \
21493 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21494 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21495 _(reset_vrf, "vrf <id> [ipv6]") \
21496 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21497 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21498 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21499 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21500 "[outer_vlan_id_any][inner_vlan_id_any]") \
21501 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21502 _(reset_fib, "vrf <n> [ipv6]") \
21503 _(dhcp_proxy_config, \
21504 "svr <v46-address> src <v46-address>\n" \
21505 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21506 _(dhcp_proxy_set_vss, \
21507 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21508 _(dhcp_proxy_dump, "ip6") \
21509 _(dhcp_client_config, \
21510 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21511 _(set_ip_flow_hash, \
21512 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21513 _(sw_interface_ip6_enable_disable, \
21514 "<intfc> | sw_if_index <id> enable | disable") \
21515 _(sw_interface_ip6_set_link_local_address, \
21516 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21517 _(ip6nd_proxy_add_del, \
21518 "<intfc> | sw_if_index <id> <ip6-address>") \
21519 _(ip6nd_proxy_dump, "") \
21520 _(sw_interface_ip6nd_ra_prefix, \
21521 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21522 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21523 "[nolink] [isno]") \
21524 _(sw_interface_ip6nd_ra_config, \
21525 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21526 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21527 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21528 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21529 _(l2_patch_add_del, \
21530 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21531 "enable | disable") \
21532 _(sr_localsid_add_del, \
21533 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21534 "fib-table <num> (end.psp) sw_if_index <num>") \
21535 _(classify_add_del_table, \
21536 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21537 " [del] [del-chain] mask <mask-value>\n" \
21538 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21539 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21540 _(classify_add_del_session, \
21541 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21542 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21543 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21544 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21545 _(classify_set_interface_ip_table, \
21546 "<intfc> | sw_if_index <nn> table <nn>") \
21547 _(classify_set_interface_l2_tables, \
21548 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21549 " [other-table <nn>]") \
21550 _(get_node_index, "node <node-name") \
21551 _(add_node_next, "node <node-name> next <next-node-name>") \
21552 _(l2tpv3_create_tunnel, \
21553 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21554 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21555 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21556 _(l2tpv3_set_tunnel_cookies, \
21557 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21558 "[new_remote_cookie <nn>]\n") \
21559 _(l2tpv3_interface_enable_disable, \
21560 "<intfc> | sw_if_index <nn> enable | disable") \
21561 _(l2tpv3_set_lookup_key, \
21562 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21563 _(sw_if_l2tpv3_tunnel_dump, "") \
21564 _(vxlan_add_del_tunnel, \
21565 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21566 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21567 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21568 _(geneve_add_del_tunnel, \
21569 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21570 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21571 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21572 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21573 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21574 _(gre_add_del_tunnel, \
21575 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21576 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21577 _(l2_fib_clear_table, "") \
21578 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21579 _(l2_interface_vlan_tag_rewrite, \
21580 "<intfc> | sw_if_index <nn> \n" \
21581 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21582 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21583 _(create_vhost_user_if, \
21584 "socket <filename> [server] [renumber <dev_instance>] " \
21585 "[mac <mac_address>]") \
21586 _(modify_vhost_user_if, \
21587 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21588 "[server] [renumber <dev_instance>]") \
21589 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21590 _(sw_interface_vhost_user_dump, "") \
21591 _(show_version, "") \
21592 _(vxlan_gpe_add_del_tunnel, \
21593 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21594 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21595 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21596 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21597 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21598 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21599 _(interface_name_renumber, \
21600 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21601 _(input_acl_set_interface, \
21602 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21603 " [l2-table <nn>] [del]") \
21604 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21605 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21606 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21607 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21608 _(ip_dump, "ipv4 | ipv6") \
21609 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21610 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21612 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21613 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21614 " integ_alg <alg> integ_key <hex>") \
21615 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21616 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21617 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21618 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21619 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21620 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21621 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21622 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21623 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21624 _(ipsec_sa_dump, "[sa_id <n>]") \
21625 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21626 " <alg> <hex>\n") \
21627 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21628 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21629 "(auth_data 0x<data> | auth_data <data>)") \
21630 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21631 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21632 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21633 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21634 "(local|remote)") \
21635 _(ikev2_set_local_key, "file <absolute_file_path>") \
21636 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21637 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21638 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21639 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21640 _(ikev2_initiate_sa_init, "<profile_name>") \
21641 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21642 _(ikev2_initiate_del_child_sa, "<ispi>") \
21643 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21644 _(delete_loopback,"sw_if_index <nn>") \
21645 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21646 _(map_add_domain, \
21647 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21648 "ip6-src <ip6addr> " \
21649 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21650 _(map_del_domain, "index <n>") \
21651 _(map_add_del_rule, \
21652 "index <n> psid <n> dst <ip6addr> [del]") \
21653 _(map_domain_dump, "") \
21654 _(map_rule_dump, "index <map-domain>") \
21655 _(want_interface_events, "enable|disable") \
21656 _(want_stats,"enable|disable") \
21657 _(get_first_msg_id, "client <name>") \
21658 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21659 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21660 "fib-id <nn> [ip4][ip6][default]") \
21661 _(get_node_graph, " ") \
21662 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21663 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21664 _(ioam_disable, "") \
21665 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21666 " sw_if_index <sw_if_index> p <priority> " \
21667 "w <weight>] [del]") \
21668 _(one_add_del_locator, "locator-set <locator_name> " \
21669 "iface <intf> | sw_if_index <sw_if_index> " \
21670 "p <priority> w <weight> [del]") \
21671 _(one_add_del_local_eid,"vni <vni> eid " \
21672 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21673 "locator-set <locator_name> [del]" \
21674 "[key-id sha1|sha256 secret-key <secret-key>]")\
21675 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21676 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21677 _(one_enable_disable, "enable|disable") \
21678 _(one_map_register_enable_disable, "enable|disable") \
21679 _(one_map_register_fallback_threshold, "<value>") \
21680 _(one_rloc_probe_enable_disable, "enable|disable") \
21681 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21683 "rloc <locator> p <prio> " \
21684 "w <weight> [rloc <loc> ... ] " \
21685 "action <action> [del-all]") \
21686 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21688 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21689 _(one_use_petr, "ip-address> | disable") \
21690 _(one_map_request_mode, "src-dst|dst-only") \
21691 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21692 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21693 _(one_locator_set_dump, "[local | remote]") \
21694 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21695 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21696 "[local] | [remote]") \
21697 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21698 _(one_ndp_bd_get, "") \
21699 _(one_ndp_entries_get, "bd <bridge-domain>") \
21700 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21701 _(one_l2_arp_bd_get, "") \
21702 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21703 _(one_stats_enable_disable, "enable|disalbe") \
21704 _(show_one_stats_enable_disable, "") \
21705 _(one_eid_table_vni_dump, "") \
21706 _(one_eid_table_map_dump, "l2|l3") \
21707 _(one_map_resolver_dump, "") \
21708 _(one_map_server_dump, "") \
21709 _(one_adjacencies_get, "vni <vni>") \
21710 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21711 _(show_one_rloc_probe_state, "") \
21712 _(show_one_map_register_state, "") \
21713 _(show_one_status, "") \
21714 _(one_stats_dump, "") \
21715 _(one_stats_flush, "") \
21716 _(one_get_map_request_itr_rlocs, "") \
21717 _(one_map_register_set_ttl, "<ttl>") \
21718 _(one_set_transport_protocol, "udp|api") \
21719 _(one_get_transport_protocol, "") \
21720 _(show_one_nsh_mapping, "") \
21721 _(show_one_pitr, "") \
21722 _(show_one_use_petr, "") \
21723 _(show_one_map_request_mode, "") \
21724 _(show_one_map_register_ttl, "") \
21725 _(show_one_map_register_fallback_threshold, "") \
21726 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21727 " sw_if_index <sw_if_index> p <priority> " \
21728 "w <weight>] [del]") \
21729 _(lisp_add_del_locator, "locator-set <locator_name> " \
21730 "iface <intf> | sw_if_index <sw_if_index> " \
21731 "p <priority> w <weight> [del]") \
21732 _(lisp_add_del_local_eid,"vni <vni> eid " \
21733 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21734 "locator-set <locator_name> [del]" \
21735 "[key-id sha1|sha256 secret-key <secret-key>]") \
21736 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21737 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21738 _(lisp_enable_disable, "enable|disable") \
21739 _(lisp_map_register_enable_disable, "enable|disable") \
21740 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21741 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21743 "rloc <locator> p <prio> " \
21744 "w <weight> [rloc <loc> ... ] " \
21745 "action <action> [del-all]") \
21746 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21748 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21749 _(lisp_use_petr, "<ip-address> | disable") \
21750 _(lisp_map_request_mode, "src-dst|dst-only") \
21751 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21752 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21753 _(lisp_locator_set_dump, "[local | remote]") \
21754 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21755 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21756 "[local] | [remote]") \
21757 _(lisp_eid_table_vni_dump, "") \
21758 _(lisp_eid_table_map_dump, "l2|l3") \
21759 _(lisp_map_resolver_dump, "") \
21760 _(lisp_map_server_dump, "") \
21761 _(lisp_adjacencies_get, "vni <vni>") \
21762 _(gpe_fwd_entry_vnis_get, "") \
21763 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21764 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21765 "[table <table-id>]") \
21766 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21767 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21768 _(gpe_set_encap_mode, "lisp|vxlan") \
21769 _(gpe_get_encap_mode, "") \
21770 _(lisp_gpe_add_del_iface, "up|down") \
21771 _(lisp_gpe_enable_disable, "enable|disable") \
21772 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21773 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21774 _(show_lisp_rloc_probe_state, "") \
21775 _(show_lisp_map_register_state, "") \
21776 _(show_lisp_status, "") \
21777 _(lisp_get_map_request_itr_rlocs, "") \
21778 _(show_lisp_pitr, "") \
21779 _(show_lisp_use_petr, "") \
21780 _(show_lisp_map_request_mode, "") \
21781 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21782 _(af_packet_delete, "name <host interface name>") \
21783 _(policer_add_del, "name <policer name> <params> [del]") \
21784 _(policer_dump, "[name <policer name>]") \
21785 _(policer_classify_set_interface, \
21786 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21787 " [l2-table <nn>] [del]") \
21788 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21789 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21790 "[master|slave]") \
21791 _(netmap_delete, "name <interface name>") \
21792 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21793 _(mpls_fib_dump, "") \
21794 _(classify_table_ids, "") \
21795 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21796 _(classify_table_info, "table_id <nn>") \
21797 _(classify_session_dump, "table_id <nn>") \
21798 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21799 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21800 "[template_interval <nn>] [udp_checksum]") \
21801 _(ipfix_exporter_dump, "") \
21802 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21803 _(ipfix_classify_stream_dump, "") \
21804 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21805 _(ipfix_classify_table_dump, "") \
21806 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21807 _(sw_interface_span_dump, "[l2]") \
21808 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21809 _(pg_create_interface, "if_id <nn>") \
21810 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21811 _(pg_enable_disable, "[stream <id>] disable") \
21812 _(ip_source_and_port_range_check_add_del, \
21813 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21814 _(ip_source_and_port_range_check_interface_add_del, \
21815 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21816 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21817 _(ipsec_gre_add_del_tunnel, \
21818 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21819 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21820 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21821 _(l2_interface_pbb_tag_rewrite, \
21822 "<intfc> | sw_if_index <nn> \n" \
21823 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21824 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21825 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21826 _(flow_classify_set_interface, \
21827 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21828 _(flow_classify_dump, "type [ip4|ip6]") \
21829 _(ip_fib_dump, "") \
21830 _(ip_mfib_dump, "") \
21831 _(ip6_fib_dump, "") \
21832 _(ip6_mfib_dump, "") \
21833 _(feature_enable_disable, "arc_name <arc_name> " \
21834 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21835 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21837 _(l2_xconnect_dump, "") \
21838 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21839 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21840 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21841 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21842 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21843 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21844 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21845 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21846 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21847 _(memfd_segment_create,"size <nnn>") \
21848 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21849 _(dns_enable_disable, "[enable][disable]") \
21850 _(dns_name_server_add_del, "<ip-address> [del]") \
21851 _(dns_resolve_name, "<hostname>")
21853 /* List of command functions, CLI names map directly to functions */
21854 #define foreach_cli_function \
21855 _(comment, "usage: comment <ignore-rest-of-line>") \
21856 _(dump_interface_table, "usage: dump_interface_table") \
21857 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21858 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21859 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21860 _(dump_stats_table, "usage: dump_stats_table") \
21861 _(dump_macro_table, "usage: dump_macro_table ") \
21862 _(dump_node_table, "usage: dump_node_table") \
21863 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21864 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21865 _(echo, "usage: echo <message>") \
21866 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21867 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21868 _(help, "usage: help") \
21869 _(q, "usage: quit") \
21870 _(quit, "usage: quit") \
21871 _(search_node_table, "usage: search_node_table <name>...") \
21872 _(set, "usage: set <variable-name> <value>") \
21873 _(script, "usage: script <file-name>") \
21874 _(unset, "usage: unset <variable-name>")
21876 static void vl_api_##n##_t_handler_uni \
21877 (vl_api_##n##_t * mp) \
21879 vat_main_t * vam = &vat_main; \
21880 if (vam->json_output) { \
21881 vl_api_##n##_t_handler_json(mp); \
21883 vl_api_##n##_t_handler(mp); \
21886 foreach_vpe_api_reply_msg;
21887 #if VPP_API_TEST_BUILTIN == 0
21888 foreach_standalone_reply_msg;
21893 vat_api_hookup (vat_main_t * vam)
21896 vl_msg_api_set_handlers(VL_API_##N, #n, \
21897 vl_api_##n##_t_handler_uni, \
21899 vl_api_##n##_t_endian, \
21900 vl_api_##n##_t_print, \
21901 sizeof(vl_api_##n##_t), 1);
21902 foreach_vpe_api_reply_msg;
21903 #if VPP_API_TEST_BUILTIN == 0
21904 foreach_standalone_reply_msg;
21908 #if (VPP_API_TEST_BUILTIN==0)
21909 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21911 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21913 vam->function_by_name = hash_create_string (0, sizeof (uword));
21915 vam->help_by_name = hash_create_string (0, sizeof (uword));
21918 /* API messages we can send */
21919 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21920 foreach_vpe_api_msg;
21924 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21925 foreach_vpe_api_msg;
21928 /* CLI functions */
21929 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21930 foreach_cli_function;
21934 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21935 foreach_cli_function;
21939 #if VPP_API_TEST_BUILTIN
21940 static clib_error_t *
21941 vat_api_hookup_shim (vlib_main_t * vm)
21943 vat_api_hookup (&vat_main);
21947 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21951 * fd.io coding-style-patch-verification: ON
21954 * eval: (c-set-style "gnu")