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 _(ikev2_profile_add_del_reply) \
5081 _(ikev2_profile_set_auth_reply) \
5082 _(ikev2_profile_set_id_reply) \
5083 _(ikev2_profile_set_ts_reply) \
5084 _(ikev2_set_local_key_reply) \
5085 _(ikev2_set_responder_reply) \
5086 _(ikev2_set_ike_transforms_reply) \
5087 _(ikev2_set_esp_transforms_reply) \
5088 _(ikev2_set_sa_lifetime_reply) \
5089 _(ikev2_initiate_sa_init_reply) \
5090 _(ikev2_initiate_del_ike_sa_reply) \
5091 _(ikev2_initiate_del_child_sa_reply) \
5092 _(ikev2_initiate_rekey_child_sa_reply) \
5093 _(delete_loopback_reply) \
5094 _(bd_ip_mac_add_del_reply) \
5095 _(map_del_domain_reply) \
5096 _(map_add_del_rule_reply) \
5097 _(want_interface_events_reply) \
5098 _(want_stats_reply) \
5099 _(cop_interface_enable_disable_reply) \
5100 _(cop_whitelist_enable_disable_reply) \
5101 _(sw_interface_clear_stats_reply) \
5102 _(ioam_enable_reply) \
5103 _(ioam_disable_reply) \
5104 _(one_add_del_locator_reply) \
5105 _(one_add_del_local_eid_reply) \
5106 _(one_add_del_remote_mapping_reply) \
5107 _(one_add_del_adjacency_reply) \
5108 _(one_add_del_map_resolver_reply) \
5109 _(one_add_del_map_server_reply) \
5110 _(one_enable_disable_reply) \
5111 _(one_rloc_probe_enable_disable_reply) \
5112 _(one_map_register_enable_disable_reply) \
5113 _(one_map_register_set_ttl_reply) \
5114 _(one_set_transport_protocol_reply) \
5115 _(one_map_register_fallback_threshold_reply) \
5116 _(one_pitr_set_locator_set_reply) \
5117 _(one_map_request_mode_reply) \
5118 _(one_add_del_map_request_itr_rlocs_reply) \
5119 _(one_eid_table_add_del_map_reply) \
5120 _(one_use_petr_reply) \
5121 _(one_stats_enable_disable_reply) \
5122 _(one_add_del_l2_arp_entry_reply) \
5123 _(one_add_del_ndp_entry_reply) \
5124 _(one_stats_flush_reply) \
5125 _(gpe_enable_disable_reply) \
5126 _(gpe_set_encap_mode_reply) \
5127 _(gpe_add_del_iface_reply) \
5128 _(gpe_add_del_native_fwd_rpath_reply) \
5129 _(af_packet_delete_reply) \
5130 _(policer_classify_set_interface_reply) \
5131 _(netmap_create_reply) \
5132 _(netmap_delete_reply) \
5133 _(set_ipfix_exporter_reply) \
5134 _(set_ipfix_classify_stream_reply) \
5135 _(ipfix_classify_table_add_del_reply) \
5136 _(flow_classify_set_interface_reply) \
5137 _(sw_interface_span_enable_disable_reply) \
5138 _(pg_capture_reply) \
5139 _(pg_enable_disable_reply) \
5140 _(ip_source_and_port_range_check_add_del_reply) \
5141 _(ip_source_and_port_range_check_interface_add_del_reply)\
5142 _(delete_subif_reply) \
5143 _(l2_interface_pbb_tag_rewrite_reply) \
5145 _(feature_enable_disable_reply) \
5146 _(sw_interface_tag_add_del_reply) \
5147 _(sw_interface_set_mtu_reply) \
5148 _(p2p_ethernet_add_reply) \
5149 _(p2p_ethernet_del_reply) \
5150 _(lldp_config_reply) \
5151 _(sw_interface_set_lldp_reply) \
5152 _(tcp_configure_src_addresses_reply) \
5153 _(app_namespace_add_del_reply) \
5154 _(dns_enable_disable_reply) \
5155 _(dns_name_server_add_del_reply)
5158 static void vl_api_##n##_t_handler \
5159 (vl_api_##n##_t * mp) \
5161 vat_main_t * vam = &vat_main; \
5162 i32 retval = ntohl(mp->retval); \
5163 if (vam->async_mode) { \
5164 vam->async_errors += (retval < 0); \
5166 vam->retval = retval; \
5167 vam->result_ready = 1; \
5170 foreach_standard_reply_retval_handler;
5174 static void vl_api_##n##_t_handler_json \
5175 (vl_api_##n##_t * mp) \
5177 vat_main_t * vam = &vat_main; \
5178 vat_json_node_t node; \
5179 vat_json_init_object(&node); \
5180 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5181 vat_json_print(vam->ofp, &node); \
5182 vam->retval = ntohl(mp->retval); \
5183 vam->result_ready = 1; \
5185 foreach_standard_reply_retval_handler;
5189 * Table of message reply handlers, must include boilerplate handlers
5193 #define foreach_vpe_api_reply_msg \
5194 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5195 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5196 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5197 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5198 _(CONTROL_PING_REPLY, control_ping_reply) \
5199 _(CLI_REPLY, cli_reply) \
5200 _(CLI_INBAND_REPLY, cli_inband_reply) \
5201 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5202 sw_interface_add_del_address_reply) \
5203 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5204 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5205 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5206 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5207 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5208 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5209 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5210 sw_interface_set_l2_xconnect_reply) \
5211 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5212 sw_interface_set_l2_bridge_reply) \
5213 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5214 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5215 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5216 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5217 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5218 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5219 _(L2_FLAGS_REPLY, l2_flags_reply) \
5220 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5221 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5222 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5223 _(TAP_DELETE_REPLY, tap_delete_reply) \
5224 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5225 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5226 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5227 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5228 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5229 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5230 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5231 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5232 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5233 proxy_arp_intfc_enable_disable_reply) \
5234 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5235 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5236 sw_interface_set_unnumbered_reply) \
5237 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5238 _(RESET_VRF_REPLY, reset_vrf_reply) \
5239 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5240 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5241 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5242 _(RESET_FIB_REPLY, reset_fib_reply) \
5243 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5244 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5245 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5246 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5247 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5248 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5249 sw_interface_ip6_enable_disable_reply) \
5250 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5251 sw_interface_ip6_set_link_local_address_reply) \
5252 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5253 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5254 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5255 sw_interface_ip6nd_ra_prefix_reply) \
5256 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5257 sw_interface_ip6nd_ra_config_reply) \
5258 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5259 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5260 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5261 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5262 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5263 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5264 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5265 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5266 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5267 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5268 classify_set_interface_ip_table_reply) \
5269 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5270 classify_set_interface_l2_tables_reply) \
5271 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5272 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5273 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5274 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5275 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5276 l2tpv3_interface_enable_disable_reply) \
5277 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5278 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5279 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5280 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5281 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5282 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5283 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5284 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5285 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5286 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5287 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5288 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5289 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5290 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5291 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5292 _(SHOW_VERSION_REPLY, show_version_reply) \
5293 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5294 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5295 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5296 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5297 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5298 _(IP4_ARP_EVENT, ip4_arp_event) \
5299 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5300 _(IP6_ND_EVENT, ip6_nd_event) \
5301 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5302 _(L2_MACS_EVENT, l2_macs_event) \
5303 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5304 _(IP_ADDRESS_DETAILS, ip_address_details) \
5305 _(IP_DETAILS, ip_details) \
5306 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5307 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5308 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5309 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5310 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5311 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5312 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5313 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5314 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5315 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5316 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5317 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5318 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5319 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5320 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5321 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5322 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5323 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5324 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5325 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5326 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5327 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5328 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5329 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5330 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5331 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5332 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5333 _(MAP_RULE_DETAILS, map_rule_details) \
5334 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5335 _(WANT_STATS_REPLY, want_stats_reply) \
5336 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5337 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5338 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5339 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5340 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5341 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5342 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5343 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5344 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5345 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5346 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5347 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5348 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5349 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5350 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5351 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5352 one_map_register_enable_disable_reply) \
5353 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5354 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5355 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5356 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5357 one_map_register_fallback_threshold_reply) \
5358 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5359 one_rloc_probe_enable_disable_reply) \
5360 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5361 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5362 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5363 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5364 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5365 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5366 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5367 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5368 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5369 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5370 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5371 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5372 _(ONE_STATS_DETAILS, one_stats_details) \
5373 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5374 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5375 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5376 show_one_stats_enable_disable_reply) \
5377 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5378 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5379 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5380 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5381 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5382 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5383 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5384 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5385 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5386 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5387 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5388 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5389 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5390 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5391 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5392 gpe_add_del_native_fwd_rpath_reply) \
5393 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5394 gpe_fwd_entry_path_details) \
5395 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5396 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5397 one_add_del_map_request_itr_rlocs_reply) \
5398 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5399 one_get_map_request_itr_rlocs_reply) \
5400 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5401 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5402 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5403 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5404 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5405 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5406 show_one_map_register_state_reply) \
5407 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5408 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5409 show_one_map_register_fallback_threshold_reply) \
5410 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5411 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5412 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5413 _(POLICER_DETAILS, policer_details) \
5414 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5415 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5416 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5417 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5418 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5419 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5420 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5421 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5422 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5423 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5424 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5425 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5426 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5427 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5428 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5429 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5430 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5431 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5432 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5433 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5434 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5435 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5436 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5437 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5438 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5439 ip_source_and_port_range_check_add_del_reply) \
5440 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5441 ip_source_and_port_range_check_interface_add_del_reply) \
5442 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5443 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5444 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5445 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5446 _(PUNT_REPLY, punt_reply) \
5447 _(IP_FIB_DETAILS, ip_fib_details) \
5448 _(IP6_FIB_DETAILS, ip6_fib_details) \
5449 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5450 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5451 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5452 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5453 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5454 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5455 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5456 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5457 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5458 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5459 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5460 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5461 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5462 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5463 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)
5465 #define foreach_standalone_reply_msg \
5466 _(SW_INTERFACE_EVENT, sw_interface_event) \
5467 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5468 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5469 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5470 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5471 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5472 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5473 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5482 #define STR_VTR_OP_CASE(op) \
5483 case L2_VTR_ ## op: \
5487 str_vtr_op (u32 vtr_op)
5491 STR_VTR_OP_CASE (DISABLED);
5492 STR_VTR_OP_CASE (PUSH_1);
5493 STR_VTR_OP_CASE (PUSH_2);
5494 STR_VTR_OP_CASE (POP_1);
5495 STR_VTR_OP_CASE (POP_2);
5496 STR_VTR_OP_CASE (TRANSLATE_1_1);
5497 STR_VTR_OP_CASE (TRANSLATE_1_2);
5498 STR_VTR_OP_CASE (TRANSLATE_2_1);
5499 STR_VTR_OP_CASE (TRANSLATE_2_2);
5506 dump_sub_interface_table (vat_main_t * vam)
5508 const sw_interface_subif_t *sub = NULL;
5510 if (vam->json_output)
5513 ("JSON output supported only for VPE API calls and dump_stats_table");
5518 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5519 "Interface", "sw_if_index",
5520 "sub id", "dot1ad", "tags", "outer id",
5521 "inner id", "exact", "default", "outer any", "inner any");
5523 vec_foreach (sub, vam->sw_if_subif_table)
5526 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5527 sub->interface_name,
5529 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5530 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5531 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5532 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5533 if (sub->vtr_op != L2_VTR_DISABLED)
5536 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5537 "tag1: %d tag2: %d ]",
5538 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5539 sub->vtr_tag1, sub->vtr_tag2);
5547 name_sort_cmp (void *a1, void *a2)
5549 name_sort_t *n1 = a1;
5550 name_sort_t *n2 = a2;
5552 return strcmp ((char *) n1->name, (char *) n2->name);
5556 dump_interface_table (vat_main_t * vam)
5559 name_sort_t *nses = 0, *ns;
5561 if (vam->json_output)
5564 ("JSON output supported only for VPE API calls and dump_stats_table");
5569 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5571 vec_add2 (nses, ns, 1);
5572 ns->name = (u8 *)(p->key);
5573 ns->value = (u32) p->value[0];
5577 vec_sort_with_function (nses, name_sort_cmp);
5579 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5580 vec_foreach (ns, nses)
5582 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5589 dump_ip_table (vat_main_t * vam, int is_ipv6)
5591 const ip_details_t *det = NULL;
5592 const ip_address_details_t *address = NULL;
5595 print (vam->ofp, "%-12s", "sw_if_index");
5597 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5604 print (vam->ofp, "%-12d", i);
5605 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5610 vec_foreach (address, det->addr)
5614 is_ipv6 ? format_ip6_address : format_ip4_address,
5615 address->ip, address->prefix_length);
5623 dump_ipv4_table (vat_main_t * vam)
5625 if (vam->json_output)
5628 ("JSON output supported only for VPE API calls and dump_stats_table");
5632 return dump_ip_table (vam, 0);
5636 dump_ipv6_table (vat_main_t * vam)
5638 if (vam->json_output)
5641 ("JSON output supported only for VPE API calls and dump_stats_table");
5645 return dump_ip_table (vam, 1);
5649 counter_type_to_str (u8 counter_type, u8 is_combined)
5653 switch (counter_type)
5655 case VNET_INTERFACE_COUNTER_DROP:
5657 case VNET_INTERFACE_COUNTER_PUNT:
5659 case VNET_INTERFACE_COUNTER_IP4:
5661 case VNET_INTERFACE_COUNTER_IP6:
5663 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5665 case VNET_INTERFACE_COUNTER_RX_MISS:
5667 case VNET_INTERFACE_COUNTER_RX_ERROR:
5669 case VNET_INTERFACE_COUNTER_TX_ERROR:
5672 return "INVALID-COUNTER-TYPE";
5677 switch (counter_type)
5679 case VNET_INTERFACE_COUNTER_RX:
5681 case VNET_INTERFACE_COUNTER_TX:
5684 return "INVALID-COUNTER-TYPE";
5690 dump_stats_table (vat_main_t * vam)
5692 vat_json_node_t node;
5693 vat_json_node_t *msg_array;
5694 vat_json_node_t *msg;
5695 vat_json_node_t *counter_array;
5696 vat_json_node_t *counter;
5697 interface_counter_t c;
5699 ip4_fib_counter_t *c4;
5700 ip6_fib_counter_t *c6;
5701 ip4_nbr_counter_t *n4;
5702 ip6_nbr_counter_t *n6;
5705 if (!vam->json_output)
5707 clib_warning ("dump_stats_table supported only in JSON format");
5711 vat_json_init_object (&node);
5713 /* interface counters */
5714 msg_array = vat_json_object_add (&node, "interface_counters");
5715 vat_json_init_array (msg_array);
5716 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5718 msg = vat_json_array_add (msg_array);
5719 vat_json_init_object (msg);
5720 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5721 (u8 *) counter_type_to_str (i, 0));
5722 vat_json_object_add_int (msg, "is_combined", 0);
5723 counter_array = vat_json_object_add (msg, "data");
5724 vat_json_init_array (counter_array);
5725 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5727 packets = vam->simple_interface_counters[i][j];
5728 vat_json_array_add_uint (counter_array, packets);
5731 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5733 msg = vat_json_array_add (msg_array);
5734 vat_json_init_object (msg);
5735 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5736 (u8 *) counter_type_to_str (i, 1));
5737 vat_json_object_add_int (msg, "is_combined", 1);
5738 counter_array = vat_json_object_add (msg, "data");
5739 vat_json_init_array (counter_array);
5740 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5742 c = vam->combined_interface_counters[i][j];
5743 counter = vat_json_array_add (counter_array);
5744 vat_json_init_object (counter);
5745 vat_json_object_add_uint (counter, "packets", c.packets);
5746 vat_json_object_add_uint (counter, "bytes", c.bytes);
5750 /* ip4 fib counters */
5751 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5752 vat_json_init_array (msg_array);
5753 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5755 msg = vat_json_array_add (msg_array);
5756 vat_json_init_object (msg);
5757 vat_json_object_add_uint (msg, "vrf_id",
5758 vam->ip4_fib_counters_vrf_id_by_index[i]);
5759 counter_array = vat_json_object_add (msg, "c");
5760 vat_json_init_array (counter_array);
5761 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5763 counter = vat_json_array_add (counter_array);
5764 vat_json_init_object (counter);
5765 c4 = &vam->ip4_fib_counters[i][j];
5766 vat_json_object_add_ip4 (counter, "address", c4->address);
5767 vat_json_object_add_uint (counter, "address_length",
5768 c4->address_length);
5769 vat_json_object_add_uint (counter, "packets", c4->packets);
5770 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5774 /* ip6 fib counters */
5775 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5776 vat_json_init_array (msg_array);
5777 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5779 msg = vat_json_array_add (msg_array);
5780 vat_json_init_object (msg);
5781 vat_json_object_add_uint (msg, "vrf_id",
5782 vam->ip6_fib_counters_vrf_id_by_index[i]);
5783 counter_array = vat_json_object_add (msg, "c");
5784 vat_json_init_array (counter_array);
5785 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5787 counter = vat_json_array_add (counter_array);
5788 vat_json_init_object (counter);
5789 c6 = &vam->ip6_fib_counters[i][j];
5790 vat_json_object_add_ip6 (counter, "address", c6->address);
5791 vat_json_object_add_uint (counter, "address_length",
5792 c6->address_length);
5793 vat_json_object_add_uint (counter, "packets", c6->packets);
5794 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5798 /* ip4 nbr counters */
5799 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5800 vat_json_init_array (msg_array);
5801 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5803 msg = vat_json_array_add (msg_array);
5804 vat_json_init_object (msg);
5805 vat_json_object_add_uint (msg, "sw_if_index", i);
5806 counter_array = vat_json_object_add (msg, "c");
5807 vat_json_init_array (counter_array);
5808 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5810 counter = vat_json_array_add (counter_array);
5811 vat_json_init_object (counter);
5812 n4 = &vam->ip4_nbr_counters[i][j];
5813 vat_json_object_add_ip4 (counter, "address", n4->address);
5814 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5815 vat_json_object_add_uint (counter, "packets", n4->packets);
5816 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5820 /* ip6 nbr counters */
5821 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5822 vat_json_init_array (msg_array);
5823 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5825 msg = vat_json_array_add (msg_array);
5826 vat_json_init_object (msg);
5827 vat_json_object_add_uint (msg, "sw_if_index", i);
5828 counter_array = vat_json_object_add (msg, "c");
5829 vat_json_init_array (counter_array);
5830 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5832 counter = vat_json_array_add (counter_array);
5833 vat_json_init_object (counter);
5834 n6 = &vam->ip6_nbr_counters[i][j];
5835 vat_json_object_add_ip6 (counter, "address", n6->address);
5836 vat_json_object_add_uint (counter, "packets", n6->packets);
5837 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5841 vat_json_print (vam->ofp, &node);
5842 vat_json_free (&node);
5848 * Pass CLI buffers directly in the CLI_INBAND API message,
5849 * instead of an additional shared memory area.
5852 exec_inband (vat_main_t * vam)
5854 vl_api_cli_inband_t *mp;
5855 unformat_input_t *i = vam->input;
5858 if (vec_len (i->buffer) == 0)
5861 if (vam->exec_mode == 0 && unformat (i, "mode"))
5866 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5873 * In order for the CLI command to work, it
5874 * must be a vector ending in \n, not a C-string ending
5877 u32 len = vec_len (vam->input->buffer);
5878 M2 (CLI_INBAND, mp, len);
5879 clib_memcpy (mp->cmd, vam->input->buffer, len);
5880 mp->length = htonl (len);
5884 /* json responses may or may not include a useful reply... */
5885 if (vec_len (vam->cmd_reply))
5886 print (vam->ofp, (char *) (vam->cmd_reply));
5891 exec (vat_main_t * vam)
5893 return exec_inband (vam);
5897 api_create_loopback (vat_main_t * vam)
5899 unformat_input_t *i = vam->input;
5900 vl_api_create_loopback_t *mp;
5901 vl_api_create_loopback_instance_t *mp_lbi;
5904 u8 is_specified = 0;
5905 u32 user_instance = 0;
5908 memset (mac_address, 0, sizeof (mac_address));
5910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5912 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5914 if (unformat (i, "instance %d", &user_instance))
5922 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5923 mp_lbi->is_specified = is_specified;
5925 mp_lbi->user_instance = htonl (user_instance);
5927 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5932 /* Construct the API message */
5933 M (CREATE_LOOPBACK, mp);
5935 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5944 api_delete_loopback (vat_main_t * vam)
5946 unformat_input_t *i = vam->input;
5947 vl_api_delete_loopback_t *mp;
5948 u32 sw_if_index = ~0;
5951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5953 if (unformat (i, "sw_if_index %d", &sw_if_index))
5959 if (sw_if_index == ~0)
5961 errmsg ("missing sw_if_index");
5965 /* Construct the API message */
5966 M (DELETE_LOOPBACK, mp);
5967 mp->sw_if_index = ntohl (sw_if_index);
5975 api_want_stats (vat_main_t * vam)
5977 unformat_input_t *i = vam->input;
5978 vl_api_want_stats_t *mp;
5982 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5984 if (unformat (i, "enable"))
5986 else if (unformat (i, "disable"))
5994 errmsg ("missing enable|disable");
5999 mp->enable_disable = enable;
6007 api_want_interface_events (vat_main_t * vam)
6009 unformat_input_t *i = vam->input;
6010 vl_api_want_interface_events_t *mp;
6014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6016 if (unformat (i, "enable"))
6018 else if (unformat (i, "disable"))
6026 errmsg ("missing enable|disable");
6030 M (WANT_INTERFACE_EVENTS, mp);
6031 mp->enable_disable = enable;
6033 vam->interface_event_display = enable;
6041 /* Note: non-static, called once to set up the initial intfc table */
6043 api_sw_interface_dump (vat_main_t * vam)
6045 vl_api_sw_interface_dump_t *mp;
6046 vl_api_control_ping_t *mp_ping;
6048 name_sort_t *nses = 0, *ns;
6049 sw_interface_subif_t *sub = NULL;
6052 /* Toss the old name table */
6054 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6056 vec_add2 (nses, ns, 1);
6057 ns->name = (u8 *)(p->key);
6058 ns->value = (u32) p->value[0];
6062 hash_free (vam->sw_if_index_by_interface_name);
6064 vec_foreach (ns, nses) vec_free (ns->name);
6068 vec_foreach (sub, vam->sw_if_subif_table)
6070 vec_free (sub->interface_name);
6072 vec_free (vam->sw_if_subif_table);
6074 /* recreate the interface name hash table */
6075 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6077 /* Get list of ethernets */
6078 M (SW_INTERFACE_DUMP, mp);
6079 mp->name_filter_valid = 1;
6080 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6083 /* and local / loopback interfaces */
6084 M (SW_INTERFACE_DUMP, mp);
6085 mp->name_filter_valid = 1;
6086 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6089 /* and packet-generator interfaces */
6090 M (SW_INTERFACE_DUMP, mp);
6091 mp->name_filter_valid = 1;
6092 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6095 /* and vxlan-gpe tunnel interfaces */
6096 M (SW_INTERFACE_DUMP, mp);
6097 mp->name_filter_valid = 1;
6098 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6099 sizeof (mp->name_filter) - 1);
6102 /* and vxlan tunnel interfaces */
6103 M (SW_INTERFACE_DUMP, mp);
6104 mp->name_filter_valid = 1;
6105 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6108 /* and geneve tunnel interfaces */
6109 M (SW_INTERFACE_DUMP, mp);
6110 mp->name_filter_valid = 1;
6111 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6114 /* and host (af_packet) interfaces */
6115 M (SW_INTERFACE_DUMP, mp);
6116 mp->name_filter_valid = 1;
6117 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6120 /* and l2tpv3 tunnel interfaces */
6121 M (SW_INTERFACE_DUMP, mp);
6122 mp->name_filter_valid = 1;
6123 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6124 sizeof (mp->name_filter) - 1);
6127 /* and GRE tunnel interfaces */
6128 M (SW_INTERFACE_DUMP, mp);
6129 mp->name_filter_valid = 1;
6130 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6133 /* and LISP-GPE interfaces */
6134 M (SW_INTERFACE_DUMP, mp);
6135 mp->name_filter_valid = 1;
6136 strncpy ((char *) mp->name_filter, "lisp_gpe",
6137 sizeof (mp->name_filter) - 1);
6140 /* and IPSEC tunnel interfaces */
6141 M (SW_INTERFACE_DUMP, mp);
6142 mp->name_filter_valid = 1;
6143 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6146 /* Use a control ping for synchronization */
6147 MPING (CONTROL_PING, mp_ping);
6155 api_sw_interface_set_flags (vat_main_t * vam)
6157 unformat_input_t *i = vam->input;
6158 vl_api_sw_interface_set_flags_t *mp;
6160 u8 sw_if_index_set = 0;
6164 /* Parse args required to build the message */
6165 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6167 if (unformat (i, "admin-up"))
6169 else if (unformat (i, "admin-down"))
6172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6173 sw_if_index_set = 1;
6174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6175 sw_if_index_set = 1;
6180 if (sw_if_index_set == 0)
6182 errmsg ("missing interface name or sw_if_index");
6186 /* Construct the API message */
6187 M (SW_INTERFACE_SET_FLAGS, mp);
6188 mp->sw_if_index = ntohl (sw_if_index);
6189 mp->admin_up_down = admin_up;
6194 /* Wait for a reply, return the good/bad news... */
6200 api_sw_interface_clear_stats (vat_main_t * vam)
6202 unformat_input_t *i = vam->input;
6203 vl_api_sw_interface_clear_stats_t *mp;
6205 u8 sw_if_index_set = 0;
6208 /* Parse args required to build the message */
6209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6212 sw_if_index_set = 1;
6213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6214 sw_if_index_set = 1;
6219 /* Construct the API message */
6220 M (SW_INTERFACE_CLEAR_STATS, mp);
6222 if (sw_if_index_set == 1)
6223 mp->sw_if_index = ntohl (sw_if_index);
6225 mp->sw_if_index = ~0;
6230 /* Wait for a reply, return the good/bad news... */
6236 api_sw_interface_add_del_address (vat_main_t * vam)
6238 unformat_input_t *i = vam->input;
6239 vl_api_sw_interface_add_del_address_t *mp;
6241 u8 sw_if_index_set = 0;
6242 u8 is_add = 1, del_all = 0;
6243 u32 address_length = 0;
6244 u8 v4_address_set = 0;
6245 u8 v6_address_set = 0;
6246 ip4_address_t v4address;
6247 ip6_address_t v6address;
6250 /* Parse args required to build the message */
6251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6253 if (unformat (i, "del-all"))
6255 else if (unformat (i, "del"))
6258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6259 sw_if_index_set = 1;
6260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6261 sw_if_index_set = 1;
6262 else if (unformat (i, "%U/%d",
6263 unformat_ip4_address, &v4address, &address_length))
6265 else if (unformat (i, "%U/%d",
6266 unformat_ip6_address, &v6address, &address_length))
6272 if (sw_if_index_set == 0)
6274 errmsg ("missing interface name or sw_if_index");
6277 if (v4_address_set && v6_address_set)
6279 errmsg ("both v4 and v6 addresses set");
6282 if (!v4_address_set && !v6_address_set && !del_all)
6284 errmsg ("no addresses set");
6288 /* Construct the API message */
6289 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6291 mp->sw_if_index = ntohl (sw_if_index);
6292 mp->is_add = is_add;
6293 mp->del_all = del_all;
6297 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6301 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6303 mp->address_length = address_length;
6308 /* Wait for a reply, return good/bad news */
6314 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6316 unformat_input_t *i = vam->input;
6317 vl_api_sw_interface_set_mpls_enable_t *mp;
6319 u8 sw_if_index_set = 0;
6323 /* Parse args required to build the message */
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6327 sw_if_index_set = 1;
6328 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6329 sw_if_index_set = 1;
6330 else if (unformat (i, "disable"))
6332 else if (unformat (i, "dis"))
6338 if (sw_if_index_set == 0)
6340 errmsg ("missing interface name or sw_if_index");
6344 /* Construct the API message */
6345 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6347 mp->sw_if_index = ntohl (sw_if_index);
6348 mp->enable = enable;
6353 /* Wait for a reply... */
6359 api_sw_interface_set_table (vat_main_t * vam)
6361 unformat_input_t *i = vam->input;
6362 vl_api_sw_interface_set_table_t *mp;
6363 u32 sw_if_index, vrf_id = 0;
6364 u8 sw_if_index_set = 0;
6368 /* Parse args required to build the message */
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "vrf %d", &vrf_id))
6377 else if (unformat (i, "ipv6"))
6383 if (sw_if_index_set == 0)
6385 errmsg ("missing interface name or sw_if_index");
6389 /* Construct the API message */
6390 M (SW_INTERFACE_SET_TABLE, mp);
6392 mp->sw_if_index = ntohl (sw_if_index);
6393 mp->is_ipv6 = is_ipv6;
6394 mp->vrf_id = ntohl (vrf_id);
6399 /* Wait for a reply... */
6404 static void vl_api_sw_interface_get_table_reply_t_handler
6405 (vl_api_sw_interface_get_table_reply_t * mp)
6407 vat_main_t *vam = &vat_main;
6409 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6411 vam->retval = ntohl (mp->retval);
6412 vam->result_ready = 1;
6416 static void vl_api_sw_interface_get_table_reply_t_handler_json
6417 (vl_api_sw_interface_get_table_reply_t * mp)
6419 vat_main_t *vam = &vat_main;
6420 vat_json_node_t node;
6422 vat_json_init_object (&node);
6423 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6424 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6426 vat_json_print (vam->ofp, &node);
6427 vat_json_free (&node);
6429 vam->retval = ntohl (mp->retval);
6430 vam->result_ready = 1;
6434 api_sw_interface_get_table (vat_main_t * vam)
6436 unformat_input_t *i = vam->input;
6437 vl_api_sw_interface_get_table_t *mp;
6439 u8 sw_if_index_set = 0;
6443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6446 sw_if_index_set = 1;
6447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "ipv6"))
6455 if (sw_if_index_set == 0)
6457 errmsg ("missing interface name or sw_if_index");
6461 M (SW_INTERFACE_GET_TABLE, mp);
6462 mp->sw_if_index = htonl (sw_if_index);
6463 mp->is_ipv6 = is_ipv6;
6471 api_sw_interface_set_vpath (vat_main_t * vam)
6473 unformat_input_t *i = vam->input;
6474 vl_api_sw_interface_set_vpath_t *mp;
6475 u32 sw_if_index = 0;
6476 u8 sw_if_index_set = 0;
6480 /* Parse args required to build the message */
6481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6483 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6484 sw_if_index_set = 1;
6485 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6486 sw_if_index_set = 1;
6487 else if (unformat (i, "enable"))
6489 else if (unformat (i, "disable"))
6495 if (sw_if_index_set == 0)
6497 errmsg ("missing interface name or sw_if_index");
6501 /* Construct the API message */
6502 M (SW_INTERFACE_SET_VPATH, mp);
6504 mp->sw_if_index = ntohl (sw_if_index);
6505 mp->enable = is_enable;
6510 /* Wait for a reply... */
6516 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6518 unformat_input_t *i = vam->input;
6519 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6520 u32 sw_if_index = 0;
6521 u8 sw_if_index_set = 0;
6526 /* Parse args required to build the message */
6527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6529 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6530 sw_if_index_set = 1;
6531 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6532 sw_if_index_set = 1;
6533 else if (unformat (i, "enable"))
6535 else if (unformat (i, "disable"))
6537 else if (unformat (i, "ip4"))
6539 else if (unformat (i, "ip6"))
6545 if (sw_if_index_set == 0)
6547 errmsg ("missing interface name or sw_if_index");
6551 /* Construct the API message */
6552 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6554 mp->sw_if_index = ntohl (sw_if_index);
6555 mp->enable = is_enable;
6556 mp->is_ipv6 = is_ipv6;
6561 /* Wait for a reply... */
6567 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6569 unformat_input_t *i = vam->input;
6570 vl_api_sw_interface_set_geneve_bypass_t *mp;
6571 u32 sw_if_index = 0;
6572 u8 sw_if_index_set = 0;
6577 /* Parse args required to build the message */
6578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6581 sw_if_index_set = 1;
6582 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6583 sw_if_index_set = 1;
6584 else if (unformat (i, "enable"))
6586 else if (unformat (i, "disable"))
6588 else if (unformat (i, "ip4"))
6590 else if (unformat (i, "ip6"))
6596 if (sw_if_index_set == 0)
6598 errmsg ("missing interface name or sw_if_index");
6602 /* Construct the API message */
6603 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6605 mp->sw_if_index = ntohl (sw_if_index);
6606 mp->enable = is_enable;
6607 mp->is_ipv6 = is_ipv6;
6612 /* Wait for a reply... */
6618 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6620 unformat_input_t *i = vam->input;
6621 vl_api_sw_interface_set_l2_xconnect_t *mp;
6623 u8 rx_sw_if_index_set = 0;
6625 u8 tx_sw_if_index_set = 0;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6633 rx_sw_if_index_set = 1;
6634 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6635 tx_sw_if_index_set = 1;
6636 else if (unformat (i, "rx"))
6638 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6640 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6642 rx_sw_if_index_set = 1;
6647 else if (unformat (i, "tx"))
6649 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6651 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6653 tx_sw_if_index_set = 1;
6658 else if (unformat (i, "enable"))
6660 else if (unformat (i, "disable"))
6666 if (rx_sw_if_index_set == 0)
6668 errmsg ("missing rx interface name or rx_sw_if_index");
6672 if (enable && (tx_sw_if_index_set == 0))
6674 errmsg ("missing tx interface name or tx_sw_if_index");
6678 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6680 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6681 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6682 mp->enable = enable;
6690 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6692 unformat_input_t *i = vam->input;
6693 vl_api_sw_interface_set_l2_bridge_t *mp;
6695 u8 rx_sw_if_index_set = 0;
6703 /* Parse args required to build the message */
6704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6706 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6707 rx_sw_if_index_set = 1;
6708 else if (unformat (i, "bd_id %d", &bd_id))
6712 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6713 rx_sw_if_index_set = 1;
6714 else if (unformat (i, "shg %d", &shg))
6716 else if (unformat (i, "bvi"))
6718 else if (unformat (i, "enable"))
6720 else if (unformat (i, "disable"))
6726 if (rx_sw_if_index_set == 0)
6728 errmsg ("missing rx interface name or sw_if_index");
6732 if (enable && (bd_id_set == 0))
6734 errmsg ("missing bridge domain");
6738 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6740 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6741 mp->bd_id = ntohl (bd_id);
6744 mp->enable = enable;
6752 api_bridge_domain_dump (vat_main_t * vam)
6754 unformat_input_t *i = vam->input;
6755 vl_api_bridge_domain_dump_t *mp;
6756 vl_api_control_ping_t *mp_ping;
6760 /* Parse args required to build the message */
6761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6763 if (unformat (i, "bd_id %d", &bd_id))
6769 M (BRIDGE_DOMAIN_DUMP, mp);
6770 mp->bd_id = ntohl (bd_id);
6773 /* Use a control ping for synchronization */
6774 MPING (CONTROL_PING, mp_ping);
6782 api_bridge_domain_add_del (vat_main_t * vam)
6784 unformat_input_t *i = vam->input;
6785 vl_api_bridge_domain_add_del_t *mp;
6788 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6793 /* Parse args required to build the message */
6794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6796 if (unformat (i, "bd_id %d", &bd_id))
6798 else if (unformat (i, "flood %d", &flood))
6800 else if (unformat (i, "uu-flood %d", &uu_flood))
6802 else if (unformat (i, "forward %d", &forward))
6804 else if (unformat (i, "learn %d", &learn))
6806 else if (unformat (i, "arp-term %d", &arp_term))
6808 else if (unformat (i, "mac-age %d", &mac_age))
6810 else if (unformat (i, "bd-tag %s", &bd_tag))
6812 else if (unformat (i, "del"))
6815 flood = uu_flood = forward = learn = 0;
6823 errmsg ("missing bridge domain");
6830 errmsg ("mac age must be less than 256 ");
6835 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6837 errmsg ("bd-tag cannot be longer than 63");
6842 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6844 mp->bd_id = ntohl (bd_id);
6846 mp->uu_flood = uu_flood;
6847 mp->forward = forward;
6849 mp->arp_term = arp_term;
6850 mp->is_add = is_add;
6851 mp->mac_age = (u8) mac_age;
6853 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6864 api_l2fib_flush_bd (vat_main_t * vam)
6866 unformat_input_t *i = vam->input;
6867 vl_api_l2fib_flush_bd_t *mp;
6871 /* Parse args required to build the message */
6872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6874 if (unformat (i, "bd_id %d", &bd_id));
6881 errmsg ("missing bridge domain");
6885 M (L2FIB_FLUSH_BD, mp);
6887 mp->bd_id = htonl (bd_id);
6895 api_l2fib_flush_int (vat_main_t * vam)
6897 unformat_input_t *i = vam->input;
6898 vl_api_l2fib_flush_int_t *mp;
6899 u32 sw_if_index = ~0;
6902 /* Parse args required to build the message */
6903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6905 if (unformat (i, "sw_if_index %d", &sw_if_index));
6907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6912 if (sw_if_index == ~0)
6914 errmsg ("missing interface name or sw_if_index");
6918 M (L2FIB_FLUSH_INT, mp);
6920 mp->sw_if_index = ntohl (sw_if_index);
6928 api_l2fib_add_del (vat_main_t * vam)
6930 unformat_input_t *i = vam->input;
6931 vl_api_l2fib_add_del_t *mp;
6937 u32 sw_if_index = ~0;
6938 u8 sw_if_index_set = 0;
6947 /* Parse args required to build the message */
6948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6950 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6952 else if (unformat (i, "bd_id %d", &bd_id))
6954 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6955 sw_if_index_set = 1;
6956 else if (unformat (i, "sw_if"))
6958 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6961 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6962 sw_if_index_set = 1;
6967 else if (unformat (i, "static"))
6969 else if (unformat (i, "filter"))
6974 else if (unformat (i, "bvi"))
6979 else if (unformat (i, "del"))
6981 else if (unformat (i, "count %d", &count))
6989 errmsg ("missing mac address");
6995 errmsg ("missing bridge domain");
6999 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7001 errmsg ("missing interface name or sw_if_index");
7007 /* Turn on async mode */
7008 vam->async_mode = 1;
7009 vam->async_errors = 0;
7010 before = vat_time_now (vam);
7013 for (j = 0; j < count; j++)
7015 M (L2FIB_ADD_DEL, mp);
7018 mp->bd_id = ntohl (bd_id);
7019 mp->is_add = is_add;
7023 mp->sw_if_index = ntohl (sw_if_index);
7024 mp->static_mac = static_mac;
7025 mp->filter_mac = filter_mac;
7026 mp->bvi_mac = bvi_mac;
7028 increment_mac_address (&mac);
7035 vl_api_control_ping_t *mp_ping;
7038 /* Shut off async mode */
7039 vam->async_mode = 0;
7041 MPING (CONTROL_PING, mp_ping);
7044 timeout = vat_time_now (vam) + 1.0;
7045 while (vat_time_now (vam) < timeout)
7046 if (vam->result_ready == 1)
7051 if (vam->retval == -99)
7054 if (vam->async_errors > 0)
7056 errmsg ("%d asynchronous errors", vam->async_errors);
7059 vam->async_errors = 0;
7060 after = vat_time_now (vam);
7062 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7063 count, after - before, count / (after - before));
7069 /* Wait for a reply... */
7073 /* Return the good/bad news */
7074 return (vam->retval);
7078 api_bridge_domain_set_mac_age (vat_main_t * vam)
7080 unformat_input_t *i = vam->input;
7081 vl_api_bridge_domain_set_mac_age_t *mp;
7086 /* Parse args required to build the message */
7087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7089 if (unformat (i, "bd_id %d", &bd_id));
7090 else if (unformat (i, "mac-age %d", &mac_age));
7097 errmsg ("missing bridge domain");
7103 errmsg ("mac age must be less than 256 ");
7107 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7109 mp->bd_id = htonl (bd_id);
7110 mp->mac_age = (u8) mac_age;
7118 api_l2_flags (vat_main_t * vam)
7120 unformat_input_t *i = vam->input;
7121 vl_api_l2_flags_t *mp;
7124 u8 sw_if_index_set = 0;
7128 /* Parse args required to build the message */
7129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7131 if (unformat (i, "sw_if_index %d", &sw_if_index))
7132 sw_if_index_set = 1;
7133 else if (unformat (i, "sw_if"))
7135 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7138 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7139 sw_if_index_set = 1;
7144 else if (unformat (i, "learn"))
7146 else if (unformat (i, "forward"))
7148 else if (unformat (i, "flood"))
7150 else if (unformat (i, "uu-flood"))
7151 flags |= L2_UU_FLOOD;
7152 else if (unformat (i, "arp-term"))
7153 flags |= L2_ARP_TERM;
7154 else if (unformat (i, "off"))
7156 else if (unformat (i, "disable"))
7162 if (sw_if_index_set == 0)
7164 errmsg ("missing interface name or sw_if_index");
7170 mp->sw_if_index = ntohl (sw_if_index);
7171 mp->feature_bitmap = ntohl (flags);
7172 mp->is_set = is_set;
7180 api_bridge_flags (vat_main_t * vam)
7182 unformat_input_t *i = vam->input;
7183 vl_api_bridge_flags_t *mp;
7190 /* Parse args required to build the message */
7191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7193 if (unformat (i, "bd_id %d", &bd_id))
7195 else if (unformat (i, "learn"))
7197 else if (unformat (i, "forward"))
7199 else if (unformat (i, "flood"))
7201 else if (unformat (i, "uu-flood"))
7202 flags |= L2_UU_FLOOD;
7203 else if (unformat (i, "arp-term"))
7204 flags |= L2_ARP_TERM;
7205 else if (unformat (i, "off"))
7207 else if (unformat (i, "disable"))
7215 errmsg ("missing bridge domain");
7219 M (BRIDGE_FLAGS, mp);
7221 mp->bd_id = ntohl (bd_id);
7222 mp->feature_bitmap = ntohl (flags);
7223 mp->is_set = is_set;
7231 api_bd_ip_mac_add_del (vat_main_t * vam)
7233 unformat_input_t *i = vam->input;
7234 vl_api_bd_ip_mac_add_del_t *mp;
7241 ip4_address_t v4addr;
7242 ip6_address_t v6addr;
7247 /* Parse args required to build the message */
7248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7250 if (unformat (i, "bd_id %d", &bd_id))
7254 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7258 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7263 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7267 else if (unformat (i, "del"))
7275 errmsg ("missing bridge domain");
7278 else if (ip_set == 0)
7280 errmsg ("missing IP address");
7283 else if (mac_set == 0)
7285 errmsg ("missing MAC address");
7289 M (BD_IP_MAC_ADD_DEL, mp);
7291 mp->bd_id = ntohl (bd_id);
7292 mp->is_ipv6 = is_ipv6;
7293 mp->is_add = is_add;
7295 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7297 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7298 clib_memcpy (mp->mac_address, macaddr, 6);
7305 api_tap_connect (vat_main_t * vam)
7307 unformat_input_t *i = vam->input;
7308 vl_api_tap_connect_t *mp;
7314 ip4_address_t ip4_address;
7316 int ip4_address_set = 0;
7317 ip6_address_t ip6_address;
7319 int ip6_address_set = 0;
7322 memset (mac_address, 0, sizeof (mac_address));
7324 /* Parse args required to build the message */
7325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7327 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7331 else if (unformat (i, "random-mac"))
7333 else if (unformat (i, "tapname %s", &tap_name))
7335 else if (unformat (i, "tag %s", &tag))
7337 else if (unformat (i, "address %U/%d",
7338 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7339 ip4_address_set = 1;
7340 else if (unformat (i, "address %U/%d",
7341 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7342 ip6_address_set = 1;
7349 errmsg ("missing tap name");
7352 if (vec_len (tap_name) > 63)
7354 errmsg ("tap name too long");
7357 vec_add1 (tap_name, 0);
7359 if (vec_len (tag) > 63)
7361 errmsg ("tag too long");
7365 /* Construct the API message */
7366 M (TAP_CONNECT, mp);
7368 mp->use_random_mac = random_mac;
7369 clib_memcpy (mp->mac_address, mac_address, 6);
7370 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7372 clib_memcpy (mp->tag, tag, vec_len (tag));
7374 if (ip4_address_set)
7376 mp->ip4_address_set = 1;
7377 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7378 mp->ip4_mask_width = ip4_mask_width;
7380 if (ip6_address_set)
7382 mp->ip6_address_set = 1;
7383 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7384 mp->ip6_mask_width = ip6_mask_width;
7387 vec_free (tap_name);
7393 /* Wait for a reply... */
7399 api_tap_modify (vat_main_t * vam)
7401 unformat_input_t *i = vam->input;
7402 vl_api_tap_modify_t *mp;
7407 u32 sw_if_index = ~0;
7408 u8 sw_if_index_set = 0;
7411 memset (mac_address, 0, sizeof (mac_address));
7413 /* Parse args required to build the message */
7414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7416 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7417 sw_if_index_set = 1;
7418 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7419 sw_if_index_set = 1;
7420 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7424 else if (unformat (i, "random-mac"))
7426 else if (unformat (i, "tapname %s", &tap_name))
7432 if (sw_if_index_set == 0)
7434 errmsg ("missing vpp interface name");
7439 errmsg ("missing tap name");
7442 if (vec_len (tap_name) > 63)
7444 errmsg ("tap name too long");
7446 vec_add1 (tap_name, 0);
7448 /* Construct the API message */
7451 mp->use_random_mac = random_mac;
7452 mp->sw_if_index = ntohl (sw_if_index);
7453 clib_memcpy (mp->mac_address, mac_address, 6);
7454 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7455 vec_free (tap_name);
7460 /* Wait for a reply... */
7466 api_tap_delete (vat_main_t * vam)
7468 unformat_input_t *i = vam->input;
7469 vl_api_tap_delete_t *mp;
7470 u32 sw_if_index = ~0;
7471 u8 sw_if_index_set = 0;
7474 /* Parse args required to build the message */
7475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7478 sw_if_index_set = 1;
7479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7480 sw_if_index_set = 1;
7485 if (sw_if_index_set == 0)
7487 errmsg ("missing vpp interface name");
7491 /* Construct the API message */
7494 mp->sw_if_index = ntohl (sw_if_index);
7499 /* Wait for a reply... */
7505 api_ip_table_add_del (vat_main_t * vam)
7507 unformat_input_t *i = vam->input;
7508 vl_api_ip_table_add_del_t *mp;
7514 /* Parse args required to build the message */
7515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7517 if (unformat (i, "ipv6"))
7519 else if (unformat (i, "del"))
7521 else if (unformat (i, "add"))
7523 else if (unformat (i, "table %d", &table_id))
7527 clib_warning ("parse error '%U'", format_unformat_error, i);
7534 errmsg ("missing table-ID");
7538 /* Construct the API message */
7539 M (IP_TABLE_ADD_DEL, mp);
7541 mp->table_id = ntohl (table_id);
7542 mp->is_ipv6 = is_ipv6;
7543 mp->is_add = is_add;
7548 /* Wait for a reply... */
7555 api_ip_add_del_route (vat_main_t * vam)
7557 unformat_input_t *i = vam->input;
7558 vl_api_ip_add_del_route_t *mp;
7559 u32 sw_if_index = ~0, vrf_id = 0;
7561 u8 is_local = 0, is_drop = 0;
7562 u8 is_unreach = 0, is_prohibit = 0;
7564 u32 next_hop_weight = 1;
7566 u8 is_multipath = 0;
7568 u8 address_length_set = 0;
7569 u32 next_hop_table_id = 0;
7570 u32 resolve_attempts = 0;
7571 u32 dst_address_length = 0;
7572 u8 next_hop_set = 0;
7573 ip4_address_t v4_dst_address, v4_next_hop_address;
7574 ip6_address_t v6_dst_address, v6_next_hop_address;
7578 u32 random_add_del = 0;
7579 u32 *random_vector = 0;
7581 u32 random_seed = 0xdeaddabe;
7582 u32 classify_table_index = ~0;
7584 u8 resolve_host = 0, resolve_attached = 0;
7585 mpls_label_t *next_hop_out_label_stack = NULL;
7586 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7587 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7589 /* Parse args required to build the message */
7590 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7592 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7594 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7596 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7601 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7606 else if (unformat (i, "/%d", &dst_address_length))
7608 address_length_set = 1;
7611 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7612 &v4_next_hop_address))
7616 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7617 &v6_next_hop_address))
7621 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7623 else if (unformat (i, "weight %d", &next_hop_weight))
7625 else if (unformat (i, "drop"))
7629 else if (unformat (i, "null-send-unreach"))
7633 else if (unformat (i, "null-send-prohibit"))
7637 else if (unformat (i, "local"))
7641 else if (unformat (i, "classify %d", &classify_table_index))
7645 else if (unformat (i, "del"))
7647 else if (unformat (i, "add"))
7649 else if (unformat (i, "not-last"))
7651 else if (unformat (i, "resolve-via-host"))
7653 else if (unformat (i, "resolve-via-attached"))
7654 resolve_attached = 1;
7655 else if (unformat (i, "multipath"))
7657 else if (unformat (i, "vrf %d", &vrf_id))
7659 else if (unformat (i, "count %d", &count))
7661 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7663 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7665 else if (unformat (i, "out-label %d", &next_hop_out_label))
7666 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7667 else if (unformat (i, "via-label %d", &next_hop_via_label))
7669 else if (unformat (i, "random"))
7671 else if (unformat (i, "seed %d", &random_seed))
7675 clib_warning ("parse error '%U'", format_unformat_error, i);
7680 if (!next_hop_set && !is_drop && !is_local &&
7681 !is_classify && !is_unreach && !is_prohibit &&
7682 MPLS_LABEL_INVALID == next_hop_via_label)
7685 ("next hop / local / drop / unreach / prohibit / classify not set");
7689 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7691 errmsg ("next hop and next-hop via label set");
7694 if (address_set == 0)
7696 errmsg ("missing addresses");
7700 if (address_length_set == 0)
7702 errmsg ("missing address length");
7706 /* Generate a pile of unique, random routes */
7709 u32 this_random_address;
7710 random_hash = hash_create (count, sizeof (uword));
7712 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7713 for (j = 0; j <= count; j++)
7717 this_random_address = random_u32 (&random_seed);
7718 this_random_address =
7719 clib_host_to_net_u32 (this_random_address);
7721 while (hash_get (random_hash, this_random_address));
7722 vec_add1 (random_vector, this_random_address);
7723 hash_set (random_hash, this_random_address, 1);
7725 hash_free (random_hash);
7726 v4_dst_address.as_u32 = random_vector[0];
7731 /* Turn on async mode */
7732 vam->async_mode = 1;
7733 vam->async_errors = 0;
7734 before = vat_time_now (vam);
7737 for (j = 0; j < count; j++)
7739 /* Construct the API message */
7740 M2 (IP_ADD_DEL_ROUTE, mp,
7741 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7743 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7744 mp->table_id = ntohl (vrf_id);
7746 mp->is_add = is_add;
7747 mp->is_drop = is_drop;
7748 mp->is_unreach = is_unreach;
7749 mp->is_prohibit = is_prohibit;
7750 mp->is_ipv6 = is_ipv6;
7751 mp->is_local = is_local;
7752 mp->is_classify = is_classify;
7753 mp->is_multipath = is_multipath;
7754 mp->is_resolve_host = resolve_host;
7755 mp->is_resolve_attached = resolve_attached;
7756 mp->not_last = not_last;
7757 mp->next_hop_weight = next_hop_weight;
7758 mp->dst_address_length = dst_address_length;
7759 mp->next_hop_table_id = ntohl (next_hop_table_id);
7760 mp->classify_table_index = ntohl (classify_table_index);
7761 mp->next_hop_via_label = ntohl (next_hop_via_label);
7762 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7763 if (0 != mp->next_hop_n_out_labels)
7765 memcpy (mp->next_hop_out_label_stack,
7766 next_hop_out_label_stack,
7767 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7768 vec_free (next_hop_out_label_stack);
7773 clib_memcpy (mp->dst_address, &v6_dst_address,
7774 sizeof (v6_dst_address));
7776 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7777 sizeof (v6_next_hop_address));
7778 increment_v6_address (&v6_dst_address);
7782 clib_memcpy (mp->dst_address, &v4_dst_address,
7783 sizeof (v4_dst_address));
7785 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7786 sizeof (v4_next_hop_address));
7788 v4_dst_address.as_u32 = random_vector[j + 1];
7790 increment_v4_address (&v4_dst_address);
7794 /* If we receive SIGTERM, stop now... */
7799 /* When testing multiple add/del ops, use a control-ping to sync */
7802 vl_api_control_ping_t *mp_ping;
7806 /* Shut off async mode */
7807 vam->async_mode = 0;
7809 MPING (CONTROL_PING, mp_ping);
7812 timeout = vat_time_now (vam) + 1.0;
7813 while (vat_time_now (vam) < timeout)
7814 if (vam->result_ready == 1)
7819 if (vam->retval == -99)
7822 if (vam->async_errors > 0)
7824 errmsg ("%d asynchronous errors", vam->async_errors);
7827 vam->async_errors = 0;
7828 after = vat_time_now (vam);
7830 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7834 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7835 count, after - before, count / (after - before));
7841 /* Wait for a reply... */
7846 /* Return the good/bad news */
7847 return (vam->retval);
7851 api_ip_mroute_add_del (vat_main_t * vam)
7853 unformat_input_t *i = vam->input;
7854 vl_api_ip_mroute_add_del_t *mp;
7855 u32 sw_if_index = ~0, vrf_id = 0;
7860 u32 grp_address_length = 0;
7861 ip4_address_t v4_grp_address, v4_src_address;
7862 ip6_address_t v6_grp_address, v6_src_address;
7863 mfib_itf_flags_t iflags = 0;
7864 mfib_entry_flags_t eflags = 0;
7867 /* Parse args required to build the message */
7868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7870 if (unformat (i, "sw_if_index %d", &sw_if_index))
7872 else if (unformat (i, "%U %U",
7873 unformat_ip4_address, &v4_src_address,
7874 unformat_ip4_address, &v4_grp_address))
7876 grp_address_length = 64;
7880 else if (unformat (i, "%U %U",
7881 unformat_ip6_address, &v6_src_address,
7882 unformat_ip6_address, &v6_grp_address))
7884 grp_address_length = 256;
7888 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7890 memset (&v4_src_address, 0, sizeof (v4_src_address));
7891 grp_address_length = 32;
7895 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7897 memset (&v6_src_address, 0, sizeof (v6_src_address));
7898 grp_address_length = 128;
7902 else if (unformat (i, "/%d", &grp_address_length))
7904 else if (unformat (i, "local"))
7908 else if (unformat (i, "del"))
7910 else if (unformat (i, "add"))
7912 else if (unformat (i, "vrf %d", &vrf_id))
7914 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7916 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7920 clib_warning ("parse error '%U'", format_unformat_error, i);
7925 if (address_set == 0)
7927 errmsg ("missing addresses\n");
7931 /* Construct the API message */
7932 M (IP_MROUTE_ADD_DEL, mp);
7934 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7935 mp->table_id = ntohl (vrf_id);
7937 mp->is_add = is_add;
7938 mp->is_ipv6 = is_ipv6;
7939 mp->is_local = is_local;
7940 mp->itf_flags = ntohl (iflags);
7941 mp->entry_flags = ntohl (eflags);
7942 mp->grp_address_length = grp_address_length;
7943 mp->grp_address_length = ntohs (mp->grp_address_length);
7947 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7948 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7952 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7953 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7959 /* Wait for a reply... */
7965 api_mpls_table_add_del (vat_main_t * vam)
7967 unformat_input_t *i = vam->input;
7968 vl_api_mpls_table_add_del_t *mp;
7973 /* Parse args required to build the message */
7974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7976 if (unformat (i, "del"))
7978 else if (unformat (i, "add"))
7980 else if (unformat (i, "table-id %d", &table_id))
7984 clib_warning ("parse error '%U'", format_unformat_error, i);
7991 errmsg ("missing table-ID");
7995 /* Construct the API message */
7996 M (MPLS_TABLE_ADD_DEL, mp);
7998 mp->mt_table_id = ntohl (table_id);
7999 mp->mt_is_add = is_add;
8004 /* Wait for a reply... */
8011 api_mpls_route_add_del (vat_main_t * vam)
8013 unformat_input_t *i = vam->input;
8014 vl_api_mpls_route_add_del_t *mp;
8015 u32 sw_if_index = ~0, table_id = 0;
8017 u32 next_hop_weight = 1;
8018 u8 is_multipath = 0;
8019 u32 next_hop_table_id = 0;
8020 u8 next_hop_set = 0;
8021 ip4_address_t v4_next_hop_address = {
8024 ip6_address_t v6_next_hop_address = { {0} };
8028 u32 classify_table_index = ~0;
8030 u8 resolve_host = 0, resolve_attached = 0;
8031 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8032 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8033 mpls_label_t *next_hop_out_label_stack = NULL;
8034 mpls_label_t local_label = MPLS_LABEL_INVALID;
8036 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8038 /* Parse args required to build the message */
8039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8045 else if (unformat (i, "%d", &local_label))
8047 else if (unformat (i, "eos"))
8049 else if (unformat (i, "non-eos"))
8051 else if (unformat (i, "via %U", unformat_ip4_address,
8052 &v4_next_hop_address))
8055 next_hop_proto = DPO_PROTO_IP4;
8057 else if (unformat (i, "via %U", unformat_ip6_address,
8058 &v6_next_hop_address))
8061 next_hop_proto = DPO_PROTO_IP6;
8063 else if (unformat (i, "weight %d", &next_hop_weight))
8065 else if (unformat (i, "classify %d", &classify_table_index))
8069 else if (unformat (i, "del"))
8071 else if (unformat (i, "add"))
8073 else if (unformat (i, "resolve-via-host"))
8075 else if (unformat (i, "resolve-via-attached"))
8076 resolve_attached = 1;
8077 else if (unformat (i, "multipath"))
8079 else if (unformat (i, "count %d", &count))
8081 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8084 next_hop_proto = DPO_PROTO_IP4;
8086 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8089 next_hop_proto = DPO_PROTO_IP6;
8091 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8093 else if (unformat (i, "via-label %d", &next_hop_via_label))
8095 else if (unformat (i, "out-label %d", &next_hop_out_label))
8096 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8099 clib_warning ("parse error '%U'", format_unformat_error, i);
8104 if (!next_hop_set && !is_classify)
8106 errmsg ("next hop / classify not set");
8110 if (MPLS_LABEL_INVALID == local_label)
8112 errmsg ("missing label");
8118 /* Turn on async mode */
8119 vam->async_mode = 1;
8120 vam->async_errors = 0;
8121 before = vat_time_now (vam);
8124 for (j = 0; j < count; j++)
8126 /* Construct the API message */
8127 M2 (MPLS_ROUTE_ADD_DEL, mp,
8128 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8130 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8131 mp->mr_table_id = ntohl (table_id);
8133 mp->mr_is_add = is_add;
8134 mp->mr_next_hop_proto = next_hop_proto;
8135 mp->mr_is_classify = is_classify;
8136 mp->mr_is_multipath = is_multipath;
8137 mp->mr_is_resolve_host = resolve_host;
8138 mp->mr_is_resolve_attached = resolve_attached;
8139 mp->mr_next_hop_weight = next_hop_weight;
8140 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8141 mp->mr_classify_table_index = ntohl (classify_table_index);
8142 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8143 mp->mr_label = ntohl (local_label);
8144 mp->mr_eos = is_eos;
8146 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8147 if (0 != mp->mr_next_hop_n_out_labels)
8149 memcpy (mp->mr_next_hop_out_label_stack,
8150 next_hop_out_label_stack,
8151 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8152 vec_free (next_hop_out_label_stack);
8157 if (DPO_PROTO_IP4 == next_hop_proto)
8159 clib_memcpy (mp->mr_next_hop,
8160 &v4_next_hop_address,
8161 sizeof (v4_next_hop_address));
8163 else if (DPO_PROTO_IP6 == next_hop_proto)
8166 clib_memcpy (mp->mr_next_hop,
8167 &v6_next_hop_address,
8168 sizeof (v6_next_hop_address));
8175 /* If we receive SIGTERM, stop now... */
8180 /* When testing multiple add/del ops, use a control-ping to sync */
8183 vl_api_control_ping_t *mp_ping;
8187 /* Shut off async mode */
8188 vam->async_mode = 0;
8190 MPING (CONTROL_PING, mp_ping);
8193 timeout = vat_time_now (vam) + 1.0;
8194 while (vat_time_now (vam) < timeout)
8195 if (vam->result_ready == 1)
8200 if (vam->retval == -99)
8203 if (vam->async_errors > 0)
8205 errmsg ("%d asynchronous errors", vam->async_errors);
8208 vam->async_errors = 0;
8209 after = vat_time_now (vam);
8211 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8215 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8216 count, after - before, count / (after - before));
8222 /* Wait for a reply... */
8227 /* Return the good/bad news */
8228 return (vam->retval);
8232 api_mpls_ip_bind_unbind (vat_main_t * vam)
8234 unformat_input_t *i = vam->input;
8235 vl_api_mpls_ip_bind_unbind_t *mp;
8236 u32 ip_table_id = 0;
8239 ip4_address_t v4_address;
8240 ip6_address_t v6_address;
8243 mpls_label_t local_label = MPLS_LABEL_INVALID;
8246 /* Parse args required to build the message */
8247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8249 if (unformat (i, "%U/%d", unformat_ip4_address,
8250 &v4_address, &address_length))
8255 else if (unformat (i, "%U/%d", unformat_ip6_address,
8256 &v6_address, &address_length))
8261 else if (unformat (i, "%d", &local_label))
8263 else if (unformat (i, "table-id %d", &ip_table_id))
8265 else if (unformat (i, "unbind"))
8267 else if (unformat (i, "bind"))
8271 clib_warning ("parse error '%U'", format_unformat_error, i);
8278 errmsg ("IP addres not set");
8282 if (MPLS_LABEL_INVALID == local_label)
8284 errmsg ("missing label");
8288 /* Construct the API message */
8289 M (MPLS_IP_BIND_UNBIND, mp);
8291 mp->mb_is_bind = is_bind;
8292 mp->mb_is_ip4 = is_ip4;
8293 mp->mb_ip_table_id = ntohl (ip_table_id);
8294 mp->mb_mpls_table_id = 0;
8295 mp->mb_label = ntohl (local_label);
8296 mp->mb_address_length = address_length;
8299 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8301 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8306 /* Wait for a reply... */
8312 api_proxy_arp_add_del (vat_main_t * vam)
8314 unformat_input_t *i = vam->input;
8315 vl_api_proxy_arp_add_del_t *mp;
8318 ip4_address_t lo, hi;
8322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8324 if (unformat (i, "vrf %d", &vrf_id))
8326 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8327 unformat_ip4_address, &hi))
8329 else if (unformat (i, "del"))
8333 clib_warning ("parse error '%U'", format_unformat_error, i);
8340 errmsg ("address range not set");
8344 M (PROXY_ARP_ADD_DEL, mp);
8346 mp->vrf_id = ntohl (vrf_id);
8347 mp->is_add = is_add;
8348 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8349 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8357 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8359 unformat_input_t *i = vam->input;
8360 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8363 u8 sw_if_index_set = 0;
8366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8368 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8369 sw_if_index_set = 1;
8370 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8371 sw_if_index_set = 1;
8372 else if (unformat (i, "enable"))
8374 else if (unformat (i, "disable"))
8378 clib_warning ("parse error '%U'", format_unformat_error, i);
8383 if (sw_if_index_set == 0)
8385 errmsg ("missing interface name or sw_if_index");
8389 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8391 mp->sw_if_index = ntohl (sw_if_index);
8392 mp->enable_disable = enable;
8400 api_mpls_tunnel_add_del (vat_main_t * vam)
8402 unformat_input_t *i = vam->input;
8403 vl_api_mpls_tunnel_add_del_t *mp;
8407 u32 sw_if_index = ~0;
8408 u32 next_hop_sw_if_index = ~0;
8409 u32 next_hop_proto_is_ip4 = 1;
8411 u32 next_hop_table_id = 0;
8412 ip4_address_t v4_next_hop_address = {
8415 ip6_address_t v6_next_hop_address = { {0} };
8416 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8419 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8421 if (unformat (i, "add"))
8423 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8425 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8427 else if (unformat (i, "via %U",
8428 unformat_ip4_address, &v4_next_hop_address))
8430 next_hop_proto_is_ip4 = 1;
8432 else if (unformat (i, "via %U",
8433 unformat_ip6_address, &v6_next_hop_address))
8435 next_hop_proto_is_ip4 = 0;
8437 else if (unformat (i, "l2-only"))
8439 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8441 else if (unformat (i, "out-label %d", &next_hop_out_label))
8442 vec_add1 (labels, ntohl (next_hop_out_label));
8445 clib_warning ("parse error '%U'", format_unformat_error, i);
8450 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8452 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8453 mp->mt_sw_if_index = ntohl (sw_if_index);
8454 mp->mt_is_add = is_add;
8455 mp->mt_l2_only = l2_only;
8456 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8457 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8459 mp->mt_next_hop_n_out_labels = vec_len (labels);
8461 if (0 != mp->mt_next_hop_n_out_labels)
8463 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8464 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8468 if (next_hop_proto_is_ip4)
8470 clib_memcpy (mp->mt_next_hop,
8471 &v4_next_hop_address, sizeof (v4_next_hop_address));
8475 clib_memcpy (mp->mt_next_hop,
8476 &v6_next_hop_address, sizeof (v6_next_hop_address));
8485 api_sw_interface_set_unnumbered (vat_main_t * vam)
8487 unformat_input_t *i = vam->input;
8488 vl_api_sw_interface_set_unnumbered_t *mp;
8490 u32 unnum_sw_index = ~0;
8492 u8 sw_if_index_set = 0;
8495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8497 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8498 sw_if_index_set = 1;
8499 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8500 sw_if_index_set = 1;
8501 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8503 else if (unformat (i, "del"))
8507 clib_warning ("parse error '%U'", format_unformat_error, i);
8512 if (sw_if_index_set == 0)
8514 errmsg ("missing interface name or sw_if_index");
8518 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8520 mp->sw_if_index = ntohl (sw_if_index);
8521 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8522 mp->is_add = is_add;
8530 api_ip_neighbor_add_del (vat_main_t * vam)
8532 unformat_input_t *i = vam->input;
8533 vl_api_ip_neighbor_add_del_t *mp;
8535 u8 sw_if_index_set = 0;
8538 u8 is_no_fib_entry = 0;
8541 u8 v4_address_set = 0;
8542 u8 v6_address_set = 0;
8543 ip4_address_t v4address;
8544 ip6_address_t v6address;
8547 memset (mac_address, 0, sizeof (mac_address));
8549 /* Parse args required to build the message */
8550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8552 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8556 else if (unformat (i, "del"))
8559 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8560 sw_if_index_set = 1;
8561 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8562 sw_if_index_set = 1;
8563 else if (unformat (i, "is_static"))
8565 else if (unformat (i, "no-fib-entry"))
8566 is_no_fib_entry = 1;
8567 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8569 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8573 clib_warning ("parse error '%U'", format_unformat_error, i);
8578 if (sw_if_index_set == 0)
8580 errmsg ("missing interface name or sw_if_index");
8583 if (v4_address_set && v6_address_set)
8585 errmsg ("both v4 and v6 addresses set");
8588 if (!v4_address_set && !v6_address_set)
8590 errmsg ("no address set");
8594 /* Construct the API message */
8595 M (IP_NEIGHBOR_ADD_DEL, mp);
8597 mp->sw_if_index = ntohl (sw_if_index);
8598 mp->is_add = is_add;
8599 mp->is_static = is_static;
8600 mp->is_no_adj_fib = is_no_fib_entry;
8602 clib_memcpy (mp->mac_address, mac_address, 6);
8606 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8610 /* mp->is_ipv6 = 0; via memset in M macro above */
8611 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8617 /* Wait for a reply, return good/bad news */
8623 api_reset_vrf (vat_main_t * vam)
8625 unformat_input_t *i = vam->input;
8626 vl_api_reset_vrf_t *mp;
8632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8634 if (unformat (i, "vrf %d", &vrf_id))
8636 else if (unformat (i, "ipv6"))
8640 clib_warning ("parse error '%U'", format_unformat_error, i);
8645 if (vrf_id_set == 0)
8647 errmsg ("missing vrf id");
8653 mp->vrf_id = ntohl (vrf_id);
8654 mp->is_ipv6 = is_ipv6;
8662 api_create_vlan_subif (vat_main_t * vam)
8664 unformat_input_t *i = vam->input;
8665 vl_api_create_vlan_subif_t *mp;
8667 u8 sw_if_index_set = 0;
8672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8674 if (unformat (i, "sw_if_index %d", &sw_if_index))
8675 sw_if_index_set = 1;
8677 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8678 sw_if_index_set = 1;
8679 else if (unformat (i, "vlan %d", &vlan_id))
8683 clib_warning ("parse error '%U'", format_unformat_error, i);
8688 if (sw_if_index_set == 0)
8690 errmsg ("missing interface name or sw_if_index");
8694 if (vlan_id_set == 0)
8696 errmsg ("missing vlan_id");
8699 M (CREATE_VLAN_SUBIF, mp);
8701 mp->sw_if_index = ntohl (sw_if_index);
8702 mp->vlan_id = ntohl (vlan_id);
8709 #define foreach_create_subif_bit \
8716 _(outer_vlan_id_any) \
8717 _(inner_vlan_id_any)
8720 api_create_subif (vat_main_t * vam)
8722 unformat_input_t *i = vam->input;
8723 vl_api_create_subif_t *mp;
8725 u8 sw_if_index_set = 0;
8732 u32 exact_match = 0;
8733 u32 default_sub = 0;
8734 u32 outer_vlan_id_any = 0;
8735 u32 inner_vlan_id_any = 0;
8737 u16 outer_vlan_id = 0;
8738 u16 inner_vlan_id = 0;
8741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8743 if (unformat (i, "sw_if_index %d", &sw_if_index))
8744 sw_if_index_set = 1;
8746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8747 sw_if_index_set = 1;
8748 else if (unformat (i, "sub_id %d", &sub_id))
8750 else if (unformat (i, "outer_vlan_id %d", &tmp))
8751 outer_vlan_id = tmp;
8752 else if (unformat (i, "inner_vlan_id %d", &tmp))
8753 inner_vlan_id = tmp;
8755 #define _(a) else if (unformat (i, #a)) a = 1 ;
8756 foreach_create_subif_bit
8760 clib_warning ("parse error '%U'", format_unformat_error, i);
8765 if (sw_if_index_set == 0)
8767 errmsg ("missing interface name or sw_if_index");
8771 if (sub_id_set == 0)
8773 errmsg ("missing sub_id");
8776 M (CREATE_SUBIF, mp);
8778 mp->sw_if_index = ntohl (sw_if_index);
8779 mp->sub_id = ntohl (sub_id);
8781 #define _(a) mp->a = a;
8782 foreach_create_subif_bit;
8785 mp->outer_vlan_id = ntohs (outer_vlan_id);
8786 mp->inner_vlan_id = ntohs (inner_vlan_id);
8794 api_oam_add_del (vat_main_t * vam)
8796 unformat_input_t *i = vam->input;
8797 vl_api_oam_add_del_t *mp;
8800 ip4_address_t src, dst;
8805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8807 if (unformat (i, "vrf %d", &vrf_id))
8809 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8811 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8813 else if (unformat (i, "del"))
8817 clib_warning ("parse error '%U'", format_unformat_error, i);
8824 errmsg ("missing src addr");
8830 errmsg ("missing dst addr");
8834 M (OAM_ADD_DEL, mp);
8836 mp->vrf_id = ntohl (vrf_id);
8837 mp->is_add = is_add;
8838 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8839 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8847 api_reset_fib (vat_main_t * vam)
8849 unformat_input_t *i = vam->input;
8850 vl_api_reset_fib_t *mp;
8856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8858 if (unformat (i, "vrf %d", &vrf_id))
8860 else if (unformat (i, "ipv6"))
8864 clib_warning ("parse error '%U'", format_unformat_error, i);
8869 if (vrf_id_set == 0)
8871 errmsg ("missing vrf id");
8877 mp->vrf_id = ntohl (vrf_id);
8878 mp->is_ipv6 = is_ipv6;
8886 api_dhcp_proxy_config (vat_main_t * vam)
8888 unformat_input_t *i = vam->input;
8889 vl_api_dhcp_proxy_config_t *mp;
8891 u32 server_vrf_id = 0;
8893 u8 v4_address_set = 0;
8894 u8 v6_address_set = 0;
8895 ip4_address_t v4address;
8896 ip6_address_t v6address;
8897 u8 v4_src_address_set = 0;
8898 u8 v6_src_address_set = 0;
8899 ip4_address_t v4srcaddress;
8900 ip6_address_t v6srcaddress;
8903 /* Parse args required to build the message */
8904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8906 if (unformat (i, "del"))
8908 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8910 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8912 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8914 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8916 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8917 v4_src_address_set = 1;
8918 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8919 v6_src_address_set = 1;
8924 if (v4_address_set && v6_address_set)
8926 errmsg ("both v4 and v6 server addresses set");
8929 if (!v4_address_set && !v6_address_set)
8931 errmsg ("no server addresses set");
8935 if (v4_src_address_set && v6_src_address_set)
8937 errmsg ("both v4 and v6 src addresses set");
8940 if (!v4_src_address_set && !v6_src_address_set)
8942 errmsg ("no src addresses set");
8946 if (!(v4_src_address_set && v4_address_set) &&
8947 !(v6_src_address_set && v6_address_set))
8949 errmsg ("no matching server and src addresses set");
8953 /* Construct the API message */
8954 M (DHCP_PROXY_CONFIG, mp);
8956 mp->is_add = is_add;
8957 mp->rx_vrf_id = ntohl (rx_vrf_id);
8958 mp->server_vrf_id = ntohl (server_vrf_id);
8962 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8963 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8967 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8968 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8974 /* Wait for a reply, return good/bad news */
8979 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8980 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8983 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8985 vat_main_t *vam = &vat_main;
8986 u32 i, count = mp->count;
8987 vl_api_dhcp_server_t *s;
8991 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8992 ntohl (mp->rx_vrf_id),
8993 format_ip6_address, mp->dhcp_src_address,
8994 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8997 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8998 ntohl (mp->rx_vrf_id),
8999 format_ip4_address, mp->dhcp_src_address,
9000 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9002 for (i = 0; i < count; i++)
9004 s = &mp->servers[i];
9008 " Server Table-ID %d, Server Address %U",
9009 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9012 " Server Table-ID %d, Server Address %U",
9013 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9017 static void vl_api_dhcp_proxy_details_t_handler_json
9018 (vl_api_dhcp_proxy_details_t * mp)
9020 vat_main_t *vam = &vat_main;
9021 vat_json_node_t *node = NULL;
9022 u32 i, count = mp->count;
9024 struct in6_addr ip6;
9025 vl_api_dhcp_server_t *s;
9027 if (VAT_JSON_ARRAY != vam->json_tree.type)
9029 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9030 vat_json_init_array (&vam->json_tree);
9032 node = vat_json_array_add (&vam->json_tree);
9034 vat_json_init_object (node);
9035 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9036 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9037 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9041 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9042 vat_json_object_add_ip6 (node, "src_address", ip6);
9046 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9047 vat_json_object_add_ip4 (node, "src_address", ip4);
9050 for (i = 0; i < count; i++)
9052 s = &mp->servers[i];
9054 vat_json_object_add_uint (node, "server-table-id",
9055 ntohl (s->server_vrf_id));
9059 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9060 vat_json_object_add_ip4 (node, "src_address", ip4);
9064 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9065 vat_json_object_add_ip6 (node, "server_address", ip6);
9071 api_dhcp_proxy_dump (vat_main_t * vam)
9073 unformat_input_t *i = vam->input;
9074 vl_api_control_ping_t *mp_ping;
9075 vl_api_dhcp_proxy_dump_t *mp;
9079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9081 if (unformat (i, "ipv6"))
9085 clib_warning ("parse error '%U'", format_unformat_error, i);
9090 M (DHCP_PROXY_DUMP, mp);
9092 mp->is_ip6 = is_ipv6;
9095 /* Use a control ping for synchronization */
9096 MPING (CONTROL_PING, mp_ping);
9104 api_dhcp_proxy_set_vss (vat_main_t * vam)
9106 unformat_input_t *i = vam->input;
9107 vl_api_dhcp_proxy_set_vss_t *mp;
9118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9120 if (unformat (i, "tbl_id %d", &tbl_id))
9122 if (unformat (i, "fib_id %d", &fib_id))
9124 if (unformat (i, "oui %d", &oui))
9126 else if (unformat (i, "ipv6"))
9128 else if (unformat (i, "del"))
9132 clib_warning ("parse error '%U'", format_unformat_error, i);
9137 if (tbl_id_set == 0)
9139 errmsg ("missing tbl id");
9143 if (fib_id_set == 0)
9145 errmsg ("missing fib id");
9150 errmsg ("missing oui");
9154 M (DHCP_PROXY_SET_VSS, mp);
9155 mp->tbl_id = ntohl (tbl_id);
9156 mp->fib_id = ntohl (fib_id);
9157 mp->oui = ntohl (oui);
9158 mp->is_ipv6 = is_ipv6;
9159 mp->is_add = is_add;
9167 api_dhcp_client_config (vat_main_t * vam)
9169 unformat_input_t *i = vam->input;
9170 vl_api_dhcp_client_config_t *mp;
9172 u8 sw_if_index_set = 0;
9175 u8 disable_event = 0;
9178 /* Parse args required to build the message */
9179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9181 if (unformat (i, "del"))
9184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9185 sw_if_index_set = 1;
9186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9187 sw_if_index_set = 1;
9188 else if (unformat (i, "hostname %s", &hostname))
9190 else if (unformat (i, "disable_event"))
9196 if (sw_if_index_set == 0)
9198 errmsg ("missing interface name or sw_if_index");
9202 if (vec_len (hostname) > 63)
9204 errmsg ("hostname too long");
9206 vec_add1 (hostname, 0);
9208 /* Construct the API message */
9209 M (DHCP_CLIENT_CONFIG, mp);
9211 mp->sw_if_index = htonl (sw_if_index);
9212 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9213 vec_free (hostname);
9214 mp->is_add = is_add;
9215 mp->want_dhcp_event = disable_event ? 0 : 1;
9216 mp->pid = htonl (getpid ());
9221 /* Wait for a reply, return good/bad news */
9227 api_set_ip_flow_hash (vat_main_t * vam)
9229 unformat_input_t *i = vam->input;
9230 vl_api_set_ip_flow_hash_t *mp;
9242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9244 if (unformat (i, "vrf %d", &vrf_id))
9246 else if (unformat (i, "ipv6"))
9248 else if (unformat (i, "src"))
9250 else if (unformat (i, "dst"))
9252 else if (unformat (i, "sport"))
9254 else if (unformat (i, "dport"))
9256 else if (unformat (i, "proto"))
9258 else if (unformat (i, "reverse"))
9263 clib_warning ("parse error '%U'", format_unformat_error, i);
9268 if (vrf_id_set == 0)
9270 errmsg ("missing vrf id");
9274 M (SET_IP_FLOW_HASH, mp);
9280 mp->reverse = reverse;
9281 mp->vrf_id = ntohl (vrf_id);
9282 mp->is_ipv6 = is_ipv6;
9290 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9292 unformat_input_t *i = vam->input;
9293 vl_api_sw_interface_ip6_enable_disable_t *mp;
9295 u8 sw_if_index_set = 0;
9299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9302 sw_if_index_set = 1;
9303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9304 sw_if_index_set = 1;
9305 else if (unformat (i, "enable"))
9307 else if (unformat (i, "disable"))
9311 clib_warning ("parse error '%U'", format_unformat_error, i);
9316 if (sw_if_index_set == 0)
9318 errmsg ("missing interface name or sw_if_index");
9322 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9324 mp->sw_if_index = ntohl (sw_if_index);
9325 mp->enable = enable;
9333 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9335 unformat_input_t *i = vam->input;
9336 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9338 u8 sw_if_index_set = 0;
9339 u8 v6_address_set = 0;
9340 ip6_address_t v6address;
9343 /* Parse args required to build the message */
9344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9347 sw_if_index_set = 1;
9348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9349 sw_if_index_set = 1;
9350 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9356 if (sw_if_index_set == 0)
9358 errmsg ("missing interface name or sw_if_index");
9361 if (!v6_address_set)
9363 errmsg ("no address set");
9367 /* Construct the API message */
9368 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9370 mp->sw_if_index = ntohl (sw_if_index);
9371 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9376 /* Wait for a reply, return good/bad news */
9382 api_ip6nd_proxy_add_del (vat_main_t * vam)
9384 unformat_input_t *i = vam->input;
9385 vl_api_ip6nd_proxy_add_del_t *mp;
9386 u32 sw_if_index = ~0;
9387 u8 v6_address_set = 0;
9388 ip6_address_t v6address;
9392 /* Parse args required to build the message */
9393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9395 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9397 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9399 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9401 if (unformat (i, "del"))
9405 clib_warning ("parse error '%U'", format_unformat_error, i);
9410 if (sw_if_index == ~0)
9412 errmsg ("missing interface name or sw_if_index");
9415 if (!v6_address_set)
9417 errmsg ("no address set");
9421 /* Construct the API message */
9422 M (IP6ND_PROXY_ADD_DEL, mp);
9424 mp->is_del = is_del;
9425 mp->sw_if_index = ntohl (sw_if_index);
9426 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9431 /* Wait for a reply, return good/bad news */
9437 api_ip6nd_proxy_dump (vat_main_t * vam)
9439 vl_api_ip6nd_proxy_dump_t *mp;
9440 vl_api_control_ping_t *mp_ping;
9443 M (IP6ND_PROXY_DUMP, mp);
9447 /* Use a control ping for synchronization */
9448 MPING (CONTROL_PING, mp_ping);
9455 static void vl_api_ip6nd_proxy_details_t_handler
9456 (vl_api_ip6nd_proxy_details_t * mp)
9458 vat_main_t *vam = &vat_main;
9460 print (vam->ofp, "host %U sw_if_index %d",
9461 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9464 static void vl_api_ip6nd_proxy_details_t_handler_json
9465 (vl_api_ip6nd_proxy_details_t * mp)
9467 vat_main_t *vam = &vat_main;
9468 struct in6_addr ip6;
9469 vat_json_node_t *node = NULL;
9471 if (VAT_JSON_ARRAY != vam->json_tree.type)
9473 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9474 vat_json_init_array (&vam->json_tree);
9476 node = vat_json_array_add (&vam->json_tree);
9478 vat_json_init_object (node);
9479 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9481 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9482 vat_json_object_add_ip6 (node, "host", ip6);
9486 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9488 unformat_input_t *i = vam->input;
9489 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9491 u8 sw_if_index_set = 0;
9492 u32 address_length = 0;
9493 u8 v6_address_set = 0;
9494 ip6_address_t v6address;
9496 u8 no_advertise = 0;
9498 u8 no_autoconfig = 0;
9501 u32 val_lifetime = 0;
9502 u32 pref_lifetime = 0;
9505 /* Parse args required to build the message */
9506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9508 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9509 sw_if_index_set = 1;
9510 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9511 sw_if_index_set = 1;
9512 else if (unformat (i, "%U/%d",
9513 unformat_ip6_address, &v6address, &address_length))
9515 else if (unformat (i, "val_life %d", &val_lifetime))
9517 else if (unformat (i, "pref_life %d", &pref_lifetime))
9519 else if (unformat (i, "def"))
9521 else if (unformat (i, "noadv"))
9523 else if (unformat (i, "offl"))
9525 else if (unformat (i, "noauto"))
9527 else if (unformat (i, "nolink"))
9529 else if (unformat (i, "isno"))
9533 clib_warning ("parse error '%U'", format_unformat_error, i);
9538 if (sw_if_index_set == 0)
9540 errmsg ("missing interface name or sw_if_index");
9543 if (!v6_address_set)
9545 errmsg ("no address set");
9549 /* Construct the API message */
9550 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9552 mp->sw_if_index = ntohl (sw_if_index);
9553 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9554 mp->address_length = address_length;
9555 mp->use_default = use_default;
9556 mp->no_advertise = no_advertise;
9557 mp->off_link = off_link;
9558 mp->no_autoconfig = no_autoconfig;
9559 mp->no_onlink = no_onlink;
9561 mp->val_lifetime = ntohl (val_lifetime);
9562 mp->pref_lifetime = ntohl (pref_lifetime);
9567 /* Wait for a reply, return good/bad news */
9573 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9575 unformat_input_t *i = vam->input;
9576 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9578 u8 sw_if_index_set = 0;
9583 u8 send_unicast = 0;
9586 u8 default_router = 0;
9587 u32 max_interval = 0;
9588 u32 min_interval = 0;
9590 u32 initial_count = 0;
9591 u32 initial_interval = 0;
9595 /* Parse args required to build the message */
9596 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9598 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9599 sw_if_index_set = 1;
9600 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9601 sw_if_index_set = 1;
9602 else if (unformat (i, "maxint %d", &max_interval))
9604 else if (unformat (i, "minint %d", &min_interval))
9606 else if (unformat (i, "life %d", &lifetime))
9608 else if (unformat (i, "count %d", &initial_count))
9610 else if (unformat (i, "interval %d", &initial_interval))
9612 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9614 else if (unformat (i, "managed"))
9616 else if (unformat (i, "other"))
9618 else if (unformat (i, "ll"))
9620 else if (unformat (i, "send"))
9622 else if (unformat (i, "cease"))
9624 else if (unformat (i, "isno"))
9626 else if (unformat (i, "def"))
9630 clib_warning ("parse error '%U'", format_unformat_error, i);
9635 if (sw_if_index_set == 0)
9637 errmsg ("missing interface name or sw_if_index");
9641 /* Construct the API message */
9642 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9644 mp->sw_if_index = ntohl (sw_if_index);
9645 mp->max_interval = ntohl (max_interval);
9646 mp->min_interval = ntohl (min_interval);
9647 mp->lifetime = ntohl (lifetime);
9648 mp->initial_count = ntohl (initial_count);
9649 mp->initial_interval = ntohl (initial_interval);
9650 mp->suppress = suppress;
9651 mp->managed = managed;
9653 mp->ll_option = ll_option;
9654 mp->send_unicast = send_unicast;
9657 mp->default_router = default_router;
9662 /* Wait for a reply, return good/bad news */
9668 api_set_arp_neighbor_limit (vat_main_t * vam)
9670 unformat_input_t *i = vam->input;
9671 vl_api_set_arp_neighbor_limit_t *mp;
9677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9679 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9681 else if (unformat (i, "ipv6"))
9685 clib_warning ("parse error '%U'", format_unformat_error, i);
9692 errmsg ("missing limit value");
9696 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9698 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9699 mp->is_ipv6 = is_ipv6;
9707 api_l2_patch_add_del (vat_main_t * vam)
9709 unformat_input_t *i = vam->input;
9710 vl_api_l2_patch_add_del_t *mp;
9712 u8 rx_sw_if_index_set = 0;
9714 u8 tx_sw_if_index_set = 0;
9718 /* Parse args required to build the message */
9719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9721 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9722 rx_sw_if_index_set = 1;
9723 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9724 tx_sw_if_index_set = 1;
9725 else if (unformat (i, "rx"))
9727 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9729 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9731 rx_sw_if_index_set = 1;
9736 else if (unformat (i, "tx"))
9738 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9740 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9742 tx_sw_if_index_set = 1;
9747 else if (unformat (i, "del"))
9753 if (rx_sw_if_index_set == 0)
9755 errmsg ("missing rx interface name or rx_sw_if_index");
9759 if (tx_sw_if_index_set == 0)
9761 errmsg ("missing tx interface name or tx_sw_if_index");
9765 M (L2_PATCH_ADD_DEL, mp);
9767 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9768 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9769 mp->is_add = is_add;
9777 u8 localsid_addr[16];
9786 api_sr_localsid_add_del (vat_main_t * vam)
9788 unformat_input_t *i = vam->input;
9789 vl_api_sr_localsid_add_del_t *mp;
9792 ip6_address_t localsid;
9796 u32 fib_table = ~(u32) 0;
9797 ip6_address_t next_hop;
9799 bool nexthop_set = 0;
9803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9805 if (unformat (i, "del"))
9807 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9808 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9810 else if (unformat (i, "behavior %u", &behavior));
9811 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9812 else if (unformat (i, "fib-table %u", &fib_table));
9813 else if (unformat (i, "end.psp %u", &behavior));
9818 M (SR_LOCALSID_ADD_DEL, mp);
9820 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9822 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9823 mp->behavior = behavior;
9824 mp->sw_if_index = ntohl (sw_if_index);
9825 mp->fib_table = ntohl (fib_table);
9826 mp->end_psp = end_psp;
9827 mp->is_del = is_del;
9835 api_ioam_enable (vat_main_t * vam)
9837 unformat_input_t *input = vam->input;
9838 vl_api_ioam_enable_t *mp;
9840 int has_trace_option = 0;
9841 int has_pot_option = 0;
9842 int has_seqno_option = 0;
9843 int has_analyse_option = 0;
9846 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9848 if (unformat (input, "trace"))
9849 has_trace_option = 1;
9850 else if (unformat (input, "pot"))
9852 else if (unformat (input, "seqno"))
9853 has_seqno_option = 1;
9854 else if (unformat (input, "analyse"))
9855 has_analyse_option = 1;
9859 M (IOAM_ENABLE, mp);
9860 mp->id = htons (id);
9861 mp->seqno = has_seqno_option;
9862 mp->analyse = has_analyse_option;
9863 mp->pot_enable = has_pot_option;
9864 mp->trace_enable = has_trace_option;
9873 api_ioam_disable (vat_main_t * vam)
9875 vl_api_ioam_disable_t *mp;
9878 M (IOAM_DISABLE, mp);
9884 #define foreach_tcp_proto_field \
9888 #define foreach_udp_proto_field \
9892 #define foreach_ip4_proto_field \
9904 u16 src_port, dst_port;
9907 #if VPP_API_TEST_BUILTIN == 0
9909 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9911 u8 **maskp = va_arg (*args, u8 **);
9913 u8 found_something = 0;
9916 #define _(a) u8 a=0;
9917 foreach_tcp_proto_field;
9920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9923 #define _(a) else if (unformat (input, #a)) a=1;
9924 foreach_tcp_proto_field
9930 #define _(a) found_something += a;
9931 foreach_tcp_proto_field;
9934 if (found_something == 0)
9937 vec_validate (mask, sizeof (*tcp) - 1);
9939 tcp = (tcp_header_t *) mask;
9941 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9942 foreach_tcp_proto_field;
9950 unformat_udp_mask (unformat_input_t * input, va_list * args)
9952 u8 **maskp = va_arg (*args, u8 **);
9954 u8 found_something = 0;
9957 #define _(a) u8 a=0;
9958 foreach_udp_proto_field;
9961 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9964 #define _(a) else if (unformat (input, #a)) a=1;
9965 foreach_udp_proto_field
9971 #define _(a) found_something += a;
9972 foreach_udp_proto_field;
9975 if (found_something == 0)
9978 vec_validate (mask, sizeof (*udp) - 1);
9980 udp = (udp_header_t *) mask;
9982 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9983 foreach_udp_proto_field;
9991 unformat_l4_mask (unformat_input_t * input, va_list * args)
9993 u8 **maskp = va_arg (*args, u8 **);
9994 u16 src_port = 0, dst_port = 0;
9995 tcpudp_header_t *tcpudp;
9997 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9999 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10001 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10003 else if (unformat (input, "src_port"))
10005 else if (unformat (input, "dst_port"))
10011 if (!src_port && !dst_port)
10015 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10017 tcpudp = (tcpudp_header_t *) mask;
10018 tcpudp->src_port = src_port;
10019 tcpudp->dst_port = dst_port;
10027 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10029 u8 **maskp = va_arg (*args, u8 **);
10031 u8 found_something = 0;
10034 #define _(a) u8 a=0;
10035 foreach_ip4_proto_field;
10041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10043 if (unformat (input, "version"))
10045 else if (unformat (input, "hdr_length"))
10047 else if (unformat (input, "src"))
10049 else if (unformat (input, "dst"))
10051 else if (unformat (input, "proto"))
10054 #define _(a) else if (unformat (input, #a)) a=1;
10055 foreach_ip4_proto_field
10061 #define _(a) found_something += a;
10062 foreach_ip4_proto_field;
10065 if (found_something == 0)
10068 vec_validate (mask, sizeof (*ip) - 1);
10070 ip = (ip4_header_t *) mask;
10072 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10073 foreach_ip4_proto_field;
10076 ip->ip_version_and_header_length = 0;
10079 ip->ip_version_and_header_length |= 0xF0;
10082 ip->ip_version_and_header_length |= 0x0F;
10088 #define foreach_ip6_proto_field \
10091 _(payload_length) \
10096 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10098 u8 **maskp = va_arg (*args, u8 **);
10100 u8 found_something = 0;
10102 u32 ip_version_traffic_class_and_flow_label;
10104 #define _(a) u8 a=0;
10105 foreach_ip6_proto_field;
10108 u8 traffic_class = 0;
10111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10113 if (unformat (input, "version"))
10115 else if (unformat (input, "traffic-class"))
10117 else if (unformat (input, "flow-label"))
10119 else if (unformat (input, "src"))
10121 else if (unformat (input, "dst"))
10123 else if (unformat (input, "proto"))
10126 #define _(a) else if (unformat (input, #a)) a=1;
10127 foreach_ip6_proto_field
10133 #define _(a) found_something += a;
10134 foreach_ip6_proto_field;
10137 if (found_something == 0)
10140 vec_validate (mask, sizeof (*ip) - 1);
10142 ip = (ip6_header_t *) mask;
10144 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10145 foreach_ip6_proto_field;
10148 ip_version_traffic_class_and_flow_label = 0;
10151 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10154 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10157 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10159 ip->ip_version_traffic_class_and_flow_label =
10160 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10167 unformat_l3_mask (unformat_input_t * input, va_list * args)
10169 u8 **maskp = va_arg (*args, u8 **);
10171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10173 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10175 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10184 unformat_l2_mask (unformat_input_t * input, va_list * args)
10186 u8 **maskp = va_arg (*args, u8 **);
10193 u8 ignore_tag1 = 0;
10194 u8 ignore_tag2 = 0;
10201 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10203 if (unformat (input, "src"))
10205 else if (unformat (input, "dst"))
10207 else if (unformat (input, "proto"))
10209 else if (unformat (input, "tag1"))
10211 else if (unformat (input, "tag2"))
10213 else if (unformat (input, "ignore-tag1"))
10215 else if (unformat (input, "ignore-tag2"))
10217 else if (unformat (input, "cos1"))
10219 else if (unformat (input, "cos2"))
10221 else if (unformat (input, "dot1q"))
10223 else if (unformat (input, "dot1ad"))
10228 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10229 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10232 if (tag1 || ignore_tag1 || cos1 || dot1q)
10234 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10237 vec_validate (mask, len - 1);
10240 memset (mask, 0xff, 6);
10243 memset (mask + 6, 0xff, 6);
10245 if (tag2 || dot1ad)
10247 /* inner vlan tag */
10256 mask[21] = mask[20] = 0xff;
10277 mask[16] = mask[17] = 0xff;
10287 mask[12] = mask[13] = 0xff;
10294 unformat_classify_mask (unformat_input_t * input, va_list * args)
10296 u8 **maskp = va_arg (*args, u8 **);
10297 u32 *skipp = va_arg (*args, u32 *);
10298 u32 *matchp = va_arg (*args, u32 *);
10306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10308 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10310 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10312 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10314 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10328 if (mask || l2 || l3 || l4)
10330 if (l2 || l3 || l4)
10332 /* "With a free Ethernet header in every package" */
10334 vec_validate (l2, 13);
10338 vec_append (mask, l3);
10343 vec_append (mask, l4);
10348 /* Scan forward looking for the first significant mask octet */
10349 for (i = 0; i < vec_len (mask); i++)
10353 /* compute (skip, match) params */
10354 *skipp = i / sizeof (u32x4);
10355 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10357 /* Pad mask to an even multiple of the vector size */
10358 while (vec_len (mask) % sizeof (u32x4))
10359 vec_add1 (mask, 0);
10361 match = vec_len (mask) / sizeof (u32x4);
10363 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10365 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10366 if (*tmp || *(tmp + 1))
10371 clib_warning ("BUG: match 0");
10373 _vec_len (mask) = match * sizeof (u32x4);
10383 #endif /* VPP_API_TEST_BUILTIN */
10385 #define foreach_l2_next \
10387 _(ethernet, ETHERNET_INPUT) \
10388 _(ip4, IP4_INPUT) \
10392 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10394 u32 *miss_next_indexp = va_arg (*args, u32 *);
10395 u32 next_index = 0;
10399 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10403 if (unformat (input, "%d", &tmp))
10412 *miss_next_indexp = next_index;
10416 #define foreach_ip_next \
10419 _(rewrite, REWRITE)
10422 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10424 u32 *miss_next_indexp = va_arg (*args, u32 *);
10425 u32 next_index = 0;
10429 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10433 if (unformat (input, "%d", &tmp))
10442 *miss_next_indexp = next_index;
10446 #define foreach_acl_next \
10450 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10452 u32 *miss_next_indexp = va_arg (*args, u32 *);
10453 u32 next_index = 0;
10457 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10461 if (unformat (input, "permit"))
10466 else if (unformat (input, "%d", &tmp))
10475 *miss_next_indexp = next_index;
10480 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10482 u32 *r = va_arg (*args, u32 *);
10484 if (unformat (input, "conform-color"))
10485 *r = POLICE_CONFORM;
10486 else if (unformat (input, "exceed-color"))
10487 *r = POLICE_EXCEED;
10495 api_classify_add_del_table (vat_main_t * vam)
10497 unformat_input_t *i = vam->input;
10498 vl_api_classify_add_del_table_t *mp;
10505 u32 table_index = ~0;
10506 u32 next_table_index = ~0;
10507 u32 miss_next_index = ~0;
10508 u32 memory_size = 32 << 20;
10510 u32 current_data_flag = 0;
10511 int current_data_offset = 0;
10514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10516 if (unformat (i, "del"))
10518 else if (unformat (i, "del-chain"))
10523 else if (unformat (i, "buckets %d", &nbuckets))
10525 else if (unformat (i, "memory_size %d", &memory_size))
10527 else if (unformat (i, "skip %d", &skip))
10529 else if (unformat (i, "match %d", &match))
10531 else if (unformat (i, "table %d", &table_index))
10533 else if (unformat (i, "mask %U", unformat_classify_mask,
10534 &mask, &skip, &match))
10536 else if (unformat (i, "next-table %d", &next_table_index))
10538 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10541 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10544 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10547 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10549 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10555 if (is_add && mask == 0)
10557 errmsg ("Mask required");
10561 if (is_add && skip == ~0)
10563 errmsg ("skip count required");
10567 if (is_add && match == ~0)
10569 errmsg ("match count required");
10573 if (!is_add && table_index == ~0)
10575 errmsg ("table index required for delete");
10579 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10581 mp->is_add = is_add;
10582 mp->del_chain = del_chain;
10583 mp->table_index = ntohl (table_index);
10584 mp->nbuckets = ntohl (nbuckets);
10585 mp->memory_size = ntohl (memory_size);
10586 mp->skip_n_vectors = ntohl (skip);
10587 mp->match_n_vectors = ntohl (match);
10588 mp->next_table_index = ntohl (next_table_index);
10589 mp->miss_next_index = ntohl (miss_next_index);
10590 mp->current_data_flag = ntohl (current_data_flag);
10591 mp->current_data_offset = ntohl (current_data_offset);
10592 clib_memcpy (mp->mask, mask, vec_len (mask));
10601 #if VPP_API_TEST_BUILTIN == 0
10603 unformat_l4_match (unformat_input_t * input, va_list * args)
10605 u8 **matchp = va_arg (*args, u8 **);
10607 u8 *proto_header = 0;
10613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10615 if (unformat (input, "src_port %d", &src_port))
10617 else if (unformat (input, "dst_port %d", &dst_port))
10623 h.src_port = clib_host_to_net_u16 (src_port);
10624 h.dst_port = clib_host_to_net_u16 (dst_port);
10625 vec_validate (proto_header, sizeof (h) - 1);
10626 memcpy (proto_header, &h, sizeof (h));
10628 *matchp = proto_header;
10634 unformat_ip4_match (unformat_input_t * input, va_list * args)
10636 u8 **matchp = va_arg (*args, u8 **);
10641 int hdr_length = 0;
10642 u32 hdr_length_val;
10643 int src = 0, dst = 0;
10644 ip4_address_t src_val, dst_val;
10651 int fragment_id = 0;
10652 u32 fragment_id_val;
10658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10660 if (unformat (input, "version %d", &version_val))
10662 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10664 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10666 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10668 else if (unformat (input, "proto %d", &proto_val))
10670 else if (unformat (input, "tos %d", &tos_val))
10672 else if (unformat (input, "length %d", &length_val))
10674 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10676 else if (unformat (input, "ttl %d", &ttl_val))
10678 else if (unformat (input, "checksum %d", &checksum_val))
10684 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10685 + ttl + checksum == 0)
10689 * Aligned because we use the real comparison functions
10691 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10693 ip = (ip4_header_t *) match;
10695 /* These are realistically matched in practice */
10697 ip->src_address.as_u32 = src_val.as_u32;
10700 ip->dst_address.as_u32 = dst_val.as_u32;
10703 ip->protocol = proto_val;
10706 /* These are not, but they're included for completeness */
10708 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10711 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10717 ip->length = clib_host_to_net_u16 (length_val);
10723 ip->checksum = clib_host_to_net_u16 (checksum_val);
10730 unformat_ip6_match (unformat_input_t * input, va_list * args)
10732 u8 **matchp = va_arg (*args, u8 **);
10737 u8 traffic_class = 0;
10738 u32 traffic_class_val = 0;
10741 int src = 0, dst = 0;
10742 ip6_address_t src_val, dst_val;
10745 int payload_length = 0;
10746 u32 payload_length_val;
10749 u32 ip_version_traffic_class_and_flow_label;
10751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10753 if (unformat (input, "version %d", &version_val))
10755 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10757 else if (unformat (input, "flow_label %d", &flow_label_val))
10759 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10761 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10763 else if (unformat (input, "proto %d", &proto_val))
10765 else if (unformat (input, "payload_length %d", &payload_length_val))
10766 payload_length = 1;
10767 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10773 if (version + traffic_class + flow_label + src + dst + proto +
10774 payload_length + hop_limit == 0)
10778 * Aligned because we use the real comparison functions
10780 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10782 ip = (ip6_header_t *) match;
10785 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10788 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10791 ip->protocol = proto_val;
10793 ip_version_traffic_class_and_flow_label = 0;
10796 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10799 ip_version_traffic_class_and_flow_label |=
10800 (traffic_class_val & 0xFF) << 20;
10803 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10805 ip->ip_version_traffic_class_and_flow_label =
10806 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10808 if (payload_length)
10809 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10812 ip->hop_limit = hop_limit_val;
10819 unformat_l3_match (unformat_input_t * input, va_list * args)
10821 u8 **matchp = va_arg (*args, u8 **);
10823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10825 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10827 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10836 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10838 u8 *tagp = va_arg (*args, u8 *);
10841 if (unformat (input, "%d", &tag))
10843 tagp[0] = (tag >> 8) & 0x0F;
10844 tagp[1] = tag & 0xFF;
10852 unformat_l2_match (unformat_input_t * input, va_list * args)
10854 u8 **matchp = va_arg (*args, u8 **);
10867 u8 ignore_tag1 = 0;
10868 u8 ignore_tag2 = 0;
10874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10876 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10879 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10881 else if (unformat (input, "proto %U",
10882 unformat_ethernet_type_host_byte_order, &proto_val))
10884 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10886 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10888 else if (unformat (input, "ignore-tag1"))
10890 else if (unformat (input, "ignore-tag2"))
10892 else if (unformat (input, "cos1 %d", &cos1_val))
10894 else if (unformat (input, "cos2 %d", &cos2_val))
10899 if ((src + dst + proto + tag1 + tag2 +
10900 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10903 if (tag1 || ignore_tag1 || cos1)
10905 if (tag2 || ignore_tag2 || cos2)
10908 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10911 clib_memcpy (match, dst_val, 6);
10914 clib_memcpy (match + 6, src_val, 6);
10918 /* inner vlan tag */
10919 match[19] = tag2_val[1];
10920 match[18] = tag2_val[0];
10922 match[18] |= (cos2_val & 0x7) << 5;
10925 match[21] = proto_val & 0xff;
10926 match[20] = proto_val >> 8;
10930 match[15] = tag1_val[1];
10931 match[14] = tag1_val[0];
10934 match[14] |= (cos1_val & 0x7) << 5;
10940 match[15] = tag1_val[1];
10941 match[14] = tag1_val[0];
10944 match[17] = proto_val & 0xff;
10945 match[16] = proto_val >> 8;
10948 match[14] |= (cos1_val & 0x7) << 5;
10954 match[18] |= (cos2_val & 0x7) << 5;
10956 match[14] |= (cos1_val & 0x7) << 5;
10959 match[13] = proto_val & 0xff;
10960 match[12] = proto_val >> 8;
10969 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10971 u8 **matchp = va_arg (*args, u8 **);
10972 u32 skip_n_vectors = va_arg (*args, u32);
10973 u32 match_n_vectors = va_arg (*args, u32);
10980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10982 if (unformat (input, "hex %U", unformat_hex_string, &match))
10984 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10986 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10988 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11002 if (match || l2 || l3 || l4)
11004 if (l2 || l3 || l4)
11006 /* "Win a free Ethernet header in every packet" */
11008 vec_validate_aligned (l2, 13, sizeof (u32x4));
11012 vec_append_aligned (match, l3, sizeof (u32x4));
11017 vec_append_aligned (match, l4, sizeof (u32x4));
11022 /* Make sure the vector is big enough even if key is all 0's */
11023 vec_validate_aligned
11024 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11027 /* Set size, include skipped vectors */
11028 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11039 api_classify_add_del_session (vat_main_t * vam)
11041 unformat_input_t *i = vam->input;
11042 vl_api_classify_add_del_session_t *mp;
11044 u32 table_index = ~0;
11045 u32 hit_next_index = ~0;
11046 u32 opaque_index = ~0;
11049 u32 skip_n_vectors = 0;
11050 u32 match_n_vectors = 0;
11056 * Warning: you have to supply skip_n and match_n
11057 * because the API client cant simply look at the classify
11061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11063 if (unformat (i, "del"))
11065 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11068 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11071 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11074 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11076 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11078 else if (unformat (i, "opaque-index %d", &opaque_index))
11080 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11082 else if (unformat (i, "match_n %d", &match_n_vectors))
11084 else if (unformat (i, "match %U", api_unformat_classify_match,
11085 &match, skip_n_vectors, match_n_vectors))
11087 else if (unformat (i, "advance %d", &advance))
11089 else if (unformat (i, "table-index %d", &table_index))
11091 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11093 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11095 else if (unformat (i, "action %d", &action))
11097 else if (unformat (i, "metadata %d", &metadata))
11103 if (table_index == ~0)
11105 errmsg ("Table index required");
11109 if (is_add && match == 0)
11111 errmsg ("Match value required");
11115 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11117 mp->is_add = is_add;
11118 mp->table_index = ntohl (table_index);
11119 mp->hit_next_index = ntohl (hit_next_index);
11120 mp->opaque_index = ntohl (opaque_index);
11121 mp->advance = ntohl (advance);
11122 mp->action = action;
11123 mp->metadata = ntohl (metadata);
11124 clib_memcpy (mp->match, match, vec_len (match));
11133 api_classify_set_interface_ip_table (vat_main_t * vam)
11135 unformat_input_t *i = vam->input;
11136 vl_api_classify_set_interface_ip_table_t *mp;
11138 int sw_if_index_set;
11139 u32 table_index = ~0;
11143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11146 sw_if_index_set = 1;
11147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11148 sw_if_index_set = 1;
11149 else if (unformat (i, "table %d", &table_index))
11153 clib_warning ("parse error '%U'", format_unformat_error, i);
11158 if (sw_if_index_set == 0)
11160 errmsg ("missing interface name or sw_if_index");
11165 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11167 mp->sw_if_index = ntohl (sw_if_index);
11168 mp->table_index = ntohl (table_index);
11169 mp->is_ipv6 = is_ipv6;
11177 api_classify_set_interface_l2_tables (vat_main_t * vam)
11179 unformat_input_t *i = vam->input;
11180 vl_api_classify_set_interface_l2_tables_t *mp;
11182 int sw_if_index_set;
11183 u32 ip4_table_index = ~0;
11184 u32 ip6_table_index = ~0;
11185 u32 other_table_index = ~0;
11189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11197 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11199 else if (unformat (i, "other-table %d", &other_table_index))
11201 else if (unformat (i, "is-input %d", &is_input))
11205 clib_warning ("parse error '%U'", format_unformat_error, i);
11210 if (sw_if_index_set == 0)
11212 errmsg ("missing interface name or sw_if_index");
11217 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11219 mp->sw_if_index = ntohl (sw_if_index);
11220 mp->ip4_table_index = ntohl (ip4_table_index);
11221 mp->ip6_table_index = ntohl (ip6_table_index);
11222 mp->other_table_index = ntohl (other_table_index);
11223 mp->is_input = (u8) is_input;
11231 api_set_ipfix_exporter (vat_main_t * vam)
11233 unformat_input_t *i = vam->input;
11234 vl_api_set_ipfix_exporter_t *mp;
11235 ip4_address_t collector_address;
11236 u8 collector_address_set = 0;
11237 u32 collector_port = ~0;
11238 ip4_address_t src_address;
11239 u8 src_address_set = 0;
11242 u32 template_interval = ~0;
11243 u8 udp_checksum = 0;
11246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (i, "collector_address %U", unformat_ip4_address,
11249 &collector_address))
11250 collector_address_set = 1;
11251 else if (unformat (i, "collector_port %d", &collector_port))
11253 else if (unformat (i, "src_address %U", unformat_ip4_address,
11255 src_address_set = 1;
11256 else if (unformat (i, "vrf_id %d", &vrf_id))
11258 else if (unformat (i, "path_mtu %d", &path_mtu))
11260 else if (unformat (i, "template_interval %d", &template_interval))
11262 else if (unformat (i, "udp_checksum"))
11268 if (collector_address_set == 0)
11270 errmsg ("collector_address required");
11274 if (src_address_set == 0)
11276 errmsg ("src_address required");
11280 M (SET_IPFIX_EXPORTER, mp);
11282 memcpy (mp->collector_address, collector_address.data,
11283 sizeof (collector_address.data));
11284 mp->collector_port = htons ((u16) collector_port);
11285 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11286 mp->vrf_id = htonl (vrf_id);
11287 mp->path_mtu = htonl (path_mtu);
11288 mp->template_interval = htonl (template_interval);
11289 mp->udp_checksum = udp_checksum;
11297 api_set_ipfix_classify_stream (vat_main_t * vam)
11299 unformat_input_t *i = vam->input;
11300 vl_api_set_ipfix_classify_stream_t *mp;
11302 u32 src_port = UDP_DST_PORT_ipfix;
11305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11307 if (unformat (i, "domain %d", &domain_id))
11309 else if (unformat (i, "src_port %d", &src_port))
11313 errmsg ("unknown input `%U'", format_unformat_error, i);
11318 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11320 mp->domain_id = htonl (domain_id);
11321 mp->src_port = htons ((u16) src_port);
11329 api_ipfix_classify_table_add_del (vat_main_t * vam)
11331 unformat_input_t *i = vam->input;
11332 vl_api_ipfix_classify_table_add_del_t *mp;
11334 u32 classify_table_index = ~0;
11336 u8 transport_protocol = 255;
11339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11341 if (unformat (i, "add"))
11343 else if (unformat (i, "del"))
11345 else if (unformat (i, "table %d", &classify_table_index))
11347 else if (unformat (i, "ip4"))
11349 else if (unformat (i, "ip6"))
11351 else if (unformat (i, "tcp"))
11352 transport_protocol = 6;
11353 else if (unformat (i, "udp"))
11354 transport_protocol = 17;
11357 errmsg ("unknown input `%U'", format_unformat_error, i);
11364 errmsg ("expecting: add|del");
11367 if (classify_table_index == ~0)
11369 errmsg ("classifier table not specified");
11372 if (ip_version == 0)
11374 errmsg ("IP version not specified");
11378 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11380 mp->is_add = is_add;
11381 mp->table_id = htonl (classify_table_index);
11382 mp->ip_version = ip_version;
11383 mp->transport_protocol = transport_protocol;
11391 api_get_node_index (vat_main_t * vam)
11393 unformat_input_t *i = vam->input;
11394 vl_api_get_node_index_t *mp;
11398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11400 if (unformat (i, "node %s", &name))
11407 errmsg ("node name required");
11410 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11412 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11416 M (GET_NODE_INDEX, mp);
11417 clib_memcpy (mp->node_name, name, vec_len (name));
11426 api_get_next_index (vat_main_t * vam)
11428 unformat_input_t *i = vam->input;
11429 vl_api_get_next_index_t *mp;
11430 u8 *node_name = 0, *next_node_name = 0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "node-name %s", &node_name))
11437 else if (unformat (i, "next-node-name %s", &next_node_name))
11441 if (node_name == 0)
11443 errmsg ("node name required");
11446 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11448 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11452 if (next_node_name == 0)
11454 errmsg ("next node name required");
11457 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11459 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11463 M (GET_NEXT_INDEX, mp);
11464 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11465 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11466 vec_free (node_name);
11467 vec_free (next_node_name);
11475 api_add_node_next (vat_main_t * vam)
11477 unformat_input_t *i = vam->input;
11478 vl_api_add_node_next_t *mp;
11483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (i, "node %s", &name))
11487 else if (unformat (i, "next %s", &next))
11494 errmsg ("node name required");
11497 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11499 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11504 errmsg ("next node required");
11507 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11509 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11513 M (ADD_NODE_NEXT, mp);
11514 clib_memcpy (mp->node_name, name, vec_len (name));
11515 clib_memcpy (mp->next_name, next, vec_len (next));
11525 api_l2tpv3_create_tunnel (vat_main_t * vam)
11527 unformat_input_t *i = vam->input;
11528 ip6_address_t client_address, our_address;
11529 int client_address_set = 0;
11530 int our_address_set = 0;
11531 u32 local_session_id = 0;
11532 u32 remote_session_id = 0;
11533 u64 local_cookie = 0;
11534 u64 remote_cookie = 0;
11535 u8 l2_sublayer_present = 0;
11536 vl_api_l2tpv3_create_tunnel_t *mp;
11539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11541 if (unformat (i, "client_address %U", unformat_ip6_address,
11543 client_address_set = 1;
11544 else if (unformat (i, "our_address %U", unformat_ip6_address,
11546 our_address_set = 1;
11547 else if (unformat (i, "local_session_id %d", &local_session_id))
11549 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11551 else if (unformat (i, "local_cookie %lld", &local_cookie))
11553 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11555 else if (unformat (i, "l2-sublayer-present"))
11556 l2_sublayer_present = 1;
11561 if (client_address_set == 0)
11563 errmsg ("client_address required");
11567 if (our_address_set == 0)
11569 errmsg ("our_address required");
11573 M (L2TPV3_CREATE_TUNNEL, mp);
11575 clib_memcpy (mp->client_address, client_address.as_u8,
11576 sizeof (mp->client_address));
11578 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11580 mp->local_session_id = ntohl (local_session_id);
11581 mp->remote_session_id = ntohl (remote_session_id);
11582 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11583 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11584 mp->l2_sublayer_present = l2_sublayer_present;
11593 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11595 unformat_input_t *i = vam->input;
11597 u8 sw_if_index_set = 0;
11598 u64 new_local_cookie = 0;
11599 u64 new_remote_cookie = 0;
11600 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11606 sw_if_index_set = 1;
11607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11608 sw_if_index_set = 1;
11609 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11611 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11617 if (sw_if_index_set == 0)
11619 errmsg ("missing interface name or sw_if_index");
11623 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11625 mp->sw_if_index = ntohl (sw_if_index);
11626 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11627 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11635 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11637 unformat_input_t *i = vam->input;
11638 vl_api_l2tpv3_interface_enable_disable_t *mp;
11640 u8 sw_if_index_set = 0;
11641 u8 enable_disable = 1;
11644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11647 sw_if_index_set = 1;
11648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11649 sw_if_index_set = 1;
11650 else if (unformat (i, "enable"))
11651 enable_disable = 1;
11652 else if (unformat (i, "disable"))
11653 enable_disable = 0;
11658 if (sw_if_index_set == 0)
11660 errmsg ("missing interface name or sw_if_index");
11664 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11666 mp->sw_if_index = ntohl (sw_if_index);
11667 mp->enable_disable = enable_disable;
11675 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11677 unformat_input_t *i = vam->input;
11678 vl_api_l2tpv3_set_lookup_key_t *mp;
11682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11684 if (unformat (i, "lookup_v6_src"))
11685 key = L2T_LOOKUP_SRC_ADDRESS;
11686 else if (unformat (i, "lookup_v6_dst"))
11687 key = L2T_LOOKUP_DST_ADDRESS;
11688 else if (unformat (i, "lookup_session_id"))
11689 key = L2T_LOOKUP_SESSION_ID;
11694 if (key == (u8) ~ 0)
11696 errmsg ("l2tp session lookup key unset");
11700 M (L2TPV3_SET_LOOKUP_KEY, mp);
11709 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11710 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11712 vat_main_t *vam = &vat_main;
11714 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11715 format_ip6_address, mp->our_address,
11716 format_ip6_address, mp->client_address,
11717 clib_net_to_host_u32 (mp->sw_if_index));
11720 " local cookies %016llx %016llx remote cookie %016llx",
11721 clib_net_to_host_u64 (mp->local_cookie[0]),
11722 clib_net_to_host_u64 (mp->local_cookie[1]),
11723 clib_net_to_host_u64 (mp->remote_cookie));
11725 print (vam->ofp, " local session-id %d remote session-id %d",
11726 clib_net_to_host_u32 (mp->local_session_id),
11727 clib_net_to_host_u32 (mp->remote_session_id));
11729 print (vam->ofp, " l2 specific sublayer %s\n",
11730 mp->l2_sublayer_present ? "preset" : "absent");
11734 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11735 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11737 vat_main_t *vam = &vat_main;
11738 vat_json_node_t *node = NULL;
11739 struct in6_addr addr;
11741 if (VAT_JSON_ARRAY != vam->json_tree.type)
11743 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11744 vat_json_init_array (&vam->json_tree);
11746 node = vat_json_array_add (&vam->json_tree);
11748 vat_json_init_object (node);
11750 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11751 vat_json_object_add_ip6 (node, "our_address", addr);
11752 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11753 vat_json_object_add_ip6 (node, "client_address", addr);
11755 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11756 vat_json_init_array (lc);
11757 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11758 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11759 vat_json_object_add_uint (node, "remote_cookie",
11760 clib_net_to_host_u64 (mp->remote_cookie));
11762 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11763 vat_json_object_add_uint (node, "local_session_id",
11764 clib_net_to_host_u32 (mp->local_session_id));
11765 vat_json_object_add_uint (node, "remote_session_id",
11766 clib_net_to_host_u32 (mp->remote_session_id));
11767 vat_json_object_add_string_copy (node, "l2_sublayer",
11768 mp->l2_sublayer_present ? (u8 *) "present"
11769 : (u8 *) "absent");
11773 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11775 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11776 vl_api_control_ping_t *mp_ping;
11779 /* Get list of l2tpv3-tunnel interfaces */
11780 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11783 /* Use a control ping for synchronization */
11784 MPING (CONTROL_PING, mp_ping);
11792 static void vl_api_sw_interface_tap_details_t_handler
11793 (vl_api_sw_interface_tap_details_t * mp)
11795 vat_main_t *vam = &vat_main;
11797 print (vam->ofp, "%-16s %d",
11798 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11801 static void vl_api_sw_interface_tap_details_t_handler_json
11802 (vl_api_sw_interface_tap_details_t * mp)
11804 vat_main_t *vam = &vat_main;
11805 vat_json_node_t *node = NULL;
11807 if (VAT_JSON_ARRAY != vam->json_tree.type)
11809 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11810 vat_json_init_array (&vam->json_tree);
11812 node = vat_json_array_add (&vam->json_tree);
11814 vat_json_init_object (node);
11815 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11816 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11820 api_sw_interface_tap_dump (vat_main_t * vam)
11822 vl_api_sw_interface_tap_dump_t *mp;
11823 vl_api_control_ping_t *mp_ping;
11826 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11827 /* Get list of tap interfaces */
11828 M (SW_INTERFACE_TAP_DUMP, mp);
11831 /* Use a control ping for synchronization */
11832 MPING (CONTROL_PING, mp_ping);
11839 static uword unformat_vxlan_decap_next
11840 (unformat_input_t * input, va_list * args)
11842 u32 *result = va_arg (*args, u32 *);
11845 if (unformat (input, "l2"))
11846 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11847 else if (unformat (input, "%d", &tmp))
11855 api_vxlan_add_del_tunnel (vat_main_t * vam)
11857 unformat_input_t *line_input = vam->input;
11858 vl_api_vxlan_add_del_tunnel_t *mp;
11859 ip46_address_t src, dst;
11861 u8 ipv4_set = 0, ipv6_set = 0;
11865 u32 mcast_sw_if_index = ~0;
11866 u32 encap_vrf_id = 0;
11867 u32 decap_next_index = ~0;
11871 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11872 memset (&src, 0, sizeof src);
11873 memset (&dst, 0, sizeof dst);
11875 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11877 if (unformat (line_input, "del"))
11880 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11886 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11892 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11898 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11903 else if (unformat (line_input, "group %U %U",
11904 unformat_ip4_address, &dst.ip4,
11905 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11907 grp_set = dst_set = 1;
11910 else if (unformat (line_input, "group %U",
11911 unformat_ip4_address, &dst.ip4))
11913 grp_set = dst_set = 1;
11916 else if (unformat (line_input, "group %U %U",
11917 unformat_ip6_address, &dst.ip6,
11918 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11920 grp_set = dst_set = 1;
11923 else if (unformat (line_input, "group %U",
11924 unformat_ip6_address, &dst.ip6))
11926 grp_set = dst_set = 1;
11930 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11932 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11934 else if (unformat (line_input, "decap-next %U",
11935 unformat_vxlan_decap_next, &decap_next_index))
11937 else if (unformat (line_input, "vni %d", &vni))
11941 errmsg ("parse error '%U'", format_unformat_error, line_input);
11948 errmsg ("tunnel src address not specified");
11953 errmsg ("tunnel dst address not specified");
11957 if (grp_set && !ip46_address_is_multicast (&dst))
11959 errmsg ("tunnel group address not multicast");
11962 if (grp_set && mcast_sw_if_index == ~0)
11964 errmsg ("tunnel nonexistent multicast device");
11967 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11969 errmsg ("tunnel dst address must be unicast");
11974 if (ipv4_set && ipv6_set)
11976 errmsg ("both IPv4 and IPv6 addresses specified");
11980 if ((vni == 0) || (vni >> 24))
11982 errmsg ("vni not specified or out of range");
11986 M (VXLAN_ADD_DEL_TUNNEL, mp);
11990 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11991 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11995 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11996 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11998 mp->encap_vrf_id = ntohl (encap_vrf_id);
11999 mp->decap_next_index = ntohl (decap_next_index);
12000 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12001 mp->vni = ntohl (vni);
12002 mp->is_add = is_add;
12003 mp->is_ipv6 = ipv6_set;
12010 static void vl_api_vxlan_tunnel_details_t_handler
12011 (vl_api_vxlan_tunnel_details_t * mp)
12013 vat_main_t *vam = &vat_main;
12014 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12015 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12017 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12018 ntohl (mp->sw_if_index),
12019 format_ip46_address, &src, IP46_TYPE_ANY,
12020 format_ip46_address, &dst, IP46_TYPE_ANY,
12021 ntohl (mp->encap_vrf_id),
12022 ntohl (mp->decap_next_index), ntohl (mp->vni),
12023 ntohl (mp->mcast_sw_if_index));
12026 static void vl_api_vxlan_tunnel_details_t_handler_json
12027 (vl_api_vxlan_tunnel_details_t * mp)
12029 vat_main_t *vam = &vat_main;
12030 vat_json_node_t *node = NULL;
12032 if (VAT_JSON_ARRAY != vam->json_tree.type)
12034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12035 vat_json_init_array (&vam->json_tree);
12037 node = vat_json_array_add (&vam->json_tree);
12039 vat_json_init_object (node);
12040 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12043 struct in6_addr ip6;
12045 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12046 vat_json_object_add_ip6 (node, "src_address", ip6);
12047 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12048 vat_json_object_add_ip6 (node, "dst_address", ip6);
12052 struct in_addr ip4;
12054 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12055 vat_json_object_add_ip4 (node, "src_address", ip4);
12056 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12057 vat_json_object_add_ip4 (node, "dst_address", ip4);
12059 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12060 vat_json_object_add_uint (node, "decap_next_index",
12061 ntohl (mp->decap_next_index));
12062 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12063 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12064 vat_json_object_add_uint (node, "mcast_sw_if_index",
12065 ntohl (mp->mcast_sw_if_index));
12069 api_vxlan_tunnel_dump (vat_main_t * vam)
12071 unformat_input_t *i = vam->input;
12072 vl_api_vxlan_tunnel_dump_t *mp;
12073 vl_api_control_ping_t *mp_ping;
12075 u8 sw_if_index_set = 0;
12078 /* Parse args required to build the message */
12079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12081 if (unformat (i, "sw_if_index %d", &sw_if_index))
12082 sw_if_index_set = 1;
12087 if (sw_if_index_set == 0)
12092 if (!vam->json_output)
12094 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12095 "sw_if_index", "src_address", "dst_address",
12096 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12099 /* Get list of vxlan-tunnel interfaces */
12100 M (VXLAN_TUNNEL_DUMP, mp);
12102 mp->sw_if_index = htonl (sw_if_index);
12106 /* Use a control ping for synchronization */
12107 MPING (CONTROL_PING, mp_ping);
12114 static uword unformat_geneve_decap_next
12115 (unformat_input_t * input, va_list * args)
12117 u32 *result = va_arg (*args, u32 *);
12120 if (unformat (input, "l2"))
12121 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12122 else if (unformat (input, "%d", &tmp))
12130 api_geneve_add_del_tunnel (vat_main_t * vam)
12132 unformat_input_t *line_input = vam->input;
12133 vl_api_geneve_add_del_tunnel_t *mp;
12134 ip46_address_t src, dst;
12136 u8 ipv4_set = 0, ipv6_set = 0;
12140 u32 mcast_sw_if_index = ~0;
12141 u32 encap_vrf_id = 0;
12142 u32 decap_next_index = ~0;
12146 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12147 memset (&src, 0, sizeof src);
12148 memset (&dst, 0, sizeof dst);
12150 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12152 if (unformat (line_input, "del"))
12155 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12161 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12167 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12173 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12178 else if (unformat (line_input, "group %U %U",
12179 unformat_ip4_address, &dst.ip4,
12180 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12182 grp_set = dst_set = 1;
12185 else if (unformat (line_input, "group %U",
12186 unformat_ip4_address, &dst.ip4))
12188 grp_set = dst_set = 1;
12191 else if (unformat (line_input, "group %U %U",
12192 unformat_ip6_address, &dst.ip6,
12193 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12195 grp_set = dst_set = 1;
12198 else if (unformat (line_input, "group %U",
12199 unformat_ip6_address, &dst.ip6))
12201 grp_set = dst_set = 1;
12205 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12207 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12209 else if (unformat (line_input, "decap-next %U",
12210 unformat_geneve_decap_next, &decap_next_index))
12212 else if (unformat (line_input, "vni %d", &vni))
12216 errmsg ("parse error '%U'", format_unformat_error, line_input);
12223 errmsg ("tunnel src address not specified");
12228 errmsg ("tunnel dst address not specified");
12232 if (grp_set && !ip46_address_is_multicast (&dst))
12234 errmsg ("tunnel group address not multicast");
12237 if (grp_set && mcast_sw_if_index == ~0)
12239 errmsg ("tunnel nonexistent multicast device");
12242 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12244 errmsg ("tunnel dst address must be unicast");
12249 if (ipv4_set && ipv6_set)
12251 errmsg ("both IPv4 and IPv6 addresses specified");
12255 if ((vni == 0) || (vni >> 24))
12257 errmsg ("vni not specified or out of range");
12261 M (GENEVE_ADD_DEL_TUNNEL, mp);
12265 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12266 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12270 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12271 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12273 mp->encap_vrf_id = ntohl (encap_vrf_id);
12274 mp->decap_next_index = ntohl (decap_next_index);
12275 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12276 mp->vni = ntohl (vni);
12277 mp->is_add = is_add;
12278 mp->is_ipv6 = ipv6_set;
12285 static void vl_api_geneve_tunnel_details_t_handler
12286 (vl_api_geneve_tunnel_details_t * mp)
12288 vat_main_t *vam = &vat_main;
12289 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12290 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12292 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12293 ntohl (mp->sw_if_index),
12294 format_ip46_address, &src, IP46_TYPE_ANY,
12295 format_ip46_address, &dst, IP46_TYPE_ANY,
12296 ntohl (mp->encap_vrf_id),
12297 ntohl (mp->decap_next_index), ntohl (mp->vni),
12298 ntohl (mp->mcast_sw_if_index));
12301 static void vl_api_geneve_tunnel_details_t_handler_json
12302 (vl_api_geneve_tunnel_details_t * mp)
12304 vat_main_t *vam = &vat_main;
12305 vat_json_node_t *node = NULL;
12307 if (VAT_JSON_ARRAY != vam->json_tree.type)
12309 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12310 vat_json_init_array (&vam->json_tree);
12312 node = vat_json_array_add (&vam->json_tree);
12314 vat_json_init_object (node);
12315 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12318 struct in6_addr ip6;
12320 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12321 vat_json_object_add_ip6 (node, "src_address", ip6);
12322 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12323 vat_json_object_add_ip6 (node, "dst_address", ip6);
12327 struct in_addr ip4;
12329 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12330 vat_json_object_add_ip4 (node, "src_address", ip4);
12331 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12332 vat_json_object_add_ip4 (node, "dst_address", ip4);
12334 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12335 vat_json_object_add_uint (node, "decap_next_index",
12336 ntohl (mp->decap_next_index));
12337 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12338 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12339 vat_json_object_add_uint (node, "mcast_sw_if_index",
12340 ntohl (mp->mcast_sw_if_index));
12344 api_geneve_tunnel_dump (vat_main_t * vam)
12346 unformat_input_t *i = vam->input;
12347 vl_api_geneve_tunnel_dump_t *mp;
12348 vl_api_control_ping_t *mp_ping;
12350 u8 sw_if_index_set = 0;
12353 /* Parse args required to build the message */
12354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12356 if (unformat (i, "sw_if_index %d", &sw_if_index))
12357 sw_if_index_set = 1;
12362 if (sw_if_index_set == 0)
12367 if (!vam->json_output)
12369 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12370 "sw_if_index", "local_address", "remote_address",
12371 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12374 /* Get list of geneve-tunnel interfaces */
12375 M (GENEVE_TUNNEL_DUMP, mp);
12377 mp->sw_if_index = htonl (sw_if_index);
12381 /* Use a control ping for synchronization */
12382 M (CONTROL_PING, mp_ping);
12390 api_gre_add_del_tunnel (vat_main_t * vam)
12392 unformat_input_t *line_input = vam->input;
12393 vl_api_gre_add_del_tunnel_t *mp;
12394 ip4_address_t src4, dst4;
12395 ip6_address_t src6, dst6;
12402 u32 outer_fib_id = 0;
12405 memset (&src4, 0, sizeof src4);
12406 memset (&dst4, 0, sizeof dst4);
12407 memset (&src6, 0, sizeof src6);
12408 memset (&dst6, 0, sizeof dst6);
12410 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12412 if (unformat (line_input, "del"))
12414 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12419 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12424 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12429 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12434 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12436 else if (unformat (line_input, "teb"))
12440 errmsg ("parse error '%U'", format_unformat_error, line_input);
12447 errmsg ("tunnel src address not specified");
12452 errmsg ("tunnel dst address not specified");
12455 if (ipv4_set && ipv6_set)
12457 errmsg ("both IPv4 and IPv6 addresses specified");
12462 M (GRE_ADD_DEL_TUNNEL, mp);
12466 clib_memcpy (&mp->src_address, &src4, 4);
12467 clib_memcpy (&mp->dst_address, &dst4, 4);
12471 clib_memcpy (&mp->src_address, &src6, 16);
12472 clib_memcpy (&mp->dst_address, &dst6, 16);
12474 mp->outer_fib_id = ntohl (outer_fib_id);
12475 mp->is_add = is_add;
12477 mp->is_ipv6 = ipv6_set;
12484 static void vl_api_gre_tunnel_details_t_handler
12485 (vl_api_gre_tunnel_details_t * mp)
12487 vat_main_t *vam = &vat_main;
12488 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12489 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12491 print (vam->ofp, "%11d%24U%24U%6d%14d",
12492 ntohl (mp->sw_if_index),
12493 format_ip46_address, &src, IP46_TYPE_ANY,
12494 format_ip46_address, &dst, IP46_TYPE_ANY,
12495 mp->teb, ntohl (mp->outer_fib_id));
12498 static void vl_api_gre_tunnel_details_t_handler_json
12499 (vl_api_gre_tunnel_details_t * mp)
12501 vat_main_t *vam = &vat_main;
12502 vat_json_node_t *node = NULL;
12503 struct in_addr ip4;
12504 struct in6_addr ip6;
12506 if (VAT_JSON_ARRAY != vam->json_tree.type)
12508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12509 vat_json_init_array (&vam->json_tree);
12511 node = vat_json_array_add (&vam->json_tree);
12513 vat_json_init_object (node);
12514 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12517 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12518 vat_json_object_add_ip4 (node, "src_address", ip4);
12519 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12520 vat_json_object_add_ip4 (node, "dst_address", ip4);
12524 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12525 vat_json_object_add_ip6 (node, "src_address", ip6);
12526 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12527 vat_json_object_add_ip6 (node, "dst_address", ip6);
12529 vat_json_object_add_uint (node, "teb", mp->teb);
12530 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12531 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12535 api_gre_tunnel_dump (vat_main_t * vam)
12537 unformat_input_t *i = vam->input;
12538 vl_api_gre_tunnel_dump_t *mp;
12539 vl_api_control_ping_t *mp_ping;
12541 u8 sw_if_index_set = 0;
12544 /* Parse args required to build the message */
12545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12547 if (unformat (i, "sw_if_index %d", &sw_if_index))
12548 sw_if_index_set = 1;
12553 if (sw_if_index_set == 0)
12558 if (!vam->json_output)
12560 print (vam->ofp, "%11s%24s%24s%6s%14s",
12561 "sw_if_index", "src_address", "dst_address", "teb",
12565 /* Get list of gre-tunnel interfaces */
12566 M (GRE_TUNNEL_DUMP, mp);
12568 mp->sw_if_index = htonl (sw_if_index);
12572 /* Use a control ping for synchronization */
12573 MPING (CONTROL_PING, mp_ping);
12581 api_l2_fib_clear_table (vat_main_t * vam)
12583 // unformat_input_t * i = vam->input;
12584 vl_api_l2_fib_clear_table_t *mp;
12587 M (L2_FIB_CLEAR_TABLE, mp);
12595 api_l2_interface_efp_filter (vat_main_t * vam)
12597 unformat_input_t *i = vam->input;
12598 vl_api_l2_interface_efp_filter_t *mp;
12601 u8 sw_if_index_set = 0;
12604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12606 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12607 sw_if_index_set = 1;
12608 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12609 sw_if_index_set = 1;
12610 else if (unformat (i, "enable"))
12612 else if (unformat (i, "disable"))
12616 clib_warning ("parse error '%U'", format_unformat_error, i);
12621 if (sw_if_index_set == 0)
12623 errmsg ("missing sw_if_index");
12627 M (L2_INTERFACE_EFP_FILTER, mp);
12629 mp->sw_if_index = ntohl (sw_if_index);
12630 mp->enable_disable = enable;
12637 #define foreach_vtr_op \
12638 _("disable", L2_VTR_DISABLED) \
12639 _("push-1", L2_VTR_PUSH_1) \
12640 _("push-2", L2_VTR_PUSH_2) \
12641 _("pop-1", L2_VTR_POP_1) \
12642 _("pop-2", L2_VTR_POP_2) \
12643 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12644 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12645 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12646 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12649 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12651 unformat_input_t *i = vam->input;
12652 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12654 u8 sw_if_index_set = 0;
12657 u32 push_dot1q = 1;
12662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12664 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12665 sw_if_index_set = 1;
12666 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12667 sw_if_index_set = 1;
12668 else if (unformat (i, "vtr_op %d", &vtr_op))
12670 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12673 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12675 else if (unformat (i, "tag1 %d", &tag1))
12677 else if (unformat (i, "tag2 %d", &tag2))
12681 clib_warning ("parse error '%U'", format_unformat_error, i);
12686 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12688 errmsg ("missing vtr operation or sw_if_index");
12692 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12693 mp->sw_if_index = ntohl (sw_if_index);
12694 mp->vtr_op = ntohl (vtr_op);
12695 mp->push_dot1q = ntohl (push_dot1q);
12696 mp->tag1 = ntohl (tag1);
12697 mp->tag2 = ntohl (tag2);
12705 api_create_vhost_user_if (vat_main_t * vam)
12707 unformat_input_t *i = vam->input;
12708 vl_api_create_vhost_user_if_t *mp;
12711 u8 file_name_set = 0;
12712 u32 custom_dev_instance = ~0;
12714 u8 use_custom_mac = 0;
12718 /* Shut up coverity */
12719 memset (hwaddr, 0, sizeof (hwaddr));
12721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12723 if (unformat (i, "socket %s", &file_name))
12727 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12729 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12730 use_custom_mac = 1;
12731 else if (unformat (i, "server"))
12733 else if (unformat (i, "tag %s", &tag))
12739 if (file_name_set == 0)
12741 errmsg ("missing socket file name");
12745 if (vec_len (file_name) > 255)
12747 errmsg ("socket file name too long");
12750 vec_add1 (file_name, 0);
12752 M (CREATE_VHOST_USER_IF, mp);
12754 mp->is_server = is_server;
12755 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12756 vec_free (file_name);
12757 if (custom_dev_instance != ~0)
12760 mp->custom_dev_instance = ntohl (custom_dev_instance);
12762 mp->use_custom_mac = use_custom_mac;
12763 clib_memcpy (mp->mac_address, hwaddr, 6);
12765 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12774 api_modify_vhost_user_if (vat_main_t * vam)
12776 unformat_input_t *i = vam->input;
12777 vl_api_modify_vhost_user_if_t *mp;
12780 u8 file_name_set = 0;
12781 u32 custom_dev_instance = ~0;
12782 u8 sw_if_index_set = 0;
12783 u32 sw_if_index = (u32) ~ 0;
12786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12789 sw_if_index_set = 1;
12790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12791 sw_if_index_set = 1;
12792 else if (unformat (i, "socket %s", &file_name))
12796 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12798 else if (unformat (i, "server"))
12804 if (sw_if_index_set == 0)
12806 errmsg ("missing sw_if_index or interface name");
12810 if (file_name_set == 0)
12812 errmsg ("missing socket file name");
12816 if (vec_len (file_name) > 255)
12818 errmsg ("socket file name too long");
12821 vec_add1 (file_name, 0);
12823 M (MODIFY_VHOST_USER_IF, mp);
12825 mp->sw_if_index = ntohl (sw_if_index);
12826 mp->is_server = is_server;
12827 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12828 vec_free (file_name);
12829 if (custom_dev_instance != ~0)
12832 mp->custom_dev_instance = ntohl (custom_dev_instance);
12841 api_delete_vhost_user_if (vat_main_t * vam)
12843 unformat_input_t *i = vam->input;
12844 vl_api_delete_vhost_user_if_t *mp;
12845 u32 sw_if_index = ~0;
12846 u8 sw_if_index_set = 0;
12849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12851 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12852 sw_if_index_set = 1;
12853 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12854 sw_if_index_set = 1;
12859 if (sw_if_index_set == 0)
12861 errmsg ("missing sw_if_index or interface name");
12866 M (DELETE_VHOST_USER_IF, mp);
12868 mp->sw_if_index = ntohl (sw_if_index);
12875 static void vl_api_sw_interface_vhost_user_details_t_handler
12876 (vl_api_sw_interface_vhost_user_details_t * mp)
12878 vat_main_t *vam = &vat_main;
12880 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12881 (char *) mp->interface_name,
12882 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12883 clib_net_to_host_u64 (mp->features), mp->is_server,
12884 ntohl (mp->num_regions), (char *) mp->sock_filename);
12885 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12888 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12889 (vl_api_sw_interface_vhost_user_details_t * mp)
12891 vat_main_t *vam = &vat_main;
12892 vat_json_node_t *node = NULL;
12894 if (VAT_JSON_ARRAY != vam->json_tree.type)
12896 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12897 vat_json_init_array (&vam->json_tree);
12899 node = vat_json_array_add (&vam->json_tree);
12901 vat_json_init_object (node);
12902 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12903 vat_json_object_add_string_copy (node, "interface_name",
12904 mp->interface_name);
12905 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12906 ntohl (mp->virtio_net_hdr_sz));
12907 vat_json_object_add_uint (node, "features",
12908 clib_net_to_host_u64 (mp->features));
12909 vat_json_object_add_uint (node, "is_server", mp->is_server);
12910 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12911 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12912 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12916 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12918 vl_api_sw_interface_vhost_user_dump_t *mp;
12919 vl_api_control_ping_t *mp_ping;
12922 "Interface name idx hdr_sz features server regions filename");
12924 /* Get list of vhost-user interfaces */
12925 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12928 /* Use a control ping for synchronization */
12929 MPING (CONTROL_PING, mp_ping);
12937 api_show_version (vat_main_t * vam)
12939 vl_api_show_version_t *mp;
12942 M (SHOW_VERSION, mp);
12951 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12953 unformat_input_t *line_input = vam->input;
12954 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12955 ip4_address_t local4, remote4;
12956 ip6_address_t local6, remote6;
12958 u8 ipv4_set = 0, ipv6_set = 0;
12962 u32 mcast_sw_if_index = ~0;
12963 u32 encap_vrf_id = 0;
12964 u32 decap_vrf_id = 0;
12970 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12971 memset (&local4, 0, sizeof local4);
12972 memset (&remote4, 0, sizeof remote4);
12973 memset (&local6, 0, sizeof local6);
12974 memset (&remote6, 0, sizeof remote6);
12976 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12978 if (unformat (line_input, "del"))
12980 else if (unformat (line_input, "local %U",
12981 unformat_ip4_address, &local4))
12986 else if (unformat (line_input, "remote %U",
12987 unformat_ip4_address, &remote4))
12992 else if (unformat (line_input, "local %U",
12993 unformat_ip6_address, &local6))
12998 else if (unformat (line_input, "remote %U",
12999 unformat_ip6_address, &remote6))
13004 else if (unformat (line_input, "group %U %U",
13005 unformat_ip4_address, &remote4,
13006 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13008 grp_set = remote_set = 1;
13011 else if (unformat (line_input, "group %U",
13012 unformat_ip4_address, &remote4))
13014 grp_set = remote_set = 1;
13017 else if (unformat (line_input, "group %U %U",
13018 unformat_ip6_address, &remote6,
13019 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13021 grp_set = remote_set = 1;
13024 else if (unformat (line_input, "group %U",
13025 unformat_ip6_address, &remote6))
13027 grp_set = remote_set = 1;
13031 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13033 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13035 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13037 else if (unformat (line_input, "vni %d", &vni))
13039 else if (unformat (line_input, "next-ip4"))
13041 else if (unformat (line_input, "next-ip6"))
13043 else if (unformat (line_input, "next-ethernet"))
13045 else if (unformat (line_input, "next-nsh"))
13049 errmsg ("parse error '%U'", format_unformat_error, line_input);
13054 if (local_set == 0)
13056 errmsg ("tunnel local address not specified");
13059 if (remote_set == 0)
13061 errmsg ("tunnel remote address not specified");
13064 if (grp_set && mcast_sw_if_index == ~0)
13066 errmsg ("tunnel nonexistent multicast device");
13069 if (ipv4_set && ipv6_set)
13071 errmsg ("both IPv4 and IPv6 addresses specified");
13077 errmsg ("vni not specified");
13081 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13086 clib_memcpy (&mp->local, &local6, sizeof (local6));
13087 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13091 clib_memcpy (&mp->local, &local4, sizeof (local4));
13092 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13095 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13096 mp->encap_vrf_id = ntohl (encap_vrf_id);
13097 mp->decap_vrf_id = ntohl (decap_vrf_id);
13098 mp->protocol = protocol;
13099 mp->vni = ntohl (vni);
13100 mp->is_add = is_add;
13101 mp->is_ipv6 = ipv6_set;
13108 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13109 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13111 vat_main_t *vam = &vat_main;
13112 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13113 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13115 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13116 ntohl (mp->sw_if_index),
13117 format_ip46_address, &local, IP46_TYPE_ANY,
13118 format_ip46_address, &remote, IP46_TYPE_ANY,
13119 ntohl (mp->vni), mp->protocol,
13120 ntohl (mp->mcast_sw_if_index),
13121 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13125 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13126 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13128 vat_main_t *vam = &vat_main;
13129 vat_json_node_t *node = NULL;
13130 struct in_addr ip4;
13131 struct in6_addr ip6;
13133 if (VAT_JSON_ARRAY != vam->json_tree.type)
13135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13136 vat_json_init_array (&vam->json_tree);
13138 node = vat_json_array_add (&vam->json_tree);
13140 vat_json_init_object (node);
13141 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13144 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13145 vat_json_object_add_ip6 (node, "local", ip6);
13146 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13147 vat_json_object_add_ip6 (node, "remote", ip6);
13151 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13152 vat_json_object_add_ip4 (node, "local", ip4);
13153 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13154 vat_json_object_add_ip4 (node, "remote", ip4);
13156 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13157 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13158 vat_json_object_add_uint (node, "mcast_sw_if_index",
13159 ntohl (mp->mcast_sw_if_index));
13160 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13161 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13162 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13166 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13168 unformat_input_t *i = vam->input;
13169 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13170 vl_api_control_ping_t *mp_ping;
13172 u8 sw_if_index_set = 0;
13175 /* Parse args required to build the message */
13176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13178 if (unformat (i, "sw_if_index %d", &sw_if_index))
13179 sw_if_index_set = 1;
13184 if (sw_if_index_set == 0)
13189 if (!vam->json_output)
13191 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13192 "sw_if_index", "local", "remote", "vni",
13193 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13196 /* Get list of vxlan-tunnel interfaces */
13197 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13199 mp->sw_if_index = htonl (sw_if_index);
13203 /* Use a control ping for synchronization */
13204 MPING (CONTROL_PING, mp_ping);
13213 format_l2_fib_mac_address (u8 * s, va_list * args)
13215 u8 *a = va_arg (*args, u8 *);
13217 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13218 a[2], a[3], a[4], a[5], a[6], a[7]);
13221 static void vl_api_l2_fib_table_details_t_handler
13222 (vl_api_l2_fib_table_details_t * mp)
13224 vat_main_t *vam = &vat_main;
13226 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13228 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13229 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13233 static void vl_api_l2_fib_table_details_t_handler_json
13234 (vl_api_l2_fib_table_details_t * mp)
13236 vat_main_t *vam = &vat_main;
13237 vat_json_node_t *node = NULL;
13239 if (VAT_JSON_ARRAY != vam->json_tree.type)
13241 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13242 vat_json_init_array (&vam->json_tree);
13244 node = vat_json_array_add (&vam->json_tree);
13246 vat_json_init_object (node);
13247 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13248 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13249 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13250 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13251 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13252 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13256 api_l2_fib_table_dump (vat_main_t * vam)
13258 unformat_input_t *i = vam->input;
13259 vl_api_l2_fib_table_dump_t *mp;
13260 vl_api_control_ping_t *mp_ping;
13265 /* Parse args required to build the message */
13266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13268 if (unformat (i, "bd_id %d", &bd_id))
13274 if (bd_id_set == 0)
13276 errmsg ("missing bridge domain");
13280 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13282 /* Get list of l2 fib entries */
13283 M (L2_FIB_TABLE_DUMP, mp);
13285 mp->bd_id = ntohl (bd_id);
13288 /* Use a control ping for synchronization */
13289 MPING (CONTROL_PING, mp_ping);
13298 api_interface_name_renumber (vat_main_t * vam)
13300 unformat_input_t *line_input = vam->input;
13301 vl_api_interface_name_renumber_t *mp;
13302 u32 sw_if_index = ~0;
13303 u32 new_show_dev_instance = ~0;
13306 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13308 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13311 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13313 else if (unformat (line_input, "new_show_dev_instance %d",
13314 &new_show_dev_instance))
13320 if (sw_if_index == ~0)
13322 errmsg ("missing interface name or sw_if_index");
13326 if (new_show_dev_instance == ~0)
13328 errmsg ("missing new_show_dev_instance");
13332 M (INTERFACE_NAME_RENUMBER, mp);
13334 mp->sw_if_index = ntohl (sw_if_index);
13335 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13343 api_want_ip4_arp_events (vat_main_t * vam)
13345 unformat_input_t *line_input = vam->input;
13346 vl_api_want_ip4_arp_events_t *mp;
13347 ip4_address_t address;
13348 int address_set = 0;
13349 u32 enable_disable = 1;
13352 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13354 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13356 else if (unformat (line_input, "del"))
13357 enable_disable = 0;
13362 if (address_set == 0)
13364 errmsg ("missing addresses");
13368 M (WANT_IP4_ARP_EVENTS, mp);
13369 mp->enable_disable = enable_disable;
13370 mp->pid = htonl (getpid ());
13371 mp->address = address.as_u32;
13379 api_want_ip6_nd_events (vat_main_t * vam)
13381 unformat_input_t *line_input = vam->input;
13382 vl_api_want_ip6_nd_events_t *mp;
13383 ip6_address_t address;
13384 int address_set = 0;
13385 u32 enable_disable = 1;
13388 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13390 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13392 else if (unformat (line_input, "del"))
13393 enable_disable = 0;
13398 if (address_set == 0)
13400 errmsg ("missing addresses");
13404 M (WANT_IP6_ND_EVENTS, mp);
13405 mp->enable_disable = enable_disable;
13406 mp->pid = htonl (getpid ());
13407 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13415 api_want_l2_macs_events (vat_main_t * vam)
13417 unformat_input_t *line_input = vam->input;
13418 vl_api_want_l2_macs_events_t *mp;
13419 u8 enable_disable = 1;
13420 u32 scan_delay = 0;
13421 u32 max_macs_in_event = 0;
13422 u32 learn_limit = 0;
13425 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13427 if (unformat (line_input, "learn-limit %d", &learn_limit))
13429 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13431 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13433 else if (unformat (line_input, "disable"))
13434 enable_disable = 0;
13439 M (WANT_L2_MACS_EVENTS, mp);
13440 mp->enable_disable = enable_disable;
13441 mp->pid = htonl (getpid ());
13442 mp->learn_limit = htonl (learn_limit);
13443 mp->scan_delay = (u8) scan_delay;
13444 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13451 api_input_acl_set_interface (vat_main_t * vam)
13453 unformat_input_t *i = vam->input;
13454 vl_api_input_acl_set_interface_t *mp;
13456 int sw_if_index_set;
13457 u32 ip4_table_index = ~0;
13458 u32 ip6_table_index = ~0;
13459 u32 l2_table_index = ~0;
13463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13466 sw_if_index_set = 1;
13467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13468 sw_if_index_set = 1;
13469 else if (unformat (i, "del"))
13471 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13473 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13475 else if (unformat (i, "l2-table %d", &l2_table_index))
13479 clib_warning ("parse error '%U'", format_unformat_error, i);
13484 if (sw_if_index_set == 0)
13486 errmsg ("missing interface name or sw_if_index");
13490 M (INPUT_ACL_SET_INTERFACE, mp);
13492 mp->sw_if_index = ntohl (sw_if_index);
13493 mp->ip4_table_index = ntohl (ip4_table_index);
13494 mp->ip6_table_index = ntohl (ip6_table_index);
13495 mp->l2_table_index = ntohl (l2_table_index);
13496 mp->is_add = is_add;
13504 api_ip_address_dump (vat_main_t * vam)
13506 unformat_input_t *i = vam->input;
13507 vl_api_ip_address_dump_t *mp;
13508 vl_api_control_ping_t *mp_ping;
13509 u32 sw_if_index = ~0;
13510 u8 sw_if_index_set = 0;
13515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13517 if (unformat (i, "sw_if_index %d", &sw_if_index))
13518 sw_if_index_set = 1;
13520 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13521 sw_if_index_set = 1;
13522 else if (unformat (i, "ipv4"))
13524 else if (unformat (i, "ipv6"))
13530 if (ipv4_set && ipv6_set)
13532 errmsg ("ipv4 and ipv6 flags cannot be both set");
13536 if ((!ipv4_set) && (!ipv6_set))
13538 errmsg ("no ipv4 nor ipv6 flag set");
13542 if (sw_if_index_set == 0)
13544 errmsg ("missing interface name or sw_if_index");
13548 vam->current_sw_if_index = sw_if_index;
13549 vam->is_ipv6 = ipv6_set;
13551 M (IP_ADDRESS_DUMP, mp);
13552 mp->sw_if_index = ntohl (sw_if_index);
13553 mp->is_ipv6 = ipv6_set;
13556 /* Use a control ping for synchronization */
13557 MPING (CONTROL_PING, mp_ping);
13565 api_ip_dump (vat_main_t * vam)
13567 vl_api_ip_dump_t *mp;
13568 vl_api_control_ping_t *mp_ping;
13569 unformat_input_t *in = vam->input;
13576 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13578 if (unformat (in, "ipv4"))
13580 else if (unformat (in, "ipv6"))
13586 if (ipv4_set && ipv6_set)
13588 errmsg ("ipv4 and ipv6 flags cannot be both set");
13592 if ((!ipv4_set) && (!ipv6_set))
13594 errmsg ("no ipv4 nor ipv6 flag set");
13598 is_ipv6 = ipv6_set;
13599 vam->is_ipv6 = is_ipv6;
13601 /* free old data */
13602 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13604 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13606 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13609 mp->is_ipv6 = ipv6_set;
13612 /* Use a control ping for synchronization */
13613 MPING (CONTROL_PING, mp_ping);
13621 api_ipsec_spd_add_del (vat_main_t * vam)
13623 unformat_input_t *i = vam->input;
13624 vl_api_ipsec_spd_add_del_t *mp;
13629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13631 if (unformat (i, "spd_id %d", &spd_id))
13633 else if (unformat (i, "del"))
13637 clib_warning ("parse error '%U'", format_unformat_error, i);
13643 errmsg ("spd_id must be set");
13647 M (IPSEC_SPD_ADD_DEL, mp);
13649 mp->spd_id = ntohl (spd_id);
13650 mp->is_add = is_add;
13658 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13660 unformat_input_t *i = vam->input;
13661 vl_api_ipsec_interface_add_del_spd_t *mp;
13663 u8 sw_if_index_set = 0;
13664 u32 spd_id = (u32) ~ 0;
13668 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13670 if (unformat (i, "del"))
13672 else if (unformat (i, "spd_id %d", &spd_id))
13675 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13676 sw_if_index_set = 1;
13677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13678 sw_if_index_set = 1;
13681 clib_warning ("parse error '%U'", format_unformat_error, i);
13687 if (spd_id == (u32) ~ 0)
13689 errmsg ("spd_id must be set");
13693 if (sw_if_index_set == 0)
13695 errmsg ("missing interface name or sw_if_index");
13699 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13701 mp->spd_id = ntohl (spd_id);
13702 mp->sw_if_index = ntohl (sw_if_index);
13703 mp->is_add = is_add;
13711 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13713 unformat_input_t *i = vam->input;
13714 vl_api_ipsec_spd_add_del_entry_t *mp;
13715 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13716 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13718 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13719 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13720 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13721 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13724 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13725 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13726 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13727 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13728 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13729 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13733 if (unformat (i, "del"))
13735 if (unformat (i, "outbound"))
13737 if (unformat (i, "inbound"))
13739 else if (unformat (i, "spd_id %d", &spd_id))
13741 else if (unformat (i, "sa_id %d", &sa_id))
13743 else if (unformat (i, "priority %d", &priority))
13745 else if (unformat (i, "protocol %d", &protocol))
13747 else if (unformat (i, "lport_start %d", &lport_start))
13749 else if (unformat (i, "lport_stop %d", &lport_stop))
13751 else if (unformat (i, "rport_start %d", &rport_start))
13753 else if (unformat (i, "rport_stop %d", &rport_stop))
13757 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13763 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13770 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13776 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13783 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13789 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13796 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13802 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13808 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13810 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13812 clib_warning ("unsupported action: 'resolve'");
13818 clib_warning ("parse error '%U'", format_unformat_error, i);
13824 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13826 mp->spd_id = ntohl (spd_id);
13827 mp->priority = ntohl (priority);
13828 mp->is_outbound = is_outbound;
13830 mp->is_ipv6 = is_ipv6;
13831 if (is_ipv6 || is_ip_any)
13833 clib_memcpy (mp->remote_address_start, &raddr6_start,
13834 sizeof (ip6_address_t));
13835 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13836 sizeof (ip6_address_t));
13837 clib_memcpy (mp->local_address_start, &laddr6_start,
13838 sizeof (ip6_address_t));
13839 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13840 sizeof (ip6_address_t));
13844 clib_memcpy (mp->remote_address_start, &raddr4_start,
13845 sizeof (ip4_address_t));
13846 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13847 sizeof (ip4_address_t));
13848 clib_memcpy (mp->local_address_start, &laddr4_start,
13849 sizeof (ip4_address_t));
13850 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13851 sizeof (ip4_address_t));
13853 mp->protocol = (u8) protocol;
13854 mp->local_port_start = ntohs ((u16) lport_start);
13855 mp->local_port_stop = ntohs ((u16) lport_stop);
13856 mp->remote_port_start = ntohs ((u16) rport_start);
13857 mp->remote_port_stop = ntohs ((u16) rport_stop);
13858 mp->policy = (u8) policy;
13859 mp->sa_id = ntohl (sa_id);
13860 mp->is_add = is_add;
13861 mp->is_ip_any = is_ip_any;
13868 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13870 unformat_input_t *i = vam->input;
13871 vl_api_ipsec_sad_add_del_entry_t *mp;
13872 u32 sad_id = 0, spi = 0;
13873 u8 *ck = 0, *ik = 0;
13876 u8 protocol = IPSEC_PROTOCOL_AH;
13877 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13878 u32 crypto_alg = 0, integ_alg = 0;
13879 ip4_address_t tun_src4;
13880 ip4_address_t tun_dst4;
13881 ip6_address_t tun_src6;
13882 ip6_address_t tun_dst6;
13885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13887 if (unformat (i, "del"))
13889 else if (unformat (i, "sad_id %d", &sad_id))
13891 else if (unformat (i, "spi %d", &spi))
13893 else if (unformat (i, "esp"))
13894 protocol = IPSEC_PROTOCOL_ESP;
13895 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13898 is_tunnel_ipv6 = 0;
13900 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13903 is_tunnel_ipv6 = 0;
13905 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13908 is_tunnel_ipv6 = 1;
13910 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13913 is_tunnel_ipv6 = 1;
13917 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13919 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13920 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13922 clib_warning ("unsupported crypto-alg: '%U'",
13923 format_ipsec_crypto_alg, crypto_alg);
13927 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13931 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13933 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13934 integ_alg >= IPSEC_INTEG_N_ALG)
13936 clib_warning ("unsupported integ-alg: '%U'",
13937 format_ipsec_integ_alg, integ_alg);
13941 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13945 clib_warning ("parse error '%U'", format_unformat_error, i);
13951 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13953 mp->sad_id = ntohl (sad_id);
13954 mp->is_add = is_add;
13955 mp->protocol = protocol;
13956 mp->spi = ntohl (spi);
13957 mp->is_tunnel = is_tunnel;
13958 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13959 mp->crypto_algorithm = crypto_alg;
13960 mp->integrity_algorithm = integ_alg;
13961 mp->crypto_key_length = vec_len (ck);
13962 mp->integrity_key_length = vec_len (ik);
13964 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13965 mp->crypto_key_length = sizeof (mp->crypto_key);
13967 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13968 mp->integrity_key_length = sizeof (mp->integrity_key);
13971 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13973 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13977 if (is_tunnel_ipv6)
13979 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13980 sizeof (ip6_address_t));
13981 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13982 sizeof (ip6_address_t));
13986 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13987 sizeof (ip4_address_t));
13988 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13989 sizeof (ip4_address_t));
13999 api_ipsec_sa_set_key (vat_main_t * vam)
14001 unformat_input_t *i = vam->input;
14002 vl_api_ipsec_sa_set_key_t *mp;
14004 u8 *ck = 0, *ik = 0;
14007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14009 if (unformat (i, "sa_id %d", &sa_id))
14011 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14013 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14017 clib_warning ("parse error '%U'", format_unformat_error, i);
14022 M (IPSEC_SA_SET_KEY, mp);
14024 mp->sa_id = ntohl (sa_id);
14025 mp->crypto_key_length = vec_len (ck);
14026 mp->integrity_key_length = vec_len (ik);
14028 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14029 mp->crypto_key_length = sizeof (mp->crypto_key);
14031 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14032 mp->integrity_key_length = sizeof (mp->integrity_key);
14035 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14037 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14045 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14047 unformat_input_t *i = vam->input;
14048 vl_api_ipsec_tunnel_if_add_del_t *mp;
14049 u32 local_spi = 0, remote_spi = 0;
14050 u32 crypto_alg = 0, integ_alg = 0;
14051 u8 *lck = NULL, *rck = NULL;
14052 u8 *lik = NULL, *rik = NULL;
14053 ip4_address_t local_ip = { {0} };
14054 ip4_address_t remote_ip = { {0} };
14057 u8 anti_replay = 0;
14060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14062 if (unformat (i, "del"))
14064 else if (unformat (i, "esn"))
14066 else if (unformat (i, "anti_replay"))
14068 else if (unformat (i, "local_spi %d", &local_spi))
14070 else if (unformat (i, "remote_spi %d", &remote_spi))
14072 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14074 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14076 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14079 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14081 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14083 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14087 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14089 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14090 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14092 errmsg ("unsupported crypto-alg: '%U'\n",
14093 format_ipsec_crypto_alg, crypto_alg);
14099 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14101 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14102 integ_alg >= IPSEC_INTEG_N_ALG)
14104 errmsg ("unsupported integ-alg: '%U'\n",
14105 format_ipsec_integ_alg, integ_alg);
14111 errmsg ("parse error '%U'\n", format_unformat_error, i);
14116 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14118 mp->is_add = is_add;
14120 mp->anti_replay = anti_replay;
14122 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14123 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14125 mp->local_spi = htonl (local_spi);
14126 mp->remote_spi = htonl (remote_spi);
14127 mp->crypto_alg = (u8) crypto_alg;
14129 mp->local_crypto_key_len = 0;
14132 mp->local_crypto_key_len = vec_len (lck);
14133 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14134 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14135 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14138 mp->remote_crypto_key_len = 0;
14141 mp->remote_crypto_key_len = vec_len (rck);
14142 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14143 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14144 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14147 mp->integ_alg = (u8) integ_alg;
14149 mp->local_integ_key_len = 0;
14152 mp->local_integ_key_len = vec_len (lik);
14153 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14154 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14155 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14158 mp->remote_integ_key_len = 0;
14161 mp->remote_integ_key_len = vec_len (rik);
14162 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14163 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14164 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14173 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14175 vat_main_t *vam = &vat_main;
14177 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14178 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14179 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14180 "tunnel_src_addr %U tunnel_dst_addr %U "
14181 "salt %u seq_outbound %lu last_seq_inbound %lu "
14182 "replay_window %lu total_data_size %lu\n",
14183 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14185 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14186 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14187 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14188 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14189 mp->tunnel_src_addr,
14190 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14191 mp->tunnel_dst_addr,
14193 clib_net_to_host_u64 (mp->seq_outbound),
14194 clib_net_to_host_u64 (mp->last_seq_inbound),
14195 clib_net_to_host_u64 (mp->replay_window),
14196 clib_net_to_host_u64 (mp->total_data_size));
14199 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14200 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14202 static void vl_api_ipsec_sa_details_t_handler_json
14203 (vl_api_ipsec_sa_details_t * mp)
14205 vat_main_t *vam = &vat_main;
14206 vat_json_node_t *node = NULL;
14207 struct in_addr src_ip4, dst_ip4;
14208 struct in6_addr src_ip6, dst_ip6;
14210 if (VAT_JSON_ARRAY != vam->json_tree.type)
14212 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14213 vat_json_init_array (&vam->json_tree);
14215 node = vat_json_array_add (&vam->json_tree);
14217 vat_json_init_object (node);
14218 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14219 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14220 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14221 vat_json_object_add_uint (node, "proto", mp->protocol);
14222 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14223 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14224 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14225 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14226 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14227 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14228 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14229 mp->crypto_key_len);
14230 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14231 mp->integ_key_len);
14232 if (mp->is_tunnel_ip6)
14234 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14235 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14236 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14237 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14241 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14242 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14243 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14244 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14246 vat_json_object_add_uint (node, "replay_window",
14247 clib_net_to_host_u64 (mp->replay_window));
14248 vat_json_object_add_uint (node, "total_data_size",
14249 clib_net_to_host_u64 (mp->total_data_size));
14254 api_ipsec_sa_dump (vat_main_t * vam)
14256 unformat_input_t *i = vam->input;
14257 vl_api_ipsec_sa_dump_t *mp;
14258 vl_api_control_ping_t *mp_ping;
14262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14264 if (unformat (i, "sa_id %d", &sa_id))
14268 clib_warning ("parse error '%U'", format_unformat_error, i);
14273 M (IPSEC_SA_DUMP, mp);
14275 mp->sa_id = ntohl (sa_id);
14279 /* Use a control ping for synchronization */
14280 M (CONTROL_PING, mp_ping);
14288 api_ikev2_profile_add_del (vat_main_t * vam)
14290 unformat_input_t *i = vam->input;
14291 vl_api_ikev2_profile_add_del_t *mp;
14296 const char *valid_chars = "a-zA-Z0-9_";
14298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14300 if (unformat (i, "del"))
14302 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14303 vec_add1 (name, 0);
14306 errmsg ("parse error '%U'", format_unformat_error, i);
14311 if (!vec_len (name))
14313 errmsg ("profile name must be specified");
14317 if (vec_len (name) > 64)
14319 errmsg ("profile name too long");
14323 M (IKEV2_PROFILE_ADD_DEL, mp);
14325 clib_memcpy (mp->name, name, vec_len (name));
14326 mp->is_add = is_add;
14335 api_ikev2_profile_set_auth (vat_main_t * vam)
14337 unformat_input_t *i = vam->input;
14338 vl_api_ikev2_profile_set_auth_t *mp;
14341 u32 auth_method = 0;
14345 const char *valid_chars = "a-zA-Z0-9_";
14347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14349 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14350 vec_add1 (name, 0);
14351 else if (unformat (i, "auth_method %U",
14352 unformat_ikev2_auth_method, &auth_method))
14354 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14356 else if (unformat (i, "auth_data %v", &data))
14360 errmsg ("parse error '%U'", format_unformat_error, i);
14365 if (!vec_len (name))
14367 errmsg ("profile name must be specified");
14371 if (vec_len (name) > 64)
14373 errmsg ("profile name too long");
14377 if (!vec_len (data))
14379 errmsg ("auth_data must be specified");
14385 errmsg ("auth_method must be specified");
14389 M (IKEV2_PROFILE_SET_AUTH, mp);
14391 mp->is_hex = is_hex;
14392 mp->auth_method = (u8) auth_method;
14393 mp->data_len = vec_len (data);
14394 clib_memcpy (mp->name, name, vec_len (name));
14395 clib_memcpy (mp->data, data, vec_len (data));
14405 api_ikev2_profile_set_id (vat_main_t * vam)
14407 unformat_input_t *i = vam->input;
14408 vl_api_ikev2_profile_set_id_t *mp;
14416 const char *valid_chars = "a-zA-Z0-9_";
14418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14420 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14421 vec_add1 (name, 0);
14422 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14424 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14426 data = vec_new (u8, 4);
14427 clib_memcpy (data, ip4.as_u8, 4);
14429 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14431 else if (unformat (i, "id_data %v", &data))
14433 else if (unformat (i, "local"))
14435 else if (unformat (i, "remote"))
14439 errmsg ("parse error '%U'", format_unformat_error, i);
14444 if (!vec_len (name))
14446 errmsg ("profile name must be specified");
14450 if (vec_len (name) > 64)
14452 errmsg ("profile name too long");
14456 if (!vec_len (data))
14458 errmsg ("id_data must be specified");
14464 errmsg ("id_type must be specified");
14468 M (IKEV2_PROFILE_SET_ID, mp);
14470 mp->is_local = is_local;
14471 mp->id_type = (u8) id_type;
14472 mp->data_len = vec_len (data);
14473 clib_memcpy (mp->name, name, vec_len (name));
14474 clib_memcpy (mp->data, data, vec_len (data));
14484 api_ikev2_profile_set_ts (vat_main_t * vam)
14486 unformat_input_t *i = vam->input;
14487 vl_api_ikev2_profile_set_ts_t *mp;
14490 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14491 ip4_address_t start_addr, end_addr;
14493 const char *valid_chars = "a-zA-Z0-9_";
14496 start_addr.as_u32 = 0;
14497 end_addr.as_u32 = (u32) ~ 0;
14499 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14501 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14502 vec_add1 (name, 0);
14503 else if (unformat (i, "protocol %d", &proto))
14505 else if (unformat (i, "start_port %d", &start_port))
14507 else if (unformat (i, "end_port %d", &end_port))
14510 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14512 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14514 else if (unformat (i, "local"))
14516 else if (unformat (i, "remote"))
14520 errmsg ("parse error '%U'", format_unformat_error, i);
14525 if (!vec_len (name))
14527 errmsg ("profile name must be specified");
14531 if (vec_len (name) > 64)
14533 errmsg ("profile name too long");
14537 M (IKEV2_PROFILE_SET_TS, mp);
14539 mp->is_local = is_local;
14540 mp->proto = (u8) proto;
14541 mp->start_port = (u16) start_port;
14542 mp->end_port = (u16) end_port;
14543 mp->start_addr = start_addr.as_u32;
14544 mp->end_addr = end_addr.as_u32;
14545 clib_memcpy (mp->name, name, vec_len (name));
14554 api_ikev2_set_local_key (vat_main_t * vam)
14556 unformat_input_t *i = vam->input;
14557 vl_api_ikev2_set_local_key_t *mp;
14561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14563 if (unformat (i, "file %v", &file))
14564 vec_add1 (file, 0);
14567 errmsg ("parse error '%U'", format_unformat_error, i);
14572 if (!vec_len (file))
14574 errmsg ("RSA key file must be specified");
14578 if (vec_len (file) > 256)
14580 errmsg ("file name too long");
14584 M (IKEV2_SET_LOCAL_KEY, mp);
14586 clib_memcpy (mp->key_file, file, vec_len (file));
14595 api_ikev2_set_responder (vat_main_t * vam)
14597 unformat_input_t *i = vam->input;
14598 vl_api_ikev2_set_responder_t *mp;
14601 u32 sw_if_index = ~0;
14602 ip4_address_t address;
14604 const char *valid_chars = "a-zA-Z0-9_";
14606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14609 (i, "%U interface %d address %U", unformat_token, valid_chars,
14610 &name, &sw_if_index, unformat_ip4_address, &address))
14611 vec_add1 (name, 0);
14614 errmsg ("parse error '%U'", format_unformat_error, i);
14619 if (!vec_len (name))
14621 errmsg ("profile name must be specified");
14625 if (vec_len (name) > 64)
14627 errmsg ("profile name too long");
14631 M (IKEV2_SET_RESPONDER, mp);
14633 clib_memcpy (mp->name, name, vec_len (name));
14636 mp->sw_if_index = sw_if_index;
14637 clib_memcpy (mp->address, &address, sizeof (address));
14645 api_ikev2_set_ike_transforms (vat_main_t * vam)
14647 unformat_input_t *i = vam->input;
14648 vl_api_ikev2_set_ike_transforms_t *mp;
14651 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14653 const char *valid_chars = "a-zA-Z0-9_";
14655 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14657 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14658 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14659 vec_add1 (name, 0);
14662 errmsg ("parse error '%U'", format_unformat_error, i);
14667 if (!vec_len (name))
14669 errmsg ("profile name must be specified");
14673 if (vec_len (name) > 64)
14675 errmsg ("profile name too long");
14679 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14681 clib_memcpy (mp->name, name, vec_len (name));
14683 mp->crypto_alg = crypto_alg;
14684 mp->crypto_key_size = crypto_key_size;
14685 mp->integ_alg = integ_alg;
14686 mp->dh_group = dh_group;
14695 api_ikev2_set_esp_transforms (vat_main_t * vam)
14697 unformat_input_t *i = vam->input;
14698 vl_api_ikev2_set_esp_transforms_t *mp;
14701 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14703 const char *valid_chars = "a-zA-Z0-9_";
14705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14707 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14708 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14709 vec_add1 (name, 0);
14712 errmsg ("parse error '%U'", format_unformat_error, i);
14717 if (!vec_len (name))
14719 errmsg ("profile name must be specified");
14723 if (vec_len (name) > 64)
14725 errmsg ("profile name too long");
14729 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14731 clib_memcpy (mp->name, name, vec_len (name));
14733 mp->crypto_alg = crypto_alg;
14734 mp->crypto_key_size = crypto_key_size;
14735 mp->integ_alg = integ_alg;
14736 mp->dh_group = dh_group;
14744 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14746 unformat_input_t *i = vam->input;
14747 vl_api_ikev2_set_sa_lifetime_t *mp;
14750 u64 lifetime, lifetime_maxdata;
14751 u32 lifetime_jitter, handover;
14753 const char *valid_chars = "a-zA-Z0-9_";
14755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14757 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14758 &lifetime, &lifetime_jitter, &handover,
14759 &lifetime_maxdata))
14760 vec_add1 (name, 0);
14763 errmsg ("parse error '%U'", format_unformat_error, i);
14768 if (!vec_len (name))
14770 errmsg ("profile name must be specified");
14774 if (vec_len (name) > 64)
14776 errmsg ("profile name too long");
14780 M (IKEV2_SET_SA_LIFETIME, mp);
14782 clib_memcpy (mp->name, name, vec_len (name));
14784 mp->lifetime = lifetime;
14785 mp->lifetime_jitter = lifetime_jitter;
14786 mp->handover = handover;
14787 mp->lifetime_maxdata = lifetime_maxdata;
14795 api_ikev2_initiate_sa_init (vat_main_t * vam)
14797 unformat_input_t *i = vam->input;
14798 vl_api_ikev2_initiate_sa_init_t *mp;
14802 const char *valid_chars = "a-zA-Z0-9_";
14804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14806 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14807 vec_add1 (name, 0);
14810 errmsg ("parse error '%U'", format_unformat_error, i);
14815 if (!vec_len (name))
14817 errmsg ("profile name must be specified");
14821 if (vec_len (name) > 64)
14823 errmsg ("profile name too long");
14827 M (IKEV2_INITIATE_SA_INIT, mp);
14829 clib_memcpy (mp->name, name, vec_len (name));
14838 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14840 unformat_input_t *i = vam->input;
14841 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14848 if (unformat (i, "%lx", &ispi))
14852 errmsg ("parse error '%U'", format_unformat_error, i);
14857 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14867 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14869 unformat_input_t *i = vam->input;
14870 vl_api_ikev2_initiate_del_child_sa_t *mp;
14875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14877 if (unformat (i, "%x", &ispi))
14881 errmsg ("parse error '%U'", format_unformat_error, i);
14886 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14896 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14898 unformat_input_t *i = vam->input;
14899 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14906 if (unformat (i, "%x", &ispi))
14910 errmsg ("parse error '%U'", format_unformat_error, i);
14915 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14928 api_map_add_domain (vat_main_t * vam)
14930 unformat_input_t *i = vam->input;
14931 vl_api_map_add_domain_t *mp;
14933 ip4_address_t ip4_prefix;
14934 ip6_address_t ip6_prefix;
14935 ip6_address_t ip6_src;
14936 u32 num_m_args = 0;
14937 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14938 0, psid_length = 0;
14939 u8 is_translation = 0;
14941 u32 ip6_src_len = 128;
14944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14946 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14947 &ip4_prefix, &ip4_prefix_len))
14949 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14950 &ip6_prefix, &ip6_prefix_len))
14954 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14957 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14959 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14961 else if (unformat (i, "psid-offset %d", &psid_offset))
14963 else if (unformat (i, "psid-len %d", &psid_length))
14965 else if (unformat (i, "mtu %d", &mtu))
14967 else if (unformat (i, "map-t"))
14968 is_translation = 1;
14971 clib_warning ("parse error '%U'", format_unformat_error, i);
14976 if (num_m_args < 3)
14978 errmsg ("mandatory argument(s) missing");
14982 /* Construct the API message */
14983 M (MAP_ADD_DOMAIN, mp);
14985 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14986 mp->ip4_prefix_len = ip4_prefix_len;
14988 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14989 mp->ip6_prefix_len = ip6_prefix_len;
14991 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14992 mp->ip6_src_prefix_len = ip6_src_len;
14994 mp->ea_bits_len = ea_bits_len;
14995 mp->psid_offset = psid_offset;
14996 mp->psid_length = psid_length;
14997 mp->is_translation = is_translation;
14998 mp->mtu = htons (mtu);
15003 /* Wait for a reply, return good/bad news */
15009 api_map_del_domain (vat_main_t * vam)
15011 unformat_input_t *i = vam->input;
15012 vl_api_map_del_domain_t *mp;
15014 u32 num_m_args = 0;
15018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15020 if (unformat (i, "index %d", &index))
15024 clib_warning ("parse error '%U'", format_unformat_error, i);
15029 if (num_m_args != 1)
15031 errmsg ("mandatory argument(s) missing");
15035 /* Construct the API message */
15036 M (MAP_DEL_DOMAIN, mp);
15038 mp->index = ntohl (index);
15043 /* Wait for a reply, return good/bad news */
15049 api_map_add_del_rule (vat_main_t * vam)
15051 unformat_input_t *i = vam->input;
15052 vl_api_map_add_del_rule_t *mp;
15054 ip6_address_t ip6_dst;
15055 u32 num_m_args = 0, index, psid = 0;
15058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15060 if (unformat (i, "index %d", &index))
15062 else if (unformat (i, "psid %d", &psid))
15064 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15066 else if (unformat (i, "del"))
15072 clib_warning ("parse error '%U'", format_unformat_error, i);
15077 /* Construct the API message */
15078 M (MAP_ADD_DEL_RULE, mp);
15080 mp->index = ntohl (index);
15081 mp->is_add = is_add;
15082 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15083 mp->psid = ntohs (psid);
15088 /* Wait for a reply, return good/bad news */
15094 api_map_domain_dump (vat_main_t * vam)
15096 vl_api_map_domain_dump_t *mp;
15097 vl_api_control_ping_t *mp_ping;
15100 /* Construct the API message */
15101 M (MAP_DOMAIN_DUMP, mp);
15106 /* Use a control ping for synchronization */
15107 MPING (CONTROL_PING, mp_ping);
15115 api_map_rule_dump (vat_main_t * vam)
15117 unformat_input_t *i = vam->input;
15118 vl_api_map_rule_dump_t *mp;
15119 vl_api_control_ping_t *mp_ping;
15120 u32 domain_index = ~0;
15123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15125 if (unformat (i, "index %u", &domain_index))
15131 if (domain_index == ~0)
15133 clib_warning ("parse error: domain index expected");
15137 /* Construct the API message */
15138 M (MAP_RULE_DUMP, mp);
15140 mp->domain_index = htonl (domain_index);
15145 /* Use a control ping for synchronization */
15146 MPING (CONTROL_PING, mp_ping);
15153 static void vl_api_map_add_domain_reply_t_handler
15154 (vl_api_map_add_domain_reply_t * mp)
15156 vat_main_t *vam = &vat_main;
15157 i32 retval = ntohl (mp->retval);
15159 if (vam->async_mode)
15161 vam->async_errors += (retval < 0);
15165 vam->retval = retval;
15166 vam->result_ready = 1;
15170 static void vl_api_map_add_domain_reply_t_handler_json
15171 (vl_api_map_add_domain_reply_t * mp)
15173 vat_main_t *vam = &vat_main;
15174 vat_json_node_t node;
15176 vat_json_init_object (&node);
15177 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15178 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15180 vat_json_print (vam->ofp, &node);
15181 vat_json_free (&node);
15183 vam->retval = ntohl (mp->retval);
15184 vam->result_ready = 1;
15188 api_get_first_msg_id (vat_main_t * vam)
15190 vl_api_get_first_msg_id_t *mp;
15191 unformat_input_t *i = vam->input;
15196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15198 if (unformat (i, "client %s", &name))
15206 errmsg ("missing client name");
15209 vec_add1 (name, 0);
15211 if (vec_len (name) > 63)
15213 errmsg ("client name too long");
15217 M (GET_FIRST_MSG_ID, mp);
15218 clib_memcpy (mp->name, name, vec_len (name));
15225 api_cop_interface_enable_disable (vat_main_t * vam)
15227 unformat_input_t *line_input = vam->input;
15228 vl_api_cop_interface_enable_disable_t *mp;
15229 u32 sw_if_index = ~0;
15230 u8 enable_disable = 1;
15233 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15235 if (unformat (line_input, "disable"))
15236 enable_disable = 0;
15237 if (unformat (line_input, "enable"))
15238 enable_disable = 1;
15239 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15240 vam, &sw_if_index))
15242 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15248 if (sw_if_index == ~0)
15250 errmsg ("missing interface name or sw_if_index");
15254 /* Construct the API message */
15255 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15256 mp->sw_if_index = ntohl (sw_if_index);
15257 mp->enable_disable = enable_disable;
15261 /* Wait for the reply */
15267 api_cop_whitelist_enable_disable (vat_main_t * vam)
15269 unformat_input_t *line_input = vam->input;
15270 vl_api_cop_whitelist_enable_disable_t *mp;
15271 u32 sw_if_index = ~0;
15272 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15276 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15278 if (unformat (line_input, "ip4"))
15280 else if (unformat (line_input, "ip6"))
15282 else if (unformat (line_input, "default"))
15284 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15285 vam, &sw_if_index))
15287 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15289 else if (unformat (line_input, "fib-id %d", &fib_id))
15295 if (sw_if_index == ~0)
15297 errmsg ("missing interface name or sw_if_index");
15301 /* Construct the API message */
15302 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15303 mp->sw_if_index = ntohl (sw_if_index);
15304 mp->fib_id = ntohl (fib_id);
15307 mp->default_cop = default_cop;
15311 /* Wait for the reply */
15317 api_get_node_graph (vat_main_t * vam)
15319 vl_api_get_node_graph_t *mp;
15322 M (GET_NODE_GRAPH, mp);
15326 /* Wait for the reply */
15332 /** Used for parsing LISP eids */
15333 typedef CLIB_PACKED(struct{
15334 u8 addr[16]; /**< eid address */
15335 u32 len; /**< prefix length if IP */
15336 u8 type; /**< type of eid */
15341 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15343 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15345 memset (a, 0, sizeof (a[0]));
15347 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15349 a->type = 0; /* ipv4 type */
15351 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15353 a->type = 1; /* ipv6 type */
15355 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15357 a->type = 2; /* mac type */
15359 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15361 a->type = 3; /* NSH type */
15362 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15363 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15370 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15379 lisp_eid_size_vat (u8 type)
15396 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15398 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15402 api_one_add_del_locator_set (vat_main_t * vam)
15404 unformat_input_t *input = vam->input;
15405 vl_api_one_add_del_locator_set_t *mp;
15407 u8 *locator_set_name = NULL;
15408 u8 locator_set_name_set = 0;
15409 vl_api_local_locator_t locator, *locators = 0;
15410 u32 sw_if_index, priority, weight;
15414 /* Parse args required to build the message */
15415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15417 if (unformat (input, "del"))
15421 else if (unformat (input, "locator-set %s", &locator_set_name))
15423 locator_set_name_set = 1;
15425 else if (unformat (input, "sw_if_index %u p %u w %u",
15426 &sw_if_index, &priority, &weight))
15428 locator.sw_if_index = htonl (sw_if_index);
15429 locator.priority = priority;
15430 locator.weight = weight;
15431 vec_add1 (locators, locator);
15435 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15436 &sw_if_index, &priority, &weight))
15438 locator.sw_if_index = htonl (sw_if_index);
15439 locator.priority = priority;
15440 locator.weight = weight;
15441 vec_add1 (locators, locator);
15447 if (locator_set_name_set == 0)
15449 errmsg ("missing locator-set name");
15450 vec_free (locators);
15454 if (vec_len (locator_set_name) > 64)
15456 errmsg ("locator-set name too long");
15457 vec_free (locator_set_name);
15458 vec_free (locators);
15461 vec_add1 (locator_set_name, 0);
15463 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15465 /* Construct the API message */
15466 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15468 mp->is_add = is_add;
15469 clib_memcpy (mp->locator_set_name, locator_set_name,
15470 vec_len (locator_set_name));
15471 vec_free (locator_set_name);
15473 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15475 clib_memcpy (mp->locators, locators, data_len);
15476 vec_free (locators);
15481 /* Wait for a reply... */
15486 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15489 api_one_add_del_locator (vat_main_t * vam)
15491 unformat_input_t *input = vam->input;
15492 vl_api_one_add_del_locator_t *mp;
15493 u32 tmp_if_index = ~0;
15494 u32 sw_if_index = ~0;
15495 u8 sw_if_index_set = 0;
15496 u8 sw_if_index_if_name_set = 0;
15498 u8 priority_set = 0;
15502 u8 *locator_set_name = NULL;
15503 u8 locator_set_name_set = 0;
15506 /* Parse args required to build the message */
15507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15509 if (unformat (input, "del"))
15513 else if (unformat (input, "locator-set %s", &locator_set_name))
15515 locator_set_name_set = 1;
15517 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15520 sw_if_index_if_name_set = 1;
15521 sw_if_index = tmp_if_index;
15523 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15525 sw_if_index_set = 1;
15526 sw_if_index = tmp_if_index;
15528 else if (unformat (input, "p %d", &priority))
15532 else if (unformat (input, "w %d", &weight))
15540 if (locator_set_name_set == 0)
15542 errmsg ("missing locator-set name");
15546 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15548 errmsg ("missing sw_if_index");
15549 vec_free (locator_set_name);
15553 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15555 errmsg ("cannot use both params interface name and sw_if_index");
15556 vec_free (locator_set_name);
15560 if (priority_set == 0)
15562 errmsg ("missing locator-set priority");
15563 vec_free (locator_set_name);
15567 if (weight_set == 0)
15569 errmsg ("missing locator-set weight");
15570 vec_free (locator_set_name);
15574 if (vec_len (locator_set_name) > 64)
15576 errmsg ("locator-set name too long");
15577 vec_free (locator_set_name);
15580 vec_add1 (locator_set_name, 0);
15582 /* Construct the API message */
15583 M (ONE_ADD_DEL_LOCATOR, mp);
15585 mp->is_add = is_add;
15586 mp->sw_if_index = ntohl (sw_if_index);
15587 mp->priority = priority;
15588 mp->weight = weight;
15589 clib_memcpy (mp->locator_set_name, locator_set_name,
15590 vec_len (locator_set_name));
15591 vec_free (locator_set_name);
15596 /* Wait for a reply... */
15601 #define api_lisp_add_del_locator api_one_add_del_locator
15604 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15606 u32 *key_id = va_arg (*args, u32 *);
15609 if (unformat (input, "%s", &s))
15611 if (!strcmp ((char *) s, "sha1"))
15612 key_id[0] = HMAC_SHA_1_96;
15613 else if (!strcmp ((char *) s, "sha256"))
15614 key_id[0] = HMAC_SHA_256_128;
15617 clib_warning ("invalid key_id: '%s'", s);
15618 key_id[0] = HMAC_NO_KEY;
15629 api_one_add_del_local_eid (vat_main_t * vam)
15631 unformat_input_t *input = vam->input;
15632 vl_api_one_add_del_local_eid_t *mp;
15635 lisp_eid_vat_t _eid, *eid = &_eid;
15636 u8 *locator_set_name = 0;
15637 u8 locator_set_name_set = 0;
15643 /* Parse args required to build the message */
15644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15646 if (unformat (input, "del"))
15650 else if (unformat (input, "vni %d", &vni))
15654 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15658 else if (unformat (input, "locator-set %s", &locator_set_name))
15660 locator_set_name_set = 1;
15662 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15664 else if (unformat (input, "secret-key %_%v%_", &key))
15670 if (locator_set_name_set == 0)
15672 errmsg ("missing locator-set name");
15678 errmsg ("EID address not set!");
15679 vec_free (locator_set_name);
15683 if (key && (0 == key_id))
15685 errmsg ("invalid key_id!");
15689 if (vec_len (key) > 64)
15691 errmsg ("key too long");
15696 if (vec_len (locator_set_name) > 64)
15698 errmsg ("locator-set name too long");
15699 vec_free (locator_set_name);
15702 vec_add1 (locator_set_name, 0);
15704 /* Construct the API message */
15705 M (ONE_ADD_DEL_LOCAL_EID, mp);
15707 mp->is_add = is_add;
15708 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15709 mp->eid_type = eid->type;
15710 mp->prefix_len = eid->len;
15711 mp->vni = clib_host_to_net_u32 (vni);
15712 mp->key_id = clib_host_to_net_u16 (key_id);
15713 clib_memcpy (mp->locator_set_name, locator_set_name,
15714 vec_len (locator_set_name));
15715 clib_memcpy (mp->key, key, vec_len (key));
15717 vec_free (locator_set_name);
15723 /* Wait for a reply... */
15728 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15731 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15733 u32 dp_table = 0, vni = 0;;
15734 unformat_input_t *input = vam->input;
15735 vl_api_gpe_add_del_fwd_entry_t *mp;
15737 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15738 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15739 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15740 u32 action = ~0, w;
15741 ip4_address_t rmt_rloc4, lcl_rloc4;
15742 ip6_address_t rmt_rloc6, lcl_rloc6;
15743 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15746 memset (&rloc, 0, sizeof (rloc));
15748 /* Parse args required to build the message */
15749 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15751 if (unformat (input, "del"))
15753 else if (unformat (input, "add"))
15755 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15759 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15763 else if (unformat (input, "vrf %d", &dp_table))
15765 else if (unformat (input, "bd %d", &dp_table))
15767 else if (unformat (input, "vni %d", &vni))
15769 else if (unformat (input, "w %d", &w))
15773 errmsg ("No RLOC configured for setting priority/weight!");
15776 curr_rloc->weight = w;
15778 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15779 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15783 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15785 vec_add1 (lcl_locs, rloc);
15787 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15788 vec_add1 (rmt_locs, rloc);
15789 /* weight saved in rmt loc */
15790 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15792 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15793 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15796 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15798 vec_add1 (lcl_locs, rloc);
15800 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15801 vec_add1 (rmt_locs, rloc);
15802 /* weight saved in rmt loc */
15803 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15805 else if (unformat (input, "action %d", &action))
15811 clib_warning ("parse error '%U'", format_unformat_error, input);
15818 errmsg ("remote eid addresses not set");
15822 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15824 errmsg ("eid types don't match");
15828 if (0 == rmt_locs && (u32) ~ 0 == action)
15830 errmsg ("action not set for negative mapping");
15834 /* Construct the API message */
15835 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15836 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15838 mp->is_add = is_add;
15839 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15840 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15841 mp->eid_type = rmt_eid->type;
15842 mp->dp_table = clib_host_to_net_u32 (dp_table);
15843 mp->vni = clib_host_to_net_u32 (vni);
15844 mp->rmt_len = rmt_eid->len;
15845 mp->lcl_len = lcl_eid->len;
15846 mp->action = action;
15848 if (0 != rmt_locs && 0 != lcl_locs)
15850 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15851 clib_memcpy (mp->locs, lcl_locs,
15852 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15854 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15855 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15856 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15858 vec_free (lcl_locs);
15859 vec_free (rmt_locs);
15864 /* Wait for a reply... */
15870 api_one_add_del_map_server (vat_main_t * vam)
15872 unformat_input_t *input = vam->input;
15873 vl_api_one_add_del_map_server_t *mp;
15877 ip4_address_t ipv4;
15878 ip6_address_t ipv6;
15881 /* Parse args required to build the message */
15882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15884 if (unformat (input, "del"))
15888 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15892 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15900 if (ipv4_set && ipv6_set)
15902 errmsg ("both eid v4 and v6 addresses set");
15906 if (!ipv4_set && !ipv6_set)
15908 errmsg ("eid addresses not set");
15912 /* Construct the API message */
15913 M (ONE_ADD_DEL_MAP_SERVER, mp);
15915 mp->is_add = is_add;
15919 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15924 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15930 /* Wait for a reply... */
15935 #define api_lisp_add_del_map_server api_one_add_del_map_server
15938 api_one_add_del_map_resolver (vat_main_t * vam)
15940 unformat_input_t *input = vam->input;
15941 vl_api_one_add_del_map_resolver_t *mp;
15945 ip4_address_t ipv4;
15946 ip6_address_t ipv6;
15949 /* Parse args required to build the message */
15950 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15952 if (unformat (input, "del"))
15956 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15960 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15968 if (ipv4_set && ipv6_set)
15970 errmsg ("both eid v4 and v6 addresses set");
15974 if (!ipv4_set && !ipv6_set)
15976 errmsg ("eid addresses not set");
15980 /* Construct the API message */
15981 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15983 mp->is_add = is_add;
15987 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15992 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15998 /* Wait for a reply... */
16003 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16006 api_lisp_gpe_enable_disable (vat_main_t * vam)
16008 unformat_input_t *input = vam->input;
16009 vl_api_gpe_enable_disable_t *mp;
16014 /* Parse args required to build the message */
16015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16017 if (unformat (input, "enable"))
16022 else if (unformat (input, "disable"))
16033 errmsg ("Value not set");
16037 /* Construct the API message */
16038 M (GPE_ENABLE_DISABLE, mp);
16045 /* Wait for a reply... */
16051 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16053 unformat_input_t *input = vam->input;
16054 vl_api_one_rloc_probe_enable_disable_t *mp;
16059 /* Parse args required to build the message */
16060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16062 if (unformat (input, "enable"))
16067 else if (unformat (input, "disable"))
16075 errmsg ("Value not set");
16079 /* Construct the API message */
16080 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16082 mp->is_enabled = is_en;
16087 /* Wait for a reply... */
16092 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16095 api_one_map_register_enable_disable (vat_main_t * vam)
16097 unformat_input_t *input = vam->input;
16098 vl_api_one_map_register_enable_disable_t *mp;
16103 /* Parse args required to build the message */
16104 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16106 if (unformat (input, "enable"))
16111 else if (unformat (input, "disable"))
16119 errmsg ("Value not set");
16123 /* Construct the API message */
16124 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16126 mp->is_enabled = is_en;
16131 /* Wait for a reply... */
16136 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16139 api_one_enable_disable (vat_main_t * vam)
16141 unformat_input_t *input = vam->input;
16142 vl_api_one_enable_disable_t *mp;
16147 /* Parse args required to build the message */
16148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16150 if (unformat (input, "enable"))
16155 else if (unformat (input, "disable"))
16165 errmsg ("Value not set");
16169 /* Construct the API message */
16170 M (ONE_ENABLE_DISABLE, mp);
16177 /* Wait for a reply... */
16182 #define api_lisp_enable_disable api_one_enable_disable
16185 api_show_one_map_register_state (vat_main_t * vam)
16187 vl_api_show_one_map_register_state_t *mp;
16190 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16195 /* wait for reply */
16200 #define api_show_lisp_map_register_state api_show_one_map_register_state
16203 api_show_one_rloc_probe_state (vat_main_t * vam)
16205 vl_api_show_one_rloc_probe_state_t *mp;
16208 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16213 /* wait for reply */
16218 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16221 api_one_add_del_ndp_entry (vat_main_t * vam)
16223 vl_api_one_add_del_ndp_entry_t *mp;
16224 unformat_input_t *input = vam->input;
16229 u8 mac[6] = { 0, };
16230 u8 ip6[16] = { 0, };
16234 /* Parse args required to build the message */
16235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16237 if (unformat (input, "del"))
16239 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16241 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16243 else if (unformat (input, "bd %d", &bd))
16247 errmsg ("parse error '%U'", format_unformat_error, input);
16252 if (!bd_set || !ip_set || (!mac_set && is_add))
16254 errmsg ("Missing BD, IP or MAC!");
16258 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16259 mp->is_add = is_add;
16260 clib_memcpy (mp->mac, mac, 6);
16261 mp->bd = clib_host_to_net_u32 (bd);
16262 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16267 /* wait for reply */
16273 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16275 vl_api_one_add_del_l2_arp_entry_t *mp;
16276 unformat_input_t *input = vam->input;
16281 u8 mac[6] = { 0, };
16282 u32 ip4 = 0, bd = ~0;
16285 /* Parse args required to build the message */
16286 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16288 if (unformat (input, "del"))
16290 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16292 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16294 else if (unformat (input, "bd %d", &bd))
16298 errmsg ("parse error '%U'", format_unformat_error, input);
16303 if (!bd_set || !ip_set || (!mac_set && is_add))
16305 errmsg ("Missing BD, IP or MAC!");
16309 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16310 mp->is_add = is_add;
16311 clib_memcpy (mp->mac, mac, 6);
16312 mp->bd = clib_host_to_net_u32 (bd);
16318 /* wait for reply */
16324 api_one_ndp_bd_get (vat_main_t * vam)
16326 vl_api_one_ndp_bd_get_t *mp;
16329 M (ONE_NDP_BD_GET, mp);
16334 /* wait for reply */
16340 api_one_ndp_entries_get (vat_main_t * vam)
16342 vl_api_one_ndp_entries_get_t *mp;
16343 unformat_input_t *input = vam->input;
16348 /* Parse args required to build the message */
16349 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16351 if (unformat (input, "bd %d", &bd))
16355 errmsg ("parse error '%U'", format_unformat_error, input);
16362 errmsg ("Expected bridge domain!");
16366 M (ONE_NDP_ENTRIES_GET, mp);
16367 mp->bd = clib_host_to_net_u32 (bd);
16372 /* wait for reply */
16378 api_one_l2_arp_bd_get (vat_main_t * vam)
16380 vl_api_one_l2_arp_bd_get_t *mp;
16383 M (ONE_L2_ARP_BD_GET, mp);
16388 /* wait for reply */
16394 api_one_l2_arp_entries_get (vat_main_t * vam)
16396 vl_api_one_l2_arp_entries_get_t *mp;
16397 unformat_input_t *input = vam->input;
16402 /* Parse args required to build the message */
16403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16405 if (unformat (input, "bd %d", &bd))
16409 errmsg ("parse error '%U'", format_unformat_error, input);
16416 errmsg ("Expected bridge domain!");
16420 M (ONE_L2_ARP_ENTRIES_GET, mp);
16421 mp->bd = clib_host_to_net_u32 (bd);
16426 /* wait for reply */
16432 api_one_stats_enable_disable (vat_main_t * vam)
16434 vl_api_one_stats_enable_disable_t *mp;
16435 unformat_input_t *input = vam->input;
16440 /* Parse args required to build the message */
16441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16443 if (unformat (input, "enable"))
16448 else if (unformat (input, "disable"))
16458 errmsg ("Value not set");
16462 M (ONE_STATS_ENABLE_DISABLE, mp);
16468 /* wait for reply */
16474 api_show_one_stats_enable_disable (vat_main_t * vam)
16476 vl_api_show_one_stats_enable_disable_t *mp;
16479 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16484 /* wait for reply */
16490 api_show_one_map_request_mode (vat_main_t * vam)
16492 vl_api_show_one_map_request_mode_t *mp;
16495 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16500 /* wait for reply */
16505 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16508 api_one_map_request_mode (vat_main_t * vam)
16510 unformat_input_t *input = vam->input;
16511 vl_api_one_map_request_mode_t *mp;
16515 /* Parse args required to build the message */
16516 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16518 if (unformat (input, "dst-only"))
16520 else if (unformat (input, "src-dst"))
16524 errmsg ("parse error '%U'", format_unformat_error, input);
16529 M (ONE_MAP_REQUEST_MODE, mp);
16536 /* wait for reply */
16541 #define api_lisp_map_request_mode api_one_map_request_mode
16544 * Enable/disable ONE proxy ITR.
16546 * @param vam vpp API test context
16547 * @return return code
16550 api_one_pitr_set_locator_set (vat_main_t * vam)
16552 u8 ls_name_set = 0;
16553 unformat_input_t *input = vam->input;
16554 vl_api_one_pitr_set_locator_set_t *mp;
16559 /* Parse args required to build the message */
16560 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16562 if (unformat (input, "del"))
16564 else if (unformat (input, "locator-set %s", &ls_name))
16568 errmsg ("parse error '%U'", format_unformat_error, input);
16575 errmsg ("locator-set name not set!");
16579 M (ONE_PITR_SET_LOCATOR_SET, mp);
16581 mp->is_add = is_add;
16582 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16583 vec_free (ls_name);
16588 /* wait for reply */
16593 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16596 api_one_nsh_set_locator_set (vat_main_t * vam)
16598 u8 ls_name_set = 0;
16599 unformat_input_t *input = vam->input;
16600 vl_api_one_nsh_set_locator_set_t *mp;
16605 /* Parse args required to build the message */
16606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16608 if (unformat (input, "del"))
16610 else if (unformat (input, "ls %s", &ls_name))
16614 errmsg ("parse error '%U'", format_unformat_error, input);
16619 if (!ls_name_set && is_add)
16621 errmsg ("locator-set name not set!");
16625 M (ONE_NSH_SET_LOCATOR_SET, mp);
16627 mp->is_add = is_add;
16628 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16629 vec_free (ls_name);
16634 /* wait for reply */
16640 api_show_one_pitr (vat_main_t * vam)
16642 vl_api_show_one_pitr_t *mp;
16645 if (!vam->json_output)
16647 print (vam->ofp, "%=20s", "lisp status:");
16650 M (SHOW_ONE_PITR, mp);
16654 /* Wait for a reply... */
16659 #define api_show_lisp_pitr api_show_one_pitr
16662 api_one_use_petr (vat_main_t * vam)
16664 unformat_input_t *input = vam->input;
16665 vl_api_one_use_petr_t *mp;
16670 memset (&ip, 0, sizeof (ip));
16672 /* Parse args required to build the message */
16673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16675 if (unformat (input, "disable"))
16678 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16681 ip_addr_version (&ip) = IP4;
16684 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16687 ip_addr_version (&ip) = IP6;
16691 errmsg ("parse error '%U'", format_unformat_error, input);
16696 M (ONE_USE_PETR, mp);
16698 mp->is_add = is_add;
16701 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16703 clib_memcpy (mp->address, &ip, 4);
16705 clib_memcpy (mp->address, &ip, 16);
16711 /* wait for reply */
16716 #define api_lisp_use_petr api_one_use_petr
16719 api_show_one_nsh_mapping (vat_main_t * vam)
16721 vl_api_show_one_use_petr_t *mp;
16724 if (!vam->json_output)
16726 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16729 M (SHOW_ONE_NSH_MAPPING, mp);
16733 /* Wait for a reply... */
16739 api_show_one_use_petr (vat_main_t * vam)
16741 vl_api_show_one_use_petr_t *mp;
16744 if (!vam->json_output)
16746 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16749 M (SHOW_ONE_USE_PETR, mp);
16753 /* Wait for a reply... */
16758 #define api_show_lisp_use_petr api_show_one_use_petr
16761 * Add/delete mapping between vni and vrf
16764 api_one_eid_table_add_del_map (vat_main_t * vam)
16766 unformat_input_t *input = vam->input;
16767 vl_api_one_eid_table_add_del_map_t *mp;
16768 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16769 u32 vni, vrf, bd_index;
16772 /* Parse args required to build the message */
16773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16775 if (unformat (input, "del"))
16777 else if (unformat (input, "vrf %d", &vrf))
16779 else if (unformat (input, "bd_index %d", &bd_index))
16781 else if (unformat (input, "vni %d", &vni))
16787 if (!vni_set || (!vrf_set && !bd_index_set))
16789 errmsg ("missing arguments!");
16793 if (vrf_set && bd_index_set)
16795 errmsg ("error: both vrf and bd entered!");
16799 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16801 mp->is_add = is_add;
16802 mp->vni = htonl (vni);
16803 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16804 mp->is_l2 = bd_index_set;
16809 /* wait for reply */
16814 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16817 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16819 u32 *action = va_arg (*args, u32 *);
16822 if (unformat (input, "%s", &s))
16824 if (!strcmp ((char *) s, "no-action"))
16826 else if (!strcmp ((char *) s, "natively-forward"))
16828 else if (!strcmp ((char *) s, "send-map-request"))
16830 else if (!strcmp ((char *) s, "drop"))
16834 clib_warning ("invalid action: '%s'", s);
16846 * Add/del remote mapping to/from ONE control plane
16848 * @param vam vpp API test context
16849 * @return return code
16852 api_one_add_del_remote_mapping (vat_main_t * vam)
16854 unformat_input_t *input = vam->input;
16855 vl_api_one_add_del_remote_mapping_t *mp;
16857 lisp_eid_vat_t _eid, *eid = &_eid;
16858 lisp_eid_vat_t _seid, *seid = &_seid;
16859 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16860 u32 action = ~0, p, w, data_len;
16861 ip4_address_t rloc4;
16862 ip6_address_t rloc6;
16863 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16866 memset (&rloc, 0, sizeof (rloc));
16868 /* Parse args required to build the message */
16869 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16871 if (unformat (input, "del-all"))
16875 else if (unformat (input, "del"))
16879 else if (unformat (input, "add"))
16883 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16887 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16891 else if (unformat (input, "vni %d", &vni))
16895 else if (unformat (input, "p %d w %d", &p, &w))
16899 errmsg ("No RLOC configured for setting priority/weight!");
16902 curr_rloc->priority = p;
16903 curr_rloc->weight = w;
16905 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16908 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16909 vec_add1 (rlocs, rloc);
16910 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16912 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16915 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16916 vec_add1 (rlocs, rloc);
16917 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16919 else if (unformat (input, "action %U",
16920 unformat_negative_mapping_action, &action))
16926 clib_warning ("parse error '%U'", format_unformat_error, input);
16933 errmsg ("missing params!");
16937 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16939 errmsg ("no action set for negative map-reply!");
16943 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16945 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16946 mp->is_add = is_add;
16947 mp->vni = htonl (vni);
16948 mp->action = (u8) action;
16949 mp->is_src_dst = seid_set;
16950 mp->eid_len = eid->len;
16951 mp->seid_len = seid->len;
16952 mp->del_all = del_all;
16953 mp->eid_type = eid->type;
16954 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16955 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16957 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16958 clib_memcpy (mp->rlocs, rlocs, data_len);
16964 /* Wait for a reply... */
16969 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16972 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16973 * forwarding entries in data-plane accordingly.
16975 * @param vam vpp API test context
16976 * @return return code
16979 api_one_add_del_adjacency (vat_main_t * vam)
16981 unformat_input_t *input = vam->input;
16982 vl_api_one_add_del_adjacency_t *mp;
16984 ip4_address_t leid4, reid4;
16985 ip6_address_t leid6, reid6;
16986 u8 reid_mac[6] = { 0 };
16987 u8 leid_mac[6] = { 0 };
16988 u8 reid_type, leid_type;
16989 u32 leid_len = 0, reid_len = 0, len;
16993 leid_type = reid_type = (u8) ~ 0;
16995 /* Parse args required to build the message */
16996 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16998 if (unformat (input, "del"))
17002 else if (unformat (input, "add"))
17006 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17009 reid_type = 0; /* ipv4 */
17012 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17015 reid_type = 1; /* ipv6 */
17018 else if (unformat (input, "reid %U", unformat_ethernet_address,
17021 reid_type = 2; /* mac */
17023 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17026 leid_type = 0; /* ipv4 */
17029 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17032 leid_type = 1; /* ipv6 */
17035 else if (unformat (input, "leid %U", unformat_ethernet_address,
17038 leid_type = 2; /* mac */
17040 else if (unformat (input, "vni %d", &vni))
17046 errmsg ("parse error '%U'", format_unformat_error, input);
17051 if ((u8) ~ 0 == reid_type)
17053 errmsg ("missing params!");
17057 if (leid_type != reid_type)
17059 errmsg ("remote and local EIDs are of different types!");
17063 M (ONE_ADD_DEL_ADJACENCY, mp);
17064 mp->is_add = is_add;
17065 mp->vni = htonl (vni);
17066 mp->leid_len = leid_len;
17067 mp->reid_len = reid_len;
17068 mp->eid_type = reid_type;
17070 switch (mp->eid_type)
17073 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17074 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17077 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17078 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17081 clib_memcpy (mp->leid, leid_mac, 6);
17082 clib_memcpy (mp->reid, reid_mac, 6);
17085 errmsg ("unknown EID type %d!", mp->eid_type);
17092 /* Wait for a reply... */
17097 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17100 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17102 u32 *mode = va_arg (*args, u32 *);
17104 if (unformat (input, "lisp"))
17106 else if (unformat (input, "vxlan"))
17115 api_gpe_get_encap_mode (vat_main_t * vam)
17117 vl_api_gpe_get_encap_mode_t *mp;
17120 /* Construct the API message */
17121 M (GPE_GET_ENCAP_MODE, mp);
17126 /* Wait for a reply... */
17132 api_gpe_set_encap_mode (vat_main_t * vam)
17134 unformat_input_t *input = vam->input;
17135 vl_api_gpe_set_encap_mode_t *mp;
17139 /* Parse args required to build the message */
17140 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17142 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17148 /* Construct the API message */
17149 M (GPE_SET_ENCAP_MODE, mp);
17156 /* Wait for a reply... */
17162 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17164 unformat_input_t *input = vam->input;
17165 vl_api_gpe_add_del_iface_t *mp;
17166 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17167 u32 dp_table = 0, vni = 0;
17170 /* Parse args required to build the message */
17171 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17173 if (unformat (input, "up"))
17178 else if (unformat (input, "down"))
17183 else if (unformat (input, "table_id %d", &dp_table))
17187 else if (unformat (input, "bd_id %d", &dp_table))
17192 else if (unformat (input, "vni %d", &vni))
17200 if (action_set == 0)
17202 errmsg ("Action not set");
17205 if (dp_table_set == 0 || vni_set == 0)
17207 errmsg ("vni and dp_table must be set");
17211 /* Construct the API message */
17212 M (GPE_ADD_DEL_IFACE, mp);
17214 mp->is_add = is_add;
17215 mp->dp_table = clib_host_to_net_u32 (dp_table);
17217 mp->vni = clib_host_to_net_u32 (vni);
17222 /* Wait for a reply... */
17228 api_one_map_register_fallback_threshold (vat_main_t * vam)
17230 unformat_input_t *input = vam->input;
17231 vl_api_one_map_register_fallback_threshold_t *mp;
17236 /* Parse args required to build the message */
17237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17239 if (unformat (input, "%u", &value))
17243 clib_warning ("parse error '%U'", format_unformat_error, input);
17250 errmsg ("fallback threshold value is missing!");
17254 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17255 mp->value = clib_host_to_net_u32 (value);
17260 /* Wait for a reply... */
17266 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17268 vl_api_show_one_map_register_fallback_threshold_t *mp;
17271 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17276 /* Wait for a reply... */
17282 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17284 u32 *proto = va_arg (*args, u32 *);
17286 if (unformat (input, "udp"))
17288 else if (unformat (input, "api"))
17297 api_one_set_transport_protocol (vat_main_t * vam)
17299 unformat_input_t *input = vam->input;
17300 vl_api_one_set_transport_protocol_t *mp;
17305 /* Parse args required to build the message */
17306 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17308 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17312 clib_warning ("parse error '%U'", format_unformat_error, input);
17319 errmsg ("Transport protocol missing!");
17323 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17324 mp->protocol = (u8) protocol;
17329 /* Wait for a reply... */
17335 api_one_get_transport_protocol (vat_main_t * vam)
17337 vl_api_one_get_transport_protocol_t *mp;
17340 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17345 /* Wait for a reply... */
17351 api_one_map_register_set_ttl (vat_main_t * vam)
17353 unformat_input_t *input = vam->input;
17354 vl_api_one_map_register_set_ttl_t *mp;
17359 /* Parse args required to build the message */
17360 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17362 if (unformat (input, "%u", &ttl))
17366 clib_warning ("parse error '%U'", format_unformat_error, input);
17373 errmsg ("TTL value missing!");
17377 M (ONE_MAP_REGISTER_SET_TTL, mp);
17378 mp->ttl = clib_host_to_net_u32 (ttl);
17383 /* Wait for a reply... */
17389 api_show_one_map_register_ttl (vat_main_t * vam)
17391 vl_api_show_one_map_register_ttl_t *mp;
17394 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17399 /* Wait for a reply... */
17405 * Add/del map request itr rlocs from ONE control plane and updates
17407 * @param vam vpp API test context
17408 * @return return code
17411 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17413 unformat_input_t *input = vam->input;
17414 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17415 u8 *locator_set_name = 0;
17416 u8 locator_set_name_set = 0;
17420 /* Parse args required to build the message */
17421 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17423 if (unformat (input, "del"))
17427 else if (unformat (input, "%_%v%_", &locator_set_name))
17429 locator_set_name_set = 1;
17433 clib_warning ("parse error '%U'", format_unformat_error, input);
17438 if (is_add && !locator_set_name_set)
17440 errmsg ("itr-rloc is not set!");
17444 if (is_add && vec_len (locator_set_name) > 64)
17446 errmsg ("itr-rloc locator-set name too long");
17447 vec_free (locator_set_name);
17451 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17452 mp->is_add = is_add;
17455 clib_memcpy (mp->locator_set_name, locator_set_name,
17456 vec_len (locator_set_name));
17460 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17462 vec_free (locator_set_name);
17467 /* Wait for a reply... */
17472 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17475 api_one_locator_dump (vat_main_t * vam)
17477 unformat_input_t *input = vam->input;
17478 vl_api_one_locator_dump_t *mp;
17479 vl_api_control_ping_t *mp_ping;
17480 u8 is_index_set = 0, is_name_set = 0;
17485 /* Parse args required to build the message */
17486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17488 if (unformat (input, "ls_name %_%v%_", &ls_name))
17492 else if (unformat (input, "ls_index %d", &ls_index))
17498 errmsg ("parse error '%U'", format_unformat_error, input);
17503 if (!is_index_set && !is_name_set)
17505 errmsg ("error: expected one of index or name!");
17509 if (is_index_set && is_name_set)
17511 errmsg ("error: only one param expected!");
17515 if (vec_len (ls_name) > 62)
17517 errmsg ("error: locator set name too long!");
17521 if (!vam->json_output)
17523 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17526 M (ONE_LOCATOR_DUMP, mp);
17527 mp->is_index_set = is_index_set;
17530 mp->ls_index = clib_host_to_net_u32 (ls_index);
17533 vec_add1 (ls_name, 0);
17534 strncpy ((char *) mp->ls_name, (char *) ls_name,
17535 sizeof (mp->ls_name) - 1);
17541 /* Use a control ping for synchronization */
17542 MPING (CONTROL_PING, mp_ping);
17545 /* Wait for a reply... */
17550 #define api_lisp_locator_dump api_one_locator_dump
17553 api_one_locator_set_dump (vat_main_t * vam)
17555 vl_api_one_locator_set_dump_t *mp;
17556 vl_api_control_ping_t *mp_ping;
17557 unformat_input_t *input = vam->input;
17561 /* Parse args required to build the message */
17562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17564 if (unformat (input, "local"))
17568 else if (unformat (input, "remote"))
17574 errmsg ("parse error '%U'", format_unformat_error, input);
17579 if (!vam->json_output)
17581 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17584 M (ONE_LOCATOR_SET_DUMP, mp);
17586 mp->filter = filter;
17591 /* Use a control ping for synchronization */
17592 MPING (CONTROL_PING, mp_ping);
17595 /* Wait for a reply... */
17600 #define api_lisp_locator_set_dump api_one_locator_set_dump
17603 api_one_eid_table_map_dump (vat_main_t * vam)
17607 unformat_input_t *input = vam->input;
17608 vl_api_one_eid_table_map_dump_t *mp;
17609 vl_api_control_ping_t *mp_ping;
17612 /* Parse args required to build the message */
17613 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17615 if (unformat (input, "l2"))
17620 else if (unformat (input, "l3"))
17627 errmsg ("parse error '%U'", format_unformat_error, input);
17634 errmsg ("expected one of 'l2' or 'l3' parameter!");
17638 if (!vam->json_output)
17640 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17643 M (ONE_EID_TABLE_MAP_DUMP, mp);
17649 /* Use a control ping for synchronization */
17650 MPING (CONTROL_PING, mp_ping);
17653 /* Wait for a reply... */
17658 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17661 api_one_eid_table_vni_dump (vat_main_t * vam)
17663 vl_api_one_eid_table_vni_dump_t *mp;
17664 vl_api_control_ping_t *mp_ping;
17667 if (!vam->json_output)
17669 print (vam->ofp, "VNI");
17672 M (ONE_EID_TABLE_VNI_DUMP, mp);
17677 /* Use a control ping for synchronization */
17678 MPING (CONTROL_PING, mp_ping);
17681 /* Wait for a reply... */
17686 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17689 api_one_eid_table_dump (vat_main_t * vam)
17691 unformat_input_t *i = vam->input;
17692 vl_api_one_eid_table_dump_t *mp;
17693 vl_api_control_ping_t *mp_ping;
17694 struct in_addr ip4;
17695 struct in6_addr ip6;
17697 u8 eid_type = ~0, eid_set = 0;
17698 u32 prefix_length = ~0, t, vni = 0;
17701 lisp_nsh_api_t nsh;
17703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17705 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17711 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17717 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17722 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17727 else if (unformat (i, "vni %d", &t))
17731 else if (unformat (i, "local"))
17735 else if (unformat (i, "remote"))
17741 errmsg ("parse error '%U'", format_unformat_error, i);
17746 if (!vam->json_output)
17748 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17749 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17752 M (ONE_EID_TABLE_DUMP, mp);
17754 mp->filter = filter;
17758 mp->vni = htonl (vni);
17759 mp->eid_type = eid_type;
17763 mp->prefix_length = prefix_length;
17764 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17767 mp->prefix_length = prefix_length;
17768 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17771 clib_memcpy (mp->eid, mac, sizeof (mac));
17774 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17777 errmsg ("unknown EID type %d!", eid_type);
17785 /* Use a control ping for synchronization */
17786 MPING (CONTROL_PING, mp_ping);
17789 /* Wait for a reply... */
17794 #define api_lisp_eid_table_dump api_one_eid_table_dump
17797 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17799 unformat_input_t *i = vam->input;
17800 vl_api_gpe_fwd_entries_get_t *mp;
17805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17807 if (unformat (i, "vni %d", &vni))
17813 errmsg ("parse error '%U'", format_unformat_error, i);
17820 errmsg ("vni not set!");
17824 if (!vam->json_output)
17826 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17830 M (GPE_FWD_ENTRIES_GET, mp);
17831 mp->vni = clib_host_to_net_u32 (vni);
17836 /* Wait for a reply... */
17841 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17842 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17843 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17844 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17845 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17846 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17847 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17848 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17851 api_one_adjacencies_get (vat_main_t * vam)
17853 unformat_input_t *i = vam->input;
17854 vl_api_one_adjacencies_get_t *mp;
17859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17861 if (unformat (i, "vni %d", &vni))
17867 errmsg ("parse error '%U'", format_unformat_error, i);
17874 errmsg ("vni not set!");
17878 if (!vam->json_output)
17880 print (vam->ofp, "%s %40s", "leid", "reid");
17883 M (ONE_ADJACENCIES_GET, mp);
17884 mp->vni = clib_host_to_net_u32 (vni);
17889 /* Wait for a reply... */
17894 #define api_lisp_adjacencies_get api_one_adjacencies_get
17897 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17899 unformat_input_t *i = vam->input;
17900 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17902 u8 ip_family_set = 0, is_ip4 = 1;
17904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17906 if (unformat (i, "ip4"))
17911 else if (unformat (i, "ip6"))
17918 errmsg ("parse error '%U'", format_unformat_error, i);
17923 if (!ip_family_set)
17925 errmsg ("ip family not set!");
17929 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17930 mp->is_ip4 = is_ip4;
17935 /* Wait for a reply... */
17941 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17943 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17946 if (!vam->json_output)
17948 print (vam->ofp, "VNIs");
17951 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17956 /* Wait for a reply... */
17962 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17964 unformat_input_t *i = vam->input;
17965 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17967 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17968 struct in_addr ip4;
17969 struct in6_addr ip6;
17970 u32 table_id = 0, nh_sw_if_index = ~0;
17972 memset (&ip4, 0, sizeof (ip4));
17973 memset (&ip6, 0, sizeof (ip6));
17975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17977 if (unformat (i, "del"))
17979 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17980 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17985 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17986 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17991 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17995 nh_sw_if_index = ~0;
17997 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18001 nh_sw_if_index = ~0;
18003 else if (unformat (i, "table %d", &table_id))
18007 errmsg ("parse error '%U'", format_unformat_error, i);
18014 errmsg ("nh addr not set!");
18018 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18019 mp->is_add = is_add;
18020 mp->table_id = clib_host_to_net_u32 (table_id);
18021 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18022 mp->is_ip4 = is_ip4;
18024 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18026 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18031 /* Wait for a reply... */
18037 api_one_map_server_dump (vat_main_t * vam)
18039 vl_api_one_map_server_dump_t *mp;
18040 vl_api_control_ping_t *mp_ping;
18043 if (!vam->json_output)
18045 print (vam->ofp, "%=20s", "Map server");
18048 M (ONE_MAP_SERVER_DUMP, mp);
18052 /* Use a control ping for synchronization */
18053 MPING (CONTROL_PING, mp_ping);
18056 /* Wait for a reply... */
18061 #define api_lisp_map_server_dump api_one_map_server_dump
18064 api_one_map_resolver_dump (vat_main_t * vam)
18066 vl_api_one_map_resolver_dump_t *mp;
18067 vl_api_control_ping_t *mp_ping;
18070 if (!vam->json_output)
18072 print (vam->ofp, "%=20s", "Map resolver");
18075 M (ONE_MAP_RESOLVER_DUMP, mp);
18079 /* Use a control ping for synchronization */
18080 MPING (CONTROL_PING, mp_ping);
18083 /* Wait for a reply... */
18088 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18091 api_one_stats_flush (vat_main_t * vam)
18093 vl_api_one_stats_flush_t *mp;
18096 M (ONE_STATS_FLUSH, mp);
18103 api_one_stats_dump (vat_main_t * vam)
18105 vl_api_one_stats_dump_t *mp;
18106 vl_api_control_ping_t *mp_ping;
18109 M (ONE_STATS_DUMP, mp);
18113 /* Use a control ping for synchronization */
18114 MPING (CONTROL_PING, mp_ping);
18117 /* Wait for a reply... */
18123 api_show_one_status (vat_main_t * vam)
18125 vl_api_show_one_status_t *mp;
18128 if (!vam->json_output)
18130 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18133 M (SHOW_ONE_STATUS, mp);
18136 /* Wait for a reply... */
18141 #define api_show_lisp_status api_show_one_status
18144 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18146 vl_api_gpe_fwd_entry_path_dump_t *mp;
18147 vl_api_control_ping_t *mp_ping;
18148 unformat_input_t *i = vam->input;
18149 u32 fwd_entry_index = ~0;
18152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18154 if (unformat (i, "index %d", &fwd_entry_index))
18160 if (~0 == fwd_entry_index)
18162 errmsg ("no index specified!");
18166 if (!vam->json_output)
18168 print (vam->ofp, "first line");
18171 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18175 /* Use a control ping for synchronization */
18176 MPING (CONTROL_PING, mp_ping);
18179 /* Wait for a reply... */
18185 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18187 vl_api_one_get_map_request_itr_rlocs_t *mp;
18190 if (!vam->json_output)
18192 print (vam->ofp, "%=20s", "itr-rlocs:");
18195 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18198 /* Wait for a reply... */
18203 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18206 api_af_packet_create (vat_main_t * vam)
18208 unformat_input_t *i = vam->input;
18209 vl_api_af_packet_create_t *mp;
18210 u8 *host_if_name = 0;
18212 u8 random_hw_addr = 1;
18215 memset (hw_addr, 0, sizeof (hw_addr));
18217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18219 if (unformat (i, "name %s", &host_if_name))
18220 vec_add1 (host_if_name, 0);
18221 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18222 random_hw_addr = 0;
18227 if (!vec_len (host_if_name))
18229 errmsg ("host-interface name must be specified");
18233 if (vec_len (host_if_name) > 64)
18235 errmsg ("host-interface name too long");
18239 M (AF_PACKET_CREATE, mp);
18241 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18242 clib_memcpy (mp->hw_addr, hw_addr, 6);
18243 mp->use_random_hw_addr = random_hw_addr;
18244 vec_free (host_if_name);
18252 fprintf (vam->ofp ? vam->ofp : stderr,
18253 " new sw_if_index = %d\n", vam->sw_if_index);
18260 api_af_packet_delete (vat_main_t * vam)
18262 unformat_input_t *i = vam->input;
18263 vl_api_af_packet_delete_t *mp;
18264 u8 *host_if_name = 0;
18267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18269 if (unformat (i, "name %s", &host_if_name))
18270 vec_add1 (host_if_name, 0);
18275 if (!vec_len (host_if_name))
18277 errmsg ("host-interface name must be specified");
18281 if (vec_len (host_if_name) > 64)
18283 errmsg ("host-interface name too long");
18287 M (AF_PACKET_DELETE, mp);
18289 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18290 vec_free (host_if_name);
18298 api_policer_add_del (vat_main_t * vam)
18300 unformat_input_t *i = vam->input;
18301 vl_api_policer_add_del_t *mp;
18311 u8 color_aware = 0;
18312 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18315 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18316 conform_action.dscp = 0;
18317 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18318 exceed_action.dscp = 0;
18319 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18320 violate_action.dscp = 0;
18322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18324 if (unformat (i, "del"))
18326 else if (unformat (i, "name %s", &name))
18327 vec_add1 (name, 0);
18328 else if (unformat (i, "cir %u", &cir))
18330 else if (unformat (i, "eir %u", &eir))
18332 else if (unformat (i, "cb %u", &cb))
18334 else if (unformat (i, "eb %u", &eb))
18336 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18339 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18342 else if (unformat (i, "type %U", unformat_policer_type, &type))
18344 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18347 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18350 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18353 else if (unformat (i, "color-aware"))
18359 if (!vec_len (name))
18361 errmsg ("policer name must be specified");
18365 if (vec_len (name) > 64)
18367 errmsg ("policer name too long");
18371 M (POLICER_ADD_DEL, mp);
18373 clib_memcpy (mp->name, name, vec_len (name));
18375 mp->is_add = is_add;
18376 mp->cir = ntohl (cir);
18377 mp->eir = ntohl (eir);
18378 mp->cb = clib_net_to_host_u64 (cb);
18379 mp->eb = clib_net_to_host_u64 (eb);
18380 mp->rate_type = rate_type;
18381 mp->round_type = round_type;
18383 mp->conform_action_type = conform_action.action_type;
18384 mp->conform_dscp = conform_action.dscp;
18385 mp->exceed_action_type = exceed_action.action_type;
18386 mp->exceed_dscp = exceed_action.dscp;
18387 mp->violate_action_type = violate_action.action_type;
18388 mp->violate_dscp = violate_action.dscp;
18389 mp->color_aware = color_aware;
18397 api_policer_dump (vat_main_t * vam)
18399 unformat_input_t *i = vam->input;
18400 vl_api_policer_dump_t *mp;
18401 vl_api_control_ping_t *mp_ping;
18402 u8 *match_name = 0;
18403 u8 match_name_valid = 0;
18406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18408 if (unformat (i, "name %s", &match_name))
18410 vec_add1 (match_name, 0);
18411 match_name_valid = 1;
18417 M (POLICER_DUMP, mp);
18418 mp->match_name_valid = match_name_valid;
18419 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18420 vec_free (match_name);
18424 /* Use a control ping for synchronization */
18425 MPING (CONTROL_PING, mp_ping);
18428 /* Wait for a reply... */
18434 api_policer_classify_set_interface (vat_main_t * vam)
18436 unformat_input_t *i = vam->input;
18437 vl_api_policer_classify_set_interface_t *mp;
18439 int sw_if_index_set;
18440 u32 ip4_table_index = ~0;
18441 u32 ip6_table_index = ~0;
18442 u32 l2_table_index = ~0;
18446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18448 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18449 sw_if_index_set = 1;
18450 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18451 sw_if_index_set = 1;
18452 else if (unformat (i, "del"))
18454 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18456 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18458 else if (unformat (i, "l2-table %d", &l2_table_index))
18462 clib_warning ("parse error '%U'", format_unformat_error, i);
18467 if (sw_if_index_set == 0)
18469 errmsg ("missing interface name or sw_if_index");
18473 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18475 mp->sw_if_index = ntohl (sw_if_index);
18476 mp->ip4_table_index = ntohl (ip4_table_index);
18477 mp->ip6_table_index = ntohl (ip6_table_index);
18478 mp->l2_table_index = ntohl (l2_table_index);
18479 mp->is_add = is_add;
18487 api_policer_classify_dump (vat_main_t * vam)
18489 unformat_input_t *i = vam->input;
18490 vl_api_policer_classify_dump_t *mp;
18491 vl_api_control_ping_t *mp_ping;
18492 u8 type = POLICER_CLASSIFY_N_TABLES;
18495 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18499 errmsg ("classify table type must be specified");
18503 if (!vam->json_output)
18505 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18508 M (POLICER_CLASSIFY_DUMP, mp);
18513 /* Use a control ping for synchronization */
18514 MPING (CONTROL_PING, mp_ping);
18517 /* Wait for a reply... */
18523 api_netmap_create (vat_main_t * vam)
18525 unformat_input_t *i = vam->input;
18526 vl_api_netmap_create_t *mp;
18529 u8 random_hw_addr = 1;
18534 memset (hw_addr, 0, sizeof (hw_addr));
18536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18538 if (unformat (i, "name %s", &if_name))
18539 vec_add1 (if_name, 0);
18540 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18541 random_hw_addr = 0;
18542 else if (unformat (i, "pipe"))
18544 else if (unformat (i, "master"))
18546 else if (unformat (i, "slave"))
18552 if (!vec_len (if_name))
18554 errmsg ("interface name must be specified");
18558 if (vec_len (if_name) > 64)
18560 errmsg ("interface name too long");
18564 M (NETMAP_CREATE, mp);
18566 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18567 clib_memcpy (mp->hw_addr, hw_addr, 6);
18568 mp->use_random_hw_addr = random_hw_addr;
18569 mp->is_pipe = is_pipe;
18570 mp->is_master = is_master;
18571 vec_free (if_name);
18579 api_netmap_delete (vat_main_t * vam)
18581 unformat_input_t *i = vam->input;
18582 vl_api_netmap_delete_t *mp;
18586 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18588 if (unformat (i, "name %s", &if_name))
18589 vec_add1 (if_name, 0);
18594 if (!vec_len (if_name))
18596 errmsg ("interface name must be specified");
18600 if (vec_len (if_name) > 64)
18602 errmsg ("interface name too long");
18606 M (NETMAP_DELETE, mp);
18608 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18609 vec_free (if_name);
18617 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18619 if (fp->afi == IP46_TYPE_IP6)
18621 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18622 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18623 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18624 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18625 format_ip6_address, fp->next_hop);
18626 else if (fp->afi == IP46_TYPE_IP4)
18628 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18629 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18630 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18631 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18632 format_ip4_address, fp->next_hop);
18636 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18637 vl_api_fib_path2_t * fp)
18639 struct in_addr ip4;
18640 struct in6_addr ip6;
18642 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18643 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18644 vat_json_object_add_uint (node, "is_local", fp->is_local);
18645 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18646 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18647 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18648 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18649 if (fp->afi == IP46_TYPE_IP4)
18651 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18652 vat_json_object_add_ip4 (node, "next_hop", ip4);
18654 else if (fp->afi == IP46_TYPE_IP6)
18656 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18657 vat_json_object_add_ip6 (node, "next_hop", ip6);
18662 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18664 vat_main_t *vam = &vat_main;
18665 int count = ntohl (mp->mt_count);
18666 vl_api_fib_path2_t *fp;
18669 print (vam->ofp, "[%d]: sw_if_index %d via:",
18670 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18672 for (i = 0; i < count; i++)
18674 vl_api_mpls_fib_path_print (vam, fp);
18678 print (vam->ofp, "");
18681 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18682 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18685 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18687 vat_main_t *vam = &vat_main;
18688 vat_json_node_t *node = NULL;
18689 int count = ntohl (mp->mt_count);
18690 vl_api_fib_path2_t *fp;
18693 if (VAT_JSON_ARRAY != vam->json_tree.type)
18695 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18696 vat_json_init_array (&vam->json_tree);
18698 node = vat_json_array_add (&vam->json_tree);
18700 vat_json_init_object (node);
18701 vat_json_object_add_uint (node, "tunnel_index",
18702 ntohl (mp->mt_tunnel_index));
18703 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18705 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18708 for (i = 0; i < count; i++)
18710 vl_api_mpls_fib_path_json_print (node, fp);
18716 api_mpls_tunnel_dump (vat_main_t * vam)
18718 vl_api_mpls_tunnel_dump_t *mp;
18719 vl_api_control_ping_t *mp_ping;
18723 /* Parse args required to build the message */
18724 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18726 if (!unformat (vam->input, "tunnel_index %d", &index))
18733 print (vam->ofp, " tunnel_index %d", index);
18735 M (MPLS_TUNNEL_DUMP, mp);
18736 mp->tunnel_index = htonl (index);
18739 /* Use a control ping for synchronization */
18740 MPING (CONTROL_PING, mp_ping);
18747 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18748 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18752 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18754 vat_main_t *vam = &vat_main;
18755 int count = ntohl (mp->count);
18756 vl_api_fib_path2_t *fp;
18760 "table-id %d, label %u, ess_bit %u",
18761 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18763 for (i = 0; i < count; i++)
18765 vl_api_mpls_fib_path_print (vam, fp);
18770 static void vl_api_mpls_fib_details_t_handler_json
18771 (vl_api_mpls_fib_details_t * mp)
18773 vat_main_t *vam = &vat_main;
18774 int count = ntohl (mp->count);
18775 vat_json_node_t *node = NULL;
18776 vl_api_fib_path2_t *fp;
18779 if (VAT_JSON_ARRAY != vam->json_tree.type)
18781 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18782 vat_json_init_array (&vam->json_tree);
18784 node = vat_json_array_add (&vam->json_tree);
18786 vat_json_init_object (node);
18787 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18788 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18789 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18790 vat_json_object_add_uint (node, "path_count", count);
18792 for (i = 0; i < count; i++)
18794 vl_api_mpls_fib_path_json_print (node, fp);
18800 api_mpls_fib_dump (vat_main_t * vam)
18802 vl_api_mpls_fib_dump_t *mp;
18803 vl_api_control_ping_t *mp_ping;
18806 M (MPLS_FIB_DUMP, mp);
18809 /* Use a control ping for synchronization */
18810 MPING (CONTROL_PING, mp_ping);
18817 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18818 #define vl_api_ip_fib_details_t_print vl_noop_handler
18821 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18823 vat_main_t *vam = &vat_main;
18824 int count = ntohl (mp->count);
18825 vl_api_fib_path_t *fp;
18829 "table-id %d, prefix %U/%d",
18830 ntohl (mp->table_id), format_ip4_address, mp->address,
18831 mp->address_length);
18833 for (i = 0; i < count; i++)
18835 if (fp->afi == IP46_TYPE_IP6)
18837 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18838 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18839 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18840 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18841 format_ip6_address, fp->next_hop);
18842 else if (fp->afi == IP46_TYPE_IP4)
18844 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18845 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18846 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18847 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18848 format_ip4_address, fp->next_hop);
18853 static void vl_api_ip_fib_details_t_handler_json
18854 (vl_api_ip_fib_details_t * mp)
18856 vat_main_t *vam = &vat_main;
18857 int count = ntohl (mp->count);
18858 vat_json_node_t *node = NULL;
18859 struct in_addr ip4;
18860 struct in6_addr ip6;
18861 vl_api_fib_path_t *fp;
18864 if (VAT_JSON_ARRAY != vam->json_tree.type)
18866 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18867 vat_json_init_array (&vam->json_tree);
18869 node = vat_json_array_add (&vam->json_tree);
18871 vat_json_init_object (node);
18872 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18873 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18874 vat_json_object_add_ip4 (node, "prefix", ip4);
18875 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18876 vat_json_object_add_uint (node, "path_count", count);
18878 for (i = 0; i < count; i++)
18880 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18881 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18882 vat_json_object_add_uint (node, "is_local", fp->is_local);
18883 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18884 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18885 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18886 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18887 if (fp->afi == IP46_TYPE_IP4)
18889 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18890 vat_json_object_add_ip4 (node, "next_hop", ip4);
18892 else if (fp->afi == IP46_TYPE_IP6)
18894 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18895 vat_json_object_add_ip6 (node, "next_hop", ip6);
18901 api_ip_fib_dump (vat_main_t * vam)
18903 vl_api_ip_fib_dump_t *mp;
18904 vl_api_control_ping_t *mp_ping;
18907 M (IP_FIB_DUMP, mp);
18910 /* Use a control ping for synchronization */
18911 MPING (CONTROL_PING, mp_ping);
18919 api_ip_mfib_dump (vat_main_t * vam)
18921 vl_api_ip_mfib_dump_t *mp;
18922 vl_api_control_ping_t *mp_ping;
18925 M (IP_MFIB_DUMP, mp);
18928 /* Use a control ping for synchronization */
18929 MPING (CONTROL_PING, mp_ping);
18936 static void vl_api_ip_neighbor_details_t_handler
18937 (vl_api_ip_neighbor_details_t * mp)
18939 vat_main_t *vam = &vat_main;
18941 print (vam->ofp, "%c %U %U",
18942 (mp->is_static) ? 'S' : 'D',
18943 format_ethernet_address, &mp->mac_address,
18944 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18948 static void vl_api_ip_neighbor_details_t_handler_json
18949 (vl_api_ip_neighbor_details_t * mp)
18952 vat_main_t *vam = &vat_main;
18953 vat_json_node_t *node;
18954 struct in_addr ip4;
18955 struct in6_addr ip6;
18957 if (VAT_JSON_ARRAY != vam->json_tree.type)
18959 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18960 vat_json_init_array (&vam->json_tree);
18962 node = vat_json_array_add (&vam->json_tree);
18964 vat_json_init_object (node);
18965 vat_json_object_add_string_copy (node, "flag",
18966 (mp->is_static) ? (u8 *) "static" : (u8 *)
18969 vat_json_object_add_string_copy (node, "link_layer",
18970 format (0, "%U", format_ethernet_address,
18971 &mp->mac_address));
18975 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18976 vat_json_object_add_ip6 (node, "ip_address", ip6);
18980 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18981 vat_json_object_add_ip4 (node, "ip_address", ip4);
18986 api_ip_neighbor_dump (vat_main_t * vam)
18988 unformat_input_t *i = vam->input;
18989 vl_api_ip_neighbor_dump_t *mp;
18990 vl_api_control_ping_t *mp_ping;
18992 u32 sw_if_index = ~0;
18995 /* Parse args required to build the message */
18996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19000 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19002 else if (unformat (i, "ip6"))
19008 if (sw_if_index == ~0)
19010 errmsg ("missing interface name or sw_if_index");
19014 M (IP_NEIGHBOR_DUMP, mp);
19015 mp->is_ipv6 = (u8) is_ipv6;
19016 mp->sw_if_index = ntohl (sw_if_index);
19019 /* Use a control ping for synchronization */
19020 MPING (CONTROL_PING, mp_ping);
19027 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19028 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19031 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19033 vat_main_t *vam = &vat_main;
19034 int count = ntohl (mp->count);
19035 vl_api_fib_path_t *fp;
19039 "table-id %d, prefix %U/%d",
19040 ntohl (mp->table_id), format_ip6_address, mp->address,
19041 mp->address_length);
19043 for (i = 0; i < count; i++)
19045 if (fp->afi == IP46_TYPE_IP6)
19047 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19048 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19049 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19050 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19051 format_ip6_address, fp->next_hop);
19052 else if (fp->afi == IP46_TYPE_IP4)
19054 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19055 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19056 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19057 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19058 format_ip4_address, fp->next_hop);
19063 static void vl_api_ip6_fib_details_t_handler_json
19064 (vl_api_ip6_fib_details_t * mp)
19066 vat_main_t *vam = &vat_main;
19067 int count = ntohl (mp->count);
19068 vat_json_node_t *node = NULL;
19069 struct in_addr ip4;
19070 struct in6_addr ip6;
19071 vl_api_fib_path_t *fp;
19074 if (VAT_JSON_ARRAY != vam->json_tree.type)
19076 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19077 vat_json_init_array (&vam->json_tree);
19079 node = vat_json_array_add (&vam->json_tree);
19081 vat_json_init_object (node);
19082 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19083 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19084 vat_json_object_add_ip6 (node, "prefix", ip6);
19085 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19086 vat_json_object_add_uint (node, "path_count", count);
19088 for (i = 0; i < count; i++)
19090 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19091 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19092 vat_json_object_add_uint (node, "is_local", fp->is_local);
19093 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19094 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19095 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19096 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19097 if (fp->afi == IP46_TYPE_IP4)
19099 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19100 vat_json_object_add_ip4 (node, "next_hop", ip4);
19102 else if (fp->afi == IP46_TYPE_IP6)
19104 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19105 vat_json_object_add_ip6 (node, "next_hop", ip6);
19111 api_ip6_fib_dump (vat_main_t * vam)
19113 vl_api_ip6_fib_dump_t *mp;
19114 vl_api_control_ping_t *mp_ping;
19117 M (IP6_FIB_DUMP, mp);
19120 /* Use a control ping for synchronization */
19121 MPING (CONTROL_PING, mp_ping);
19129 api_ip6_mfib_dump (vat_main_t * vam)
19131 vl_api_ip6_mfib_dump_t *mp;
19132 vl_api_control_ping_t *mp_ping;
19135 M (IP6_MFIB_DUMP, mp);
19138 /* Use a control ping for synchronization */
19139 MPING (CONTROL_PING, mp_ping);
19147 api_classify_table_ids (vat_main_t * vam)
19149 vl_api_classify_table_ids_t *mp;
19152 /* Construct the API message */
19153 M (CLASSIFY_TABLE_IDS, mp);
19162 api_classify_table_by_interface (vat_main_t * vam)
19164 unformat_input_t *input = vam->input;
19165 vl_api_classify_table_by_interface_t *mp;
19167 u32 sw_if_index = ~0;
19169 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19171 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19173 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19178 if (sw_if_index == ~0)
19180 errmsg ("missing interface name or sw_if_index");
19184 /* Construct the API message */
19185 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19187 mp->sw_if_index = ntohl (sw_if_index);
19195 api_classify_table_info (vat_main_t * vam)
19197 unformat_input_t *input = vam->input;
19198 vl_api_classify_table_info_t *mp;
19202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19204 if (unformat (input, "table_id %d", &table_id))
19209 if (table_id == ~0)
19211 errmsg ("missing table id");
19215 /* Construct the API message */
19216 M (CLASSIFY_TABLE_INFO, mp);
19218 mp->table_id = ntohl (table_id);
19226 api_classify_session_dump (vat_main_t * vam)
19228 unformat_input_t *input = vam->input;
19229 vl_api_classify_session_dump_t *mp;
19230 vl_api_control_ping_t *mp_ping;
19234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19236 if (unformat (input, "table_id %d", &table_id))
19241 if (table_id == ~0)
19243 errmsg ("missing table id");
19247 /* Construct the API message */
19248 M (CLASSIFY_SESSION_DUMP, mp);
19250 mp->table_id = ntohl (table_id);
19253 /* Use a control ping for synchronization */
19254 MPING (CONTROL_PING, mp_ping);
19262 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19264 vat_main_t *vam = &vat_main;
19266 print (vam->ofp, "collector_address %U, collector_port %d, "
19267 "src_address %U, vrf_id %d, path_mtu %u, "
19268 "template_interval %u, udp_checksum %d",
19269 format_ip4_address, mp->collector_address,
19270 ntohs (mp->collector_port),
19271 format_ip4_address, mp->src_address,
19272 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19273 ntohl (mp->template_interval), mp->udp_checksum);
19276 vam->result_ready = 1;
19280 vl_api_ipfix_exporter_details_t_handler_json
19281 (vl_api_ipfix_exporter_details_t * mp)
19283 vat_main_t *vam = &vat_main;
19284 vat_json_node_t node;
19285 struct in_addr collector_address;
19286 struct in_addr src_address;
19288 vat_json_init_object (&node);
19289 clib_memcpy (&collector_address, &mp->collector_address,
19290 sizeof (collector_address));
19291 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19292 vat_json_object_add_uint (&node, "collector_port",
19293 ntohs (mp->collector_port));
19294 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19295 vat_json_object_add_ip4 (&node, "src_address", src_address);
19296 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19297 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19298 vat_json_object_add_uint (&node, "template_interval",
19299 ntohl (mp->template_interval));
19300 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19302 vat_json_print (vam->ofp, &node);
19303 vat_json_free (&node);
19305 vam->result_ready = 1;
19309 api_ipfix_exporter_dump (vat_main_t * vam)
19311 vl_api_ipfix_exporter_dump_t *mp;
19314 /* Construct the API message */
19315 M (IPFIX_EXPORTER_DUMP, mp);
19324 api_ipfix_classify_stream_dump (vat_main_t * vam)
19326 vl_api_ipfix_classify_stream_dump_t *mp;
19329 /* Construct the API message */
19330 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19341 vl_api_ipfix_classify_stream_details_t_handler
19342 (vl_api_ipfix_classify_stream_details_t * mp)
19344 vat_main_t *vam = &vat_main;
19345 print (vam->ofp, "domain_id %d, src_port %d",
19346 ntohl (mp->domain_id), ntohs (mp->src_port));
19348 vam->result_ready = 1;
19352 vl_api_ipfix_classify_stream_details_t_handler_json
19353 (vl_api_ipfix_classify_stream_details_t * mp)
19355 vat_main_t *vam = &vat_main;
19356 vat_json_node_t node;
19358 vat_json_init_object (&node);
19359 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19360 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19362 vat_json_print (vam->ofp, &node);
19363 vat_json_free (&node);
19365 vam->result_ready = 1;
19369 api_ipfix_classify_table_dump (vat_main_t * vam)
19371 vl_api_ipfix_classify_table_dump_t *mp;
19372 vl_api_control_ping_t *mp_ping;
19375 if (!vam->json_output)
19377 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19378 "transport_protocol");
19381 /* Construct the API message */
19382 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19387 /* Use a control ping for synchronization */
19388 MPING (CONTROL_PING, mp_ping);
19396 vl_api_ipfix_classify_table_details_t_handler
19397 (vl_api_ipfix_classify_table_details_t * mp)
19399 vat_main_t *vam = &vat_main;
19400 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19401 mp->transport_protocol);
19405 vl_api_ipfix_classify_table_details_t_handler_json
19406 (vl_api_ipfix_classify_table_details_t * mp)
19408 vat_json_node_t *node = NULL;
19409 vat_main_t *vam = &vat_main;
19411 if (VAT_JSON_ARRAY != vam->json_tree.type)
19413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19414 vat_json_init_array (&vam->json_tree);
19417 node = vat_json_array_add (&vam->json_tree);
19418 vat_json_init_object (node);
19420 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19421 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19422 vat_json_object_add_uint (node, "transport_protocol",
19423 mp->transport_protocol);
19427 api_sw_interface_span_enable_disable (vat_main_t * vam)
19429 unformat_input_t *i = vam->input;
19430 vl_api_sw_interface_span_enable_disable_t *mp;
19431 u32 src_sw_if_index = ~0;
19432 u32 dst_sw_if_index = ~0;
19437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19440 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19442 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19446 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19448 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19450 else if (unformat (i, "disable"))
19452 else if (unformat (i, "rx"))
19454 else if (unformat (i, "tx"))
19456 else if (unformat (i, "both"))
19458 else if (unformat (i, "l2"))
19464 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19466 mp->sw_if_index_from = htonl (src_sw_if_index);
19467 mp->sw_if_index_to = htonl (dst_sw_if_index);
19477 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19480 vat_main_t *vam = &vat_main;
19481 u8 *sw_if_from_name = 0;
19482 u8 *sw_if_to_name = 0;
19483 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19484 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19485 char *states[] = { "none", "rx", "tx", "both" };
19489 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19491 if ((u32) p->value[0] == sw_if_index_from)
19493 sw_if_from_name = (u8 *)(p->key);
19497 if ((u32) p->value[0] == sw_if_index_to)
19499 sw_if_to_name = (u8 *)(p->key);
19500 if (sw_if_from_name)
19505 print (vam->ofp, "%20s => %20s (%s)",
19506 sw_if_from_name, sw_if_to_name, states[mp->state]);
19510 vl_api_sw_interface_span_details_t_handler_json
19511 (vl_api_sw_interface_span_details_t * mp)
19513 vat_main_t *vam = &vat_main;
19514 vat_json_node_t *node = NULL;
19515 u8 *sw_if_from_name = 0;
19516 u8 *sw_if_to_name = 0;
19517 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19518 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19522 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19524 if ((u32) p->value[0] == sw_if_index_from)
19526 sw_if_from_name = (u8 *)(p->key);
19530 if ((u32) p->value[0] == sw_if_index_to)
19532 sw_if_to_name = (u8 *)(p->key);
19533 if (sw_if_from_name)
19539 if (VAT_JSON_ARRAY != vam->json_tree.type)
19541 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19542 vat_json_init_array (&vam->json_tree);
19544 node = vat_json_array_add (&vam->json_tree);
19546 vat_json_init_object (node);
19547 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19548 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19549 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19550 if (0 != sw_if_to_name)
19552 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19554 vat_json_object_add_uint (node, "state", mp->state);
19558 api_sw_interface_span_dump (vat_main_t * vam)
19560 unformat_input_t *input = vam->input;
19561 vl_api_sw_interface_span_dump_t *mp;
19562 vl_api_control_ping_t *mp_ping;
19566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19568 if (unformat (input, "l2"))
19574 M (SW_INTERFACE_SPAN_DUMP, mp);
19578 /* Use a control ping for synchronization */
19579 MPING (CONTROL_PING, mp_ping);
19587 api_pg_create_interface (vat_main_t * vam)
19589 unformat_input_t *input = vam->input;
19590 vl_api_pg_create_interface_t *mp;
19594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19596 if (unformat (input, "if_id %d", &if_id))
19603 errmsg ("missing pg interface index");
19607 /* Construct the API message */
19608 M (PG_CREATE_INTERFACE, mp);
19610 mp->interface_id = ntohl (if_id);
19618 api_pg_capture (vat_main_t * vam)
19620 unformat_input_t *input = vam->input;
19621 vl_api_pg_capture_t *mp;
19626 u8 pcap_file_set = 0;
19629 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19631 if (unformat (input, "if_id %d", &if_id))
19633 else if (unformat (input, "pcap %s", &pcap_file))
19635 else if (unformat (input, "count %d", &count))
19637 else if (unformat (input, "disable"))
19644 errmsg ("missing pg interface index");
19647 if (pcap_file_set > 0)
19649 if (vec_len (pcap_file) > 255)
19651 errmsg ("pcap file name is too long");
19656 u32 name_len = vec_len (pcap_file);
19657 /* Construct the API message */
19658 M (PG_CAPTURE, mp);
19660 mp->interface_id = ntohl (if_id);
19661 mp->is_enabled = enable;
19662 mp->count = ntohl (count);
19663 mp->pcap_name_length = ntohl (name_len);
19664 if (pcap_file_set != 0)
19666 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19668 vec_free (pcap_file);
19676 api_pg_enable_disable (vat_main_t * vam)
19678 unformat_input_t *input = vam->input;
19679 vl_api_pg_enable_disable_t *mp;
19682 u8 stream_name_set = 0;
19683 u8 *stream_name = 0;
19685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19687 if (unformat (input, "stream %s", &stream_name))
19688 stream_name_set = 1;
19689 else if (unformat (input, "disable"))
19695 if (stream_name_set > 0)
19697 if (vec_len (stream_name) > 255)
19699 errmsg ("stream name too long");
19704 u32 name_len = vec_len (stream_name);
19705 /* Construct the API message */
19706 M (PG_ENABLE_DISABLE, mp);
19708 mp->is_enabled = enable;
19709 if (stream_name_set != 0)
19711 mp->stream_name_length = ntohl (name_len);
19712 clib_memcpy (mp->stream_name, stream_name, name_len);
19714 vec_free (stream_name);
19722 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19724 unformat_input_t *input = vam->input;
19725 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19727 u16 *low_ports = 0;
19728 u16 *high_ports = 0;
19731 ip4_address_t ip4_addr;
19732 ip6_address_t ip6_addr;
19741 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19743 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19749 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19754 else if (unformat (input, "vrf %d", &vrf_id))
19756 else if (unformat (input, "del"))
19758 else if (unformat (input, "port %d", &tmp))
19760 if (tmp == 0 || tmp > 65535)
19762 errmsg ("port %d out of range", tmp);
19766 this_hi = this_low + 1;
19767 vec_add1 (low_ports, this_low);
19768 vec_add1 (high_ports, this_hi);
19770 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19772 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19774 errmsg ("incorrect range parameters");
19778 /* Note: in debug CLI +1 is added to high before
19779 passing to real fn that does "the work"
19780 (ip_source_and_port_range_check_add_del).
19781 This fn is a wrapper around the binary API fn a
19782 control plane will call, which expects this increment
19783 to have occurred. Hence letting the binary API control
19784 plane fn do the increment for consistency between VAT
19785 and other control planes.
19788 vec_add1 (low_ports, this_low);
19789 vec_add1 (high_ports, this_hi);
19795 if (prefix_set == 0)
19797 errmsg ("<address>/<mask> not specified");
19803 errmsg ("VRF ID required, not specified");
19810 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19814 if (vec_len (low_ports) == 0)
19816 errmsg ("At least one port or port range required");
19820 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19822 mp->is_add = is_add;
19827 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19832 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19835 mp->mask_length = length;
19836 mp->number_of_ranges = vec_len (low_ports);
19838 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19839 vec_free (low_ports);
19841 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19842 vec_free (high_ports);
19844 mp->vrf_id = ntohl (vrf_id);
19852 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19854 unformat_input_t *input = vam->input;
19855 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19856 u32 sw_if_index = ~0;
19858 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19859 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19865 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19867 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19869 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19871 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19873 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19875 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19877 else if (unformat (input, "del"))
19883 if (sw_if_index == ~0)
19885 errmsg ("Interface required but not specified");
19891 errmsg ("VRF ID required but not specified");
19895 if (tcp_out_vrf_id == 0
19896 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19899 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19903 /* Construct the API message */
19904 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19906 mp->sw_if_index = ntohl (sw_if_index);
19907 mp->is_add = is_add;
19908 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19909 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19910 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19911 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19916 /* Wait for a reply... */
19922 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19924 unformat_input_t *i = vam->input;
19925 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19926 u32 local_sa_id = 0;
19927 u32 remote_sa_id = 0;
19928 ip4_address_t src_address;
19929 ip4_address_t dst_address;
19933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19935 if (unformat (i, "local_sa %d", &local_sa_id))
19937 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19939 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19941 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19943 else if (unformat (i, "del"))
19947 clib_warning ("parse error '%U'", format_unformat_error, i);
19952 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19954 mp->local_sa_id = ntohl (local_sa_id);
19955 mp->remote_sa_id = ntohl (remote_sa_id);
19956 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19957 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19958 mp->is_add = is_add;
19966 api_punt (vat_main_t * vam)
19968 unformat_input_t *i = vam->input;
19976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19978 if (unformat (i, "ip %d", &ipv))
19980 else if (unformat (i, "protocol %d", &protocol))
19982 else if (unformat (i, "port %d", &port))
19984 else if (unformat (i, "del"))
19988 clib_warning ("parse error '%U'", format_unformat_error, i);
19995 mp->is_add = (u8) is_add;
19996 mp->ipv = (u8) ipv;
19997 mp->l4_protocol = (u8) protocol;
19998 mp->l4_port = htons ((u16) port);
20005 static void vl_api_ipsec_gre_tunnel_details_t_handler
20006 (vl_api_ipsec_gre_tunnel_details_t * mp)
20008 vat_main_t *vam = &vat_main;
20010 print (vam->ofp, "%11d%15U%15U%14d%14d",
20011 ntohl (mp->sw_if_index),
20012 format_ip4_address, &mp->src_address,
20013 format_ip4_address, &mp->dst_address,
20014 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20017 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20018 (vl_api_ipsec_gre_tunnel_details_t * mp)
20020 vat_main_t *vam = &vat_main;
20021 vat_json_node_t *node = NULL;
20022 struct in_addr ip4;
20024 if (VAT_JSON_ARRAY != vam->json_tree.type)
20026 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20027 vat_json_init_array (&vam->json_tree);
20029 node = vat_json_array_add (&vam->json_tree);
20031 vat_json_init_object (node);
20032 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20033 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20034 vat_json_object_add_ip4 (node, "src_address", ip4);
20035 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20036 vat_json_object_add_ip4 (node, "dst_address", ip4);
20037 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20038 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20042 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20044 unformat_input_t *i = vam->input;
20045 vl_api_ipsec_gre_tunnel_dump_t *mp;
20046 vl_api_control_ping_t *mp_ping;
20048 u8 sw_if_index_set = 0;
20051 /* Parse args required to build the message */
20052 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20054 if (unformat (i, "sw_if_index %d", &sw_if_index))
20055 sw_if_index_set = 1;
20060 if (sw_if_index_set == 0)
20065 if (!vam->json_output)
20067 print (vam->ofp, "%11s%15s%15s%14s%14s",
20068 "sw_if_index", "src_address", "dst_address",
20069 "local_sa_id", "remote_sa_id");
20072 /* Get list of gre-tunnel interfaces */
20073 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20075 mp->sw_if_index = htonl (sw_if_index);
20079 /* Use a control ping for synchronization */
20080 MPING (CONTROL_PING, mp_ping);
20088 api_delete_subif (vat_main_t * vam)
20090 unformat_input_t *i = vam->input;
20091 vl_api_delete_subif_t *mp;
20092 u32 sw_if_index = ~0;
20095 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20097 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20099 if (unformat (i, "sw_if_index %d", &sw_if_index))
20105 if (sw_if_index == ~0)
20107 errmsg ("missing sw_if_index");
20111 /* Construct the API message */
20112 M (DELETE_SUBIF, mp);
20113 mp->sw_if_index = ntohl (sw_if_index);
20120 #define foreach_pbb_vtr_op \
20121 _("disable", L2_VTR_DISABLED) \
20122 _("pop", L2_VTR_POP_2) \
20123 _("push", L2_VTR_PUSH_2)
20126 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20128 unformat_input_t *i = vam->input;
20129 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20130 u32 sw_if_index = ~0, vtr_op = ~0;
20131 u16 outer_tag = ~0;
20132 u8 dmac[6], smac[6];
20133 u8 dmac_set = 0, smac_set = 0;
20139 /* Shut up coverity */
20140 memset (dmac, 0, sizeof (dmac));
20141 memset (smac, 0, sizeof (smac));
20143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20149 else if (unformat (i, "vtr_op %d", &vtr_op))
20151 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20154 else if (unformat (i, "translate_pbb_stag"))
20156 if (unformat (i, "%d", &tmp))
20158 vtr_op = L2_VTR_TRANSLATE_2_1;
20164 ("translate_pbb_stag operation requires outer tag definition");
20168 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20170 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20172 else if (unformat (i, "sid %d", &sid))
20174 else if (unformat (i, "vlanid %d", &tmp))
20178 clib_warning ("parse error '%U'", format_unformat_error, i);
20183 if ((sw_if_index == ~0) || (vtr_op == ~0))
20185 errmsg ("missing sw_if_index or vtr operation");
20188 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20189 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20192 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20196 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20197 mp->sw_if_index = ntohl (sw_if_index);
20198 mp->vtr_op = ntohl (vtr_op);
20199 mp->outer_tag = ntohs (outer_tag);
20200 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20201 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20202 mp->b_vlanid = ntohs (vlanid);
20203 mp->i_sid = ntohl (sid);
20211 api_flow_classify_set_interface (vat_main_t * vam)
20213 unformat_input_t *i = vam->input;
20214 vl_api_flow_classify_set_interface_t *mp;
20216 int sw_if_index_set;
20217 u32 ip4_table_index = ~0;
20218 u32 ip6_table_index = ~0;
20222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20225 sw_if_index_set = 1;
20226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20227 sw_if_index_set = 1;
20228 else if (unformat (i, "del"))
20230 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20232 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20236 clib_warning ("parse error '%U'", format_unformat_error, i);
20241 if (sw_if_index_set == 0)
20243 errmsg ("missing interface name or sw_if_index");
20247 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20249 mp->sw_if_index = ntohl (sw_if_index);
20250 mp->ip4_table_index = ntohl (ip4_table_index);
20251 mp->ip6_table_index = ntohl (ip6_table_index);
20252 mp->is_add = is_add;
20260 api_flow_classify_dump (vat_main_t * vam)
20262 unformat_input_t *i = vam->input;
20263 vl_api_flow_classify_dump_t *mp;
20264 vl_api_control_ping_t *mp_ping;
20265 u8 type = FLOW_CLASSIFY_N_TABLES;
20268 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20272 errmsg ("classify table type must be specified");
20276 if (!vam->json_output)
20278 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20281 M (FLOW_CLASSIFY_DUMP, mp);
20286 /* Use a control ping for synchronization */
20287 MPING (CONTROL_PING, mp_ping);
20290 /* Wait for a reply... */
20296 api_feature_enable_disable (vat_main_t * vam)
20298 unformat_input_t *i = vam->input;
20299 vl_api_feature_enable_disable_t *mp;
20301 u8 *feature_name = 0;
20302 u32 sw_if_index = ~0;
20306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20308 if (unformat (i, "arc_name %s", &arc_name))
20310 else if (unformat (i, "feature_name %s", &feature_name))
20313 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20315 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20317 else if (unformat (i, "disable"))
20325 errmsg ("missing arc name");
20328 if (vec_len (arc_name) > 63)
20330 errmsg ("arc name too long");
20333 if (feature_name == 0)
20335 errmsg ("missing feature name");
20338 if (vec_len (feature_name) > 63)
20340 errmsg ("feature name too long");
20343 if (sw_if_index == ~0)
20345 errmsg ("missing interface name or sw_if_index");
20349 /* Construct the API message */
20350 M (FEATURE_ENABLE_DISABLE, mp);
20351 mp->sw_if_index = ntohl (sw_if_index);
20352 mp->enable = enable;
20353 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20354 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20355 vec_free (arc_name);
20356 vec_free (feature_name);
20364 api_sw_interface_tag_add_del (vat_main_t * vam)
20366 unformat_input_t *i = vam->input;
20367 vl_api_sw_interface_tag_add_del_t *mp;
20368 u32 sw_if_index = ~0;
20373 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20375 if (unformat (i, "tag %s", &tag))
20377 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20379 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20381 else if (unformat (i, "del"))
20387 if (sw_if_index == ~0)
20389 errmsg ("missing interface name or sw_if_index");
20393 if (enable && (tag == 0))
20395 errmsg ("no tag specified");
20399 /* Construct the API message */
20400 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20401 mp->sw_if_index = ntohl (sw_if_index);
20402 mp->is_add = enable;
20404 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20412 static void vl_api_l2_xconnect_details_t_handler
20413 (vl_api_l2_xconnect_details_t * mp)
20415 vat_main_t *vam = &vat_main;
20417 print (vam->ofp, "%15d%15d",
20418 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20421 static void vl_api_l2_xconnect_details_t_handler_json
20422 (vl_api_l2_xconnect_details_t * mp)
20424 vat_main_t *vam = &vat_main;
20425 vat_json_node_t *node = NULL;
20427 if (VAT_JSON_ARRAY != vam->json_tree.type)
20429 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20430 vat_json_init_array (&vam->json_tree);
20432 node = vat_json_array_add (&vam->json_tree);
20434 vat_json_init_object (node);
20435 vat_json_object_add_uint (node, "rx_sw_if_index",
20436 ntohl (mp->rx_sw_if_index));
20437 vat_json_object_add_uint (node, "tx_sw_if_index",
20438 ntohl (mp->tx_sw_if_index));
20442 api_l2_xconnect_dump (vat_main_t * vam)
20444 vl_api_l2_xconnect_dump_t *mp;
20445 vl_api_control_ping_t *mp_ping;
20448 if (!vam->json_output)
20450 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20453 M (L2_XCONNECT_DUMP, mp);
20457 /* Use a control ping for synchronization */
20458 MPING (CONTROL_PING, mp_ping);
20466 api_sw_interface_set_mtu (vat_main_t * vam)
20468 unformat_input_t *i = vam->input;
20469 vl_api_sw_interface_set_mtu_t *mp;
20470 u32 sw_if_index = ~0;
20474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20476 if (unformat (i, "mtu %d", &mtu))
20478 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20480 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20486 if (sw_if_index == ~0)
20488 errmsg ("missing interface name or sw_if_index");
20494 errmsg ("no mtu specified");
20498 /* Construct the API message */
20499 M (SW_INTERFACE_SET_MTU, mp);
20500 mp->sw_if_index = ntohl (sw_if_index);
20501 mp->mtu = ntohs ((u16) mtu);
20509 api_p2p_ethernet_add (vat_main_t * vam)
20511 unformat_input_t *i = vam->input;
20512 vl_api_p2p_ethernet_add_t *mp;
20513 u32 parent_if_index = ~0;
20519 memset (remote_mac, 0, sizeof (remote_mac));
20520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20524 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20528 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20530 else if (unformat (i, "sub_id %d", &sub_id))
20534 clib_warning ("parse error '%U'", format_unformat_error, i);
20539 if (parent_if_index == ~0)
20541 errmsg ("missing interface name or sw_if_index");
20546 errmsg ("missing remote mac address");
20551 errmsg ("missing sub-interface id");
20555 M (P2P_ETHERNET_ADD, mp);
20556 mp->parent_if_index = ntohl (parent_if_index);
20557 mp->subif_id = ntohl (sub_id);
20558 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20566 api_p2p_ethernet_del (vat_main_t * vam)
20568 unformat_input_t *i = vam->input;
20569 vl_api_p2p_ethernet_del_t *mp;
20570 u32 parent_if_index = ~0;
20575 memset (remote_mac, 0, sizeof (remote_mac));
20576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20578 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20580 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20584 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20588 clib_warning ("parse error '%U'", format_unformat_error, i);
20593 if (parent_if_index == ~0)
20595 errmsg ("missing interface name or sw_if_index");
20600 errmsg ("missing remote mac address");
20604 M (P2P_ETHERNET_DEL, mp);
20605 mp->parent_if_index = ntohl (parent_if_index);
20606 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20614 api_lldp_config (vat_main_t * vam)
20616 unformat_input_t *i = vam->input;
20617 vl_api_lldp_config_t *mp;
20619 int tx_interval = 0;
20620 u8 *sys_name = NULL;
20623 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20625 if (unformat (i, "system-name %s", &sys_name))
20627 else if (unformat (i, "tx-hold %d", &tx_hold))
20629 else if (unformat (i, "tx-interval %d", &tx_interval))
20633 clib_warning ("parse error '%U'", format_unformat_error, i);
20638 vec_add1 (sys_name, 0);
20640 M (LLDP_CONFIG, mp);
20641 mp->tx_hold = htonl (tx_hold);
20642 mp->tx_interval = htonl (tx_interval);
20643 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20644 vec_free (sys_name);
20652 api_sw_interface_set_lldp (vat_main_t * vam)
20654 unformat_input_t *i = vam->input;
20655 vl_api_sw_interface_set_lldp_t *mp;
20656 u32 sw_if_index = ~0;
20658 u8 *port_desc = NULL, *mgmt_oid = NULL;
20659 ip4_address_t ip4_addr;
20660 ip6_address_t ip6_addr;
20663 memset (&ip4_addr, 0, sizeof (ip4_addr));
20664 memset (&ip6_addr, 0, sizeof (ip6_addr));
20666 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20668 if (unformat (i, "disable"))
20671 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20673 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20675 else if (unformat (i, "port-desc %s", &port_desc))
20677 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20679 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20681 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20687 if (sw_if_index == ~0)
20689 errmsg ("missing interface name or sw_if_index");
20693 /* Construct the API message */
20694 vec_add1 (port_desc, 0);
20695 vec_add1 (mgmt_oid, 0);
20696 M (SW_INTERFACE_SET_LLDP, mp);
20697 mp->sw_if_index = ntohl (sw_if_index);
20698 mp->enable = enable;
20699 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20700 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20701 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20702 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20703 vec_free (port_desc);
20704 vec_free (mgmt_oid);
20712 api_tcp_configure_src_addresses (vat_main_t * vam)
20714 vl_api_tcp_configure_src_addresses_t *mp;
20715 unformat_input_t *i = vam->input;
20716 ip4_address_t v4first, v4last;
20717 ip6_address_t v6first, v6last;
20722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20724 if (unformat (i, "%U - %U",
20725 unformat_ip4_address, &v4first,
20726 unformat_ip4_address, &v4last))
20730 errmsg ("one range per message (range already set)");
20735 else if (unformat (i, "%U - %U",
20736 unformat_ip6_address, &v6first,
20737 unformat_ip6_address, &v6last))
20741 errmsg ("one range per message (range already set)");
20746 else if (unformat (i, "vrf %d", &vrf_id))
20752 if (range_set == 0)
20754 errmsg ("address range not set");
20758 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20759 mp->vrf_id = ntohl (vrf_id);
20761 if (range_set == 2)
20764 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20765 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20770 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20771 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20779 api_app_namespace_add_del (vat_main_t * vam)
20781 vl_api_app_namespace_add_del_t *mp;
20782 unformat_input_t *i = vam->input;
20783 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20784 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20790 if (unformat (i, "id %_%v%_", &ns_id))
20792 else if (unformat (i, "secret %lu", &secret))
20794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20795 sw_if_index_set = 1;
20796 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20798 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20803 if (!ns_id || !secret_set || !sw_if_index_set)
20805 errmsg ("namespace id, secret and sw_if_index must be set");
20808 if (vec_len (ns_id) > 64)
20810 errmsg ("namespace id too long");
20813 M (APP_NAMESPACE_ADD_DEL, mp);
20815 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20816 mp->namespace_id_len = vec_len (ns_id);
20817 mp->secret = secret;
20818 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20819 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20820 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20828 api_memfd_segment_create (vat_main_t * vam)
20830 unformat_input_t *i = vam->input;
20831 vl_api_memfd_segment_create_t *mp;
20832 u64 size = 64 << 20;
20835 #if VPP_API_TEST_BUILTIN == 1
20836 errmsg ("memfd_segment_create (builtin) not supported");
20840 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20842 if (unformat (i, "size %U", unformat_memory_size, &size))
20848 M (MEMFD_SEGMENT_CREATE, mp);
20849 mp->requested_size = size;
20856 api_dns_enable_disable (vat_main_t * vam)
20858 unformat_input_t *line_input = vam->input;
20859 vl_api_dns_enable_disable_t *mp;
20860 u8 enable_disable = 1;
20863 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20865 if (unformat (line_input, "disable"))
20866 enable_disable = 0;
20867 if (unformat (line_input, "enable"))
20868 enable_disable = 1;
20873 /* Construct the API message */
20874 M (DNS_ENABLE_DISABLE, mp);
20875 mp->enable = enable_disable;
20879 /* Wait for the reply */
20885 api_dns_resolve_name (vat_main_t * vam)
20887 unformat_input_t *line_input = vam->input;
20888 vl_api_dns_resolve_name_t *mp;
20892 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20894 if (unformat (line_input, "%s", &name))
20900 if (vec_len (name) > 127)
20902 errmsg ("name too long");
20906 /* Construct the API message */
20907 M (DNS_RESOLVE_NAME, mp);
20908 memcpy (mp->name, name, vec_len (name));
20913 /* Wait for the reply */
20919 api_dns_name_server_add_del (vat_main_t * vam)
20921 unformat_input_t *i = vam->input;
20922 vl_api_dns_name_server_add_del_t *mp;
20924 ip6_address_t ip6_server;
20925 ip4_address_t ip4_server;
20930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20932 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
20934 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
20936 else if (unformat (i, "del"))
20940 clib_warning ("parse error '%U'", format_unformat_error, i);
20945 if (ip4_set && ip6_set)
20947 errmsg ("Only one server address allowed per message");
20950 if ((ip4_set + ip6_set) == 0)
20952 errmsg ("Server address required");
20956 /* Construct the API message */
20957 M (DNS_NAME_SERVER_ADD_DEL, mp);
20961 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
20966 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
20970 mp->is_add = is_add;
20975 /* Wait for a reply, return good/bad news */
20982 q_or_quit (vat_main_t * vam)
20984 #if VPP_API_TEST_BUILTIN == 0
20985 longjmp (vam->jump_buf, 1);
20987 return 0; /* not so much */
20991 q (vat_main_t * vam)
20993 return q_or_quit (vam);
20997 quit (vat_main_t * vam)
20999 return q_or_quit (vam);
21003 comment (vat_main_t * vam)
21009 cmd_cmp (void *a1, void *a2)
21014 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21018 help (vat_main_t * vam)
21023 unformat_input_t *i = vam->input;
21026 if (unformat (i, "%s", &name))
21030 vec_add1 (name, 0);
21032 hs = hash_get_mem (vam->help_by_name, name);
21034 print (vam->ofp, "usage: %s %s", name, hs[0]);
21036 print (vam->ofp, "No such msg / command '%s'", name);
21041 print (vam->ofp, "Help is available for the following:");
21044 hash_foreach_pair (p, vam->function_by_name,
21046 vec_add1 (cmds, (u8 *)(p->key));
21050 vec_sort_with_function (cmds, cmd_cmp);
21052 for (j = 0; j < vec_len (cmds); j++)
21053 print (vam->ofp, "%s", cmds[j]);
21060 set (vat_main_t * vam)
21062 u8 *name = 0, *value = 0;
21063 unformat_input_t *i = vam->input;
21065 if (unformat (i, "%s", &name))
21067 /* The input buffer is a vector, not a string. */
21068 value = vec_dup (i->buffer);
21069 vec_delete (value, i->index, 0);
21070 /* Almost certainly has a trailing newline */
21071 if (value[vec_len (value) - 1] == '\n')
21072 value[vec_len (value) - 1] = 0;
21073 /* Make sure it's a proper string, one way or the other */
21074 vec_add1 (value, 0);
21075 (void) clib_macro_set_value (&vam->macro_main,
21076 (char *) name, (char *) value);
21079 errmsg ("usage: set <name> <value>");
21087 unset (vat_main_t * vam)
21091 if (unformat (vam->input, "%s", &name))
21092 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21093 errmsg ("unset: %s wasn't set", name);
21106 macro_sort_cmp (void *a1, void *a2)
21108 macro_sort_t *s1 = a1;
21109 macro_sort_t *s2 = a2;
21111 return strcmp ((char *) (s1->name), (char *) (s2->name));
21115 dump_macro_table (vat_main_t * vam)
21117 macro_sort_t *sort_me = 0, *sm;
21122 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21124 vec_add2 (sort_me, sm, 1);
21125 sm->name = (u8 *)(p->key);
21126 sm->value = (u8 *) (p->value[0]);
21130 vec_sort_with_function (sort_me, macro_sort_cmp);
21132 if (vec_len (sort_me))
21133 print (vam->ofp, "%-15s%s", "Name", "Value");
21135 print (vam->ofp, "The macro table is empty...");
21137 for (i = 0; i < vec_len (sort_me); i++)
21138 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21143 dump_node_table (vat_main_t * vam)
21146 vlib_node_t *node, *next_node;
21148 if (vec_len (vam->graph_nodes) == 0)
21150 print (vam->ofp, "Node table empty, issue get_node_graph...");
21154 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21156 node = vam->graph_nodes[i];
21157 print (vam->ofp, "[%d] %s", i, node->name);
21158 for (j = 0; j < vec_len (node->next_nodes); j++)
21160 if (node->next_nodes[j] != ~0)
21162 next_node = vam->graph_nodes[node->next_nodes[j]];
21163 print (vam->ofp, " [%d] %s", j, next_node->name);
21171 value_sort_cmp (void *a1, void *a2)
21173 name_sort_t *n1 = a1;
21174 name_sort_t *n2 = a2;
21176 if (n1->value < n2->value)
21178 if (n1->value > n2->value)
21185 dump_msg_api_table (vat_main_t * vam)
21187 api_main_t *am = &api_main;
21188 name_sort_t *nses = 0, *ns;
21193 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21195 vec_add2 (nses, ns, 1);
21196 ns->name = (u8 *)(hp->key);
21197 ns->value = (u32) hp->value[0];
21201 vec_sort_with_function (nses, value_sort_cmp);
21203 for (i = 0; i < vec_len (nses); i++)
21204 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21210 get_msg_id (vat_main_t * vam)
21215 if (unformat (vam->input, "%s", &name_and_crc))
21217 message_index = vl_api_get_msg_index (name_and_crc);
21218 if (message_index == ~0)
21220 print (vam->ofp, " '%s' not found", name_and_crc);
21223 print (vam->ofp, " '%s' has message index %d",
21224 name_and_crc, message_index);
21227 errmsg ("name_and_crc required...");
21232 search_node_table (vat_main_t * vam)
21234 unformat_input_t *line_input = vam->input;
21237 vlib_node_t *node, *next_node;
21240 if (vam->graph_node_index_by_name == 0)
21242 print (vam->ofp, "Node table empty, issue get_node_graph...");
21246 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21248 if (unformat (line_input, "%s", &node_to_find))
21250 vec_add1 (node_to_find, 0);
21251 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21254 print (vam->ofp, "%s not found...", node_to_find);
21257 node = vam->graph_nodes[p[0]];
21258 print (vam->ofp, "[%d] %s", p[0], node->name);
21259 for (j = 0; j < vec_len (node->next_nodes); j++)
21261 if (node->next_nodes[j] != ~0)
21263 next_node = vam->graph_nodes[node->next_nodes[j]];
21264 print (vam->ofp, " [%d] %s", j, next_node->name);
21271 clib_warning ("parse error '%U'", format_unformat_error,
21277 vec_free (node_to_find);
21286 script (vat_main_t * vam)
21288 #if (VPP_API_TEST_BUILTIN==0)
21290 char *save_current_file;
21291 unformat_input_t save_input;
21292 jmp_buf save_jump_buf;
21293 u32 save_line_number;
21295 FILE *new_fp, *save_ifp;
21297 if (unformat (vam->input, "%s", &s))
21299 new_fp = fopen ((char *) s, "r");
21302 errmsg ("Couldn't open script file %s", s);
21309 errmsg ("Missing script name");
21313 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21314 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21315 save_ifp = vam->ifp;
21316 save_line_number = vam->input_line_number;
21317 save_current_file = (char *) vam->current_file;
21319 vam->input_line_number = 0;
21321 vam->current_file = s;
21324 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21325 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21326 vam->ifp = save_ifp;
21327 vam->input_line_number = save_line_number;
21328 vam->current_file = (u8 *) save_current_file;
21333 clib_warning ("use the exec command...");
21339 echo (vat_main_t * vam)
21341 print (vam->ofp, "%v", vam->input->buffer);
21345 /* List of API message constructors, CLI names map to api_xxx */
21346 #define foreach_vpe_api_msg \
21347 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21348 _(sw_interface_dump,"") \
21349 _(sw_interface_set_flags, \
21350 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21351 _(sw_interface_add_del_address, \
21352 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21353 _(sw_interface_set_table, \
21354 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21355 _(sw_interface_set_mpls_enable, \
21356 "<intfc> | sw_if_index [disable | dis]") \
21357 _(sw_interface_set_vpath, \
21358 "<intfc> | sw_if_index <id> enable | disable") \
21359 _(sw_interface_set_vxlan_bypass, \
21360 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21361 _(sw_interface_set_geneve_bypass, \
21362 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21363 _(sw_interface_set_l2_xconnect, \
21364 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21365 "enable | disable") \
21366 _(sw_interface_set_l2_bridge, \
21367 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21368 "[shg <split-horizon-group>] [bvi]\n" \
21369 "enable | disable") \
21370 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21371 _(bridge_domain_add_del, \
21372 "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") \
21373 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21375 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21376 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21377 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21379 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21381 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21383 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21385 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21387 "<vpp-if-name> | sw_if_index <id>") \
21388 _(sw_interface_tap_dump, "") \
21389 _(ip_table_add_del, \
21390 "table-id <n> [ipv6]\n") \
21391 _(ip_add_del_route, \
21392 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21393 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21394 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21395 "[multipath] [count <n>]") \
21396 _(ip_mroute_add_del, \
21397 "<src> <grp>/<mask> [table-id <n>]\n" \
21398 "[<intfc> | sw_if_index <id>] [local] [del]") \
21399 _(mpls_table_add_del, \
21400 "table-id <n>\n") \
21401 _(mpls_route_add_del, \
21402 "<label> <eos> via <addr> [table-id <n>]\n" \
21403 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21404 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21405 "[multipath] [count <n>]") \
21406 _(mpls_ip_bind_unbind, \
21407 "<label> <addr/len>") \
21408 _(mpls_tunnel_add_del, \
21409 " via <addr> [table-id <n>]\n" \
21410 "sw_if_index <id>] [l2] [del]") \
21411 _(proxy_arp_add_del, \
21412 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21413 _(proxy_arp_intfc_enable_disable, \
21414 "<intfc> | sw_if_index <id> enable | disable") \
21415 _(sw_interface_set_unnumbered, \
21416 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21417 _(ip_neighbor_add_del, \
21418 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21419 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21420 _(reset_vrf, "vrf <id> [ipv6]") \
21421 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21422 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21423 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21424 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21425 "[outer_vlan_id_any][inner_vlan_id_any]") \
21426 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21427 _(reset_fib, "vrf <n> [ipv6]") \
21428 _(dhcp_proxy_config, \
21429 "svr <v46-address> src <v46-address>\n" \
21430 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21431 _(dhcp_proxy_set_vss, \
21432 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21433 _(dhcp_proxy_dump, "ip6") \
21434 _(dhcp_client_config, \
21435 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21436 _(set_ip_flow_hash, \
21437 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21438 _(sw_interface_ip6_enable_disable, \
21439 "<intfc> | sw_if_index <id> enable | disable") \
21440 _(sw_interface_ip6_set_link_local_address, \
21441 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21442 _(ip6nd_proxy_add_del, \
21443 "<intfc> | sw_if_index <id> <ip6-address>") \
21444 _(ip6nd_proxy_dump, "") \
21445 _(sw_interface_ip6nd_ra_prefix, \
21446 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21447 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21448 "[nolink] [isno]") \
21449 _(sw_interface_ip6nd_ra_config, \
21450 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21451 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21452 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21453 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21454 _(l2_patch_add_del, \
21455 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21456 "enable | disable") \
21457 _(sr_localsid_add_del, \
21458 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21459 "fib-table <num> (end.psp) sw_if_index <num>") \
21460 _(classify_add_del_table, \
21461 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21462 " [del] [del-chain] mask <mask-value>\n" \
21463 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21464 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21465 _(classify_add_del_session, \
21466 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21467 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21468 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21469 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21470 _(classify_set_interface_ip_table, \
21471 "<intfc> | sw_if_index <nn> table <nn>") \
21472 _(classify_set_interface_l2_tables, \
21473 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21474 " [other-table <nn>]") \
21475 _(get_node_index, "node <node-name") \
21476 _(add_node_next, "node <node-name> next <next-node-name>") \
21477 _(l2tpv3_create_tunnel, \
21478 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21479 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21480 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21481 _(l2tpv3_set_tunnel_cookies, \
21482 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21483 "[new_remote_cookie <nn>]\n") \
21484 _(l2tpv3_interface_enable_disable, \
21485 "<intfc> | sw_if_index <nn> enable | disable") \
21486 _(l2tpv3_set_lookup_key, \
21487 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21488 _(sw_if_l2tpv3_tunnel_dump, "") \
21489 _(vxlan_add_del_tunnel, \
21490 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21491 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21492 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21493 _(geneve_add_del_tunnel, \
21494 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21495 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21496 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21497 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21498 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21499 _(gre_add_del_tunnel, \
21500 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21501 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21502 _(l2_fib_clear_table, "") \
21503 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21504 _(l2_interface_vlan_tag_rewrite, \
21505 "<intfc> | sw_if_index <nn> \n" \
21506 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21507 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21508 _(create_vhost_user_if, \
21509 "socket <filename> [server] [renumber <dev_instance>] " \
21510 "[mac <mac_address>]") \
21511 _(modify_vhost_user_if, \
21512 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21513 "[server] [renumber <dev_instance>]") \
21514 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21515 _(sw_interface_vhost_user_dump, "") \
21516 _(show_version, "") \
21517 _(vxlan_gpe_add_del_tunnel, \
21518 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21519 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21520 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21521 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21522 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21523 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21524 _(interface_name_renumber, \
21525 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21526 _(input_acl_set_interface, \
21527 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21528 " [l2-table <nn>] [del]") \
21529 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21530 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21531 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21532 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21533 _(ip_dump, "ipv4 | ipv6") \
21534 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21535 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21537 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21538 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21539 " integ_alg <alg> integ_key <hex>") \
21540 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21541 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21542 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21543 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21544 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21545 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21546 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21547 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21548 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21549 _(ipsec_sa_dump, "[sa_id <n>]") \
21550 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21551 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21552 "(auth_data 0x<data> | auth_data <data>)") \
21553 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21554 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21555 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21556 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21557 "(local|remote)") \
21558 _(ikev2_set_local_key, "file <absolute_file_path>") \
21559 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21560 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21561 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21562 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21563 _(ikev2_initiate_sa_init, "<profile_name>") \
21564 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21565 _(ikev2_initiate_del_child_sa, "<ispi>") \
21566 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21567 _(delete_loopback,"sw_if_index <nn>") \
21568 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21569 _(map_add_domain, \
21570 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21571 "ip6-src <ip6addr> " \
21572 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21573 _(map_del_domain, "index <n>") \
21574 _(map_add_del_rule, \
21575 "index <n> psid <n> dst <ip6addr> [del]") \
21576 _(map_domain_dump, "") \
21577 _(map_rule_dump, "index <map-domain>") \
21578 _(want_interface_events, "enable|disable") \
21579 _(want_stats,"enable|disable") \
21580 _(get_first_msg_id, "client <name>") \
21581 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21582 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21583 "fib-id <nn> [ip4][ip6][default]") \
21584 _(get_node_graph, " ") \
21585 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21586 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21587 _(ioam_disable, "") \
21588 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21589 " sw_if_index <sw_if_index> p <priority> " \
21590 "w <weight>] [del]") \
21591 _(one_add_del_locator, "locator-set <locator_name> " \
21592 "iface <intf> | sw_if_index <sw_if_index> " \
21593 "p <priority> w <weight> [del]") \
21594 _(one_add_del_local_eid,"vni <vni> eid " \
21595 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21596 "locator-set <locator_name> [del]" \
21597 "[key-id sha1|sha256 secret-key <secret-key>]")\
21598 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21599 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21600 _(one_enable_disable, "enable|disable") \
21601 _(one_map_register_enable_disable, "enable|disable") \
21602 _(one_map_register_fallback_threshold, "<value>") \
21603 _(one_rloc_probe_enable_disable, "enable|disable") \
21604 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21606 "rloc <locator> p <prio> " \
21607 "w <weight> [rloc <loc> ... ] " \
21608 "action <action> [del-all]") \
21609 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21611 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21612 _(one_use_petr, "ip-address> | disable") \
21613 _(one_map_request_mode, "src-dst|dst-only") \
21614 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21615 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21616 _(one_locator_set_dump, "[local | remote]") \
21617 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21618 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21619 "[local] | [remote]") \
21620 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21621 _(one_ndp_bd_get, "") \
21622 _(one_ndp_entries_get, "bd <bridge-domain>") \
21623 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21624 _(one_l2_arp_bd_get, "") \
21625 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21626 _(one_stats_enable_disable, "enable|disalbe") \
21627 _(show_one_stats_enable_disable, "") \
21628 _(one_eid_table_vni_dump, "") \
21629 _(one_eid_table_map_dump, "l2|l3") \
21630 _(one_map_resolver_dump, "") \
21631 _(one_map_server_dump, "") \
21632 _(one_adjacencies_get, "vni <vni>") \
21633 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21634 _(show_one_rloc_probe_state, "") \
21635 _(show_one_map_register_state, "") \
21636 _(show_one_status, "") \
21637 _(one_stats_dump, "") \
21638 _(one_stats_flush, "") \
21639 _(one_get_map_request_itr_rlocs, "") \
21640 _(one_map_register_set_ttl, "<ttl>") \
21641 _(one_set_transport_protocol, "udp|api") \
21642 _(one_get_transport_protocol, "") \
21643 _(show_one_nsh_mapping, "") \
21644 _(show_one_pitr, "") \
21645 _(show_one_use_petr, "") \
21646 _(show_one_map_request_mode, "") \
21647 _(show_one_map_register_ttl, "") \
21648 _(show_one_map_register_fallback_threshold, "") \
21649 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21650 " sw_if_index <sw_if_index> p <priority> " \
21651 "w <weight>] [del]") \
21652 _(lisp_add_del_locator, "locator-set <locator_name> " \
21653 "iface <intf> | sw_if_index <sw_if_index> " \
21654 "p <priority> w <weight> [del]") \
21655 _(lisp_add_del_local_eid,"vni <vni> eid " \
21656 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21657 "locator-set <locator_name> [del]" \
21658 "[key-id sha1|sha256 secret-key <secret-key>]") \
21659 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21660 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21661 _(lisp_enable_disable, "enable|disable") \
21662 _(lisp_map_register_enable_disable, "enable|disable") \
21663 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21664 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21666 "rloc <locator> p <prio> " \
21667 "w <weight> [rloc <loc> ... ] " \
21668 "action <action> [del-all]") \
21669 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21671 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21672 _(lisp_use_petr, "<ip-address> | disable") \
21673 _(lisp_map_request_mode, "src-dst|dst-only") \
21674 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21675 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21676 _(lisp_locator_set_dump, "[local | remote]") \
21677 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21678 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21679 "[local] | [remote]") \
21680 _(lisp_eid_table_vni_dump, "") \
21681 _(lisp_eid_table_map_dump, "l2|l3") \
21682 _(lisp_map_resolver_dump, "") \
21683 _(lisp_map_server_dump, "") \
21684 _(lisp_adjacencies_get, "vni <vni>") \
21685 _(gpe_fwd_entry_vnis_get, "") \
21686 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21687 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21688 "[table <table-id>]") \
21689 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21690 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21691 _(gpe_set_encap_mode, "lisp|vxlan") \
21692 _(gpe_get_encap_mode, "") \
21693 _(lisp_gpe_add_del_iface, "up|down") \
21694 _(lisp_gpe_enable_disable, "enable|disable") \
21695 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21696 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21697 _(show_lisp_rloc_probe_state, "") \
21698 _(show_lisp_map_register_state, "") \
21699 _(show_lisp_status, "") \
21700 _(lisp_get_map_request_itr_rlocs, "") \
21701 _(show_lisp_pitr, "") \
21702 _(show_lisp_use_petr, "") \
21703 _(show_lisp_map_request_mode, "") \
21704 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21705 _(af_packet_delete, "name <host interface name>") \
21706 _(policer_add_del, "name <policer name> <params> [del]") \
21707 _(policer_dump, "[name <policer name>]") \
21708 _(policer_classify_set_interface, \
21709 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21710 " [l2-table <nn>] [del]") \
21711 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21712 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21713 "[master|slave]") \
21714 _(netmap_delete, "name <interface name>") \
21715 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21716 _(mpls_fib_dump, "") \
21717 _(classify_table_ids, "") \
21718 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21719 _(classify_table_info, "table_id <nn>") \
21720 _(classify_session_dump, "table_id <nn>") \
21721 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21722 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21723 "[template_interval <nn>] [udp_checksum]") \
21724 _(ipfix_exporter_dump, "") \
21725 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21726 _(ipfix_classify_stream_dump, "") \
21727 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21728 _(ipfix_classify_table_dump, "") \
21729 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21730 _(sw_interface_span_dump, "[l2]") \
21731 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21732 _(pg_create_interface, "if_id <nn>") \
21733 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21734 _(pg_enable_disable, "[stream <id>] disable") \
21735 _(ip_source_and_port_range_check_add_del, \
21736 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21737 _(ip_source_and_port_range_check_interface_add_del, \
21738 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21739 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21740 _(ipsec_gre_add_del_tunnel, \
21741 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21742 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21743 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21744 _(l2_interface_pbb_tag_rewrite, \
21745 "<intfc> | sw_if_index <nn> \n" \
21746 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21747 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21748 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21749 _(flow_classify_set_interface, \
21750 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21751 _(flow_classify_dump, "type [ip4|ip6]") \
21752 _(ip_fib_dump, "") \
21753 _(ip_mfib_dump, "") \
21754 _(ip6_fib_dump, "") \
21755 _(ip6_mfib_dump, "") \
21756 _(feature_enable_disable, "arc_name <arc_name> " \
21757 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21758 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21760 _(l2_xconnect_dump, "") \
21761 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21762 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21763 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21764 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21765 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21766 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21767 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21768 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21769 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21770 _(memfd_segment_create,"size <nnn>") \
21771 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21772 _(dns_enable_disable, "[enable][disable]") \
21773 _(dns_name_server_add_del, "<ip-address> [del]") \
21774 _(dns_resolve_name, "<hostname>")
21776 /* List of command functions, CLI names map directly to functions */
21777 #define foreach_cli_function \
21778 _(comment, "usage: comment <ignore-rest-of-line>") \
21779 _(dump_interface_table, "usage: dump_interface_table") \
21780 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21781 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21782 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21783 _(dump_stats_table, "usage: dump_stats_table") \
21784 _(dump_macro_table, "usage: dump_macro_table ") \
21785 _(dump_node_table, "usage: dump_node_table") \
21786 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21787 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21788 _(echo, "usage: echo <message>") \
21789 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21790 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21791 _(help, "usage: help") \
21792 _(q, "usage: quit") \
21793 _(quit, "usage: quit") \
21794 _(search_node_table, "usage: search_node_table <name>...") \
21795 _(set, "usage: set <variable-name> <value>") \
21796 _(script, "usage: script <file-name>") \
21797 _(unset, "usage: unset <variable-name>")
21799 static void vl_api_##n##_t_handler_uni \
21800 (vl_api_##n##_t * mp) \
21802 vat_main_t * vam = &vat_main; \
21803 if (vam->json_output) { \
21804 vl_api_##n##_t_handler_json(mp); \
21806 vl_api_##n##_t_handler(mp); \
21809 foreach_vpe_api_reply_msg;
21810 #if VPP_API_TEST_BUILTIN == 0
21811 foreach_standalone_reply_msg;
21816 vat_api_hookup (vat_main_t * vam)
21819 vl_msg_api_set_handlers(VL_API_##N, #n, \
21820 vl_api_##n##_t_handler_uni, \
21822 vl_api_##n##_t_endian, \
21823 vl_api_##n##_t_print, \
21824 sizeof(vl_api_##n##_t), 1);
21825 foreach_vpe_api_reply_msg;
21826 #if VPP_API_TEST_BUILTIN == 0
21827 foreach_standalone_reply_msg;
21831 #if (VPP_API_TEST_BUILTIN==0)
21832 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21834 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21836 vam->function_by_name = hash_create_string (0, sizeof (uword));
21838 vam->help_by_name = hash_create_string (0, sizeof (uword));
21841 /* API messages we can send */
21842 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21843 foreach_vpe_api_msg;
21847 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21848 foreach_vpe_api_msg;
21851 /* CLI functions */
21852 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21853 foreach_cli_function;
21857 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21858 foreach_cli_function;
21862 #if VPP_API_TEST_BUILTIN
21863 static clib_error_t *
21864 vat_api_hookup_shim (vlib_main_t * vm)
21866 vat_api_hookup (&vat_main);
21870 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21874 * fd.io coding-style-patch-verification: ON
21877 * eval: (c-set-style "gnu")