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 /* Note: this closes memfd.fd */
2141 retval = memfd_slave_init (&memfd);
2143 clib_warning ("WARNING: segment map returned %d", retval);
2145 /* Pivot to the memory client segment that vpp just created */
2147 am->vlib_rp = (void *) (memfd.requested_va + MMAP_PAGESIZE);
2149 am->shmem_hdr = (void *) am->vlib_rp->user_ctx;
2151 vl_client_install_client_message_handlers ();
2153 vl_client_connect_to_vlib_no_map ("pvt",
2155 32 /* input_queue_length */ );
2156 vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
2158 vl_socket_client_enable_disable (&vam->socket_client_main,
2159 0 /* disable socket */ );
2163 if (vam->async_mode)
2165 vam->async_errors += (retval < 0);
2169 vam->retval = retval;
2170 vam->result_ready = 1;
2175 static void vl_api_memfd_segment_create_reply_t_handler_json
2176 (vl_api_memfd_segment_create_reply_t * mp)
2178 clib_warning ("no");
2181 static void vl_api_dns_resolve_name_reply_t_handler
2182 (vl_api_dns_resolve_name_reply_t * mp)
2184 vat_main_t *vam = &vat_main;
2185 i32 retval = ntohl (mp->retval);
2186 if (vam->async_mode)
2188 vam->async_errors += (retval < 0);
2192 vam->retval = retval;
2193 vam->result_ready = 1;
2198 clib_warning ("ip4 address %U", format_ip4_address,
2199 (ip4_address_t *) mp->ip4_address);
2201 clib_warning ("ip6 address %U", format_ip6_address,
2202 (ip6_address_t *) mp->ip6_address);
2205 clib_warning ("retval %d", retval);
2209 static void vl_api_dns_resolve_name_reply_t_handler_json
2210 (vl_api_dns_resolve_name_reply_t * mp)
2212 clib_warning ("not implemented");
2215 static void vl_api_dns_resolve_ip_reply_t_handler
2216 (vl_api_dns_resolve_ip_reply_t * mp)
2218 vat_main_t *vam = &vat_main;
2219 i32 retval = ntohl (mp->retval);
2220 if (vam->async_mode)
2222 vam->async_errors += (retval < 0);
2226 vam->retval = retval;
2227 vam->result_ready = 1;
2231 clib_warning ("canonical name %s", mp->name);
2234 clib_warning ("retval %d", retval);
2238 static void vl_api_dns_resolve_ip_reply_t_handler_json
2239 (vl_api_dns_resolve_ip_reply_t * mp)
2241 clib_warning ("not implemented");
2245 static void vl_api_ip_address_details_t_handler
2246 (vl_api_ip_address_details_t * mp)
2248 vat_main_t *vam = &vat_main;
2249 static ip_address_details_t empty_ip_address_details = { {0} };
2250 ip_address_details_t *address = NULL;
2251 ip_details_t *current_ip_details = NULL;
2252 ip_details_t *details = NULL;
2254 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2256 if (!details || vam->current_sw_if_index >= vec_len (details)
2257 || !details[vam->current_sw_if_index].present)
2259 errmsg ("ip address details arrived but not stored");
2260 errmsg ("ip_dump should be called first");
2264 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2266 #define addresses (current_ip_details->addr)
2268 vec_validate_init_empty (addresses, vec_len (addresses),
2269 empty_ip_address_details);
2271 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2273 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2274 address->prefix_length = mp->prefix_length;
2278 static void vl_api_ip_address_details_t_handler_json
2279 (vl_api_ip_address_details_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t *node = NULL;
2283 struct in6_addr ip6;
2286 if (VAT_JSON_ARRAY != vam->json_tree.type)
2288 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2289 vat_json_init_array (&vam->json_tree);
2291 node = vat_json_array_add (&vam->json_tree);
2293 vat_json_init_object (node);
2296 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2297 vat_json_object_add_ip6 (node, "ip", ip6);
2301 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2302 vat_json_object_add_ip4 (node, "ip", ip4);
2304 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2308 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2310 vat_main_t *vam = &vat_main;
2311 static ip_details_t empty_ip_details = { 0 };
2312 ip_details_t *ip = NULL;
2313 u32 sw_if_index = ~0;
2315 sw_if_index = ntohl (mp->sw_if_index);
2317 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2318 sw_if_index, empty_ip_details);
2320 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2327 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2329 vat_main_t *vam = &vat_main;
2331 if (VAT_JSON_ARRAY != vam->json_tree.type)
2333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2334 vat_json_init_array (&vam->json_tree);
2336 vat_json_array_add_uint (&vam->json_tree,
2337 clib_net_to_host_u32 (mp->sw_if_index));
2340 static void vl_api_map_domain_details_t_handler_json
2341 (vl_api_map_domain_details_t * mp)
2343 vat_json_node_t *node = NULL;
2344 vat_main_t *vam = &vat_main;
2345 struct in6_addr ip6;
2348 if (VAT_JSON_ARRAY != vam->json_tree.type)
2350 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2351 vat_json_init_array (&vam->json_tree);
2354 node = vat_json_array_add (&vam->json_tree);
2355 vat_json_init_object (node);
2357 vat_json_object_add_uint (node, "domain_index",
2358 clib_net_to_host_u32 (mp->domain_index));
2359 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2360 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2361 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2362 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2363 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2364 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2365 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2366 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2367 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2368 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2369 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2370 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2371 vat_json_object_add_uint (node, "flags", mp->flags);
2372 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2373 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2376 static void vl_api_map_domain_details_t_handler
2377 (vl_api_map_domain_details_t * mp)
2379 vat_main_t *vam = &vat_main;
2381 if (mp->is_translation)
2384 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2385 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2386 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2387 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2388 clib_net_to_host_u32 (mp->domain_index));
2393 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2394 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2395 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2396 format_ip6_address, mp->ip6_src,
2397 clib_net_to_host_u32 (mp->domain_index));
2399 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2400 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2401 mp->is_translation ? "map-t" : "");
2404 static void vl_api_map_rule_details_t_handler_json
2405 (vl_api_map_rule_details_t * mp)
2407 struct in6_addr ip6;
2408 vat_json_node_t *node = NULL;
2409 vat_main_t *vam = &vat_main;
2411 if (VAT_JSON_ARRAY != vam->json_tree.type)
2413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2414 vat_json_init_array (&vam->json_tree);
2417 node = vat_json_array_add (&vam->json_tree);
2418 vat_json_init_object (node);
2420 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2421 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2422 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2426 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2430 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2434 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2436 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2437 "router_addr %U host_mac %U",
2438 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2439 format_ip4_address, &mp->host_address,
2440 format_ip4_address, &mp->router_address,
2441 format_ethernet_address, mp->host_mac);
2444 static void vl_api_dhcp_compl_event_t_handler_json
2445 (vl_api_dhcp_compl_event_t * mp)
2447 /* JSON output not supported */
2451 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2454 vat_main_t *vam = &vat_main;
2455 static u64 default_counter = 0;
2457 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2459 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2460 sw_if_index, default_counter);
2461 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2465 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2466 interface_counter_t counter)
2468 vat_main_t *vam = &vat_main;
2469 static interface_counter_t default_counter = { 0, };
2471 vec_validate_init_empty (vam->combined_interface_counters,
2472 vnet_counter_type, NULL);
2473 vec_validate_init_empty (vam->combined_interface_counters
2474 [vnet_counter_type], sw_if_index, default_counter);
2475 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2478 static void vl_api_vnet_interface_simple_counters_t_handler
2479 (vl_api_vnet_interface_simple_counters_t * mp)
2484 static void vl_api_vnet_interface_combined_counters_t_handler
2485 (vl_api_vnet_interface_combined_counters_t * mp)
2490 static void vl_api_vnet_interface_simple_counters_t_handler_json
2491 (vl_api_vnet_interface_simple_counters_t * mp)
2496 u32 first_sw_if_index;
2499 count = ntohl (mp->count);
2500 first_sw_if_index = ntohl (mp->first_sw_if_index);
2502 v_packets = (u64 *) & mp->data;
2503 for (i = 0; i < count; i++)
2505 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2506 set_simple_interface_counter (mp->vnet_counter_type,
2507 first_sw_if_index + i, packets);
2512 static void vl_api_vnet_interface_combined_counters_t_handler_json
2513 (vl_api_vnet_interface_combined_counters_t * mp)
2515 interface_counter_t counter;
2517 u32 first_sw_if_index;
2521 count = ntohl (mp->count);
2522 first_sw_if_index = ntohl (mp->first_sw_if_index);
2524 v = (vlib_counter_t *) & mp->data;
2525 for (i = 0; i < count; i++)
2528 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2530 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2531 set_combined_interface_counter (mp->vnet_counter_type,
2532 first_sw_if_index + i, counter);
2538 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2540 vat_main_t *vam = &vat_main;
2543 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2545 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2554 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2556 vat_main_t *vam = &vat_main;
2559 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2561 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2569 static void vl_api_vnet_ip4_fib_counters_t_handler
2570 (vl_api_vnet_ip4_fib_counters_t * mp)
2575 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2576 (vl_api_vnet_ip4_fib_counters_t * mp)
2578 vat_main_t *vam = &vat_main;
2579 vl_api_ip4_fib_counter_t *v;
2580 ip4_fib_counter_t *counter;
2587 vrf_id = ntohl (mp->vrf_id);
2588 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2589 if (~0 == vrf_index)
2591 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2592 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2593 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2594 vec_validate (vam->ip4_fib_counters, vrf_index);
2595 vam->ip4_fib_counters[vrf_index] = NULL;
2598 vec_free (vam->ip4_fib_counters[vrf_index]);
2599 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2600 count = ntohl (mp->count);
2601 for (i = 0; i < count; i++)
2603 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2604 counter = &vam->ip4_fib_counters[vrf_index][i];
2605 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2606 counter->address = ip4;
2607 counter->address_length = v->address_length;
2608 counter->packets = clib_net_to_host_u64 (v->packets);
2609 counter->bytes = clib_net_to_host_u64 (v->bytes);
2614 static void vl_api_vnet_ip4_nbr_counters_t_handler
2615 (vl_api_vnet_ip4_nbr_counters_t * mp)
2620 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2621 (vl_api_vnet_ip4_nbr_counters_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vl_api_ip4_nbr_counter_t *v;
2625 ip4_nbr_counter_t *counter;
2630 sw_if_index = ntohl (mp->sw_if_index);
2631 count = ntohl (mp->count);
2632 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2635 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2637 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2638 for (i = 0; i < count; i++)
2640 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2641 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2642 counter->address.s_addr = v->address;
2643 counter->packets = clib_net_to_host_u64 (v->packets);
2644 counter->bytes = clib_net_to_host_u64 (v->bytes);
2645 counter->linkt = v->link_type;
2650 static void vl_api_vnet_ip6_fib_counters_t_handler
2651 (vl_api_vnet_ip6_fib_counters_t * mp)
2656 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2657 (vl_api_vnet_ip6_fib_counters_t * mp)
2659 vat_main_t *vam = &vat_main;
2660 vl_api_ip6_fib_counter_t *v;
2661 ip6_fib_counter_t *counter;
2662 struct in6_addr ip6;
2668 vrf_id = ntohl (mp->vrf_id);
2669 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2670 if (~0 == vrf_index)
2672 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2673 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2674 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2675 vec_validate (vam->ip6_fib_counters, vrf_index);
2676 vam->ip6_fib_counters[vrf_index] = NULL;
2679 vec_free (vam->ip6_fib_counters[vrf_index]);
2680 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2681 count = ntohl (mp->count);
2682 for (i = 0; i < count; i++)
2684 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2685 counter = &vam->ip6_fib_counters[vrf_index][i];
2686 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2687 counter->address = ip6;
2688 counter->address_length = v->address_length;
2689 counter->packets = clib_net_to_host_u64 (v->packets);
2690 counter->bytes = clib_net_to_host_u64 (v->bytes);
2695 static void vl_api_vnet_ip6_nbr_counters_t_handler
2696 (vl_api_vnet_ip6_nbr_counters_t * mp)
2701 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2702 (vl_api_vnet_ip6_nbr_counters_t * mp)
2704 vat_main_t *vam = &vat_main;
2705 vl_api_ip6_nbr_counter_t *v;
2706 ip6_nbr_counter_t *counter;
2707 struct in6_addr ip6;
2712 sw_if_index = ntohl (mp->sw_if_index);
2713 count = ntohl (mp->count);
2714 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2717 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2719 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2720 for (i = 0; i < count; i++)
2722 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2723 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2724 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2725 counter->address = ip6;
2726 counter->packets = clib_net_to_host_u64 (v->packets);
2727 counter->bytes = clib_net_to_host_u64 (v->bytes);
2732 static void vl_api_get_first_msg_id_reply_t_handler
2733 (vl_api_get_first_msg_id_reply_t * mp)
2735 vat_main_t *vam = &vat_main;
2736 i32 retval = ntohl (mp->retval);
2738 if (vam->async_mode)
2740 vam->async_errors += (retval < 0);
2744 vam->retval = retval;
2745 vam->result_ready = 1;
2749 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2753 static void vl_api_get_first_msg_id_reply_t_handler_json
2754 (vl_api_get_first_msg_id_reply_t * mp)
2756 vat_main_t *vam = &vat_main;
2757 vat_json_node_t node;
2759 vat_json_init_object (&node);
2760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2761 vat_json_object_add_uint (&node, "first_msg_id",
2762 (uint) ntohs (mp->first_msg_id));
2764 vat_json_print (vam->ofp, &node);
2765 vat_json_free (&node);
2767 vam->retval = ntohl (mp->retval);
2768 vam->result_ready = 1;
2771 static void vl_api_get_node_graph_reply_t_handler
2772 (vl_api_get_node_graph_reply_t * mp)
2774 vat_main_t *vam = &vat_main;
2775 api_main_t *am = &api_main;
2776 i32 retval = ntohl (mp->retval);
2777 u8 *pvt_copy, *reply;
2782 if (vam->async_mode)
2784 vam->async_errors += (retval < 0);
2788 vam->retval = retval;
2789 vam->result_ready = 1;
2792 /* "Should never happen..." */
2796 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2797 pvt_copy = vec_dup (reply);
2799 /* Toss the shared-memory original... */
2800 pthread_mutex_lock (&am->vlib_rp->mutex);
2801 oldheap = svm_push_data_heap (am->vlib_rp);
2805 svm_pop_heap (oldheap);
2806 pthread_mutex_unlock (&am->vlib_rp->mutex);
2808 if (vam->graph_nodes)
2810 hash_free (vam->graph_node_index_by_name);
2812 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2814 node = vam->graph_nodes[i];
2815 vec_free (node->name);
2816 vec_free (node->next_nodes);
2819 vec_free (vam->graph_nodes);
2822 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2823 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2824 vec_free (pvt_copy);
2826 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2828 node = vam->graph_nodes[i];
2829 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2833 static void vl_api_get_node_graph_reply_t_handler_json
2834 (vl_api_get_node_graph_reply_t * mp)
2836 vat_main_t *vam = &vat_main;
2837 api_main_t *am = &api_main;
2839 vat_json_node_t node;
2842 /* $$$$ make this real? */
2843 vat_json_init_object (&node);
2844 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2845 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2847 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2849 /* Toss the shared-memory original... */
2850 pthread_mutex_lock (&am->vlib_rp->mutex);
2851 oldheap = svm_push_data_heap (am->vlib_rp);
2855 svm_pop_heap (oldheap);
2856 pthread_mutex_unlock (&am->vlib_rp->mutex);
2858 vat_json_print (vam->ofp, &node);
2859 vat_json_free (&node);
2861 vam->retval = ntohl (mp->retval);
2862 vam->result_ready = 1;
2866 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2868 vat_main_t *vam = &vat_main;
2873 s = format (s, "%=16d%=16d%=16d",
2874 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2878 s = format (s, "%=16U%=16d%=16d",
2879 mp->is_ipv6 ? format_ip6_address :
2881 mp->ip_address, mp->priority, mp->weight);
2884 print (vam->ofp, "%v", s);
2889 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2891 vat_main_t *vam = &vat_main;
2892 vat_json_node_t *node = NULL;
2893 struct in6_addr ip6;
2896 if (VAT_JSON_ARRAY != vam->json_tree.type)
2898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2899 vat_json_init_array (&vam->json_tree);
2901 node = vat_json_array_add (&vam->json_tree);
2902 vat_json_init_object (node);
2904 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2905 vat_json_object_add_uint (node, "priority", mp->priority);
2906 vat_json_object_add_uint (node, "weight", mp->weight);
2909 vat_json_object_add_uint (node, "sw_if_index",
2910 clib_net_to_host_u32 (mp->sw_if_index));
2915 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2916 vat_json_object_add_ip6 (node, "address", ip6);
2920 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2921 vat_json_object_add_ip4 (node, "address", ip4);
2927 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2930 vat_main_t *vam = &vat_main;
2933 ls_name = format (0, "%s", mp->ls_name);
2935 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2941 vl_api_one_locator_set_details_t_handler_json
2942 (vl_api_one_locator_set_details_t * mp)
2944 vat_main_t *vam = &vat_main;
2945 vat_json_node_t *node = 0;
2948 ls_name = format (0, "%s", mp->ls_name);
2949 vec_add1 (ls_name, 0);
2951 if (VAT_JSON_ARRAY != vam->json_tree.type)
2953 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2954 vat_json_init_array (&vam->json_tree);
2956 node = vat_json_array_add (&vam->json_tree);
2958 vat_json_init_object (node);
2959 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2960 vat_json_object_add_uint (node, "ls_index",
2961 clib_net_to_host_u32 (mp->ls_index));
2969 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2972 unformat_nsh_address (unformat_input_t * input, va_list * args)
2974 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2975 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2979 format_nsh_address_vat (u8 * s, va_list * args)
2981 nsh_t *a = va_arg (*args, nsh_t *);
2982 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2986 format_lisp_flat_eid (u8 * s, va_list * args)
2988 u32 type = va_arg (*args, u32);
2989 u8 *eid = va_arg (*args, u8 *);
2990 u32 eid_len = va_arg (*args, u32);
2995 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2997 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2999 return format (s, "%U", format_ethernet_address, eid);
3001 return format (s, "%U", format_nsh_address_vat, eid);
3007 format_lisp_eid_vat (u8 * s, va_list * args)
3009 u32 type = va_arg (*args, u32);
3010 u8 *eid = va_arg (*args, u8 *);
3011 u32 eid_len = va_arg (*args, u32);
3012 u8 *seid = va_arg (*args, u8 *);
3013 u32 seid_len = va_arg (*args, u32);
3014 u32 is_src_dst = va_arg (*args, u32);
3017 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3019 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3025 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3027 vat_main_t *vam = &vat_main;
3028 u8 *s = 0, *eid = 0;
3030 if (~0 == mp->locator_set_index)
3031 s = format (0, "action: %d", mp->action);
3033 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3035 eid = format (0, "%U", format_lisp_eid_vat,
3039 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3042 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3043 clib_net_to_host_u32 (mp->vni),
3045 mp->is_local ? "local" : "remote",
3046 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3047 clib_net_to_host_u16 (mp->key_id), mp->key);
3054 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3057 vat_main_t *vam = &vat_main;
3058 vat_json_node_t *node = 0;
3061 if (VAT_JSON_ARRAY != vam->json_tree.type)
3063 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3064 vat_json_init_array (&vam->json_tree);
3066 node = vat_json_array_add (&vam->json_tree);
3068 vat_json_init_object (node);
3069 if (~0 == mp->locator_set_index)
3070 vat_json_object_add_uint (node, "action", mp->action);
3072 vat_json_object_add_uint (node, "locator_set_index",
3073 clib_net_to_host_u32 (mp->locator_set_index));
3075 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3076 if (mp->eid_type == 3)
3078 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3079 vat_json_init_object (nsh_json);
3080 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3081 vat_json_object_add_uint (nsh_json, "spi",
3082 clib_net_to_host_u32 (nsh->spi));
3083 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3087 eid = format (0, "%U", format_lisp_eid_vat,
3091 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3093 vat_json_object_add_string_copy (node, "eid", eid);
3096 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3097 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3098 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3102 vat_json_object_add_uint (node, "key_id",
3103 clib_net_to_host_u16 (mp->key_id));
3104 vat_json_object_add_string_copy (node, "key", mp->key);
3109 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3111 vat_main_t *vam = &vat_main;
3112 u8 *seid = 0, *deid = 0;
3113 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3115 deid = format (0, "%U", format_lisp_eid_vat,
3116 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3118 seid = format (0, "%U", format_lisp_eid_vat,
3119 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3125 format_ip_address_fcn = format_ip4_address;
3127 format_ip_address_fcn = format_ip6_address;
3130 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3131 clib_net_to_host_u32 (mp->vni),
3133 format_ip_address_fcn, mp->lloc,
3134 format_ip_address_fcn, mp->rloc,
3135 clib_net_to_host_u32 (mp->pkt_count),
3136 clib_net_to_host_u32 (mp->bytes));
3143 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3145 struct in6_addr ip6;
3147 vat_main_t *vam = &vat_main;
3148 vat_json_node_t *node = 0;
3149 u8 *deid = 0, *seid = 0;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3158 vat_json_init_object (node);
3159 deid = format (0, "%U", format_lisp_eid_vat,
3160 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3162 seid = format (0, "%U", format_lisp_eid_vat,
3163 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3168 vat_json_object_add_string_copy (node, "seid", seid);
3169 vat_json_object_add_string_copy (node, "deid", deid);
3170 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3174 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3175 vat_json_object_add_ip4 (node, "lloc", ip4);
3176 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3177 vat_json_object_add_ip4 (node, "rloc", ip4);
3181 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3182 vat_json_object_add_ip6 (node, "lloc", ip6);
3183 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3184 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 vat_json_object_add_uint (node, "pkt_count",
3187 clib_net_to_host_u32 (mp->pkt_count));
3188 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3195 vl_api_one_eid_table_map_details_t_handler
3196 (vl_api_one_eid_table_map_details_t * mp)
3198 vat_main_t *vam = &vat_main;
3200 u8 *line = format (0, "%=10d%=10d",
3201 clib_net_to_host_u32 (mp->vni),
3202 clib_net_to_host_u32 (mp->dp_table));
3203 print (vam->ofp, "%v", line);
3208 vl_api_one_eid_table_map_details_t_handler_json
3209 (vl_api_one_eid_table_map_details_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t *node = NULL;
3214 if (VAT_JSON_ARRAY != vam->json_tree.type)
3216 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3217 vat_json_init_array (&vam->json_tree);
3219 node = vat_json_array_add (&vam->json_tree);
3220 vat_json_init_object (node);
3221 vat_json_object_add_uint (node, "dp_table",
3222 clib_net_to_host_u32 (mp->dp_table));
3223 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3227 vl_api_one_eid_table_vni_details_t_handler
3228 (vl_api_one_eid_table_vni_details_t * mp)
3230 vat_main_t *vam = &vat_main;
3232 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3233 print (vam->ofp, "%v", line);
3238 vl_api_one_eid_table_vni_details_t_handler_json
3239 (vl_api_one_eid_table_vni_details_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t *node = NULL;
3244 if (VAT_JSON_ARRAY != vam->json_tree.type)
3246 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3247 vat_json_init_array (&vam->json_tree);
3249 node = vat_json_array_add (&vam->json_tree);
3250 vat_json_init_object (node);
3251 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3255 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3256 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3258 vat_main_t *vam = &vat_main;
3259 int retval = clib_net_to_host_u32 (mp->retval);
3261 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3262 print (vam->ofp, "fallback threshold value: %d", mp->value);
3264 vam->retval = retval;
3265 vam->result_ready = 1;
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3270 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3272 vat_main_t *vam = &vat_main;
3273 vat_json_node_t _node, *node = &_node;
3274 int retval = clib_net_to_host_u32 (mp->retval);
3276 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3277 vat_json_init_object (node);
3278 vat_json_object_add_uint (node, "value", mp->value);
3280 vat_json_print (vam->ofp, node);
3281 vat_json_free (node);
3283 vam->retval = retval;
3284 vam->result_ready = 1;
3288 vl_api_show_one_map_register_state_reply_t_handler
3289 (vl_api_show_one_map_register_state_reply_t * mp)
3291 vat_main_t *vam = &vat_main;
3292 int retval = clib_net_to_host_u32 (mp->retval);
3294 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3296 vam->retval = retval;
3297 vam->result_ready = 1;
3301 vl_api_show_one_map_register_state_reply_t_handler_json
3302 (vl_api_show_one_map_register_state_reply_t * mp)
3304 vat_main_t *vam = &vat_main;
3305 vat_json_node_t _node, *node = &_node;
3306 int retval = clib_net_to_host_u32 (mp->retval);
3308 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3310 vat_json_init_object (node);
3311 vat_json_object_add_string_copy (node, "state", s);
3313 vat_json_print (vam->ofp, node);
3314 vat_json_free (node);
3316 vam->retval = retval;
3317 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 int retval = clib_net_to_host_u32 (mp->retval);
3331 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3333 vam->retval = retval;
3334 vam->result_ready = 1;
3338 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3339 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3341 vat_main_t *vam = &vat_main;
3342 vat_json_node_t _node, *node = &_node;
3343 int retval = clib_net_to_host_u32 (mp->retval);
3345 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3346 vat_json_init_object (node);
3347 vat_json_object_add_string_copy (node, "state", s);
3349 vat_json_print (vam->ofp, node);
3350 vat_json_free (node);
3352 vam->retval = retval;
3353 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 int retval = clib_net_to_host_u32 (mp->retval);
3367 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3369 vam->retval = retval;
3370 vam->result_ready = 1;
3374 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3375 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3377 vat_main_t *vam = &vat_main;
3378 vat_json_node_t _node, *node = &_node;
3379 int retval = clib_net_to_host_u32 (mp->retval);
3381 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3382 vat_json_init_object (node);
3383 vat_json_object_add_string_copy (node, "state", s);
3385 vat_json_print (vam->ofp, node);
3386 vat_json_free (node);
3388 vam->retval = retval;
3389 vam->result_ready = 1;
3394 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3396 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3397 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3398 e->vni = clib_net_to_host_u32 (e->vni);
3402 gpe_fwd_entries_get_reply_t_net_to_host
3403 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3407 mp->count = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < mp->count; i++)
3410 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3415 format_gpe_encap_mode (u8 * s, va_list * args)
3417 u32 mode = va_arg (*args, u32);
3422 return format (s, "lisp");
3424 return format (s, "vxlan");
3430 vl_api_gpe_get_encap_mode_reply_t_handler
3431 (vl_api_gpe_get_encap_mode_reply_t * mp)
3433 vat_main_t *vam = &vat_main;
3435 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3436 vam->retval = ntohl (mp->retval);
3437 vam->result_ready = 1;
3441 vl_api_gpe_get_encap_mode_reply_t_handler_json
3442 (vl_api_gpe_get_encap_mode_reply_t * mp)
3444 vat_main_t *vam = &vat_main;
3445 vat_json_node_t node;
3447 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3448 vec_add1 (encap_mode, 0);
3450 vat_json_init_object (&node);
3451 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3453 vec_free (encap_mode);
3454 vat_json_print (vam->ofp, &node);
3455 vat_json_free (&node);
3457 vam->retval = ntohl (mp->retval);
3458 vam->result_ready = 1;
3462 vl_api_gpe_fwd_entry_path_details_t_handler
3463 (vl_api_gpe_fwd_entry_path_details_t * mp)
3465 vat_main_t *vam = &vat_main;
3466 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3468 if (mp->lcl_loc.is_ip4)
3469 format_ip_address_fcn = format_ip4_address;
3471 format_ip_address_fcn = format_ip6_address;
3473 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3474 format_ip_address_fcn, &mp->lcl_loc,
3475 format_ip_address_fcn, &mp->rmt_loc);
3479 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3481 struct in6_addr ip6;
3486 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3487 vat_json_object_add_ip4 (n, "address", ip4);
3491 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3494 vat_json_object_add_uint (n, "weight", loc->weight);
3498 vl_api_gpe_fwd_entry_path_details_t_handler_json
3499 (vl_api_gpe_fwd_entry_path_details_t * mp)
3501 vat_main_t *vam = &vat_main;
3502 vat_json_node_t *node = NULL;
3503 vat_json_node_t *loc_node;
3505 if (VAT_JSON_ARRAY != vam->json_tree.type)
3507 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3508 vat_json_init_array (&vam->json_tree);
3510 node = vat_json_array_add (&vam->json_tree);
3511 vat_json_init_object (node);
3513 loc_node = vat_json_object_add (node, "local_locator");
3514 vat_json_init_object (loc_node);
3515 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3517 loc_node = vat_json_object_add (node, "remote_locator");
3518 vat_json_init_object (loc_node);
3519 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3523 vl_api_gpe_fwd_entries_get_reply_t_handler
3524 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3528 int retval = clib_net_to_host_u32 (mp->retval);
3529 vl_api_gpe_fwd_entry_t *e;
3534 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3536 for (i = 0; i < mp->count; i++)
3538 e = &mp->entries[i];
3539 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3540 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3541 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3545 vam->retval = retval;
3546 vam->result_ready = 1;
3550 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3551 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3554 vat_main_t *vam = &vat_main;
3555 vat_json_node_t *e = 0, root;
3557 int retval = clib_net_to_host_u32 (mp->retval);
3558 vl_api_gpe_fwd_entry_t *fwd;
3563 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3564 vat_json_init_array (&root);
3566 for (i = 0; i < mp->count; i++)
3568 e = vat_json_array_add (&root);
3569 fwd = &mp->entries[i];
3571 vat_json_init_object (e);
3572 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3573 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3574 vat_json_object_add_int (e, "vni", fwd->vni);
3575 vat_json_object_add_int (e, "action", fwd->action);
3577 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3578 fwd->leid_prefix_len);
3580 vat_json_object_add_string_copy (e, "leid", s);
3583 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3584 fwd->reid_prefix_len);
3586 vat_json_object_add_string_copy (e, "reid", s);
3590 vat_json_print (vam->ofp, &root);
3591 vat_json_free (&root);
3594 vam->retval = retval;
3595 vam->result_ready = 1;
3599 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3600 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3602 vat_main_t *vam = &vat_main;
3604 int retval = clib_net_to_host_u32 (mp->retval);
3605 vl_api_gpe_native_fwd_rpath_t *r;
3610 n = clib_net_to_host_u32 (mp->count);
3612 for (i = 0; i < n; i++)
3614 r = &mp->entries[i];
3615 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3616 clib_net_to_host_u32 (r->fib_index),
3617 clib_net_to_host_u32 (r->nh_sw_if_index),
3618 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3622 vam->retval = retval;
3623 vam->result_ready = 1;
3627 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3628 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3630 vat_main_t *vam = &vat_main;
3631 vat_json_node_t root, *e;
3633 int retval = clib_net_to_host_u32 (mp->retval);
3634 vl_api_gpe_native_fwd_rpath_t *r;
3640 n = clib_net_to_host_u32 (mp->count);
3641 vat_json_init_array (&root);
3643 for (i = 0; i < n; i++)
3645 e = vat_json_array_add (&root);
3646 vat_json_init_object (e);
3647 r = &mp->entries[i];
3649 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3652 vat_json_object_add_string_copy (e, "ip4", s);
3655 vat_json_object_add_uint (e, "fib_index",
3656 clib_net_to_host_u32 (r->fib_index));
3657 vat_json_object_add_uint (e, "nh_sw_if_index",
3658 clib_net_to_host_u32 (r->nh_sw_if_index));
3661 vat_json_print (vam->ofp, &root);
3662 vat_json_free (&root);
3665 vam->retval = retval;
3666 vam->result_ready = 1;
3670 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3671 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3673 vat_main_t *vam = &vat_main;
3675 int retval = clib_net_to_host_u32 (mp->retval);
3680 n = clib_net_to_host_u32 (mp->count);
3682 for (i = 0; i < n; i++)
3683 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3686 vam->retval = retval;
3687 vam->result_ready = 1;
3691 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3692 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3694 vat_main_t *vam = &vat_main;
3695 vat_json_node_t root;
3697 int retval = clib_net_to_host_u32 (mp->retval);
3702 n = clib_net_to_host_u32 (mp->count);
3703 vat_json_init_array (&root);
3705 for (i = 0; i < n; i++)
3706 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3708 vat_json_print (vam->ofp, &root);
3709 vat_json_free (&root);
3712 vam->retval = retval;
3713 vam->result_ready = 1;
3717 vl_api_one_ndp_entries_get_reply_t_handler
3718 (vl_api_one_ndp_entries_get_reply_t * mp)
3720 vat_main_t *vam = &vat_main;
3722 int retval = clib_net_to_host_u32 (mp->retval);
3727 n = clib_net_to_host_u32 (mp->count);
3729 for (i = 0; i < n; i++)
3730 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3731 format_ethernet_address, mp->entries[i].mac);
3734 vam->retval = retval;
3735 vam->result_ready = 1;
3739 vl_api_one_ndp_entries_get_reply_t_handler_json
3740 (vl_api_one_ndp_entries_get_reply_t * mp)
3743 vat_main_t *vam = &vat_main;
3744 vat_json_node_t *e = 0, root;
3746 int retval = clib_net_to_host_u32 (mp->retval);
3747 vl_api_one_ndp_entry_t *arp_entry;
3752 n = clib_net_to_host_u32 (mp->count);
3753 vat_json_init_array (&root);
3755 for (i = 0; i < n; i++)
3757 e = vat_json_array_add (&root);
3758 arp_entry = &mp->entries[i];
3760 vat_json_init_object (e);
3761 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3764 vat_json_object_add_string_copy (e, "mac", s);
3767 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3769 vat_json_object_add_string_copy (e, "ip6", s);
3773 vat_json_print (vam->ofp, &root);
3774 vat_json_free (&root);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_one_l2_arp_entries_get_reply_t_handler
3783 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3787 int retval = clib_net_to_host_u32 (mp->retval);
3792 n = clib_net_to_host_u32 (mp->count);
3794 for (i = 0; i < n; i++)
3795 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3796 format_ethernet_address, mp->entries[i].mac);
3799 vam->retval = retval;
3800 vam->result_ready = 1;
3804 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3805 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 vat_json_node_t *e = 0, root;
3811 int retval = clib_net_to_host_u32 (mp->retval);
3812 vl_api_one_l2_arp_entry_t *arp_entry;
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 e = vat_json_array_add (&root);
3823 arp_entry = &mp->entries[i];
3825 vat_json_init_object (e);
3826 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3829 vat_json_object_add_string_copy (e, "mac", s);
3832 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3834 vat_json_object_add_string_copy (e, "ip4", s);
3838 vat_json_print (vam->ofp, &root);
3839 vat_json_free (&root);
3842 vam->retval = retval;
3843 vam->result_ready = 1;
3847 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3849 vat_main_t *vam = &vat_main;
3851 int retval = clib_net_to_host_u32 (mp->retval);
3856 n = clib_net_to_host_u32 (mp->count);
3858 for (i = 0; i < n; i++)
3860 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3864 vam->retval = retval;
3865 vam->result_ready = 1;
3869 vl_api_one_ndp_bd_get_reply_t_handler_json
3870 (vl_api_one_ndp_bd_get_reply_t * mp)
3872 vat_main_t *vam = &vat_main;
3873 vat_json_node_t root;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3880 n = clib_net_to_host_u32 (mp->count);
3881 vat_json_init_array (&root);
3883 for (i = 0; i < n; i++)
3885 vat_json_array_add_uint (&root,
3886 clib_net_to_host_u32 (mp->bridge_domains[i]));
3889 vat_json_print (vam->ofp, &root);
3890 vat_json_free (&root);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_one_l2_arp_bd_get_reply_t_handler
3899 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3908 n = clib_net_to_host_u32 (mp->count);
3910 for (i = 0; i < n; i++)
3912 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3916 vam->retval = retval;
3917 vam->result_ready = 1;
3921 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3922 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 vat_json_node_t root;
3927 int retval = clib_net_to_host_u32 (mp->retval);
3932 n = clib_net_to_host_u32 (mp->count);
3933 vat_json_init_array (&root);
3935 for (i = 0; i < n; i++)
3937 vat_json_array_add_uint (&root,
3938 clib_net_to_host_u32 (mp->bridge_domains[i]));
3941 vat_json_print (vam->ofp, &root);
3942 vat_json_free (&root);
3945 vam->retval = retval;
3946 vam->result_ready = 1;
3950 vl_api_one_adjacencies_get_reply_t_handler
3951 (vl_api_one_adjacencies_get_reply_t * mp)
3953 vat_main_t *vam = &vat_main;
3955 int retval = clib_net_to_host_u32 (mp->retval);
3956 vl_api_one_adjacency_t *a;
3961 n = clib_net_to_host_u32 (mp->count);
3963 for (i = 0; i < n; i++)
3965 a = &mp->adjacencies[i];
3966 print (vam->ofp, "%U %40U",
3967 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3968 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3972 vam->retval = retval;
3973 vam->result_ready = 1;
3977 vl_api_one_adjacencies_get_reply_t_handler_json
3978 (vl_api_one_adjacencies_get_reply_t * mp)
3981 vat_main_t *vam = &vat_main;
3982 vat_json_node_t *e = 0, root;
3984 int retval = clib_net_to_host_u32 (mp->retval);
3985 vl_api_one_adjacency_t *a;
3990 n = clib_net_to_host_u32 (mp->count);
3991 vat_json_init_array (&root);
3993 for (i = 0; i < n; i++)
3995 e = vat_json_array_add (&root);
3996 a = &mp->adjacencies[i];
3998 vat_json_init_object (e);
3999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
4000 a->leid_prefix_len);
4002 vat_json_object_add_string_copy (e, "leid", s);
4005 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
4006 a->reid_prefix_len);
4008 vat_json_object_add_string_copy (e, "reid", s);
4012 vat_json_print (vam->ofp, &root);
4013 vat_json_free (&root);
4016 vam->retval = retval;
4017 vam->result_ready = 1;
4021 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4023 vat_main_t *vam = &vat_main;
4025 print (vam->ofp, "%=20U",
4026 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4031 vl_api_one_map_server_details_t_handler_json
4032 (vl_api_one_map_server_details_t * mp)
4034 vat_main_t *vam = &vat_main;
4035 vat_json_node_t *node = NULL;
4036 struct in6_addr ip6;
4039 if (VAT_JSON_ARRAY != vam->json_tree.type)
4041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4042 vat_json_init_array (&vam->json_tree);
4044 node = vat_json_array_add (&vam->json_tree);
4046 vat_json_init_object (node);
4049 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4050 vat_json_object_add_ip6 (node, "map-server", ip6);
4054 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4055 vat_json_object_add_ip4 (node, "map-server", ip4);
4060 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4063 vat_main_t *vam = &vat_main;
4065 print (vam->ofp, "%=20U",
4066 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4071 vl_api_one_map_resolver_details_t_handler_json
4072 (vl_api_one_map_resolver_details_t * mp)
4074 vat_main_t *vam = &vat_main;
4075 vat_json_node_t *node = NULL;
4076 struct in6_addr ip6;
4079 if (VAT_JSON_ARRAY != vam->json_tree.type)
4081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4082 vat_json_init_array (&vam->json_tree);
4084 node = vat_json_array_add (&vam->json_tree);
4086 vat_json_init_object (node);
4089 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4090 vat_json_object_add_ip6 (node, "map resolver", ip6);
4094 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4095 vat_json_object_add_ip4 (node, "map resolver", ip4);
4100 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 i32 retval = ntohl (mp->retval);
4107 print (vam->ofp, "feature: %s\ngpe: %s",
4108 mp->feature_status ? "enabled" : "disabled",
4109 mp->gpe_status ? "enabled" : "disabled");
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_show_one_status_reply_t_handler_json
4118 (vl_api_show_one_status_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t node;
4122 u8 *gpe_status = NULL;
4123 u8 *feature_status = NULL;
4125 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4126 feature_status = format (0, "%s",
4127 mp->feature_status ? "enabled" : "disabled");
4128 vec_add1 (gpe_status, 0);
4129 vec_add1 (feature_status, 0);
4131 vat_json_init_object (&node);
4132 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4133 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4135 vec_free (gpe_status);
4136 vec_free (feature_status);
4138 vat_json_print (vam->ofp, &node);
4139 vat_json_free (&node);
4141 vam->retval = ntohl (mp->retval);
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 i32 retval = ntohl (mp->retval);
4154 print (vam->ofp, "%=20s", mp->locator_set_name);
4157 vam->retval = retval;
4158 vam->result_ready = 1;
4162 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4163 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4165 vat_main_t *vam = &vat_main;
4166 vat_json_node_t *node = NULL;
4168 if (VAT_JSON_ARRAY != vam->json_tree.type)
4170 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4171 vat_json_init_array (&vam->json_tree);
4173 node = vat_json_array_add (&vam->json_tree);
4175 vat_json_init_object (node);
4176 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4178 vat_json_print (vam->ofp, node);
4179 vat_json_free (node);
4181 vam->retval = ntohl (mp->retval);
4182 vam->result_ready = 1;
4186 format_lisp_map_request_mode (u8 * s, va_list * args)
4188 u32 mode = va_arg (*args, u32);
4193 return format (0, "dst-only");
4195 return format (0, "src-dst");
4201 vl_api_show_one_map_request_mode_reply_t_handler
4202 (vl_api_show_one_map_request_mode_reply_t * mp)
4204 vat_main_t *vam = &vat_main;
4205 i32 retval = ntohl (mp->retval);
4209 u32 mode = mp->mode;
4210 print (vam->ofp, "map_request_mode: %U",
4211 format_lisp_map_request_mode, mode);
4214 vam->retval = retval;
4215 vam->result_ready = 1;
4219 vl_api_show_one_map_request_mode_reply_t_handler_json
4220 (vl_api_show_one_map_request_mode_reply_t * mp)
4222 vat_main_t *vam = &vat_main;
4223 vat_json_node_t node;
4228 s = format (0, "%U", format_lisp_map_request_mode, mode);
4231 vat_json_init_object (&node);
4232 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4233 vat_json_print (vam->ofp, &node);
4234 vat_json_free (&node);
4237 vam->retval = ntohl (mp->retval);
4238 vam->result_ready = 1;
4242 vl_api_show_one_use_petr_reply_t_handler
4243 (vl_api_show_one_use_petr_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 i32 retval = ntohl (mp->retval);
4250 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4253 print (vam->ofp, "Proxy-ETR address; %U",
4254 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4259 vam->retval = retval;
4260 vam->result_ready = 1;
4264 vl_api_show_one_use_petr_reply_t_handler_json
4265 (vl_api_show_one_use_petr_reply_t * mp)
4267 vat_main_t *vam = &vat_main;
4268 vat_json_node_t node;
4271 struct in6_addr ip6;
4273 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4274 vec_add1 (status, 0);
4276 vat_json_init_object (&node);
4277 vat_json_object_add_string_copy (&node, "status", status);
4282 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4283 vat_json_object_add_ip6 (&node, "address", ip6);
4287 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4288 vat_json_object_add_ip4 (&node, "address", ip4);
4294 vat_json_print (vam->ofp, &node);
4295 vat_json_free (&node);
4297 vam->retval = ntohl (mp->retval);
4298 vam->result_ready = 1;
4302 vl_api_show_one_nsh_mapping_reply_t_handler
4303 (vl_api_show_one_nsh_mapping_reply_t * mp)
4305 vat_main_t *vam = &vat_main;
4306 i32 retval = ntohl (mp->retval);
4310 print (vam->ofp, "%-20s%-16s",
4311 mp->is_set ? "set" : "not-set",
4312 mp->is_set ? (char *) mp->locator_set_name : "");
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_show_one_nsh_mapping_reply_t_handler_json
4321 (vl_api_show_one_nsh_mapping_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 status = format (0, "%s", mp->is_set ? "yes" : "no");
4328 vec_add1 (status, 0);
4330 vat_json_init_object (&node);
4331 vat_json_object_add_string_copy (&node, "is_set", status);
4334 vat_json_object_add_string_copy (&node, "locator_set",
4335 mp->locator_set_name);
4340 vat_json_print (vam->ofp, &node);
4341 vat_json_free (&node);
4343 vam->retval = ntohl (mp->retval);
4344 vam->result_ready = 1;
4348 vl_api_show_one_map_register_ttl_reply_t_handler
4349 (vl_api_show_one_map_register_ttl_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 i32 retval = ntohl (mp->retval);
4354 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4358 print (vam->ofp, "ttl: %u", mp->ttl);
4361 vam->retval = retval;
4362 vam->result_ready = 1;
4366 vl_api_show_one_map_register_ttl_reply_t_handler_json
4367 (vl_api_show_one_map_register_ttl_reply_t * mp)
4369 vat_main_t *vam = &vat_main;
4370 vat_json_node_t node;
4372 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4373 vat_json_init_object (&node);
4374 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4376 vat_json_print (vam->ofp, &node);
4377 vat_json_free (&node);
4379 vam->retval = ntohl (mp->retval);
4380 vam->result_ready = 1;
4384 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4386 vat_main_t *vam = &vat_main;
4387 i32 retval = ntohl (mp->retval);
4391 print (vam->ofp, "%-20s%-16s",
4392 mp->status ? "enabled" : "disabled",
4393 mp->status ? (char *) mp->locator_set_name : "");
4396 vam->retval = retval;
4397 vam->result_ready = 1;
4401 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4403 vat_main_t *vam = &vat_main;
4404 vat_json_node_t node;
4407 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4408 vec_add1 (status, 0);
4410 vat_json_init_object (&node);
4411 vat_json_object_add_string_copy (&node, "status", status);
4414 vat_json_object_add_string_copy (&node, "locator_set",
4415 mp->locator_set_name);
4420 vat_json_print (vam->ofp, &node);
4421 vat_json_free (&node);
4423 vam->retval = ntohl (mp->retval);
4424 vam->result_ready = 1;
4428 format_policer_type (u8 * s, va_list * va)
4430 u32 i = va_arg (*va, u32);
4432 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4433 s = format (s, "1r2c");
4434 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4435 s = format (s, "1r3c");
4436 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4437 s = format (s, "2r3c-2698");
4438 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4439 s = format (s, "2r3c-4115");
4440 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4441 s = format (s, "2r3c-mef5cf1");
4443 s = format (s, "ILLEGAL");
4448 format_policer_rate_type (u8 * s, va_list * va)
4450 u32 i = va_arg (*va, u32);
4452 if (i == SSE2_QOS_RATE_KBPS)
4453 s = format (s, "kbps");
4454 else if (i == SSE2_QOS_RATE_PPS)
4455 s = format (s, "pps");
4457 s = format (s, "ILLEGAL");
4462 format_policer_round_type (u8 * s, va_list * va)
4464 u32 i = va_arg (*va, u32);
4466 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4467 s = format (s, "closest");
4468 else if (i == SSE2_QOS_ROUND_TO_UP)
4469 s = format (s, "up");
4470 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4471 s = format (s, "down");
4473 s = format (s, "ILLEGAL");
4478 format_policer_action_type (u8 * s, va_list * va)
4480 u32 i = va_arg (*va, u32);
4482 if (i == SSE2_QOS_ACTION_DROP)
4483 s = format (s, "drop");
4484 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4485 s = format (s, "transmit");
4486 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4487 s = format (s, "mark-and-transmit");
4489 s = format (s, "ILLEGAL");
4494 format_dscp (u8 * s, va_list * va)
4496 u32 i = va_arg (*va, u32);
4501 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4505 return format (s, "ILLEGAL");
4507 s = format (s, "%s", t);
4512 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4514 vat_main_t *vam = &vat_main;
4515 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4517 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4518 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4520 conform_dscp_str = format (0, "");
4522 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4523 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4525 exceed_dscp_str = format (0, "");
4527 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4528 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4530 violate_dscp_str = format (0, "");
4532 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4533 "rate type %U, round type %U, %s rate, %s color-aware, "
4534 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4535 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4536 "conform action %U%s, exceed action %U%s, violate action %U%s",
4538 format_policer_type, mp->type,
4541 clib_net_to_host_u64 (mp->cb),
4542 clib_net_to_host_u64 (mp->eb),
4543 format_policer_rate_type, mp->rate_type,
4544 format_policer_round_type, mp->round_type,
4545 mp->single_rate ? "single" : "dual",
4546 mp->color_aware ? "is" : "not",
4547 ntohl (mp->cir_tokens_per_period),
4548 ntohl (mp->pir_tokens_per_period),
4550 ntohl (mp->current_limit),
4551 ntohl (mp->current_bucket),
4552 ntohl (mp->extended_limit),
4553 ntohl (mp->extended_bucket),
4554 clib_net_to_host_u64 (mp->last_update_time),
4555 format_policer_action_type, mp->conform_action_type,
4557 format_policer_action_type, mp->exceed_action_type,
4559 format_policer_action_type, mp->violate_action_type,
4562 vec_free (conform_dscp_str);
4563 vec_free (exceed_dscp_str);
4564 vec_free (violate_dscp_str);
4567 static void vl_api_policer_details_t_handler_json
4568 (vl_api_policer_details_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 vat_json_node_t *node;
4572 u8 *rate_type_str, *round_type_str, *type_str;
4573 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4575 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4577 format (0, "%U", format_policer_round_type, mp->round_type);
4578 type_str = format (0, "%U", format_policer_type, mp->type);
4579 conform_action_str = format (0, "%U", format_policer_action_type,
4580 mp->conform_action_type);
4581 exceed_action_str = format (0, "%U", format_policer_action_type,
4582 mp->exceed_action_type);
4583 violate_action_str = format (0, "%U", format_policer_action_type,
4584 mp->violate_action_type);
4586 if (VAT_JSON_ARRAY != vam->json_tree.type)
4588 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4589 vat_json_init_array (&vam->json_tree);
4591 node = vat_json_array_add (&vam->json_tree);
4593 vat_json_init_object (node);
4594 vat_json_object_add_string_copy (node, "name", mp->name);
4595 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4596 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4597 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4598 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4599 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4600 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4601 vat_json_object_add_string_copy (node, "type", type_str);
4602 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4603 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4604 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4605 vat_json_object_add_uint (node, "cir_tokens_per_period",
4606 ntohl (mp->cir_tokens_per_period));
4607 vat_json_object_add_uint (node, "eir_tokens_per_period",
4608 ntohl (mp->pir_tokens_per_period));
4609 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4610 vat_json_object_add_uint (node, "current_bucket",
4611 ntohl (mp->current_bucket));
4612 vat_json_object_add_uint (node, "extended_limit",
4613 ntohl (mp->extended_limit));
4614 vat_json_object_add_uint (node, "extended_bucket",
4615 ntohl (mp->extended_bucket));
4616 vat_json_object_add_uint (node, "last_update_time",
4617 ntohl (mp->last_update_time));
4618 vat_json_object_add_string_copy (node, "conform_action",
4619 conform_action_str);
4620 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4622 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4623 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4624 vec_free (dscp_str);
4626 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4627 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4629 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4630 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4631 vec_free (dscp_str);
4633 vat_json_object_add_string_copy (node, "violate_action",
4634 violate_action_str);
4635 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4637 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4638 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4639 vec_free (dscp_str);
4642 vec_free (rate_type_str);
4643 vec_free (round_type_str);
4644 vec_free (type_str);
4645 vec_free (conform_action_str);
4646 vec_free (exceed_action_str);
4647 vec_free (violate_action_str);
4651 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4654 vat_main_t *vam = &vat_main;
4655 int i, count = ntohl (mp->count);
4658 print (vam->ofp, "classify table ids (%d) : ", count);
4659 for (i = 0; i < count; i++)
4661 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4662 print (vam->ofp, (i < count - 1) ? "," : "");
4664 vam->retval = ntohl (mp->retval);
4665 vam->result_ready = 1;
4669 vl_api_classify_table_ids_reply_t_handler_json
4670 (vl_api_classify_table_ids_reply_t * mp)
4672 vat_main_t *vam = &vat_main;
4673 int i, count = ntohl (mp->count);
4677 vat_json_node_t node;
4679 vat_json_init_object (&node);
4680 for (i = 0; i < count; i++)
4682 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4684 vat_json_print (vam->ofp, &node);
4685 vat_json_free (&node);
4687 vam->retval = ntohl (mp->retval);
4688 vam->result_ready = 1;
4692 vl_api_classify_table_by_interface_reply_t_handler
4693 (vl_api_classify_table_by_interface_reply_t * mp)
4695 vat_main_t *vam = &vat_main;
4698 table_id = ntohl (mp->l2_table_id);
4700 print (vam->ofp, "l2 table id : %d", table_id);
4702 print (vam->ofp, "l2 table id : No input ACL tables configured");
4703 table_id = ntohl (mp->ip4_table_id);
4705 print (vam->ofp, "ip4 table id : %d", table_id);
4707 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4708 table_id = ntohl (mp->ip6_table_id);
4710 print (vam->ofp, "ip6 table id : %d", table_id);
4712 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4713 vam->retval = ntohl (mp->retval);
4714 vam->result_ready = 1;
4718 vl_api_classify_table_by_interface_reply_t_handler_json
4719 (vl_api_classify_table_by_interface_reply_t * mp)
4721 vat_main_t *vam = &vat_main;
4722 vat_json_node_t node;
4724 vat_json_init_object (&node);
4726 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4727 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4728 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4730 vat_json_print (vam->ofp, &node);
4731 vat_json_free (&node);
4733 vam->retval = ntohl (mp->retval);
4734 vam->result_ready = 1;
4737 static void vl_api_policer_add_del_reply_t_handler
4738 (vl_api_policer_add_del_reply_t * mp)
4740 vat_main_t *vam = &vat_main;
4741 i32 retval = ntohl (mp->retval);
4742 if (vam->async_mode)
4744 vam->async_errors += (retval < 0);
4748 vam->retval = retval;
4749 vam->result_ready = 1;
4750 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4752 * Note: this is just barely thread-safe, depends on
4753 * the main thread spinning waiting for an answer...
4755 errmsg ("policer index %d", ntohl (mp->policer_index));
4759 static void vl_api_policer_add_del_reply_t_handler_json
4760 (vl_api_policer_add_del_reply_t * mp)
4762 vat_main_t *vam = &vat_main;
4763 vat_json_node_t node;
4765 vat_json_init_object (&node);
4766 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4767 vat_json_object_add_uint (&node, "policer_index",
4768 ntohl (mp->policer_index));
4770 vat_json_print (vam->ofp, &node);
4771 vat_json_free (&node);
4773 vam->retval = ntohl (mp->retval);
4774 vam->result_ready = 1;
4777 /* Format hex dump. */
4779 format_hex_bytes (u8 * s, va_list * va)
4781 u8 *bytes = va_arg (*va, u8 *);
4782 int n_bytes = va_arg (*va, int);
4785 /* Print short or long form depending on byte count. */
4786 uword short_form = n_bytes <= 32;
4787 u32 indent = format_get_indent (s);
4792 for (i = 0; i < n_bytes; i++)
4794 if (!short_form && (i % 32) == 0)
4795 s = format (s, "%08x: ", i);
4796 s = format (s, "%02x", bytes[i]);
4797 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4798 s = format (s, "\n%U", format_white_space, indent);
4805 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4808 vat_main_t *vam = &vat_main;
4809 i32 retval = ntohl (mp->retval);
4812 print (vam->ofp, "classify table info :");
4813 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4814 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4815 ntohl (mp->miss_next_index));
4816 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4817 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4818 ntohl (mp->match_n_vectors));
4819 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4820 ntohl (mp->mask_length));
4822 vam->retval = retval;
4823 vam->result_ready = 1;
4827 vl_api_classify_table_info_reply_t_handler_json
4828 (vl_api_classify_table_info_reply_t * mp)
4830 vat_main_t *vam = &vat_main;
4831 vat_json_node_t node;
4833 i32 retval = ntohl (mp->retval);
4836 vat_json_init_object (&node);
4838 vat_json_object_add_int (&node, "sessions",
4839 ntohl (mp->active_sessions));
4840 vat_json_object_add_int (&node, "nexttbl",
4841 ntohl (mp->next_table_index));
4842 vat_json_object_add_int (&node, "nextnode",
4843 ntohl (mp->miss_next_index));
4844 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4845 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4846 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4847 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4848 ntohl (mp->mask_length), 0);
4849 vat_json_object_add_string_copy (&node, "mask", s);
4851 vat_json_print (vam->ofp, &node);
4852 vat_json_free (&node);
4854 vam->retval = ntohl (mp->retval);
4855 vam->result_ready = 1;
4859 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4862 vat_main_t *vam = &vat_main;
4864 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4865 ntohl (mp->hit_next_index), ntohl (mp->advance),
4866 ntohl (mp->opaque_index));
4867 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4868 ntohl (mp->match_length));
4872 vl_api_classify_session_details_t_handler_json
4873 (vl_api_classify_session_details_t * mp)
4875 vat_main_t *vam = &vat_main;
4876 vat_json_node_t *node = NULL;
4878 if (VAT_JSON_ARRAY != vam->json_tree.type)
4880 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4881 vat_json_init_array (&vam->json_tree);
4883 node = vat_json_array_add (&vam->json_tree);
4885 vat_json_init_object (node);
4886 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4887 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4888 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4890 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4892 vat_json_object_add_string_copy (node, "match", s);
4895 static void vl_api_pg_create_interface_reply_t_handler
4896 (vl_api_pg_create_interface_reply_t * mp)
4898 vat_main_t *vam = &vat_main;
4900 vam->retval = ntohl (mp->retval);
4901 vam->result_ready = 1;
4904 static void vl_api_pg_create_interface_reply_t_handler_json
4905 (vl_api_pg_create_interface_reply_t * mp)
4907 vat_main_t *vam = &vat_main;
4908 vat_json_node_t node;
4910 i32 retval = ntohl (mp->retval);
4913 vat_json_init_object (&node);
4915 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4917 vat_json_print (vam->ofp, &node);
4918 vat_json_free (&node);
4920 vam->retval = ntohl (mp->retval);
4921 vam->result_ready = 1;
4924 static void vl_api_policer_classify_details_t_handler
4925 (vl_api_policer_classify_details_t * mp)
4927 vat_main_t *vam = &vat_main;
4929 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4930 ntohl (mp->table_index));
4933 static void vl_api_policer_classify_details_t_handler_json
4934 (vl_api_policer_classify_details_t * mp)
4936 vat_main_t *vam = &vat_main;
4937 vat_json_node_t *node;
4939 if (VAT_JSON_ARRAY != vam->json_tree.type)
4941 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4942 vat_json_init_array (&vam->json_tree);
4944 node = vat_json_array_add (&vam->json_tree);
4946 vat_json_init_object (node);
4947 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4948 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4951 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4952 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4954 vat_main_t *vam = &vat_main;
4955 i32 retval = ntohl (mp->retval);
4956 if (vam->async_mode)
4958 vam->async_errors += (retval < 0);
4962 vam->retval = retval;
4963 vam->sw_if_index = ntohl (mp->sw_if_index);
4964 vam->result_ready = 1;
4968 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4969 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4971 vat_main_t *vam = &vat_main;
4972 vat_json_node_t node;
4974 vat_json_init_object (&node);
4975 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4976 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4978 vat_json_print (vam->ofp, &node);
4979 vat_json_free (&node);
4981 vam->retval = ntohl (mp->retval);
4982 vam->result_ready = 1;
4985 static void vl_api_flow_classify_details_t_handler
4986 (vl_api_flow_classify_details_t * mp)
4988 vat_main_t *vam = &vat_main;
4990 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4991 ntohl (mp->table_index));
4994 static void vl_api_flow_classify_details_t_handler_json
4995 (vl_api_flow_classify_details_t * mp)
4997 vat_main_t *vam = &vat_main;
4998 vat_json_node_t *node;
5000 if (VAT_JSON_ARRAY != vam->json_tree.type)
5002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5003 vat_json_init_array (&vam->json_tree);
5005 node = vat_json_array_add (&vam->json_tree);
5007 vat_json_init_object (node);
5008 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5009 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5012 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
5013 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
5014 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
5015 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
5016 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
5017 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
5018 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
5019 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
5020 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
5021 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
5022 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
5023 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
5024 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5025 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5026 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5027 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5028 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5029 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5030 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5031 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5032 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5033 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5036 * Generate boilerplate reply handlers, which
5037 * dig the return value out of the xxx_reply_t API message,
5038 * stick it into vam->retval, and set vam->result_ready
5040 * Could also do this by pointing N message decode slots at
5041 * a single function, but that could break in subtle ways.
5044 #define foreach_standard_reply_retval_handler \
5045 _(sw_interface_set_flags_reply) \
5046 _(sw_interface_add_del_address_reply) \
5047 _(sw_interface_set_table_reply) \
5048 _(sw_interface_set_mpls_enable_reply) \
5049 _(sw_interface_set_vpath_reply) \
5050 _(sw_interface_set_vxlan_bypass_reply) \
5051 _(sw_interface_set_geneve_bypass_reply) \
5052 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5053 _(sw_interface_set_l2_bridge_reply) \
5054 _(bridge_domain_add_del_reply) \
5055 _(sw_interface_set_l2_xconnect_reply) \
5056 _(l2fib_add_del_reply) \
5057 _(l2fib_flush_int_reply) \
5058 _(l2fib_flush_bd_reply) \
5059 _(ip_add_del_route_reply) \
5060 _(ip_table_add_del_reply) \
5061 _(ip_mroute_add_del_reply) \
5062 _(mpls_route_add_del_reply) \
5063 _(mpls_table_add_del_reply) \
5064 _(mpls_ip_bind_unbind_reply) \
5065 _(proxy_arp_add_del_reply) \
5066 _(proxy_arp_intfc_enable_disable_reply) \
5067 _(sw_interface_set_unnumbered_reply) \
5068 _(ip_neighbor_add_del_reply) \
5069 _(reset_vrf_reply) \
5070 _(oam_add_del_reply) \
5071 _(reset_fib_reply) \
5072 _(dhcp_proxy_config_reply) \
5073 _(dhcp_proxy_set_vss_reply) \
5074 _(dhcp_client_config_reply) \
5075 _(set_ip_flow_hash_reply) \
5076 _(sw_interface_ip6_enable_disable_reply) \
5077 _(sw_interface_ip6_set_link_local_address_reply) \
5078 _(ip6nd_proxy_add_del_reply) \
5079 _(sw_interface_ip6nd_ra_prefix_reply) \
5080 _(sw_interface_ip6nd_ra_config_reply) \
5081 _(set_arp_neighbor_limit_reply) \
5082 _(l2_patch_add_del_reply) \
5083 _(sr_policy_add_reply) \
5084 _(sr_policy_mod_reply) \
5085 _(sr_policy_del_reply) \
5086 _(sr_localsid_add_del_reply) \
5087 _(sr_steering_add_del_reply) \
5088 _(classify_add_del_session_reply) \
5089 _(classify_set_interface_ip_table_reply) \
5090 _(classify_set_interface_l2_tables_reply) \
5091 _(l2tpv3_set_tunnel_cookies_reply) \
5092 _(l2tpv3_interface_enable_disable_reply) \
5093 _(l2tpv3_set_lookup_key_reply) \
5094 _(l2_fib_clear_table_reply) \
5095 _(l2_interface_efp_filter_reply) \
5096 _(l2_interface_vlan_tag_rewrite_reply) \
5097 _(modify_vhost_user_if_reply) \
5098 _(delete_vhost_user_if_reply) \
5099 _(want_ip4_arp_events_reply) \
5100 _(want_ip6_nd_events_reply) \
5101 _(want_l2_macs_events_reply) \
5102 _(input_acl_set_interface_reply) \
5103 _(ipsec_spd_add_del_reply) \
5104 _(ipsec_interface_add_del_spd_reply) \
5105 _(ipsec_spd_add_del_entry_reply) \
5106 _(ipsec_sad_add_del_entry_reply) \
5107 _(ipsec_sa_set_key_reply) \
5108 _(ipsec_tunnel_if_add_del_reply) \
5109 _(ipsec_tunnel_if_set_key_reply) \
5110 _(ikev2_profile_add_del_reply) \
5111 _(ikev2_profile_set_auth_reply) \
5112 _(ikev2_profile_set_id_reply) \
5113 _(ikev2_profile_set_ts_reply) \
5114 _(ikev2_set_local_key_reply) \
5115 _(ikev2_set_responder_reply) \
5116 _(ikev2_set_ike_transforms_reply) \
5117 _(ikev2_set_esp_transforms_reply) \
5118 _(ikev2_set_sa_lifetime_reply) \
5119 _(ikev2_initiate_sa_init_reply) \
5120 _(ikev2_initiate_del_ike_sa_reply) \
5121 _(ikev2_initiate_del_child_sa_reply) \
5122 _(ikev2_initiate_rekey_child_sa_reply) \
5123 _(delete_loopback_reply) \
5124 _(bd_ip_mac_add_del_reply) \
5125 _(map_del_domain_reply) \
5126 _(map_add_del_rule_reply) \
5127 _(want_interface_events_reply) \
5128 _(want_stats_reply) \
5129 _(cop_interface_enable_disable_reply) \
5130 _(cop_whitelist_enable_disable_reply) \
5131 _(sw_interface_clear_stats_reply) \
5132 _(ioam_enable_reply) \
5133 _(ioam_disable_reply) \
5134 _(one_add_del_locator_reply) \
5135 _(one_add_del_local_eid_reply) \
5136 _(one_add_del_remote_mapping_reply) \
5137 _(one_add_del_adjacency_reply) \
5138 _(one_add_del_map_resolver_reply) \
5139 _(one_add_del_map_server_reply) \
5140 _(one_enable_disable_reply) \
5141 _(one_rloc_probe_enable_disable_reply) \
5142 _(one_map_register_enable_disable_reply) \
5143 _(one_map_register_set_ttl_reply) \
5144 _(one_set_transport_protocol_reply) \
5145 _(one_map_register_fallback_threshold_reply) \
5146 _(one_pitr_set_locator_set_reply) \
5147 _(one_map_request_mode_reply) \
5148 _(one_add_del_map_request_itr_rlocs_reply) \
5149 _(one_eid_table_add_del_map_reply) \
5150 _(one_use_petr_reply) \
5151 _(one_stats_enable_disable_reply) \
5152 _(one_add_del_l2_arp_entry_reply) \
5153 _(one_add_del_ndp_entry_reply) \
5154 _(one_stats_flush_reply) \
5155 _(gpe_enable_disable_reply) \
5156 _(gpe_set_encap_mode_reply) \
5157 _(gpe_add_del_iface_reply) \
5158 _(gpe_add_del_native_fwd_rpath_reply) \
5159 _(af_packet_delete_reply) \
5160 _(policer_classify_set_interface_reply) \
5161 _(netmap_create_reply) \
5162 _(netmap_delete_reply) \
5163 _(set_ipfix_exporter_reply) \
5164 _(set_ipfix_classify_stream_reply) \
5165 _(ipfix_classify_table_add_del_reply) \
5166 _(flow_classify_set_interface_reply) \
5167 _(sw_interface_span_enable_disable_reply) \
5168 _(pg_capture_reply) \
5169 _(pg_enable_disable_reply) \
5170 _(ip_source_and_port_range_check_add_del_reply) \
5171 _(ip_source_and_port_range_check_interface_add_del_reply)\
5172 _(delete_subif_reply) \
5173 _(l2_interface_pbb_tag_rewrite_reply) \
5175 _(feature_enable_disable_reply) \
5176 _(sw_interface_tag_add_del_reply) \
5177 _(sw_interface_set_mtu_reply) \
5178 _(p2p_ethernet_add_reply) \
5179 _(p2p_ethernet_del_reply) \
5180 _(lldp_config_reply) \
5181 _(sw_interface_set_lldp_reply) \
5182 _(tcp_configure_src_addresses_reply) \
5183 _(app_namespace_add_del_reply) \
5184 _(dns_enable_disable_reply) \
5185 _(dns_name_server_add_del_reply)
5188 static void vl_api_##n##_t_handler \
5189 (vl_api_##n##_t * mp) \
5191 vat_main_t * vam = &vat_main; \
5192 i32 retval = ntohl(mp->retval); \
5193 if (vam->async_mode) { \
5194 vam->async_errors += (retval < 0); \
5196 vam->retval = retval; \
5197 vam->result_ready = 1; \
5200 foreach_standard_reply_retval_handler;
5204 static void vl_api_##n##_t_handler_json \
5205 (vl_api_##n##_t * mp) \
5207 vat_main_t * vam = &vat_main; \
5208 vat_json_node_t node; \
5209 vat_json_init_object(&node); \
5210 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5211 vat_json_print(vam->ofp, &node); \
5212 vam->retval = ntohl(mp->retval); \
5213 vam->result_ready = 1; \
5215 foreach_standard_reply_retval_handler;
5219 * Table of message reply handlers, must include boilerplate handlers
5223 #define foreach_vpe_api_reply_msg \
5224 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5225 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5226 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5227 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5228 _(CONTROL_PING_REPLY, control_ping_reply) \
5229 _(CLI_REPLY, cli_reply) \
5230 _(CLI_INBAND_REPLY, cli_inband_reply) \
5231 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5232 sw_interface_add_del_address_reply) \
5233 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5234 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5235 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5236 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5237 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5238 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5239 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5240 sw_interface_set_l2_xconnect_reply) \
5241 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5242 sw_interface_set_l2_bridge_reply) \
5243 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5244 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5245 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5246 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5247 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5248 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5249 _(L2_FLAGS_REPLY, l2_flags_reply) \
5250 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5251 _(TAP_CONNECT_REPLY, tap_connect_reply) \
5252 _(TAP_MODIFY_REPLY, tap_modify_reply) \
5253 _(TAP_DELETE_REPLY, tap_delete_reply) \
5254 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
5255 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5256 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5257 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5258 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5259 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5260 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5261 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5262 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5263 proxy_arp_intfc_enable_disable_reply) \
5264 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5265 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5266 sw_interface_set_unnumbered_reply) \
5267 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5268 _(RESET_VRF_REPLY, reset_vrf_reply) \
5269 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5270 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5271 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5272 _(RESET_FIB_REPLY, reset_fib_reply) \
5273 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5274 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5275 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5276 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5277 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5278 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5279 sw_interface_ip6_enable_disable_reply) \
5280 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
5281 sw_interface_ip6_set_link_local_address_reply) \
5282 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5283 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5284 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5285 sw_interface_ip6nd_ra_prefix_reply) \
5286 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5287 sw_interface_ip6nd_ra_config_reply) \
5288 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5289 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5290 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5291 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5292 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5293 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5294 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5295 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5296 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5297 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5298 classify_set_interface_ip_table_reply) \
5299 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5300 classify_set_interface_l2_tables_reply) \
5301 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5302 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5303 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5304 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5305 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5306 l2tpv3_interface_enable_disable_reply) \
5307 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5308 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5309 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5310 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5311 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5312 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5313 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5314 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5315 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5316 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5317 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5318 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5319 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5320 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5321 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5322 _(SHOW_VERSION_REPLY, show_version_reply) \
5323 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5324 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5325 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5326 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5327 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5328 _(IP4_ARP_EVENT, ip4_arp_event) \
5329 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5330 _(IP6_ND_EVENT, ip6_nd_event) \
5331 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5332 _(L2_MACS_EVENT, l2_macs_event) \
5333 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5334 _(IP_ADDRESS_DETAILS, ip_address_details) \
5335 _(IP_DETAILS, ip_details) \
5336 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5337 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5338 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5339 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5340 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5341 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5342 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5343 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5344 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5345 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5346 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5347 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5348 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5349 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5350 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5351 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5352 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5353 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5354 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5355 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5356 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5357 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5358 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5359 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5360 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5361 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5362 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5363 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5364 _(MAP_RULE_DETAILS, map_rule_details) \
5365 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5366 _(WANT_STATS_REPLY, want_stats_reply) \
5367 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5368 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5369 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5370 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5371 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5372 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5373 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5374 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5375 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5376 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5377 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5378 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5379 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5380 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5381 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5382 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5383 one_map_register_enable_disable_reply) \
5384 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5385 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5386 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5387 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5388 one_map_register_fallback_threshold_reply) \
5389 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5390 one_rloc_probe_enable_disable_reply) \
5391 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5392 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5393 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5394 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5395 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5396 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5397 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5398 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5399 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5400 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5401 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5402 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5403 _(ONE_STATS_DETAILS, one_stats_details) \
5404 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5405 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5406 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5407 show_one_stats_enable_disable_reply) \
5408 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5409 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5410 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5411 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5412 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5413 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5414 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5415 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5416 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5417 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5418 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5419 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5420 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5421 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5422 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5423 gpe_add_del_native_fwd_rpath_reply) \
5424 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5425 gpe_fwd_entry_path_details) \
5426 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5427 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5428 one_add_del_map_request_itr_rlocs_reply) \
5429 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5430 one_get_map_request_itr_rlocs_reply) \
5431 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5432 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5433 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5434 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5435 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5436 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5437 show_one_map_register_state_reply) \
5438 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5439 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5440 show_one_map_register_fallback_threshold_reply) \
5441 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5442 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5443 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5444 _(POLICER_DETAILS, policer_details) \
5445 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5446 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5447 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5448 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5449 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5450 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5451 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5452 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5453 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5454 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5455 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5456 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5457 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5458 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5459 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5460 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5461 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5462 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5463 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5464 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5465 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5466 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5467 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5468 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5469 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5470 ip_source_and_port_range_check_add_del_reply) \
5471 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5472 ip_source_and_port_range_check_interface_add_del_reply) \
5473 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5474 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5475 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5476 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5477 _(PUNT_REPLY, punt_reply) \
5478 _(IP_FIB_DETAILS, ip_fib_details) \
5479 _(IP6_FIB_DETAILS, ip6_fib_details) \
5480 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5481 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5482 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5483 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5484 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5485 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5486 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5487 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5488 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5489 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5490 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5491 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5492 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5493 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5494 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5495 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply)
5497 #define foreach_standalone_reply_msg \
5498 _(SW_INTERFACE_EVENT, sw_interface_event) \
5499 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5500 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5501 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5502 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5503 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5504 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters) \
5505 _(MEMFD_SEGMENT_CREATE_REPLY, memfd_segment_create_reply) \
5514 #define STR_VTR_OP_CASE(op) \
5515 case L2_VTR_ ## op: \
5519 str_vtr_op (u32 vtr_op)
5523 STR_VTR_OP_CASE (DISABLED);
5524 STR_VTR_OP_CASE (PUSH_1);
5525 STR_VTR_OP_CASE (PUSH_2);
5526 STR_VTR_OP_CASE (POP_1);
5527 STR_VTR_OP_CASE (POP_2);
5528 STR_VTR_OP_CASE (TRANSLATE_1_1);
5529 STR_VTR_OP_CASE (TRANSLATE_1_2);
5530 STR_VTR_OP_CASE (TRANSLATE_2_1);
5531 STR_VTR_OP_CASE (TRANSLATE_2_2);
5538 dump_sub_interface_table (vat_main_t * vam)
5540 const sw_interface_subif_t *sub = NULL;
5542 if (vam->json_output)
5545 ("JSON output supported only for VPE API calls and dump_stats_table");
5550 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5551 "Interface", "sw_if_index",
5552 "sub id", "dot1ad", "tags", "outer id",
5553 "inner id", "exact", "default", "outer any", "inner any");
5555 vec_foreach (sub, vam->sw_if_subif_table)
5558 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5559 sub->interface_name,
5561 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5562 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5563 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5564 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5565 if (sub->vtr_op != L2_VTR_DISABLED)
5568 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5569 "tag1: %d tag2: %d ]",
5570 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5571 sub->vtr_tag1, sub->vtr_tag2);
5579 name_sort_cmp (void *a1, void *a2)
5581 name_sort_t *n1 = a1;
5582 name_sort_t *n2 = a2;
5584 return strcmp ((char *) n1->name, (char *) n2->name);
5588 dump_interface_table (vat_main_t * vam)
5591 name_sort_t *nses = 0, *ns;
5593 if (vam->json_output)
5596 ("JSON output supported only for VPE API calls and dump_stats_table");
5601 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5603 vec_add2 (nses, ns, 1);
5604 ns->name = (u8 *)(p->key);
5605 ns->value = (u32) p->value[0];
5609 vec_sort_with_function (nses, name_sort_cmp);
5611 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5612 vec_foreach (ns, nses)
5614 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5621 dump_ip_table (vat_main_t * vam, int is_ipv6)
5623 const ip_details_t *det = NULL;
5624 const ip_address_details_t *address = NULL;
5627 print (vam->ofp, "%-12s", "sw_if_index");
5629 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5636 print (vam->ofp, "%-12d", i);
5637 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5642 vec_foreach (address, det->addr)
5646 is_ipv6 ? format_ip6_address : format_ip4_address,
5647 address->ip, address->prefix_length);
5655 dump_ipv4_table (vat_main_t * vam)
5657 if (vam->json_output)
5660 ("JSON output supported only for VPE API calls and dump_stats_table");
5664 return dump_ip_table (vam, 0);
5668 dump_ipv6_table (vat_main_t * vam)
5670 if (vam->json_output)
5673 ("JSON output supported only for VPE API calls and dump_stats_table");
5677 return dump_ip_table (vam, 1);
5681 counter_type_to_str (u8 counter_type, u8 is_combined)
5685 switch (counter_type)
5687 case VNET_INTERFACE_COUNTER_DROP:
5689 case VNET_INTERFACE_COUNTER_PUNT:
5691 case VNET_INTERFACE_COUNTER_IP4:
5693 case VNET_INTERFACE_COUNTER_IP6:
5695 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5697 case VNET_INTERFACE_COUNTER_RX_MISS:
5699 case VNET_INTERFACE_COUNTER_RX_ERROR:
5701 case VNET_INTERFACE_COUNTER_TX_ERROR:
5704 return "INVALID-COUNTER-TYPE";
5709 switch (counter_type)
5711 case VNET_INTERFACE_COUNTER_RX:
5713 case VNET_INTERFACE_COUNTER_TX:
5716 return "INVALID-COUNTER-TYPE";
5722 dump_stats_table (vat_main_t * vam)
5724 vat_json_node_t node;
5725 vat_json_node_t *msg_array;
5726 vat_json_node_t *msg;
5727 vat_json_node_t *counter_array;
5728 vat_json_node_t *counter;
5729 interface_counter_t c;
5731 ip4_fib_counter_t *c4;
5732 ip6_fib_counter_t *c6;
5733 ip4_nbr_counter_t *n4;
5734 ip6_nbr_counter_t *n6;
5737 if (!vam->json_output)
5739 clib_warning ("dump_stats_table supported only in JSON format");
5743 vat_json_init_object (&node);
5745 /* interface counters */
5746 msg_array = vat_json_object_add (&node, "interface_counters");
5747 vat_json_init_array (msg_array);
5748 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5750 msg = vat_json_array_add (msg_array);
5751 vat_json_init_object (msg);
5752 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5753 (u8 *) counter_type_to_str (i, 0));
5754 vat_json_object_add_int (msg, "is_combined", 0);
5755 counter_array = vat_json_object_add (msg, "data");
5756 vat_json_init_array (counter_array);
5757 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5759 packets = vam->simple_interface_counters[i][j];
5760 vat_json_array_add_uint (counter_array, packets);
5763 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5765 msg = vat_json_array_add (msg_array);
5766 vat_json_init_object (msg);
5767 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5768 (u8 *) counter_type_to_str (i, 1));
5769 vat_json_object_add_int (msg, "is_combined", 1);
5770 counter_array = vat_json_object_add (msg, "data");
5771 vat_json_init_array (counter_array);
5772 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5774 c = vam->combined_interface_counters[i][j];
5775 counter = vat_json_array_add (counter_array);
5776 vat_json_init_object (counter);
5777 vat_json_object_add_uint (counter, "packets", c.packets);
5778 vat_json_object_add_uint (counter, "bytes", c.bytes);
5782 /* ip4 fib counters */
5783 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5784 vat_json_init_array (msg_array);
5785 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5787 msg = vat_json_array_add (msg_array);
5788 vat_json_init_object (msg);
5789 vat_json_object_add_uint (msg, "vrf_id",
5790 vam->ip4_fib_counters_vrf_id_by_index[i]);
5791 counter_array = vat_json_object_add (msg, "c");
5792 vat_json_init_array (counter_array);
5793 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5795 counter = vat_json_array_add (counter_array);
5796 vat_json_init_object (counter);
5797 c4 = &vam->ip4_fib_counters[i][j];
5798 vat_json_object_add_ip4 (counter, "address", c4->address);
5799 vat_json_object_add_uint (counter, "address_length",
5800 c4->address_length);
5801 vat_json_object_add_uint (counter, "packets", c4->packets);
5802 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5806 /* ip6 fib counters */
5807 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5808 vat_json_init_array (msg_array);
5809 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5811 msg = vat_json_array_add (msg_array);
5812 vat_json_init_object (msg);
5813 vat_json_object_add_uint (msg, "vrf_id",
5814 vam->ip6_fib_counters_vrf_id_by_index[i]);
5815 counter_array = vat_json_object_add (msg, "c");
5816 vat_json_init_array (counter_array);
5817 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5819 counter = vat_json_array_add (counter_array);
5820 vat_json_init_object (counter);
5821 c6 = &vam->ip6_fib_counters[i][j];
5822 vat_json_object_add_ip6 (counter, "address", c6->address);
5823 vat_json_object_add_uint (counter, "address_length",
5824 c6->address_length);
5825 vat_json_object_add_uint (counter, "packets", c6->packets);
5826 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5830 /* ip4 nbr counters */
5831 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5832 vat_json_init_array (msg_array);
5833 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5835 msg = vat_json_array_add (msg_array);
5836 vat_json_init_object (msg);
5837 vat_json_object_add_uint (msg, "sw_if_index", i);
5838 counter_array = vat_json_object_add (msg, "c");
5839 vat_json_init_array (counter_array);
5840 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5842 counter = vat_json_array_add (counter_array);
5843 vat_json_init_object (counter);
5844 n4 = &vam->ip4_nbr_counters[i][j];
5845 vat_json_object_add_ip4 (counter, "address", n4->address);
5846 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5847 vat_json_object_add_uint (counter, "packets", n4->packets);
5848 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5852 /* ip6 nbr counters */
5853 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5854 vat_json_init_array (msg_array);
5855 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5857 msg = vat_json_array_add (msg_array);
5858 vat_json_init_object (msg);
5859 vat_json_object_add_uint (msg, "sw_if_index", i);
5860 counter_array = vat_json_object_add (msg, "c");
5861 vat_json_init_array (counter_array);
5862 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5864 counter = vat_json_array_add (counter_array);
5865 vat_json_init_object (counter);
5866 n6 = &vam->ip6_nbr_counters[i][j];
5867 vat_json_object_add_ip6 (counter, "address", n6->address);
5868 vat_json_object_add_uint (counter, "packets", n6->packets);
5869 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5873 vat_json_print (vam->ofp, &node);
5874 vat_json_free (&node);
5880 * Pass CLI buffers directly in the CLI_INBAND API message,
5881 * instead of an additional shared memory area.
5884 exec_inband (vat_main_t * vam)
5886 vl_api_cli_inband_t *mp;
5887 unformat_input_t *i = vam->input;
5890 if (vec_len (i->buffer) == 0)
5893 if (vam->exec_mode == 0 && unformat (i, "mode"))
5898 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5905 * In order for the CLI command to work, it
5906 * must be a vector ending in \n, not a C-string ending
5909 u32 len = vec_len (vam->input->buffer);
5910 M2 (CLI_INBAND, mp, len);
5911 clib_memcpy (mp->cmd, vam->input->buffer, len);
5912 mp->length = htonl (len);
5916 /* json responses may or may not include a useful reply... */
5917 if (vec_len (vam->cmd_reply))
5918 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5923 exec (vat_main_t * vam)
5925 return exec_inband (vam);
5929 api_create_loopback (vat_main_t * vam)
5931 unformat_input_t *i = vam->input;
5932 vl_api_create_loopback_t *mp;
5933 vl_api_create_loopback_instance_t *mp_lbi;
5936 u8 is_specified = 0;
5937 u32 user_instance = 0;
5940 memset (mac_address, 0, sizeof (mac_address));
5942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5944 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5946 if (unformat (i, "instance %d", &user_instance))
5954 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5955 mp_lbi->is_specified = is_specified;
5957 mp_lbi->user_instance = htonl (user_instance);
5959 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5964 /* Construct the API message */
5965 M (CREATE_LOOPBACK, mp);
5967 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5976 api_delete_loopback (vat_main_t * vam)
5978 unformat_input_t *i = vam->input;
5979 vl_api_delete_loopback_t *mp;
5980 u32 sw_if_index = ~0;
5983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5985 if (unformat (i, "sw_if_index %d", &sw_if_index))
5991 if (sw_if_index == ~0)
5993 errmsg ("missing sw_if_index");
5997 /* Construct the API message */
5998 M (DELETE_LOOPBACK, mp);
5999 mp->sw_if_index = ntohl (sw_if_index);
6007 api_want_stats (vat_main_t * vam)
6009 unformat_input_t *i = vam->input;
6010 vl_api_want_stats_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");
6031 mp->enable_disable = enable;
6039 api_want_interface_events (vat_main_t * vam)
6041 unformat_input_t *i = vam->input;
6042 vl_api_want_interface_events_t *mp;
6046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6048 if (unformat (i, "enable"))
6050 else if (unformat (i, "disable"))
6058 errmsg ("missing enable|disable");
6062 M (WANT_INTERFACE_EVENTS, mp);
6063 mp->enable_disable = enable;
6065 vam->interface_event_display = enable;
6073 /* Note: non-static, called once to set up the initial intfc table */
6075 api_sw_interface_dump (vat_main_t * vam)
6077 vl_api_sw_interface_dump_t *mp;
6078 vl_api_control_ping_t *mp_ping;
6080 name_sort_t *nses = 0, *ns;
6081 sw_interface_subif_t *sub = NULL;
6084 /* Toss the old name table */
6086 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
6088 vec_add2 (nses, ns, 1);
6089 ns->name = (u8 *)(p->key);
6090 ns->value = (u32) p->value[0];
6094 hash_free (vam->sw_if_index_by_interface_name);
6096 vec_foreach (ns, nses) vec_free (ns->name);
6100 vec_foreach (sub, vam->sw_if_subif_table)
6102 vec_free (sub->interface_name);
6104 vec_free (vam->sw_if_subif_table);
6106 /* recreate the interface name hash table */
6107 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
6109 /* Get list of ethernets */
6110 M (SW_INTERFACE_DUMP, mp);
6111 mp->name_filter_valid = 1;
6112 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
6115 /* and local / loopback interfaces */
6116 M (SW_INTERFACE_DUMP, mp);
6117 mp->name_filter_valid = 1;
6118 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
6121 /* and packet-generator interfaces */
6122 M (SW_INTERFACE_DUMP, mp);
6123 mp->name_filter_valid = 1;
6124 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
6127 /* and vxlan-gpe tunnel interfaces */
6128 M (SW_INTERFACE_DUMP, mp);
6129 mp->name_filter_valid = 1;
6130 strncpy ((char *) mp->name_filter, "vxlan_gpe",
6131 sizeof (mp->name_filter) - 1);
6134 /* and vxlan tunnel interfaces */
6135 M (SW_INTERFACE_DUMP, mp);
6136 mp->name_filter_valid = 1;
6137 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
6140 /* and geneve tunnel interfaces */
6141 M (SW_INTERFACE_DUMP, mp);
6142 mp->name_filter_valid = 1;
6143 strncpy ((char *) mp->name_filter, "geneve", sizeof (mp->name_filter) - 1);
6146 /* and host (af_packet) interfaces */
6147 M (SW_INTERFACE_DUMP, mp);
6148 mp->name_filter_valid = 1;
6149 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
6152 /* and l2tpv3 tunnel interfaces */
6153 M (SW_INTERFACE_DUMP, mp);
6154 mp->name_filter_valid = 1;
6155 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
6156 sizeof (mp->name_filter) - 1);
6159 /* and GRE tunnel interfaces */
6160 M (SW_INTERFACE_DUMP, mp);
6161 mp->name_filter_valid = 1;
6162 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
6165 /* and LISP-GPE interfaces */
6166 M (SW_INTERFACE_DUMP, mp);
6167 mp->name_filter_valid = 1;
6168 strncpy ((char *) mp->name_filter, "lisp_gpe",
6169 sizeof (mp->name_filter) - 1);
6172 /* and IPSEC tunnel interfaces */
6173 M (SW_INTERFACE_DUMP, mp);
6174 mp->name_filter_valid = 1;
6175 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
6178 /* Use a control ping for synchronization */
6179 MPING (CONTROL_PING, mp_ping);
6187 api_sw_interface_set_flags (vat_main_t * vam)
6189 unformat_input_t *i = vam->input;
6190 vl_api_sw_interface_set_flags_t *mp;
6192 u8 sw_if_index_set = 0;
6196 /* Parse args required to build the message */
6197 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6199 if (unformat (i, "admin-up"))
6201 else if (unformat (i, "admin-down"))
6204 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6205 sw_if_index_set = 1;
6206 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6207 sw_if_index_set = 1;
6212 if (sw_if_index_set == 0)
6214 errmsg ("missing interface name or sw_if_index");
6218 /* Construct the API message */
6219 M (SW_INTERFACE_SET_FLAGS, mp);
6220 mp->sw_if_index = ntohl (sw_if_index);
6221 mp->admin_up_down = admin_up;
6226 /* Wait for a reply, return the good/bad news... */
6232 api_sw_interface_clear_stats (vat_main_t * vam)
6234 unformat_input_t *i = vam->input;
6235 vl_api_sw_interface_clear_stats_t *mp;
6237 u8 sw_if_index_set = 0;
6240 /* Parse args required to build the message */
6241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6243 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6244 sw_if_index_set = 1;
6245 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6246 sw_if_index_set = 1;
6251 /* Construct the API message */
6252 M (SW_INTERFACE_CLEAR_STATS, mp);
6254 if (sw_if_index_set == 1)
6255 mp->sw_if_index = ntohl (sw_if_index);
6257 mp->sw_if_index = ~0;
6262 /* Wait for a reply, return the good/bad news... */
6268 api_sw_interface_add_del_address (vat_main_t * vam)
6270 unformat_input_t *i = vam->input;
6271 vl_api_sw_interface_add_del_address_t *mp;
6273 u8 sw_if_index_set = 0;
6274 u8 is_add = 1, del_all = 0;
6275 u32 address_length = 0;
6276 u8 v4_address_set = 0;
6277 u8 v6_address_set = 0;
6278 ip4_address_t v4address;
6279 ip6_address_t v6address;
6282 /* Parse args required to build the message */
6283 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6285 if (unformat (i, "del-all"))
6287 else if (unformat (i, "del"))
6290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6291 sw_if_index_set = 1;
6292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6293 sw_if_index_set = 1;
6294 else if (unformat (i, "%U/%d",
6295 unformat_ip4_address, &v4address, &address_length))
6297 else if (unformat (i, "%U/%d",
6298 unformat_ip6_address, &v6address, &address_length))
6304 if (sw_if_index_set == 0)
6306 errmsg ("missing interface name or sw_if_index");
6309 if (v4_address_set && v6_address_set)
6311 errmsg ("both v4 and v6 addresses set");
6314 if (!v4_address_set && !v6_address_set && !del_all)
6316 errmsg ("no addresses set");
6320 /* Construct the API message */
6321 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6323 mp->sw_if_index = ntohl (sw_if_index);
6324 mp->is_add = is_add;
6325 mp->del_all = del_all;
6329 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6333 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6335 mp->address_length = address_length;
6340 /* Wait for a reply, return good/bad news */
6346 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6348 unformat_input_t *i = vam->input;
6349 vl_api_sw_interface_set_mpls_enable_t *mp;
6351 u8 sw_if_index_set = 0;
6355 /* Parse args required to build the message */
6356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6358 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6359 sw_if_index_set = 1;
6360 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6361 sw_if_index_set = 1;
6362 else if (unformat (i, "disable"))
6364 else if (unformat (i, "dis"))
6370 if (sw_if_index_set == 0)
6372 errmsg ("missing interface name or sw_if_index");
6376 /* Construct the API message */
6377 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6379 mp->sw_if_index = ntohl (sw_if_index);
6380 mp->enable = enable;
6385 /* Wait for a reply... */
6391 api_sw_interface_set_table (vat_main_t * vam)
6393 unformat_input_t *i = vam->input;
6394 vl_api_sw_interface_set_table_t *mp;
6395 u32 sw_if_index, vrf_id = 0;
6396 u8 sw_if_index_set = 0;
6400 /* Parse args required to build the message */
6401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6403 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6404 sw_if_index_set = 1;
6405 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6406 sw_if_index_set = 1;
6407 else if (unformat (i, "vrf %d", &vrf_id))
6409 else if (unformat (i, "ipv6"))
6415 if (sw_if_index_set == 0)
6417 errmsg ("missing interface name or sw_if_index");
6421 /* Construct the API message */
6422 M (SW_INTERFACE_SET_TABLE, mp);
6424 mp->sw_if_index = ntohl (sw_if_index);
6425 mp->is_ipv6 = is_ipv6;
6426 mp->vrf_id = ntohl (vrf_id);
6431 /* Wait for a reply... */
6436 static void vl_api_sw_interface_get_table_reply_t_handler
6437 (vl_api_sw_interface_get_table_reply_t * mp)
6439 vat_main_t *vam = &vat_main;
6441 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6443 vam->retval = ntohl (mp->retval);
6444 vam->result_ready = 1;
6448 static void vl_api_sw_interface_get_table_reply_t_handler_json
6449 (vl_api_sw_interface_get_table_reply_t * mp)
6451 vat_main_t *vam = &vat_main;
6452 vat_json_node_t node;
6454 vat_json_init_object (&node);
6455 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6456 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6458 vat_json_print (vam->ofp, &node);
6459 vat_json_free (&node);
6461 vam->retval = ntohl (mp->retval);
6462 vam->result_ready = 1;
6466 api_sw_interface_get_table (vat_main_t * vam)
6468 unformat_input_t *i = vam->input;
6469 vl_api_sw_interface_get_table_t *mp;
6471 u8 sw_if_index_set = 0;
6475 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6478 sw_if_index_set = 1;
6479 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6480 sw_if_index_set = 1;
6481 else if (unformat (i, "ipv6"))
6487 if (sw_if_index_set == 0)
6489 errmsg ("missing interface name or sw_if_index");
6493 M (SW_INTERFACE_GET_TABLE, mp);
6494 mp->sw_if_index = htonl (sw_if_index);
6495 mp->is_ipv6 = is_ipv6;
6503 api_sw_interface_set_vpath (vat_main_t * vam)
6505 unformat_input_t *i = vam->input;
6506 vl_api_sw_interface_set_vpath_t *mp;
6507 u32 sw_if_index = 0;
6508 u8 sw_if_index_set = 0;
6512 /* Parse args required to build the message */
6513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6515 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6516 sw_if_index_set = 1;
6517 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6518 sw_if_index_set = 1;
6519 else if (unformat (i, "enable"))
6521 else if (unformat (i, "disable"))
6527 if (sw_if_index_set == 0)
6529 errmsg ("missing interface name or sw_if_index");
6533 /* Construct the API message */
6534 M (SW_INTERFACE_SET_VPATH, mp);
6536 mp->sw_if_index = ntohl (sw_if_index);
6537 mp->enable = is_enable;
6542 /* Wait for a reply... */
6548 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6550 unformat_input_t *i = vam->input;
6551 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6552 u32 sw_if_index = 0;
6553 u8 sw_if_index_set = 0;
6558 /* Parse args required to build the message */
6559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6562 sw_if_index_set = 1;
6563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6564 sw_if_index_set = 1;
6565 else if (unformat (i, "enable"))
6567 else if (unformat (i, "disable"))
6569 else if (unformat (i, "ip4"))
6571 else if (unformat (i, "ip6"))
6577 if (sw_if_index_set == 0)
6579 errmsg ("missing interface name or sw_if_index");
6583 /* Construct the API message */
6584 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6586 mp->sw_if_index = ntohl (sw_if_index);
6587 mp->enable = is_enable;
6588 mp->is_ipv6 = is_ipv6;
6593 /* Wait for a reply... */
6599 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6601 unformat_input_t *i = vam->input;
6602 vl_api_sw_interface_set_geneve_bypass_t *mp;
6603 u32 sw_if_index = 0;
6604 u8 sw_if_index_set = 0;
6609 /* Parse args required to build the message */
6610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6612 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6613 sw_if_index_set = 1;
6614 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6615 sw_if_index_set = 1;
6616 else if (unformat (i, "enable"))
6618 else if (unformat (i, "disable"))
6620 else if (unformat (i, "ip4"))
6622 else if (unformat (i, "ip6"))
6628 if (sw_if_index_set == 0)
6630 errmsg ("missing interface name or sw_if_index");
6634 /* Construct the API message */
6635 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6637 mp->sw_if_index = ntohl (sw_if_index);
6638 mp->enable = is_enable;
6639 mp->is_ipv6 = is_ipv6;
6644 /* Wait for a reply... */
6650 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6652 unformat_input_t *i = vam->input;
6653 vl_api_sw_interface_set_l2_xconnect_t *mp;
6655 u8 rx_sw_if_index_set = 0;
6657 u8 tx_sw_if_index_set = 0;
6661 /* Parse args required to build the message */
6662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6664 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6665 rx_sw_if_index_set = 1;
6666 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6667 tx_sw_if_index_set = 1;
6668 else if (unformat (i, "rx"))
6670 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6672 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6674 rx_sw_if_index_set = 1;
6679 else if (unformat (i, "tx"))
6681 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6683 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6685 tx_sw_if_index_set = 1;
6690 else if (unformat (i, "enable"))
6692 else if (unformat (i, "disable"))
6698 if (rx_sw_if_index_set == 0)
6700 errmsg ("missing rx interface name or rx_sw_if_index");
6704 if (enable && (tx_sw_if_index_set == 0))
6706 errmsg ("missing tx interface name or tx_sw_if_index");
6710 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6712 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6713 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6714 mp->enable = enable;
6722 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6724 unformat_input_t *i = vam->input;
6725 vl_api_sw_interface_set_l2_bridge_t *mp;
6727 u8 rx_sw_if_index_set = 0;
6735 /* Parse args required to build the message */
6736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6738 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6739 rx_sw_if_index_set = 1;
6740 else if (unformat (i, "bd_id %d", &bd_id))
6744 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6745 rx_sw_if_index_set = 1;
6746 else if (unformat (i, "shg %d", &shg))
6748 else if (unformat (i, "bvi"))
6750 else if (unformat (i, "enable"))
6752 else if (unformat (i, "disable"))
6758 if (rx_sw_if_index_set == 0)
6760 errmsg ("missing rx interface name or sw_if_index");
6764 if (enable && (bd_id_set == 0))
6766 errmsg ("missing bridge domain");
6770 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6772 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6773 mp->bd_id = ntohl (bd_id);
6776 mp->enable = enable;
6784 api_bridge_domain_dump (vat_main_t * vam)
6786 unformat_input_t *i = vam->input;
6787 vl_api_bridge_domain_dump_t *mp;
6788 vl_api_control_ping_t *mp_ping;
6792 /* Parse args required to build the message */
6793 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6795 if (unformat (i, "bd_id %d", &bd_id))
6801 M (BRIDGE_DOMAIN_DUMP, mp);
6802 mp->bd_id = ntohl (bd_id);
6805 /* Use a control ping for synchronization */
6806 MPING (CONTROL_PING, mp_ping);
6814 api_bridge_domain_add_del (vat_main_t * vam)
6816 unformat_input_t *i = vam->input;
6817 vl_api_bridge_domain_add_del_t *mp;
6820 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6825 /* Parse args required to build the message */
6826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6828 if (unformat (i, "bd_id %d", &bd_id))
6830 else if (unformat (i, "flood %d", &flood))
6832 else if (unformat (i, "uu-flood %d", &uu_flood))
6834 else if (unformat (i, "forward %d", &forward))
6836 else if (unformat (i, "learn %d", &learn))
6838 else if (unformat (i, "arp-term %d", &arp_term))
6840 else if (unformat (i, "mac-age %d", &mac_age))
6842 else if (unformat (i, "bd-tag %s", &bd_tag))
6844 else if (unformat (i, "del"))
6847 flood = uu_flood = forward = learn = 0;
6855 errmsg ("missing bridge domain");
6862 errmsg ("mac age must be less than 256 ");
6867 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6869 errmsg ("bd-tag cannot be longer than 63");
6874 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6876 mp->bd_id = ntohl (bd_id);
6878 mp->uu_flood = uu_flood;
6879 mp->forward = forward;
6881 mp->arp_term = arp_term;
6882 mp->is_add = is_add;
6883 mp->mac_age = (u8) mac_age;
6885 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6896 api_l2fib_flush_bd (vat_main_t * vam)
6898 unformat_input_t *i = vam->input;
6899 vl_api_l2fib_flush_bd_t *mp;
6903 /* Parse args required to build the message */
6904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6906 if (unformat (i, "bd_id %d", &bd_id));
6913 errmsg ("missing bridge domain");
6917 M (L2FIB_FLUSH_BD, mp);
6919 mp->bd_id = htonl (bd_id);
6927 api_l2fib_flush_int (vat_main_t * vam)
6929 unformat_input_t *i = vam->input;
6930 vl_api_l2fib_flush_int_t *mp;
6931 u32 sw_if_index = ~0;
6934 /* Parse args required to build the message */
6935 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6937 if (unformat (i, "sw_if_index %d", &sw_if_index));
6939 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6944 if (sw_if_index == ~0)
6946 errmsg ("missing interface name or sw_if_index");
6950 M (L2FIB_FLUSH_INT, mp);
6952 mp->sw_if_index = ntohl (sw_if_index);
6960 api_l2fib_add_del (vat_main_t * vam)
6962 unformat_input_t *i = vam->input;
6963 vl_api_l2fib_add_del_t *mp;
6969 u32 sw_if_index = ~0;
6970 u8 sw_if_index_set = 0;
6979 /* Parse args required to build the message */
6980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6982 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6984 else if (unformat (i, "bd_id %d", &bd_id))
6986 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6987 sw_if_index_set = 1;
6988 else if (unformat (i, "sw_if"))
6990 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6993 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6994 sw_if_index_set = 1;
6999 else if (unformat (i, "static"))
7001 else if (unformat (i, "filter"))
7006 else if (unformat (i, "bvi"))
7011 else if (unformat (i, "del"))
7013 else if (unformat (i, "count %d", &count))
7021 errmsg ("missing mac address");
7027 errmsg ("missing bridge domain");
7031 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7033 errmsg ("missing interface name or sw_if_index");
7039 /* Turn on async mode */
7040 vam->async_mode = 1;
7041 vam->async_errors = 0;
7042 before = vat_time_now (vam);
7045 for (j = 0; j < count; j++)
7047 M (L2FIB_ADD_DEL, mp);
7050 mp->bd_id = ntohl (bd_id);
7051 mp->is_add = is_add;
7055 mp->sw_if_index = ntohl (sw_if_index);
7056 mp->static_mac = static_mac;
7057 mp->filter_mac = filter_mac;
7058 mp->bvi_mac = bvi_mac;
7060 increment_mac_address (&mac);
7067 vl_api_control_ping_t *mp_ping;
7070 /* Shut off async mode */
7071 vam->async_mode = 0;
7073 MPING (CONTROL_PING, mp_ping);
7076 timeout = vat_time_now (vam) + 1.0;
7077 while (vat_time_now (vam) < timeout)
7078 if (vam->result_ready == 1)
7083 if (vam->retval == -99)
7086 if (vam->async_errors > 0)
7088 errmsg ("%d asynchronous errors", vam->async_errors);
7091 vam->async_errors = 0;
7092 after = vat_time_now (vam);
7094 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7095 count, after - before, count / (after - before));
7101 /* Wait for a reply... */
7105 /* Return the good/bad news */
7106 return (vam->retval);
7110 api_bridge_domain_set_mac_age (vat_main_t * vam)
7112 unformat_input_t *i = vam->input;
7113 vl_api_bridge_domain_set_mac_age_t *mp;
7118 /* Parse args required to build the message */
7119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7121 if (unformat (i, "bd_id %d", &bd_id));
7122 else if (unformat (i, "mac-age %d", &mac_age));
7129 errmsg ("missing bridge domain");
7135 errmsg ("mac age must be less than 256 ");
7139 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7141 mp->bd_id = htonl (bd_id);
7142 mp->mac_age = (u8) mac_age;
7150 api_l2_flags (vat_main_t * vam)
7152 unformat_input_t *i = vam->input;
7153 vl_api_l2_flags_t *mp;
7156 u8 sw_if_index_set = 0;
7160 /* Parse args required to build the message */
7161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7163 if (unformat (i, "sw_if_index %d", &sw_if_index))
7164 sw_if_index_set = 1;
7165 else if (unformat (i, "sw_if"))
7167 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7170 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7171 sw_if_index_set = 1;
7176 else if (unformat (i, "learn"))
7178 else if (unformat (i, "forward"))
7180 else if (unformat (i, "flood"))
7182 else if (unformat (i, "uu-flood"))
7183 flags |= L2_UU_FLOOD;
7184 else if (unformat (i, "arp-term"))
7185 flags |= L2_ARP_TERM;
7186 else if (unformat (i, "off"))
7188 else if (unformat (i, "disable"))
7194 if (sw_if_index_set == 0)
7196 errmsg ("missing interface name or sw_if_index");
7202 mp->sw_if_index = ntohl (sw_if_index);
7203 mp->feature_bitmap = ntohl (flags);
7204 mp->is_set = is_set;
7212 api_bridge_flags (vat_main_t * vam)
7214 unformat_input_t *i = vam->input;
7215 vl_api_bridge_flags_t *mp;
7222 /* Parse args required to build the message */
7223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7225 if (unformat (i, "bd_id %d", &bd_id))
7227 else if (unformat (i, "learn"))
7229 else if (unformat (i, "forward"))
7231 else if (unformat (i, "flood"))
7233 else if (unformat (i, "uu-flood"))
7234 flags |= L2_UU_FLOOD;
7235 else if (unformat (i, "arp-term"))
7236 flags |= L2_ARP_TERM;
7237 else if (unformat (i, "off"))
7239 else if (unformat (i, "disable"))
7247 errmsg ("missing bridge domain");
7251 M (BRIDGE_FLAGS, mp);
7253 mp->bd_id = ntohl (bd_id);
7254 mp->feature_bitmap = ntohl (flags);
7255 mp->is_set = is_set;
7263 api_bd_ip_mac_add_del (vat_main_t * vam)
7265 unformat_input_t *i = vam->input;
7266 vl_api_bd_ip_mac_add_del_t *mp;
7273 ip4_address_t v4addr;
7274 ip6_address_t v6addr;
7279 /* Parse args required to build the message */
7280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7282 if (unformat (i, "bd_id %d", &bd_id))
7286 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
7290 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
7295 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
7299 else if (unformat (i, "del"))
7307 errmsg ("missing bridge domain");
7310 else if (ip_set == 0)
7312 errmsg ("missing IP address");
7315 else if (mac_set == 0)
7317 errmsg ("missing MAC address");
7321 M (BD_IP_MAC_ADD_DEL, mp);
7323 mp->bd_id = ntohl (bd_id);
7324 mp->is_ipv6 = is_ipv6;
7325 mp->is_add = is_add;
7327 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
7329 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
7330 clib_memcpy (mp->mac_address, macaddr, 6);
7337 api_tap_connect (vat_main_t * vam)
7339 unformat_input_t *i = vam->input;
7340 vl_api_tap_connect_t *mp;
7346 ip4_address_t ip4_address;
7348 int ip4_address_set = 0;
7349 ip6_address_t ip6_address;
7351 int ip6_address_set = 0;
7354 memset (mac_address, 0, sizeof (mac_address));
7356 /* Parse args required to build the message */
7357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7359 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7363 else if (unformat (i, "random-mac"))
7365 else if (unformat (i, "tapname %s", &tap_name))
7367 else if (unformat (i, "tag %s", &tag))
7369 else if (unformat (i, "address %U/%d",
7370 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7371 ip4_address_set = 1;
7372 else if (unformat (i, "address %U/%d",
7373 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7374 ip6_address_set = 1;
7381 errmsg ("missing tap name");
7384 if (vec_len (tap_name) > 63)
7386 errmsg ("tap name too long");
7389 vec_add1 (tap_name, 0);
7391 if (vec_len (tag) > 63)
7393 errmsg ("tag too long");
7397 /* Construct the API message */
7398 M (TAP_CONNECT, mp);
7400 mp->use_random_mac = random_mac;
7401 clib_memcpy (mp->mac_address, mac_address, 6);
7402 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7404 clib_memcpy (mp->tag, tag, vec_len (tag));
7406 if (ip4_address_set)
7408 mp->ip4_address_set = 1;
7409 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7410 mp->ip4_mask_width = ip4_mask_width;
7412 if (ip6_address_set)
7414 mp->ip6_address_set = 1;
7415 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7416 mp->ip6_mask_width = ip6_mask_width;
7419 vec_free (tap_name);
7425 /* Wait for a reply... */
7431 api_tap_modify (vat_main_t * vam)
7433 unformat_input_t *i = vam->input;
7434 vl_api_tap_modify_t *mp;
7439 u32 sw_if_index = ~0;
7440 u8 sw_if_index_set = 0;
7443 memset (mac_address, 0, sizeof (mac_address));
7445 /* Parse args required to build the message */
7446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7448 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7449 sw_if_index_set = 1;
7450 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7451 sw_if_index_set = 1;
7452 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7456 else if (unformat (i, "random-mac"))
7458 else if (unformat (i, "tapname %s", &tap_name))
7464 if (sw_if_index_set == 0)
7466 errmsg ("missing vpp interface name");
7471 errmsg ("missing tap name");
7474 if (vec_len (tap_name) > 63)
7476 errmsg ("tap name too long");
7478 vec_add1 (tap_name, 0);
7480 /* Construct the API message */
7483 mp->use_random_mac = random_mac;
7484 mp->sw_if_index = ntohl (sw_if_index);
7485 clib_memcpy (mp->mac_address, mac_address, 6);
7486 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7487 vec_free (tap_name);
7492 /* Wait for a reply... */
7498 api_tap_delete (vat_main_t * vam)
7500 unformat_input_t *i = vam->input;
7501 vl_api_tap_delete_t *mp;
7502 u32 sw_if_index = ~0;
7503 u8 sw_if_index_set = 0;
7506 /* Parse args required to build the message */
7507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7510 sw_if_index_set = 1;
7511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7512 sw_if_index_set = 1;
7517 if (sw_if_index_set == 0)
7519 errmsg ("missing vpp interface name");
7523 /* Construct the API message */
7526 mp->sw_if_index = ntohl (sw_if_index);
7531 /* Wait for a reply... */
7537 api_ip_table_add_del (vat_main_t * vam)
7539 unformat_input_t *i = vam->input;
7540 vl_api_ip_table_add_del_t *mp;
7546 /* Parse args required to build the message */
7547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7549 if (unformat (i, "ipv6"))
7551 else if (unformat (i, "del"))
7553 else if (unformat (i, "add"))
7555 else if (unformat (i, "table %d", &table_id))
7559 clib_warning ("parse error '%U'", format_unformat_error, i);
7566 errmsg ("missing table-ID");
7570 /* Construct the API message */
7571 M (IP_TABLE_ADD_DEL, mp);
7573 mp->table_id = ntohl (table_id);
7574 mp->is_ipv6 = is_ipv6;
7575 mp->is_add = is_add;
7580 /* Wait for a reply... */
7587 api_ip_add_del_route (vat_main_t * vam)
7589 unformat_input_t *i = vam->input;
7590 vl_api_ip_add_del_route_t *mp;
7591 u32 sw_if_index = ~0, vrf_id = 0;
7593 u8 is_local = 0, is_drop = 0;
7594 u8 is_unreach = 0, is_prohibit = 0;
7595 u8 create_vrf_if_needed = 0;
7597 u32 next_hop_weight = 1;
7598 u8 is_multipath = 0;
7600 u8 address_length_set = 0;
7601 u32 next_hop_table_id = 0;
7602 u32 resolve_attempts = 0;
7603 u32 dst_address_length = 0;
7604 u8 next_hop_set = 0;
7605 ip4_address_t v4_dst_address, v4_next_hop_address;
7606 ip6_address_t v6_dst_address, v6_next_hop_address;
7610 u32 random_add_del = 0;
7611 u32 *random_vector = 0;
7613 u32 random_seed = 0xdeaddabe;
7614 u32 classify_table_index = ~0;
7616 u8 resolve_host = 0, resolve_attached = 0;
7617 mpls_label_t *next_hop_out_label_stack = NULL;
7618 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7619 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7621 /* Parse args required to build the message */
7622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7624 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7626 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7628 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7633 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7638 else if (unformat (i, "/%d", &dst_address_length))
7640 address_length_set = 1;
7643 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7644 &v4_next_hop_address))
7648 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7649 &v6_next_hop_address))
7653 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7655 else if (unformat (i, "weight %d", &next_hop_weight))
7657 else if (unformat (i, "drop"))
7661 else if (unformat (i, "null-send-unreach"))
7665 else if (unformat (i, "null-send-prohibit"))
7669 else if (unformat (i, "local"))
7673 else if (unformat (i, "classify %d", &classify_table_index))
7677 else if (unformat (i, "del"))
7679 else if (unformat (i, "add"))
7681 else if (unformat (i, "resolve-via-host"))
7683 else if (unformat (i, "resolve-via-attached"))
7684 resolve_attached = 1;
7685 else if (unformat (i, "multipath"))
7687 else if (unformat (i, "vrf %d", &vrf_id))
7689 else if (unformat (i, "create-vrf"))
7690 create_vrf_if_needed = 1;
7691 else if (unformat (i, "count %d", &count))
7693 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7695 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7697 else if (unformat (i, "out-label %d", &next_hop_out_label))
7698 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7699 else if (unformat (i, "via-label %d", &next_hop_via_label))
7701 else if (unformat (i, "random"))
7703 else if (unformat (i, "seed %d", &random_seed))
7707 clib_warning ("parse error '%U'", format_unformat_error, i);
7712 if (!next_hop_set && !is_drop && !is_local &&
7713 !is_classify && !is_unreach && !is_prohibit &&
7714 MPLS_LABEL_INVALID == next_hop_via_label)
7717 ("next hop / local / drop / unreach / prohibit / classify not set");
7721 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7723 errmsg ("next hop and next-hop via label set");
7726 if (address_set == 0)
7728 errmsg ("missing addresses");
7732 if (address_length_set == 0)
7734 errmsg ("missing address length");
7738 /* Generate a pile of unique, random routes */
7741 u32 this_random_address;
7742 random_hash = hash_create (count, sizeof (uword));
7744 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7745 for (j = 0; j <= count; j++)
7749 this_random_address = random_u32 (&random_seed);
7750 this_random_address =
7751 clib_host_to_net_u32 (this_random_address);
7753 while (hash_get (random_hash, this_random_address));
7754 vec_add1 (random_vector, this_random_address);
7755 hash_set (random_hash, this_random_address, 1);
7757 hash_free (random_hash);
7758 v4_dst_address.as_u32 = random_vector[0];
7763 /* Turn on async mode */
7764 vam->async_mode = 1;
7765 vam->async_errors = 0;
7766 before = vat_time_now (vam);
7769 for (j = 0; j < count; j++)
7771 /* Construct the API message */
7772 M2 (IP_ADD_DEL_ROUTE, mp,
7773 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7775 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7776 mp->table_id = ntohl (vrf_id);
7777 mp->create_vrf_if_needed = create_vrf_if_needed;
7779 mp->is_add = is_add;
7780 mp->is_drop = is_drop;
7781 mp->is_unreach = is_unreach;
7782 mp->is_prohibit = is_prohibit;
7783 mp->is_ipv6 = is_ipv6;
7784 mp->is_local = is_local;
7785 mp->is_classify = is_classify;
7786 mp->is_multipath = is_multipath;
7787 mp->is_resolve_host = resolve_host;
7788 mp->is_resolve_attached = resolve_attached;
7789 mp->next_hop_weight = next_hop_weight;
7790 mp->dst_address_length = dst_address_length;
7791 mp->next_hop_table_id = ntohl (next_hop_table_id);
7792 mp->classify_table_index = ntohl (classify_table_index);
7793 mp->next_hop_via_label = ntohl (next_hop_via_label);
7794 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7795 if (0 != mp->next_hop_n_out_labels)
7797 memcpy (mp->next_hop_out_label_stack,
7798 next_hop_out_label_stack,
7799 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7800 vec_free (next_hop_out_label_stack);
7805 clib_memcpy (mp->dst_address, &v6_dst_address,
7806 sizeof (v6_dst_address));
7808 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7809 sizeof (v6_next_hop_address));
7810 increment_v6_address (&v6_dst_address);
7814 clib_memcpy (mp->dst_address, &v4_dst_address,
7815 sizeof (v4_dst_address));
7817 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7818 sizeof (v4_next_hop_address));
7820 v4_dst_address.as_u32 = random_vector[j + 1];
7822 increment_v4_address (&v4_dst_address);
7826 /* If we receive SIGTERM, stop now... */
7831 /* When testing multiple add/del ops, use a control-ping to sync */
7834 vl_api_control_ping_t *mp_ping;
7838 /* Shut off async mode */
7839 vam->async_mode = 0;
7841 MPING (CONTROL_PING, mp_ping);
7844 timeout = vat_time_now (vam) + 1.0;
7845 while (vat_time_now (vam) < timeout)
7846 if (vam->result_ready == 1)
7851 if (vam->retval == -99)
7854 if (vam->async_errors > 0)
7856 errmsg ("%d asynchronous errors", vam->async_errors);
7859 vam->async_errors = 0;
7860 after = vat_time_now (vam);
7862 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7866 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7867 count, after - before, count / (after - before));
7873 /* Wait for a reply... */
7878 /* Return the good/bad news */
7879 return (vam->retval);
7883 api_ip_mroute_add_del (vat_main_t * vam)
7885 unformat_input_t *i = vam->input;
7886 vl_api_ip_mroute_add_del_t *mp;
7887 u32 sw_if_index = ~0, vrf_id = 0;
7890 u8 create_vrf_if_needed = 0;
7893 u32 grp_address_length = 0;
7894 ip4_address_t v4_grp_address, v4_src_address;
7895 ip6_address_t v6_grp_address, v6_src_address;
7896 mfib_itf_flags_t iflags = 0;
7897 mfib_entry_flags_t eflags = 0;
7900 /* Parse args required to build the message */
7901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7903 if (unformat (i, "sw_if_index %d", &sw_if_index))
7905 else if (unformat (i, "%U %U",
7906 unformat_ip4_address, &v4_src_address,
7907 unformat_ip4_address, &v4_grp_address))
7909 grp_address_length = 64;
7913 else if (unformat (i, "%U %U",
7914 unformat_ip6_address, &v6_src_address,
7915 unformat_ip6_address, &v6_grp_address))
7917 grp_address_length = 256;
7921 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7923 memset (&v4_src_address, 0, sizeof (v4_src_address));
7924 grp_address_length = 32;
7928 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7930 memset (&v6_src_address, 0, sizeof (v6_src_address));
7931 grp_address_length = 128;
7935 else if (unformat (i, "/%d", &grp_address_length))
7937 else if (unformat (i, "local"))
7941 else if (unformat (i, "del"))
7943 else if (unformat (i, "add"))
7945 else if (unformat (i, "vrf %d", &vrf_id))
7947 else if (unformat (i, "create-vrf"))
7948 create_vrf_if_needed = 1;
7949 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7951 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7955 clib_warning ("parse error '%U'", format_unformat_error, i);
7960 if (address_set == 0)
7962 errmsg ("missing addresses\n");
7966 /* Construct the API message */
7967 M (IP_MROUTE_ADD_DEL, mp);
7969 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7970 mp->table_id = ntohl (vrf_id);
7971 mp->create_vrf_if_needed = create_vrf_if_needed;
7973 mp->is_add = is_add;
7974 mp->is_ipv6 = is_ipv6;
7975 mp->is_local = is_local;
7976 mp->itf_flags = ntohl (iflags);
7977 mp->entry_flags = ntohl (eflags);
7978 mp->grp_address_length = grp_address_length;
7979 mp->grp_address_length = ntohs (mp->grp_address_length);
7983 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7984 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7988 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7989 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7995 /* Wait for a reply... */
8001 api_mpls_table_add_del (vat_main_t * vam)
8003 unformat_input_t *i = vam->input;
8004 vl_api_mpls_table_add_del_t *mp;
8009 /* Parse args required to build the message */
8010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8012 if (unformat (i, "table %d", &table_id))
8014 else if (unformat (i, "del"))
8016 else if (unformat (i, "add"))
8020 clib_warning ("parse error '%U'", format_unformat_error, i);
8027 errmsg ("missing table-ID");
8031 /* Construct the API message */
8032 M (MPLS_TABLE_ADD_DEL, mp);
8034 mp->mt_table_id = ntohl (table_id);
8035 mp->mt_is_add = is_add;
8040 /* Wait for a reply... */
8047 api_mpls_route_add_del (vat_main_t * vam)
8049 unformat_input_t *i = vam->input;
8050 vl_api_mpls_route_add_del_t *mp;
8051 u32 sw_if_index = ~0, table_id = 0;
8052 u8 create_table_if_needed = 0;
8054 u32 next_hop_weight = 1;
8055 u8 is_multipath = 0;
8056 u32 next_hop_table_id = 0;
8057 u8 next_hop_set = 0;
8058 ip4_address_t v4_next_hop_address = {
8061 ip6_address_t v6_next_hop_address = { {0} };
8065 u32 classify_table_index = ~0;
8067 u8 resolve_host = 0, resolve_attached = 0;
8068 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8069 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8070 mpls_label_t *next_hop_out_label_stack = NULL;
8071 mpls_label_t local_label = MPLS_LABEL_INVALID;
8073 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
8075 /* Parse args required to build the message */
8076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8082 else if (unformat (i, "%d", &local_label))
8084 else if (unformat (i, "eos"))
8086 else if (unformat (i, "non-eos"))
8088 else if (unformat (i, "via %U", unformat_ip4_address,
8089 &v4_next_hop_address))
8092 next_hop_proto = DPO_PROTO_IP4;
8094 else if (unformat (i, "via %U", unformat_ip6_address,
8095 &v6_next_hop_address))
8098 next_hop_proto = DPO_PROTO_IP6;
8100 else if (unformat (i, "weight %d", &next_hop_weight))
8102 else if (unformat (i, "create-table"))
8103 create_table_if_needed = 1;
8104 else if (unformat (i, "classify %d", &classify_table_index))
8108 else if (unformat (i, "del"))
8110 else if (unformat (i, "add"))
8112 else if (unformat (i, "resolve-via-host"))
8114 else if (unformat (i, "resolve-via-attached"))
8115 resolve_attached = 1;
8116 else if (unformat (i, "multipath"))
8118 else if (unformat (i, "count %d", &count))
8120 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
8123 next_hop_proto = DPO_PROTO_IP4;
8125 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
8128 next_hop_proto = DPO_PROTO_IP6;
8130 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8132 else if (unformat (i, "via-label %d", &next_hop_via_label))
8134 else if (unformat (i, "out-label %d", &next_hop_out_label))
8135 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
8138 clib_warning ("parse error '%U'", format_unformat_error, i);
8143 if (!next_hop_set && !is_classify)
8145 errmsg ("next hop / classify not set");
8149 if (MPLS_LABEL_INVALID == local_label)
8151 errmsg ("missing label");
8157 /* Turn on async mode */
8158 vam->async_mode = 1;
8159 vam->async_errors = 0;
8160 before = vat_time_now (vam);
8163 for (j = 0; j < count; j++)
8165 /* Construct the API message */
8166 M2 (MPLS_ROUTE_ADD_DEL, mp,
8167 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
8169 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8170 mp->mr_table_id = ntohl (table_id);
8171 mp->mr_create_table_if_needed = create_table_if_needed;
8173 mp->mr_is_add = is_add;
8174 mp->mr_next_hop_proto = next_hop_proto;
8175 mp->mr_is_classify = is_classify;
8176 mp->mr_is_multipath = is_multipath;
8177 mp->mr_is_resolve_host = resolve_host;
8178 mp->mr_is_resolve_attached = resolve_attached;
8179 mp->mr_next_hop_weight = next_hop_weight;
8180 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8181 mp->mr_classify_table_index = ntohl (classify_table_index);
8182 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8183 mp->mr_label = ntohl (local_label);
8184 mp->mr_eos = is_eos;
8186 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8187 if (0 != mp->mr_next_hop_n_out_labels)
8189 memcpy (mp->mr_next_hop_out_label_stack,
8190 next_hop_out_label_stack,
8191 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
8192 vec_free (next_hop_out_label_stack);
8197 if (DPO_PROTO_IP4 == next_hop_proto)
8199 clib_memcpy (mp->mr_next_hop,
8200 &v4_next_hop_address,
8201 sizeof (v4_next_hop_address));
8203 else if (DPO_PROTO_IP6 == next_hop_proto)
8206 clib_memcpy (mp->mr_next_hop,
8207 &v6_next_hop_address,
8208 sizeof (v6_next_hop_address));
8215 /* If we receive SIGTERM, stop now... */
8220 /* When testing multiple add/del ops, use a control-ping to sync */
8223 vl_api_control_ping_t *mp_ping;
8227 /* Shut off async mode */
8228 vam->async_mode = 0;
8230 MPING (CONTROL_PING, mp_ping);
8233 timeout = vat_time_now (vam) + 1.0;
8234 while (vat_time_now (vam) < timeout)
8235 if (vam->result_ready == 1)
8240 if (vam->retval == -99)
8243 if (vam->async_errors > 0)
8245 errmsg ("%d asynchronous errors", vam->async_errors);
8248 vam->async_errors = 0;
8249 after = vat_time_now (vam);
8251 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8255 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8256 count, after - before, count / (after - before));
8262 /* Wait for a reply... */
8267 /* Return the good/bad news */
8268 return (vam->retval);
8272 api_mpls_ip_bind_unbind (vat_main_t * vam)
8274 unformat_input_t *i = vam->input;
8275 vl_api_mpls_ip_bind_unbind_t *mp;
8276 u32 ip_table_id = 0;
8277 u8 create_table_if_needed = 0;
8280 ip4_address_t v4_address;
8281 ip6_address_t v6_address;
8284 mpls_label_t local_label = MPLS_LABEL_INVALID;
8287 /* Parse args required to build the message */
8288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8290 if (unformat (i, "%U/%d", unformat_ip4_address,
8291 &v4_address, &address_length))
8296 else if (unformat (i, "%U/%d", unformat_ip6_address,
8297 &v6_address, &address_length))
8302 else if (unformat (i, "%d", &local_label))
8304 else if (unformat (i, "create-table"))
8305 create_table_if_needed = 1;
8306 else if (unformat (i, "table-id %d", &ip_table_id))
8308 else if (unformat (i, "unbind"))
8310 else if (unformat (i, "bind"))
8314 clib_warning ("parse error '%U'", format_unformat_error, i);
8321 errmsg ("IP addres not set");
8325 if (MPLS_LABEL_INVALID == local_label)
8327 errmsg ("missing label");
8331 /* Construct the API message */
8332 M (MPLS_IP_BIND_UNBIND, mp);
8334 mp->mb_create_table_if_needed = create_table_if_needed;
8335 mp->mb_is_bind = is_bind;
8336 mp->mb_is_ip4 = is_ip4;
8337 mp->mb_ip_table_id = ntohl (ip_table_id);
8338 mp->mb_mpls_table_id = 0;
8339 mp->mb_label = ntohl (local_label);
8340 mp->mb_address_length = address_length;
8343 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8345 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8350 /* Wait for a reply... */
8356 api_proxy_arp_add_del (vat_main_t * vam)
8358 unformat_input_t *i = vam->input;
8359 vl_api_proxy_arp_add_del_t *mp;
8362 ip4_address_t lo, hi;
8366 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8368 if (unformat (i, "vrf %d", &vrf_id))
8370 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8371 unformat_ip4_address, &hi))
8373 else if (unformat (i, "del"))
8377 clib_warning ("parse error '%U'", format_unformat_error, i);
8384 errmsg ("address range not set");
8388 M (PROXY_ARP_ADD_DEL, mp);
8390 mp->vrf_id = ntohl (vrf_id);
8391 mp->is_add = is_add;
8392 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8393 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8401 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8403 unformat_input_t *i = vam->input;
8404 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8407 u8 sw_if_index_set = 0;
8410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8412 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8413 sw_if_index_set = 1;
8414 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8415 sw_if_index_set = 1;
8416 else if (unformat (i, "enable"))
8418 else if (unformat (i, "disable"))
8422 clib_warning ("parse error '%U'", format_unformat_error, i);
8427 if (sw_if_index_set == 0)
8429 errmsg ("missing interface name or sw_if_index");
8433 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8435 mp->sw_if_index = ntohl (sw_if_index);
8436 mp->enable_disable = enable;
8444 api_mpls_tunnel_add_del (vat_main_t * vam)
8446 unformat_input_t *i = vam->input;
8447 vl_api_mpls_tunnel_add_del_t *mp;
8451 u32 sw_if_index = ~0;
8452 u32 next_hop_sw_if_index = ~0;
8453 u32 next_hop_proto_is_ip4 = 1;
8455 u32 next_hop_table_id = 0;
8456 ip4_address_t v4_next_hop_address = {
8459 ip6_address_t v6_next_hop_address = { {0} };
8460 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8465 if (unformat (i, "add"))
8467 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8469 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8471 else if (unformat (i, "via %U",
8472 unformat_ip4_address, &v4_next_hop_address))
8474 next_hop_proto_is_ip4 = 1;
8476 else if (unformat (i, "via %U",
8477 unformat_ip6_address, &v6_next_hop_address))
8479 next_hop_proto_is_ip4 = 0;
8481 else if (unformat (i, "l2-only"))
8483 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8485 else if (unformat (i, "out-label %d", &next_hop_out_label))
8486 vec_add1 (labels, ntohl (next_hop_out_label));
8489 clib_warning ("parse error '%U'", format_unformat_error, i);
8494 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8496 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8497 mp->mt_sw_if_index = ntohl (sw_if_index);
8498 mp->mt_is_add = is_add;
8499 mp->mt_l2_only = l2_only;
8500 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8501 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8503 mp->mt_next_hop_n_out_labels = vec_len (labels);
8505 if (0 != mp->mt_next_hop_n_out_labels)
8507 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8508 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8512 if (next_hop_proto_is_ip4)
8514 clib_memcpy (mp->mt_next_hop,
8515 &v4_next_hop_address, sizeof (v4_next_hop_address));
8519 clib_memcpy (mp->mt_next_hop,
8520 &v6_next_hop_address, sizeof (v6_next_hop_address));
8529 api_sw_interface_set_unnumbered (vat_main_t * vam)
8531 unformat_input_t *i = vam->input;
8532 vl_api_sw_interface_set_unnumbered_t *mp;
8534 u32 unnum_sw_index = ~0;
8536 u8 sw_if_index_set = 0;
8539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8541 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8542 sw_if_index_set = 1;
8543 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8544 sw_if_index_set = 1;
8545 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8547 else if (unformat (i, "del"))
8551 clib_warning ("parse error '%U'", format_unformat_error, i);
8556 if (sw_if_index_set == 0)
8558 errmsg ("missing interface name or sw_if_index");
8562 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8564 mp->sw_if_index = ntohl (sw_if_index);
8565 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8566 mp->is_add = is_add;
8574 api_ip_neighbor_add_del (vat_main_t * vam)
8576 unformat_input_t *i = vam->input;
8577 vl_api_ip_neighbor_add_del_t *mp;
8579 u8 sw_if_index_set = 0;
8582 u8 is_no_fib_entry = 0;
8585 u8 v4_address_set = 0;
8586 u8 v6_address_set = 0;
8587 ip4_address_t v4address;
8588 ip6_address_t v6address;
8591 memset (mac_address, 0, sizeof (mac_address));
8593 /* Parse args required to build the message */
8594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8596 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8600 else if (unformat (i, "del"))
8603 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8604 sw_if_index_set = 1;
8605 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8606 sw_if_index_set = 1;
8607 else if (unformat (i, "is_static"))
8609 else if (unformat (i, "no-fib-entry"))
8610 is_no_fib_entry = 1;
8611 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8613 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8617 clib_warning ("parse error '%U'", format_unformat_error, i);
8622 if (sw_if_index_set == 0)
8624 errmsg ("missing interface name or sw_if_index");
8627 if (v4_address_set && v6_address_set)
8629 errmsg ("both v4 and v6 addresses set");
8632 if (!v4_address_set && !v6_address_set)
8634 errmsg ("no address set");
8638 /* Construct the API message */
8639 M (IP_NEIGHBOR_ADD_DEL, mp);
8641 mp->sw_if_index = ntohl (sw_if_index);
8642 mp->is_add = is_add;
8643 mp->is_static = is_static;
8644 mp->is_no_adj_fib = is_no_fib_entry;
8646 clib_memcpy (mp->mac_address, mac_address, 6);
8650 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8654 /* mp->is_ipv6 = 0; via memset in M macro above */
8655 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8661 /* Wait for a reply, return good/bad news */
8667 api_reset_vrf (vat_main_t * vam)
8669 unformat_input_t *i = vam->input;
8670 vl_api_reset_vrf_t *mp;
8676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8678 if (unformat (i, "vrf %d", &vrf_id))
8680 else if (unformat (i, "ipv6"))
8684 clib_warning ("parse error '%U'", format_unformat_error, i);
8689 if (vrf_id_set == 0)
8691 errmsg ("missing vrf id");
8697 mp->vrf_id = ntohl (vrf_id);
8698 mp->is_ipv6 = is_ipv6;
8706 api_create_vlan_subif (vat_main_t * vam)
8708 unformat_input_t *i = vam->input;
8709 vl_api_create_vlan_subif_t *mp;
8711 u8 sw_if_index_set = 0;
8716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8718 if (unformat (i, "sw_if_index %d", &sw_if_index))
8719 sw_if_index_set = 1;
8721 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8722 sw_if_index_set = 1;
8723 else if (unformat (i, "vlan %d", &vlan_id))
8727 clib_warning ("parse error '%U'", format_unformat_error, i);
8732 if (sw_if_index_set == 0)
8734 errmsg ("missing interface name or sw_if_index");
8738 if (vlan_id_set == 0)
8740 errmsg ("missing vlan_id");
8743 M (CREATE_VLAN_SUBIF, mp);
8745 mp->sw_if_index = ntohl (sw_if_index);
8746 mp->vlan_id = ntohl (vlan_id);
8753 #define foreach_create_subif_bit \
8760 _(outer_vlan_id_any) \
8761 _(inner_vlan_id_any)
8764 api_create_subif (vat_main_t * vam)
8766 unformat_input_t *i = vam->input;
8767 vl_api_create_subif_t *mp;
8769 u8 sw_if_index_set = 0;
8776 u32 exact_match = 0;
8777 u32 default_sub = 0;
8778 u32 outer_vlan_id_any = 0;
8779 u32 inner_vlan_id_any = 0;
8781 u16 outer_vlan_id = 0;
8782 u16 inner_vlan_id = 0;
8785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8787 if (unformat (i, "sw_if_index %d", &sw_if_index))
8788 sw_if_index_set = 1;
8790 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8791 sw_if_index_set = 1;
8792 else if (unformat (i, "sub_id %d", &sub_id))
8794 else if (unformat (i, "outer_vlan_id %d", &tmp))
8795 outer_vlan_id = tmp;
8796 else if (unformat (i, "inner_vlan_id %d", &tmp))
8797 inner_vlan_id = tmp;
8799 #define _(a) else if (unformat (i, #a)) a = 1 ;
8800 foreach_create_subif_bit
8804 clib_warning ("parse error '%U'", format_unformat_error, i);
8809 if (sw_if_index_set == 0)
8811 errmsg ("missing interface name or sw_if_index");
8815 if (sub_id_set == 0)
8817 errmsg ("missing sub_id");
8820 M (CREATE_SUBIF, mp);
8822 mp->sw_if_index = ntohl (sw_if_index);
8823 mp->sub_id = ntohl (sub_id);
8825 #define _(a) mp->a = a;
8826 foreach_create_subif_bit;
8829 mp->outer_vlan_id = ntohs (outer_vlan_id);
8830 mp->inner_vlan_id = ntohs (inner_vlan_id);
8838 api_oam_add_del (vat_main_t * vam)
8840 unformat_input_t *i = vam->input;
8841 vl_api_oam_add_del_t *mp;
8844 ip4_address_t src, dst;
8849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8851 if (unformat (i, "vrf %d", &vrf_id))
8853 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8855 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8857 else if (unformat (i, "del"))
8861 clib_warning ("parse error '%U'", format_unformat_error, i);
8868 errmsg ("missing src addr");
8874 errmsg ("missing dst addr");
8878 M (OAM_ADD_DEL, mp);
8880 mp->vrf_id = ntohl (vrf_id);
8881 mp->is_add = is_add;
8882 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8883 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8891 api_reset_fib (vat_main_t * vam)
8893 unformat_input_t *i = vam->input;
8894 vl_api_reset_fib_t *mp;
8900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8902 if (unformat (i, "vrf %d", &vrf_id))
8904 else if (unformat (i, "ipv6"))
8908 clib_warning ("parse error '%U'", format_unformat_error, i);
8913 if (vrf_id_set == 0)
8915 errmsg ("missing vrf id");
8921 mp->vrf_id = ntohl (vrf_id);
8922 mp->is_ipv6 = is_ipv6;
8930 api_dhcp_proxy_config (vat_main_t * vam)
8932 unformat_input_t *i = vam->input;
8933 vl_api_dhcp_proxy_config_t *mp;
8935 u32 server_vrf_id = 0;
8937 u8 v4_address_set = 0;
8938 u8 v6_address_set = 0;
8939 ip4_address_t v4address;
8940 ip6_address_t v6address;
8941 u8 v4_src_address_set = 0;
8942 u8 v6_src_address_set = 0;
8943 ip4_address_t v4srcaddress;
8944 ip6_address_t v6srcaddress;
8947 /* Parse args required to build the message */
8948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8950 if (unformat (i, "del"))
8952 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8954 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8956 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8958 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8960 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8961 v4_src_address_set = 1;
8962 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8963 v6_src_address_set = 1;
8968 if (v4_address_set && v6_address_set)
8970 errmsg ("both v4 and v6 server addresses set");
8973 if (!v4_address_set && !v6_address_set)
8975 errmsg ("no server addresses set");
8979 if (v4_src_address_set && v6_src_address_set)
8981 errmsg ("both v4 and v6 src addresses set");
8984 if (!v4_src_address_set && !v6_src_address_set)
8986 errmsg ("no src addresses set");
8990 if (!(v4_src_address_set && v4_address_set) &&
8991 !(v6_src_address_set && v6_address_set))
8993 errmsg ("no matching server and src addresses set");
8997 /* Construct the API message */
8998 M (DHCP_PROXY_CONFIG, mp);
9000 mp->is_add = is_add;
9001 mp->rx_vrf_id = ntohl (rx_vrf_id);
9002 mp->server_vrf_id = ntohl (server_vrf_id);
9006 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9007 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9011 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9012 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9018 /* Wait for a reply, return good/bad news */
9023 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9024 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9027 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9029 vat_main_t *vam = &vat_main;
9030 u32 i, count = mp->count;
9031 vl_api_dhcp_server_t *s;
9035 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9036 ntohl (mp->rx_vrf_id),
9037 format_ip6_address, mp->dhcp_src_address,
9038 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9041 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
9042 ntohl (mp->rx_vrf_id),
9043 format_ip4_address, mp->dhcp_src_address,
9044 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9046 for (i = 0; i < count; i++)
9048 s = &mp->servers[i];
9052 " Server Table-ID %d, Server Address %U",
9053 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9056 " Server Table-ID %d, Server Address %U",
9057 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9061 static void vl_api_dhcp_proxy_details_t_handler_json
9062 (vl_api_dhcp_proxy_details_t * mp)
9064 vat_main_t *vam = &vat_main;
9065 vat_json_node_t *node = NULL;
9066 u32 i, count = mp->count;
9068 struct in6_addr ip6;
9069 vl_api_dhcp_server_t *s;
9071 if (VAT_JSON_ARRAY != vam->json_tree.type)
9073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9074 vat_json_init_array (&vam->json_tree);
9076 node = vat_json_array_add (&vam->json_tree);
9078 vat_json_init_object (node);
9079 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9080 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9081 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9085 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9086 vat_json_object_add_ip6 (node, "src_address", ip6);
9090 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9091 vat_json_object_add_ip4 (node, "src_address", ip4);
9094 for (i = 0; i < count; i++)
9096 s = &mp->servers[i];
9098 vat_json_object_add_uint (node, "server-table-id",
9099 ntohl (s->server_vrf_id));
9103 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9104 vat_json_object_add_ip4 (node, "src_address", ip4);
9108 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9109 vat_json_object_add_ip6 (node, "server_address", ip6);
9115 api_dhcp_proxy_dump (vat_main_t * vam)
9117 unformat_input_t *i = vam->input;
9118 vl_api_control_ping_t *mp_ping;
9119 vl_api_dhcp_proxy_dump_t *mp;
9123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9125 if (unformat (i, "ipv6"))
9129 clib_warning ("parse error '%U'", format_unformat_error, i);
9134 M (DHCP_PROXY_DUMP, mp);
9136 mp->is_ip6 = is_ipv6;
9139 /* Use a control ping for synchronization */
9140 MPING (CONTROL_PING, mp_ping);
9148 api_dhcp_proxy_set_vss (vat_main_t * vam)
9150 unformat_input_t *i = vam->input;
9151 vl_api_dhcp_proxy_set_vss_t *mp;
9162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9164 if (unformat (i, "tbl_id %d", &tbl_id))
9166 if (unformat (i, "fib_id %d", &fib_id))
9168 if (unformat (i, "oui %d", &oui))
9170 else if (unformat (i, "ipv6"))
9172 else if (unformat (i, "del"))
9176 clib_warning ("parse error '%U'", format_unformat_error, i);
9181 if (tbl_id_set == 0)
9183 errmsg ("missing tbl id");
9187 if (fib_id_set == 0)
9189 errmsg ("missing fib id");
9194 errmsg ("missing oui");
9198 M (DHCP_PROXY_SET_VSS, mp);
9199 mp->tbl_id = ntohl (tbl_id);
9200 mp->fib_id = ntohl (fib_id);
9201 mp->oui = ntohl (oui);
9202 mp->is_ipv6 = is_ipv6;
9203 mp->is_add = is_add;
9211 api_dhcp_client_config (vat_main_t * vam)
9213 unformat_input_t *i = vam->input;
9214 vl_api_dhcp_client_config_t *mp;
9216 u8 sw_if_index_set = 0;
9219 u8 disable_event = 0;
9222 /* Parse args required to build the message */
9223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9225 if (unformat (i, "del"))
9228 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9229 sw_if_index_set = 1;
9230 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9231 sw_if_index_set = 1;
9232 else if (unformat (i, "hostname %s", &hostname))
9234 else if (unformat (i, "disable_event"))
9240 if (sw_if_index_set == 0)
9242 errmsg ("missing interface name or sw_if_index");
9246 if (vec_len (hostname) > 63)
9248 errmsg ("hostname too long");
9250 vec_add1 (hostname, 0);
9252 /* Construct the API message */
9253 M (DHCP_CLIENT_CONFIG, mp);
9255 mp->sw_if_index = htonl (sw_if_index);
9256 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
9257 vec_free (hostname);
9258 mp->is_add = is_add;
9259 mp->want_dhcp_event = disable_event ? 0 : 1;
9260 mp->pid = htonl (getpid ());
9265 /* Wait for a reply, return good/bad news */
9271 api_set_ip_flow_hash (vat_main_t * vam)
9273 unformat_input_t *i = vam->input;
9274 vl_api_set_ip_flow_hash_t *mp;
9286 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9288 if (unformat (i, "vrf %d", &vrf_id))
9290 else if (unformat (i, "ipv6"))
9292 else if (unformat (i, "src"))
9294 else if (unformat (i, "dst"))
9296 else if (unformat (i, "sport"))
9298 else if (unformat (i, "dport"))
9300 else if (unformat (i, "proto"))
9302 else if (unformat (i, "reverse"))
9307 clib_warning ("parse error '%U'", format_unformat_error, i);
9312 if (vrf_id_set == 0)
9314 errmsg ("missing vrf id");
9318 M (SET_IP_FLOW_HASH, mp);
9324 mp->reverse = reverse;
9325 mp->vrf_id = ntohl (vrf_id);
9326 mp->is_ipv6 = is_ipv6;
9334 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9336 unformat_input_t *i = vam->input;
9337 vl_api_sw_interface_ip6_enable_disable_t *mp;
9339 u8 sw_if_index_set = 0;
9343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9346 sw_if_index_set = 1;
9347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9348 sw_if_index_set = 1;
9349 else if (unformat (i, "enable"))
9351 else if (unformat (i, "disable"))
9355 clib_warning ("parse error '%U'", format_unformat_error, i);
9360 if (sw_if_index_set == 0)
9362 errmsg ("missing interface name or sw_if_index");
9366 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9368 mp->sw_if_index = ntohl (sw_if_index);
9369 mp->enable = enable;
9377 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9379 unformat_input_t *i = vam->input;
9380 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9382 u8 sw_if_index_set = 0;
9383 u8 v6_address_set = 0;
9384 ip6_address_t v6address;
9387 /* Parse args required to build the message */
9388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9390 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9391 sw_if_index_set = 1;
9392 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9393 sw_if_index_set = 1;
9394 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9400 if (sw_if_index_set == 0)
9402 errmsg ("missing interface name or sw_if_index");
9405 if (!v6_address_set)
9407 errmsg ("no address set");
9411 /* Construct the API message */
9412 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9414 mp->sw_if_index = ntohl (sw_if_index);
9415 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9420 /* Wait for a reply, return good/bad news */
9426 api_ip6nd_proxy_add_del (vat_main_t * vam)
9428 unformat_input_t *i = vam->input;
9429 vl_api_ip6nd_proxy_add_del_t *mp;
9430 u32 sw_if_index = ~0;
9431 u8 v6_address_set = 0;
9432 ip6_address_t v6address;
9436 /* Parse args required to build the message */
9437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9439 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9441 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9443 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9445 if (unformat (i, "del"))
9449 clib_warning ("parse error '%U'", format_unformat_error, i);
9454 if (sw_if_index == ~0)
9456 errmsg ("missing interface name or sw_if_index");
9459 if (!v6_address_set)
9461 errmsg ("no address set");
9465 /* Construct the API message */
9466 M (IP6ND_PROXY_ADD_DEL, mp);
9468 mp->is_del = is_del;
9469 mp->sw_if_index = ntohl (sw_if_index);
9470 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9475 /* Wait for a reply, return good/bad news */
9481 api_ip6nd_proxy_dump (vat_main_t * vam)
9483 vl_api_ip6nd_proxy_dump_t *mp;
9484 vl_api_control_ping_t *mp_ping;
9487 M (IP6ND_PROXY_DUMP, mp);
9491 /* Use a control ping for synchronization */
9492 MPING (CONTROL_PING, mp_ping);
9499 static void vl_api_ip6nd_proxy_details_t_handler
9500 (vl_api_ip6nd_proxy_details_t * mp)
9502 vat_main_t *vam = &vat_main;
9504 print (vam->ofp, "host %U sw_if_index %d",
9505 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9508 static void vl_api_ip6nd_proxy_details_t_handler_json
9509 (vl_api_ip6nd_proxy_details_t * mp)
9511 vat_main_t *vam = &vat_main;
9512 struct in6_addr ip6;
9513 vat_json_node_t *node = NULL;
9515 if (VAT_JSON_ARRAY != vam->json_tree.type)
9517 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9518 vat_json_init_array (&vam->json_tree);
9520 node = vat_json_array_add (&vam->json_tree);
9522 vat_json_init_object (node);
9523 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9525 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9526 vat_json_object_add_ip6 (node, "host", ip6);
9530 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9532 unformat_input_t *i = vam->input;
9533 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9535 u8 sw_if_index_set = 0;
9536 u32 address_length = 0;
9537 u8 v6_address_set = 0;
9538 ip6_address_t v6address;
9540 u8 no_advertise = 0;
9542 u8 no_autoconfig = 0;
9545 u32 val_lifetime = 0;
9546 u32 pref_lifetime = 0;
9549 /* Parse args required to build the message */
9550 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9552 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9553 sw_if_index_set = 1;
9554 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9555 sw_if_index_set = 1;
9556 else if (unformat (i, "%U/%d",
9557 unformat_ip6_address, &v6address, &address_length))
9559 else if (unformat (i, "val_life %d", &val_lifetime))
9561 else if (unformat (i, "pref_life %d", &pref_lifetime))
9563 else if (unformat (i, "def"))
9565 else if (unformat (i, "noadv"))
9567 else if (unformat (i, "offl"))
9569 else if (unformat (i, "noauto"))
9571 else if (unformat (i, "nolink"))
9573 else if (unformat (i, "isno"))
9577 clib_warning ("parse error '%U'", format_unformat_error, i);
9582 if (sw_if_index_set == 0)
9584 errmsg ("missing interface name or sw_if_index");
9587 if (!v6_address_set)
9589 errmsg ("no address set");
9593 /* Construct the API message */
9594 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9596 mp->sw_if_index = ntohl (sw_if_index);
9597 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9598 mp->address_length = address_length;
9599 mp->use_default = use_default;
9600 mp->no_advertise = no_advertise;
9601 mp->off_link = off_link;
9602 mp->no_autoconfig = no_autoconfig;
9603 mp->no_onlink = no_onlink;
9605 mp->val_lifetime = ntohl (val_lifetime);
9606 mp->pref_lifetime = ntohl (pref_lifetime);
9611 /* Wait for a reply, return good/bad news */
9617 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9619 unformat_input_t *i = vam->input;
9620 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9622 u8 sw_if_index_set = 0;
9627 u8 send_unicast = 0;
9630 u8 default_router = 0;
9631 u32 max_interval = 0;
9632 u32 min_interval = 0;
9634 u32 initial_count = 0;
9635 u32 initial_interval = 0;
9639 /* Parse args required to build the message */
9640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9642 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9643 sw_if_index_set = 1;
9644 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9645 sw_if_index_set = 1;
9646 else if (unformat (i, "maxint %d", &max_interval))
9648 else if (unformat (i, "minint %d", &min_interval))
9650 else if (unformat (i, "life %d", &lifetime))
9652 else if (unformat (i, "count %d", &initial_count))
9654 else if (unformat (i, "interval %d", &initial_interval))
9656 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9658 else if (unformat (i, "managed"))
9660 else if (unformat (i, "other"))
9662 else if (unformat (i, "ll"))
9664 else if (unformat (i, "send"))
9666 else if (unformat (i, "cease"))
9668 else if (unformat (i, "isno"))
9670 else if (unformat (i, "def"))
9674 clib_warning ("parse error '%U'", format_unformat_error, i);
9679 if (sw_if_index_set == 0)
9681 errmsg ("missing interface name or sw_if_index");
9685 /* Construct the API message */
9686 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9688 mp->sw_if_index = ntohl (sw_if_index);
9689 mp->max_interval = ntohl (max_interval);
9690 mp->min_interval = ntohl (min_interval);
9691 mp->lifetime = ntohl (lifetime);
9692 mp->initial_count = ntohl (initial_count);
9693 mp->initial_interval = ntohl (initial_interval);
9694 mp->suppress = suppress;
9695 mp->managed = managed;
9697 mp->ll_option = ll_option;
9698 mp->send_unicast = send_unicast;
9701 mp->default_router = default_router;
9706 /* Wait for a reply, return good/bad news */
9712 api_set_arp_neighbor_limit (vat_main_t * vam)
9714 unformat_input_t *i = vam->input;
9715 vl_api_set_arp_neighbor_limit_t *mp;
9721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9723 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9725 else if (unformat (i, "ipv6"))
9729 clib_warning ("parse error '%U'", format_unformat_error, i);
9736 errmsg ("missing limit value");
9740 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9742 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9743 mp->is_ipv6 = is_ipv6;
9751 api_l2_patch_add_del (vat_main_t * vam)
9753 unformat_input_t *i = vam->input;
9754 vl_api_l2_patch_add_del_t *mp;
9756 u8 rx_sw_if_index_set = 0;
9758 u8 tx_sw_if_index_set = 0;
9762 /* Parse args required to build the message */
9763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9765 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9766 rx_sw_if_index_set = 1;
9767 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9768 tx_sw_if_index_set = 1;
9769 else if (unformat (i, "rx"))
9771 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9773 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9775 rx_sw_if_index_set = 1;
9780 else if (unformat (i, "tx"))
9782 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9784 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9786 tx_sw_if_index_set = 1;
9791 else if (unformat (i, "del"))
9797 if (rx_sw_if_index_set == 0)
9799 errmsg ("missing rx interface name or rx_sw_if_index");
9803 if (tx_sw_if_index_set == 0)
9805 errmsg ("missing tx interface name or tx_sw_if_index");
9809 M (L2_PATCH_ADD_DEL, mp);
9811 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9812 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9813 mp->is_add = is_add;
9821 u8 localsid_addr[16];
9830 api_sr_localsid_add_del (vat_main_t * vam)
9832 unformat_input_t *i = vam->input;
9833 vl_api_sr_localsid_add_del_t *mp;
9836 ip6_address_t localsid;
9840 u32 fib_table = ~(u32) 0;
9841 ip6_address_t next_hop;
9843 bool nexthop_set = 0;
9847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9849 if (unformat (i, "del"))
9851 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9852 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9854 else if (unformat (i, "behavior %u", &behavior));
9855 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9856 else if (unformat (i, "fib-table %u", &fib_table));
9857 else if (unformat (i, "end.psp %u", &behavior));
9862 M (SR_LOCALSID_ADD_DEL, mp);
9864 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9866 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9867 mp->behavior = behavior;
9868 mp->sw_if_index = ntohl (sw_if_index);
9869 mp->fib_table = ntohl (fib_table);
9870 mp->end_psp = end_psp;
9871 mp->is_del = is_del;
9879 api_ioam_enable (vat_main_t * vam)
9881 unformat_input_t *input = vam->input;
9882 vl_api_ioam_enable_t *mp;
9884 int has_trace_option = 0;
9885 int has_pot_option = 0;
9886 int has_seqno_option = 0;
9887 int has_analyse_option = 0;
9890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9892 if (unformat (input, "trace"))
9893 has_trace_option = 1;
9894 else if (unformat (input, "pot"))
9896 else if (unformat (input, "seqno"))
9897 has_seqno_option = 1;
9898 else if (unformat (input, "analyse"))
9899 has_analyse_option = 1;
9903 M (IOAM_ENABLE, mp);
9904 mp->id = htons (id);
9905 mp->seqno = has_seqno_option;
9906 mp->analyse = has_analyse_option;
9907 mp->pot_enable = has_pot_option;
9908 mp->trace_enable = has_trace_option;
9917 api_ioam_disable (vat_main_t * vam)
9919 vl_api_ioam_disable_t *mp;
9922 M (IOAM_DISABLE, mp);
9928 #define foreach_tcp_proto_field \
9932 #define foreach_udp_proto_field \
9936 #define foreach_ip4_proto_field \
9948 u16 src_port, dst_port;
9951 #if VPP_API_TEST_BUILTIN == 0
9953 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9955 u8 **maskp = va_arg (*args, u8 **);
9957 u8 found_something = 0;
9960 #define _(a) u8 a=0;
9961 foreach_tcp_proto_field;
9964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9967 #define _(a) else if (unformat (input, #a)) a=1;
9968 foreach_tcp_proto_field
9974 #define _(a) found_something += a;
9975 foreach_tcp_proto_field;
9978 if (found_something == 0)
9981 vec_validate (mask, sizeof (*tcp) - 1);
9983 tcp = (tcp_header_t *) mask;
9985 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9986 foreach_tcp_proto_field;
9994 unformat_udp_mask (unformat_input_t * input, va_list * args)
9996 u8 **maskp = va_arg (*args, u8 **);
9998 u8 found_something = 0;
10001 #define _(a) u8 a=0;
10002 foreach_udp_proto_field;
10005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10008 #define _(a) else if (unformat (input, #a)) a=1;
10009 foreach_udp_proto_field
10015 #define _(a) found_something += a;
10016 foreach_udp_proto_field;
10019 if (found_something == 0)
10022 vec_validate (mask, sizeof (*udp) - 1);
10024 udp = (udp_header_t *) mask;
10026 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
10027 foreach_udp_proto_field;
10035 unformat_l4_mask (unformat_input_t * input, va_list * args)
10037 u8 **maskp = va_arg (*args, u8 **);
10038 u16 src_port = 0, dst_port = 0;
10039 tcpudp_header_t *tcpudp;
10041 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10043 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10045 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10047 else if (unformat (input, "src_port"))
10049 else if (unformat (input, "dst_port"))
10055 if (!src_port && !dst_port)
10059 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10061 tcpudp = (tcpudp_header_t *) mask;
10062 tcpudp->src_port = src_port;
10063 tcpudp->dst_port = dst_port;
10071 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10073 u8 **maskp = va_arg (*args, u8 **);
10075 u8 found_something = 0;
10078 #define _(a) u8 a=0;
10079 foreach_ip4_proto_field;
10085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10087 if (unformat (input, "version"))
10089 else if (unformat (input, "hdr_length"))
10091 else if (unformat (input, "src"))
10093 else if (unformat (input, "dst"))
10095 else if (unformat (input, "proto"))
10098 #define _(a) else if (unformat (input, #a)) a=1;
10099 foreach_ip4_proto_field
10105 #define _(a) found_something += a;
10106 foreach_ip4_proto_field;
10109 if (found_something == 0)
10112 vec_validate (mask, sizeof (*ip) - 1);
10114 ip = (ip4_header_t *) mask;
10116 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10117 foreach_ip4_proto_field;
10120 ip->ip_version_and_header_length = 0;
10123 ip->ip_version_and_header_length |= 0xF0;
10126 ip->ip_version_and_header_length |= 0x0F;
10132 #define foreach_ip6_proto_field \
10135 _(payload_length) \
10140 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10142 u8 **maskp = va_arg (*args, u8 **);
10144 u8 found_something = 0;
10146 u32 ip_version_traffic_class_and_flow_label;
10148 #define _(a) u8 a=0;
10149 foreach_ip6_proto_field;
10152 u8 traffic_class = 0;
10155 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10157 if (unformat (input, "version"))
10159 else if (unformat (input, "traffic-class"))
10161 else if (unformat (input, "flow-label"))
10163 else if (unformat (input, "src"))
10165 else if (unformat (input, "dst"))
10167 else if (unformat (input, "proto"))
10170 #define _(a) else if (unformat (input, #a)) a=1;
10171 foreach_ip6_proto_field
10177 #define _(a) found_something += a;
10178 foreach_ip6_proto_field;
10181 if (found_something == 0)
10184 vec_validate (mask, sizeof (*ip) - 1);
10186 ip = (ip6_header_t *) mask;
10188 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
10189 foreach_ip6_proto_field;
10192 ip_version_traffic_class_and_flow_label = 0;
10195 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10198 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10201 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10203 ip->ip_version_traffic_class_and_flow_label =
10204 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10211 unformat_l3_mask (unformat_input_t * input, va_list * args)
10213 u8 **maskp = va_arg (*args, u8 **);
10215 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10217 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10219 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10228 unformat_l2_mask (unformat_input_t * input, va_list * args)
10230 u8 **maskp = va_arg (*args, u8 **);
10237 u8 ignore_tag1 = 0;
10238 u8 ignore_tag2 = 0;
10245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10247 if (unformat (input, "src"))
10249 else if (unformat (input, "dst"))
10251 else if (unformat (input, "proto"))
10253 else if (unformat (input, "tag1"))
10255 else if (unformat (input, "tag2"))
10257 else if (unformat (input, "ignore-tag1"))
10259 else if (unformat (input, "ignore-tag2"))
10261 else if (unformat (input, "cos1"))
10263 else if (unformat (input, "cos2"))
10265 else if (unformat (input, "dot1q"))
10267 else if (unformat (input, "dot1ad"))
10272 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10273 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10276 if (tag1 || ignore_tag1 || cos1 || dot1q)
10278 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10281 vec_validate (mask, len - 1);
10284 memset (mask, 0xff, 6);
10287 memset (mask + 6, 0xff, 6);
10289 if (tag2 || dot1ad)
10291 /* inner vlan tag */
10300 mask[21] = mask[20] = 0xff;
10321 mask[16] = mask[17] = 0xff;
10331 mask[12] = mask[13] = 0xff;
10338 unformat_classify_mask (unformat_input_t * input, va_list * args)
10340 u8 **maskp = va_arg (*args, u8 **);
10341 u32 *skipp = va_arg (*args, u32 *);
10342 u32 *matchp = va_arg (*args, u32 *);
10350 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10352 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10354 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10356 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10358 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10372 if (mask || l2 || l3 || l4)
10374 if (l2 || l3 || l4)
10376 /* "With a free Ethernet header in every package" */
10378 vec_validate (l2, 13);
10382 vec_append (mask, l3);
10387 vec_append (mask, l4);
10392 /* Scan forward looking for the first significant mask octet */
10393 for (i = 0; i < vec_len (mask); i++)
10397 /* compute (skip, match) params */
10398 *skipp = i / sizeof (u32x4);
10399 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10401 /* Pad mask to an even multiple of the vector size */
10402 while (vec_len (mask) % sizeof (u32x4))
10403 vec_add1 (mask, 0);
10405 match = vec_len (mask) / sizeof (u32x4);
10407 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10409 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10410 if (*tmp || *(tmp + 1))
10415 clib_warning ("BUG: match 0");
10417 _vec_len (mask) = match * sizeof (u32x4);
10427 #endif /* VPP_API_TEST_BUILTIN */
10429 #define foreach_l2_next \
10431 _(ethernet, ETHERNET_INPUT) \
10432 _(ip4, IP4_INPUT) \
10436 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10438 u32 *miss_next_indexp = va_arg (*args, u32 *);
10439 u32 next_index = 0;
10443 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10447 if (unformat (input, "%d", &tmp))
10456 *miss_next_indexp = next_index;
10460 #define foreach_ip_next \
10463 _(rewrite, REWRITE)
10466 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10468 u32 *miss_next_indexp = va_arg (*args, u32 *);
10469 u32 next_index = 0;
10473 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10477 if (unformat (input, "%d", &tmp))
10486 *miss_next_indexp = next_index;
10490 #define foreach_acl_next \
10494 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10496 u32 *miss_next_indexp = va_arg (*args, u32 *);
10497 u32 next_index = 0;
10501 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10505 if (unformat (input, "permit"))
10510 else if (unformat (input, "%d", &tmp))
10519 *miss_next_indexp = next_index;
10524 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10526 u32 *r = va_arg (*args, u32 *);
10528 if (unformat (input, "conform-color"))
10529 *r = POLICE_CONFORM;
10530 else if (unformat (input, "exceed-color"))
10531 *r = POLICE_EXCEED;
10539 api_classify_add_del_table (vat_main_t * vam)
10541 unformat_input_t *i = vam->input;
10542 vl_api_classify_add_del_table_t *mp;
10549 u32 table_index = ~0;
10550 u32 next_table_index = ~0;
10551 u32 miss_next_index = ~0;
10552 u32 memory_size = 32 << 20;
10554 u32 current_data_flag = 0;
10555 int current_data_offset = 0;
10558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10560 if (unformat (i, "del"))
10562 else if (unformat (i, "del-chain"))
10567 else if (unformat (i, "buckets %d", &nbuckets))
10569 else if (unformat (i, "memory_size %d", &memory_size))
10571 else if (unformat (i, "skip %d", &skip))
10573 else if (unformat (i, "match %d", &match))
10575 else if (unformat (i, "table %d", &table_index))
10577 else if (unformat (i, "mask %U", unformat_classify_mask,
10578 &mask, &skip, &match))
10580 else if (unformat (i, "next-table %d", &next_table_index))
10582 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10585 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10588 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10591 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10593 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10599 if (is_add && mask == 0)
10601 errmsg ("Mask required");
10605 if (is_add && skip == ~0)
10607 errmsg ("skip count required");
10611 if (is_add && match == ~0)
10613 errmsg ("match count required");
10617 if (!is_add && table_index == ~0)
10619 errmsg ("table index required for delete");
10623 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10625 mp->is_add = is_add;
10626 mp->del_chain = del_chain;
10627 mp->table_index = ntohl (table_index);
10628 mp->nbuckets = ntohl (nbuckets);
10629 mp->memory_size = ntohl (memory_size);
10630 mp->skip_n_vectors = ntohl (skip);
10631 mp->match_n_vectors = ntohl (match);
10632 mp->next_table_index = ntohl (next_table_index);
10633 mp->miss_next_index = ntohl (miss_next_index);
10634 mp->current_data_flag = ntohl (current_data_flag);
10635 mp->current_data_offset = ntohl (current_data_offset);
10636 clib_memcpy (mp->mask, mask, vec_len (mask));
10645 #if VPP_API_TEST_BUILTIN == 0
10647 unformat_l4_match (unformat_input_t * input, va_list * args)
10649 u8 **matchp = va_arg (*args, u8 **);
10651 u8 *proto_header = 0;
10657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10659 if (unformat (input, "src_port %d", &src_port))
10661 else if (unformat (input, "dst_port %d", &dst_port))
10667 h.src_port = clib_host_to_net_u16 (src_port);
10668 h.dst_port = clib_host_to_net_u16 (dst_port);
10669 vec_validate (proto_header, sizeof (h) - 1);
10670 memcpy (proto_header, &h, sizeof (h));
10672 *matchp = proto_header;
10678 unformat_ip4_match (unformat_input_t * input, va_list * args)
10680 u8 **matchp = va_arg (*args, u8 **);
10685 int hdr_length = 0;
10686 u32 hdr_length_val;
10687 int src = 0, dst = 0;
10688 ip4_address_t src_val, dst_val;
10695 int fragment_id = 0;
10696 u32 fragment_id_val;
10702 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (input, "version %d", &version_val))
10706 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10708 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10710 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10712 else if (unformat (input, "proto %d", &proto_val))
10714 else if (unformat (input, "tos %d", &tos_val))
10716 else if (unformat (input, "length %d", &length_val))
10718 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10720 else if (unformat (input, "ttl %d", &ttl_val))
10722 else if (unformat (input, "checksum %d", &checksum_val))
10728 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10729 + ttl + checksum == 0)
10733 * Aligned because we use the real comparison functions
10735 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10737 ip = (ip4_header_t *) match;
10739 /* These are realistically matched in practice */
10741 ip->src_address.as_u32 = src_val.as_u32;
10744 ip->dst_address.as_u32 = dst_val.as_u32;
10747 ip->protocol = proto_val;
10750 /* These are not, but they're included for completeness */
10752 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10755 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10761 ip->length = clib_host_to_net_u16 (length_val);
10767 ip->checksum = clib_host_to_net_u16 (checksum_val);
10774 unformat_ip6_match (unformat_input_t * input, va_list * args)
10776 u8 **matchp = va_arg (*args, u8 **);
10781 u8 traffic_class = 0;
10782 u32 traffic_class_val = 0;
10785 int src = 0, dst = 0;
10786 ip6_address_t src_val, dst_val;
10789 int payload_length = 0;
10790 u32 payload_length_val;
10793 u32 ip_version_traffic_class_and_flow_label;
10795 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10797 if (unformat (input, "version %d", &version_val))
10799 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10801 else if (unformat (input, "flow_label %d", &flow_label_val))
10803 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10805 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10807 else if (unformat (input, "proto %d", &proto_val))
10809 else if (unformat (input, "payload_length %d", &payload_length_val))
10810 payload_length = 1;
10811 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10817 if (version + traffic_class + flow_label + src + dst + proto +
10818 payload_length + hop_limit == 0)
10822 * Aligned because we use the real comparison functions
10824 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10826 ip = (ip6_header_t *) match;
10829 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10832 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10835 ip->protocol = proto_val;
10837 ip_version_traffic_class_and_flow_label = 0;
10840 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10843 ip_version_traffic_class_and_flow_label |=
10844 (traffic_class_val & 0xFF) << 20;
10847 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10849 ip->ip_version_traffic_class_and_flow_label =
10850 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10852 if (payload_length)
10853 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10856 ip->hop_limit = hop_limit_val;
10863 unformat_l3_match (unformat_input_t * input, va_list * args)
10865 u8 **matchp = va_arg (*args, u8 **);
10867 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10869 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10871 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10880 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10882 u8 *tagp = va_arg (*args, u8 *);
10885 if (unformat (input, "%d", &tag))
10887 tagp[0] = (tag >> 8) & 0x0F;
10888 tagp[1] = tag & 0xFF;
10896 unformat_l2_match (unformat_input_t * input, va_list * args)
10898 u8 **matchp = va_arg (*args, u8 **);
10911 u8 ignore_tag1 = 0;
10912 u8 ignore_tag2 = 0;
10918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10920 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10923 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10925 else if (unformat (input, "proto %U",
10926 unformat_ethernet_type_host_byte_order, &proto_val))
10928 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10930 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10932 else if (unformat (input, "ignore-tag1"))
10934 else if (unformat (input, "ignore-tag2"))
10936 else if (unformat (input, "cos1 %d", &cos1_val))
10938 else if (unformat (input, "cos2 %d", &cos2_val))
10943 if ((src + dst + proto + tag1 + tag2 +
10944 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10947 if (tag1 || ignore_tag1 || cos1)
10949 if (tag2 || ignore_tag2 || cos2)
10952 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10955 clib_memcpy (match, dst_val, 6);
10958 clib_memcpy (match + 6, src_val, 6);
10962 /* inner vlan tag */
10963 match[19] = tag2_val[1];
10964 match[18] = tag2_val[0];
10966 match[18] |= (cos2_val & 0x7) << 5;
10969 match[21] = proto_val & 0xff;
10970 match[20] = proto_val >> 8;
10974 match[15] = tag1_val[1];
10975 match[14] = tag1_val[0];
10978 match[14] |= (cos1_val & 0x7) << 5;
10984 match[15] = tag1_val[1];
10985 match[14] = tag1_val[0];
10988 match[17] = proto_val & 0xff;
10989 match[16] = proto_val >> 8;
10992 match[14] |= (cos1_val & 0x7) << 5;
10998 match[18] |= (cos2_val & 0x7) << 5;
11000 match[14] |= (cos1_val & 0x7) << 5;
11003 match[13] = proto_val & 0xff;
11004 match[12] = proto_val >> 8;
11013 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11015 u8 **matchp = va_arg (*args, u8 **);
11016 u32 skip_n_vectors = va_arg (*args, u32);
11017 u32 match_n_vectors = va_arg (*args, u32);
11024 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11026 if (unformat (input, "hex %U", unformat_hex_string, &match))
11028 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11030 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11032 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11046 if (match || l2 || l3 || l4)
11048 if (l2 || l3 || l4)
11050 /* "Win a free Ethernet header in every packet" */
11052 vec_validate_aligned (l2, 13, sizeof (u32x4));
11056 vec_append_aligned (match, l3, sizeof (u32x4));
11061 vec_append_aligned (match, l4, sizeof (u32x4));
11066 /* Make sure the vector is big enough even if key is all 0's */
11067 vec_validate_aligned
11068 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11071 /* Set size, include skipped vectors */
11072 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11083 api_classify_add_del_session (vat_main_t * vam)
11085 unformat_input_t *i = vam->input;
11086 vl_api_classify_add_del_session_t *mp;
11088 u32 table_index = ~0;
11089 u32 hit_next_index = ~0;
11090 u32 opaque_index = ~0;
11093 u32 skip_n_vectors = 0;
11094 u32 match_n_vectors = 0;
11100 * Warning: you have to supply skip_n and match_n
11101 * because the API client cant simply look at the classify
11105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11107 if (unformat (i, "del"))
11109 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11112 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11115 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11118 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11120 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11122 else if (unformat (i, "opaque-index %d", &opaque_index))
11124 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11126 else if (unformat (i, "match_n %d", &match_n_vectors))
11128 else if (unformat (i, "match %U", api_unformat_classify_match,
11129 &match, skip_n_vectors, match_n_vectors))
11131 else if (unformat (i, "advance %d", &advance))
11133 else if (unformat (i, "table-index %d", &table_index))
11135 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11137 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11139 else if (unformat (i, "action %d", &action))
11141 else if (unformat (i, "metadata %d", &metadata))
11147 if (table_index == ~0)
11149 errmsg ("Table index required");
11153 if (is_add && match == 0)
11155 errmsg ("Match value required");
11159 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11161 mp->is_add = is_add;
11162 mp->table_index = ntohl (table_index);
11163 mp->hit_next_index = ntohl (hit_next_index);
11164 mp->opaque_index = ntohl (opaque_index);
11165 mp->advance = ntohl (advance);
11166 mp->action = action;
11167 mp->metadata = ntohl (metadata);
11168 clib_memcpy (mp->match, match, vec_len (match));
11177 api_classify_set_interface_ip_table (vat_main_t * vam)
11179 unformat_input_t *i = vam->input;
11180 vl_api_classify_set_interface_ip_table_t *mp;
11182 int sw_if_index_set;
11183 u32 table_index = ~0;
11187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11189 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11190 sw_if_index_set = 1;
11191 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "table %d", &table_index))
11197 clib_warning ("parse error '%U'", format_unformat_error, i);
11202 if (sw_if_index_set == 0)
11204 errmsg ("missing interface name or sw_if_index");
11209 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11211 mp->sw_if_index = ntohl (sw_if_index);
11212 mp->table_index = ntohl (table_index);
11213 mp->is_ipv6 = is_ipv6;
11221 api_classify_set_interface_l2_tables (vat_main_t * vam)
11223 unformat_input_t *i = vam->input;
11224 vl_api_classify_set_interface_l2_tables_t *mp;
11226 int sw_if_index_set;
11227 u32 ip4_table_index = ~0;
11228 u32 ip6_table_index = ~0;
11229 u32 other_table_index = ~0;
11233 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11235 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11236 sw_if_index_set = 1;
11237 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11238 sw_if_index_set = 1;
11239 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11241 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11243 else if (unformat (i, "other-table %d", &other_table_index))
11245 else if (unformat (i, "is-input %d", &is_input))
11249 clib_warning ("parse error '%U'", format_unformat_error, i);
11254 if (sw_if_index_set == 0)
11256 errmsg ("missing interface name or sw_if_index");
11261 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11263 mp->sw_if_index = ntohl (sw_if_index);
11264 mp->ip4_table_index = ntohl (ip4_table_index);
11265 mp->ip6_table_index = ntohl (ip6_table_index);
11266 mp->other_table_index = ntohl (other_table_index);
11267 mp->is_input = (u8) is_input;
11275 api_set_ipfix_exporter (vat_main_t * vam)
11277 unformat_input_t *i = vam->input;
11278 vl_api_set_ipfix_exporter_t *mp;
11279 ip4_address_t collector_address;
11280 u8 collector_address_set = 0;
11281 u32 collector_port = ~0;
11282 ip4_address_t src_address;
11283 u8 src_address_set = 0;
11286 u32 template_interval = ~0;
11287 u8 udp_checksum = 0;
11290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11292 if (unformat (i, "collector_address %U", unformat_ip4_address,
11293 &collector_address))
11294 collector_address_set = 1;
11295 else if (unformat (i, "collector_port %d", &collector_port))
11297 else if (unformat (i, "src_address %U", unformat_ip4_address,
11299 src_address_set = 1;
11300 else if (unformat (i, "vrf_id %d", &vrf_id))
11302 else if (unformat (i, "path_mtu %d", &path_mtu))
11304 else if (unformat (i, "template_interval %d", &template_interval))
11306 else if (unformat (i, "udp_checksum"))
11312 if (collector_address_set == 0)
11314 errmsg ("collector_address required");
11318 if (src_address_set == 0)
11320 errmsg ("src_address required");
11324 M (SET_IPFIX_EXPORTER, mp);
11326 memcpy (mp->collector_address, collector_address.data,
11327 sizeof (collector_address.data));
11328 mp->collector_port = htons ((u16) collector_port);
11329 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11330 mp->vrf_id = htonl (vrf_id);
11331 mp->path_mtu = htonl (path_mtu);
11332 mp->template_interval = htonl (template_interval);
11333 mp->udp_checksum = udp_checksum;
11341 api_set_ipfix_classify_stream (vat_main_t * vam)
11343 unformat_input_t *i = vam->input;
11344 vl_api_set_ipfix_classify_stream_t *mp;
11346 u32 src_port = UDP_DST_PORT_ipfix;
11349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11351 if (unformat (i, "domain %d", &domain_id))
11353 else if (unformat (i, "src_port %d", &src_port))
11357 errmsg ("unknown input `%U'", format_unformat_error, i);
11362 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11364 mp->domain_id = htonl (domain_id);
11365 mp->src_port = htons ((u16) src_port);
11373 api_ipfix_classify_table_add_del (vat_main_t * vam)
11375 unformat_input_t *i = vam->input;
11376 vl_api_ipfix_classify_table_add_del_t *mp;
11378 u32 classify_table_index = ~0;
11380 u8 transport_protocol = 255;
11383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11385 if (unformat (i, "add"))
11387 else if (unformat (i, "del"))
11389 else if (unformat (i, "table %d", &classify_table_index))
11391 else if (unformat (i, "ip4"))
11393 else if (unformat (i, "ip6"))
11395 else if (unformat (i, "tcp"))
11396 transport_protocol = 6;
11397 else if (unformat (i, "udp"))
11398 transport_protocol = 17;
11401 errmsg ("unknown input `%U'", format_unformat_error, i);
11408 errmsg ("expecting: add|del");
11411 if (classify_table_index == ~0)
11413 errmsg ("classifier table not specified");
11416 if (ip_version == 0)
11418 errmsg ("IP version not specified");
11422 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11424 mp->is_add = is_add;
11425 mp->table_id = htonl (classify_table_index);
11426 mp->ip_version = ip_version;
11427 mp->transport_protocol = transport_protocol;
11435 api_get_node_index (vat_main_t * vam)
11437 unformat_input_t *i = vam->input;
11438 vl_api_get_node_index_t *mp;
11442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11444 if (unformat (i, "node %s", &name))
11451 errmsg ("node name required");
11454 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11456 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11460 M (GET_NODE_INDEX, mp);
11461 clib_memcpy (mp->node_name, name, vec_len (name));
11470 api_get_next_index (vat_main_t * vam)
11472 unformat_input_t *i = vam->input;
11473 vl_api_get_next_index_t *mp;
11474 u8 *node_name = 0, *next_node_name = 0;
11477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11479 if (unformat (i, "node-name %s", &node_name))
11481 else if (unformat (i, "next-node-name %s", &next_node_name))
11485 if (node_name == 0)
11487 errmsg ("node name required");
11490 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11492 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11496 if (next_node_name == 0)
11498 errmsg ("next node name required");
11501 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11503 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11507 M (GET_NEXT_INDEX, mp);
11508 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11509 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11510 vec_free (node_name);
11511 vec_free (next_node_name);
11519 api_add_node_next (vat_main_t * vam)
11521 unformat_input_t *i = vam->input;
11522 vl_api_add_node_next_t *mp;
11527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11529 if (unformat (i, "node %s", &name))
11531 else if (unformat (i, "next %s", &next))
11538 errmsg ("node name required");
11541 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11543 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11548 errmsg ("next node required");
11551 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11553 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11557 M (ADD_NODE_NEXT, mp);
11558 clib_memcpy (mp->node_name, name, vec_len (name));
11559 clib_memcpy (mp->next_name, next, vec_len (next));
11569 api_l2tpv3_create_tunnel (vat_main_t * vam)
11571 unformat_input_t *i = vam->input;
11572 ip6_address_t client_address, our_address;
11573 int client_address_set = 0;
11574 int our_address_set = 0;
11575 u32 local_session_id = 0;
11576 u32 remote_session_id = 0;
11577 u64 local_cookie = 0;
11578 u64 remote_cookie = 0;
11579 u8 l2_sublayer_present = 0;
11580 vl_api_l2tpv3_create_tunnel_t *mp;
11583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11585 if (unformat (i, "client_address %U", unformat_ip6_address,
11587 client_address_set = 1;
11588 else if (unformat (i, "our_address %U", unformat_ip6_address,
11590 our_address_set = 1;
11591 else if (unformat (i, "local_session_id %d", &local_session_id))
11593 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11595 else if (unformat (i, "local_cookie %lld", &local_cookie))
11597 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11599 else if (unformat (i, "l2-sublayer-present"))
11600 l2_sublayer_present = 1;
11605 if (client_address_set == 0)
11607 errmsg ("client_address required");
11611 if (our_address_set == 0)
11613 errmsg ("our_address required");
11617 M (L2TPV3_CREATE_TUNNEL, mp);
11619 clib_memcpy (mp->client_address, client_address.as_u8,
11620 sizeof (mp->client_address));
11622 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11624 mp->local_session_id = ntohl (local_session_id);
11625 mp->remote_session_id = ntohl (remote_session_id);
11626 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11627 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11628 mp->l2_sublayer_present = l2_sublayer_present;
11637 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11639 unformat_input_t *i = vam->input;
11641 u8 sw_if_index_set = 0;
11642 u64 new_local_cookie = 0;
11643 u64 new_remote_cookie = 0;
11644 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11649 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11650 sw_if_index_set = 1;
11651 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11652 sw_if_index_set = 1;
11653 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11655 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11661 if (sw_if_index_set == 0)
11663 errmsg ("missing interface name or sw_if_index");
11667 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11669 mp->sw_if_index = ntohl (sw_if_index);
11670 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11671 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11679 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11681 unformat_input_t *i = vam->input;
11682 vl_api_l2tpv3_interface_enable_disable_t *mp;
11684 u8 sw_if_index_set = 0;
11685 u8 enable_disable = 1;
11688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11691 sw_if_index_set = 1;
11692 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11693 sw_if_index_set = 1;
11694 else if (unformat (i, "enable"))
11695 enable_disable = 1;
11696 else if (unformat (i, "disable"))
11697 enable_disable = 0;
11702 if (sw_if_index_set == 0)
11704 errmsg ("missing interface name or sw_if_index");
11708 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11710 mp->sw_if_index = ntohl (sw_if_index);
11711 mp->enable_disable = enable_disable;
11719 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11721 unformat_input_t *i = vam->input;
11722 vl_api_l2tpv3_set_lookup_key_t *mp;
11726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11728 if (unformat (i, "lookup_v6_src"))
11729 key = L2T_LOOKUP_SRC_ADDRESS;
11730 else if (unformat (i, "lookup_v6_dst"))
11731 key = L2T_LOOKUP_DST_ADDRESS;
11732 else if (unformat (i, "lookup_session_id"))
11733 key = L2T_LOOKUP_SESSION_ID;
11738 if (key == (u8) ~ 0)
11740 errmsg ("l2tp session lookup key unset");
11744 M (L2TPV3_SET_LOOKUP_KEY, mp);
11753 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11754 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11756 vat_main_t *vam = &vat_main;
11758 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11759 format_ip6_address, mp->our_address,
11760 format_ip6_address, mp->client_address,
11761 clib_net_to_host_u32 (mp->sw_if_index));
11764 " local cookies %016llx %016llx remote cookie %016llx",
11765 clib_net_to_host_u64 (mp->local_cookie[0]),
11766 clib_net_to_host_u64 (mp->local_cookie[1]),
11767 clib_net_to_host_u64 (mp->remote_cookie));
11769 print (vam->ofp, " local session-id %d remote session-id %d",
11770 clib_net_to_host_u32 (mp->local_session_id),
11771 clib_net_to_host_u32 (mp->remote_session_id));
11773 print (vam->ofp, " l2 specific sublayer %s\n",
11774 mp->l2_sublayer_present ? "preset" : "absent");
11778 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11779 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11781 vat_main_t *vam = &vat_main;
11782 vat_json_node_t *node = NULL;
11783 struct in6_addr addr;
11785 if (VAT_JSON_ARRAY != vam->json_tree.type)
11787 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11788 vat_json_init_array (&vam->json_tree);
11790 node = vat_json_array_add (&vam->json_tree);
11792 vat_json_init_object (node);
11794 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11795 vat_json_object_add_ip6 (node, "our_address", addr);
11796 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11797 vat_json_object_add_ip6 (node, "client_address", addr);
11799 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11800 vat_json_init_array (lc);
11801 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11802 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11803 vat_json_object_add_uint (node, "remote_cookie",
11804 clib_net_to_host_u64 (mp->remote_cookie));
11806 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11807 vat_json_object_add_uint (node, "local_session_id",
11808 clib_net_to_host_u32 (mp->local_session_id));
11809 vat_json_object_add_uint (node, "remote_session_id",
11810 clib_net_to_host_u32 (mp->remote_session_id));
11811 vat_json_object_add_string_copy (node, "l2_sublayer",
11812 mp->l2_sublayer_present ? (u8 *) "present"
11813 : (u8 *) "absent");
11817 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11819 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11820 vl_api_control_ping_t *mp_ping;
11823 /* Get list of l2tpv3-tunnel interfaces */
11824 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11827 /* Use a control ping for synchronization */
11828 MPING (CONTROL_PING, mp_ping);
11836 static void vl_api_sw_interface_tap_details_t_handler
11837 (vl_api_sw_interface_tap_details_t * mp)
11839 vat_main_t *vam = &vat_main;
11841 print (vam->ofp, "%-16s %d",
11842 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11845 static void vl_api_sw_interface_tap_details_t_handler_json
11846 (vl_api_sw_interface_tap_details_t * mp)
11848 vat_main_t *vam = &vat_main;
11849 vat_json_node_t *node = NULL;
11851 if (VAT_JSON_ARRAY != vam->json_tree.type)
11853 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11854 vat_json_init_array (&vam->json_tree);
11856 node = vat_json_array_add (&vam->json_tree);
11858 vat_json_init_object (node);
11859 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11860 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11864 api_sw_interface_tap_dump (vat_main_t * vam)
11866 vl_api_sw_interface_tap_dump_t *mp;
11867 vl_api_control_ping_t *mp_ping;
11870 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11871 /* Get list of tap interfaces */
11872 M (SW_INTERFACE_TAP_DUMP, mp);
11875 /* Use a control ping for synchronization */
11876 MPING (CONTROL_PING, mp_ping);
11883 static uword unformat_vxlan_decap_next
11884 (unformat_input_t * input, va_list * args)
11886 u32 *result = va_arg (*args, u32 *);
11889 if (unformat (input, "l2"))
11890 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11891 else if (unformat (input, "%d", &tmp))
11899 api_vxlan_add_del_tunnel (vat_main_t * vam)
11901 unformat_input_t *line_input = vam->input;
11902 vl_api_vxlan_add_del_tunnel_t *mp;
11903 ip46_address_t src, dst;
11905 u8 ipv4_set = 0, ipv6_set = 0;
11909 u32 mcast_sw_if_index = ~0;
11910 u32 encap_vrf_id = 0;
11911 u32 decap_next_index = ~0;
11915 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11916 memset (&src, 0, sizeof src);
11917 memset (&dst, 0, sizeof dst);
11919 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11921 if (unformat (line_input, "del"))
11924 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11930 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11936 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11942 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11947 else if (unformat (line_input, "group %U %U",
11948 unformat_ip4_address, &dst.ip4,
11949 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11951 grp_set = dst_set = 1;
11954 else if (unformat (line_input, "group %U",
11955 unformat_ip4_address, &dst.ip4))
11957 grp_set = dst_set = 1;
11960 else if (unformat (line_input, "group %U %U",
11961 unformat_ip6_address, &dst.ip6,
11962 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11964 grp_set = dst_set = 1;
11967 else if (unformat (line_input, "group %U",
11968 unformat_ip6_address, &dst.ip6))
11970 grp_set = dst_set = 1;
11974 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11976 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11978 else if (unformat (line_input, "decap-next %U",
11979 unformat_vxlan_decap_next, &decap_next_index))
11981 else if (unformat (line_input, "vni %d", &vni))
11985 errmsg ("parse error '%U'", format_unformat_error, line_input);
11992 errmsg ("tunnel src address not specified");
11997 errmsg ("tunnel dst address not specified");
12001 if (grp_set && !ip46_address_is_multicast (&dst))
12003 errmsg ("tunnel group address not multicast");
12006 if (grp_set && mcast_sw_if_index == ~0)
12008 errmsg ("tunnel nonexistent multicast device");
12011 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12013 errmsg ("tunnel dst address must be unicast");
12018 if (ipv4_set && ipv6_set)
12020 errmsg ("both IPv4 and IPv6 addresses specified");
12024 if ((vni == 0) || (vni >> 24))
12026 errmsg ("vni not specified or out of range");
12030 M (VXLAN_ADD_DEL_TUNNEL, mp);
12034 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12035 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12039 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12040 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12042 mp->encap_vrf_id = ntohl (encap_vrf_id);
12043 mp->decap_next_index = ntohl (decap_next_index);
12044 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12045 mp->vni = ntohl (vni);
12046 mp->is_add = is_add;
12047 mp->is_ipv6 = ipv6_set;
12054 static void vl_api_vxlan_tunnel_details_t_handler
12055 (vl_api_vxlan_tunnel_details_t * mp)
12057 vat_main_t *vam = &vat_main;
12058 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12059 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12061 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12062 ntohl (mp->sw_if_index),
12063 format_ip46_address, &src, IP46_TYPE_ANY,
12064 format_ip46_address, &dst, IP46_TYPE_ANY,
12065 ntohl (mp->encap_vrf_id),
12066 ntohl (mp->decap_next_index), ntohl (mp->vni),
12067 ntohl (mp->mcast_sw_if_index));
12070 static void vl_api_vxlan_tunnel_details_t_handler_json
12071 (vl_api_vxlan_tunnel_details_t * mp)
12073 vat_main_t *vam = &vat_main;
12074 vat_json_node_t *node = NULL;
12076 if (VAT_JSON_ARRAY != vam->json_tree.type)
12078 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12079 vat_json_init_array (&vam->json_tree);
12081 node = vat_json_array_add (&vam->json_tree);
12083 vat_json_init_object (node);
12084 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12087 struct in6_addr ip6;
12089 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12090 vat_json_object_add_ip6 (node, "src_address", ip6);
12091 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12092 vat_json_object_add_ip6 (node, "dst_address", ip6);
12096 struct in_addr ip4;
12098 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12099 vat_json_object_add_ip4 (node, "src_address", ip4);
12100 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12101 vat_json_object_add_ip4 (node, "dst_address", ip4);
12103 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12104 vat_json_object_add_uint (node, "decap_next_index",
12105 ntohl (mp->decap_next_index));
12106 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12107 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12108 vat_json_object_add_uint (node, "mcast_sw_if_index",
12109 ntohl (mp->mcast_sw_if_index));
12113 api_vxlan_tunnel_dump (vat_main_t * vam)
12115 unformat_input_t *i = vam->input;
12116 vl_api_vxlan_tunnel_dump_t *mp;
12117 vl_api_control_ping_t *mp_ping;
12119 u8 sw_if_index_set = 0;
12122 /* Parse args required to build the message */
12123 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12125 if (unformat (i, "sw_if_index %d", &sw_if_index))
12126 sw_if_index_set = 1;
12131 if (sw_if_index_set == 0)
12136 if (!vam->json_output)
12138 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12139 "sw_if_index", "src_address", "dst_address",
12140 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12143 /* Get list of vxlan-tunnel interfaces */
12144 M (VXLAN_TUNNEL_DUMP, mp);
12146 mp->sw_if_index = htonl (sw_if_index);
12150 /* Use a control ping for synchronization */
12151 MPING (CONTROL_PING, mp_ping);
12158 static uword unformat_geneve_decap_next
12159 (unformat_input_t * input, va_list * args)
12161 u32 *result = va_arg (*args, u32 *);
12164 if (unformat (input, "l2"))
12165 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12166 else if (unformat (input, "%d", &tmp))
12174 api_geneve_add_del_tunnel (vat_main_t * vam)
12176 unformat_input_t *line_input = vam->input;
12177 vl_api_geneve_add_del_tunnel_t *mp;
12178 ip46_address_t src, dst;
12180 u8 ipv4_set = 0, ipv6_set = 0;
12184 u32 mcast_sw_if_index = ~0;
12185 u32 encap_vrf_id = 0;
12186 u32 decap_next_index = ~0;
12190 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12191 memset (&src, 0, sizeof src);
12192 memset (&dst, 0, sizeof dst);
12194 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12196 if (unformat (line_input, "del"))
12199 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12205 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12211 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12217 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12222 else if (unformat (line_input, "group %U %U",
12223 unformat_ip4_address, &dst.ip4,
12224 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12226 grp_set = dst_set = 1;
12229 else if (unformat (line_input, "group %U",
12230 unformat_ip4_address, &dst.ip4))
12232 grp_set = dst_set = 1;
12235 else if (unformat (line_input, "group %U %U",
12236 unformat_ip6_address, &dst.ip6,
12237 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12239 grp_set = dst_set = 1;
12242 else if (unformat (line_input, "group %U",
12243 unformat_ip6_address, &dst.ip6))
12245 grp_set = dst_set = 1;
12249 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12251 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12253 else if (unformat (line_input, "decap-next %U",
12254 unformat_geneve_decap_next, &decap_next_index))
12256 else if (unformat (line_input, "vni %d", &vni))
12260 errmsg ("parse error '%U'", format_unformat_error, line_input);
12267 errmsg ("tunnel src address not specified");
12272 errmsg ("tunnel dst address not specified");
12276 if (grp_set && !ip46_address_is_multicast (&dst))
12278 errmsg ("tunnel group address not multicast");
12281 if (grp_set && mcast_sw_if_index == ~0)
12283 errmsg ("tunnel nonexistent multicast device");
12286 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12288 errmsg ("tunnel dst address must be unicast");
12293 if (ipv4_set && ipv6_set)
12295 errmsg ("both IPv4 and IPv6 addresses specified");
12299 if ((vni == 0) || (vni >> 24))
12301 errmsg ("vni not specified or out of range");
12305 M (GENEVE_ADD_DEL_TUNNEL, mp);
12309 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12310 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12314 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12315 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12317 mp->encap_vrf_id = ntohl (encap_vrf_id);
12318 mp->decap_next_index = ntohl (decap_next_index);
12319 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12320 mp->vni = ntohl (vni);
12321 mp->is_add = is_add;
12322 mp->is_ipv6 = ipv6_set;
12329 static void vl_api_geneve_tunnel_details_t_handler
12330 (vl_api_geneve_tunnel_details_t * mp)
12332 vat_main_t *vam = &vat_main;
12333 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12334 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12336 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12337 ntohl (mp->sw_if_index),
12338 format_ip46_address, &src, IP46_TYPE_ANY,
12339 format_ip46_address, &dst, IP46_TYPE_ANY,
12340 ntohl (mp->encap_vrf_id),
12341 ntohl (mp->decap_next_index), ntohl (mp->vni),
12342 ntohl (mp->mcast_sw_if_index));
12345 static void vl_api_geneve_tunnel_details_t_handler_json
12346 (vl_api_geneve_tunnel_details_t * mp)
12348 vat_main_t *vam = &vat_main;
12349 vat_json_node_t *node = NULL;
12351 if (VAT_JSON_ARRAY != vam->json_tree.type)
12353 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12354 vat_json_init_array (&vam->json_tree);
12356 node = vat_json_array_add (&vam->json_tree);
12358 vat_json_init_object (node);
12359 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12362 struct in6_addr ip6;
12364 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12365 vat_json_object_add_ip6 (node, "src_address", ip6);
12366 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12367 vat_json_object_add_ip6 (node, "dst_address", ip6);
12371 struct in_addr ip4;
12373 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12374 vat_json_object_add_ip4 (node, "src_address", ip4);
12375 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12376 vat_json_object_add_ip4 (node, "dst_address", ip4);
12378 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12379 vat_json_object_add_uint (node, "decap_next_index",
12380 ntohl (mp->decap_next_index));
12381 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12382 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12383 vat_json_object_add_uint (node, "mcast_sw_if_index",
12384 ntohl (mp->mcast_sw_if_index));
12388 api_geneve_tunnel_dump (vat_main_t * vam)
12390 unformat_input_t *i = vam->input;
12391 vl_api_geneve_tunnel_dump_t *mp;
12392 vl_api_control_ping_t *mp_ping;
12394 u8 sw_if_index_set = 0;
12397 /* Parse args required to build the message */
12398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12400 if (unformat (i, "sw_if_index %d", &sw_if_index))
12401 sw_if_index_set = 1;
12406 if (sw_if_index_set == 0)
12411 if (!vam->json_output)
12413 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12414 "sw_if_index", "local_address", "remote_address",
12415 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12418 /* Get list of geneve-tunnel interfaces */
12419 M (GENEVE_TUNNEL_DUMP, mp);
12421 mp->sw_if_index = htonl (sw_if_index);
12425 /* Use a control ping for synchronization */
12426 M (CONTROL_PING, mp_ping);
12434 api_gre_add_del_tunnel (vat_main_t * vam)
12436 unformat_input_t *line_input = vam->input;
12437 vl_api_gre_add_del_tunnel_t *mp;
12438 ip4_address_t src4, dst4;
12439 ip6_address_t src6, dst6;
12446 u32 outer_fib_id = 0;
12449 memset (&src4, 0, sizeof src4);
12450 memset (&dst4, 0, sizeof dst4);
12451 memset (&src6, 0, sizeof src6);
12452 memset (&dst6, 0, sizeof dst6);
12454 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12456 if (unformat (line_input, "del"))
12458 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
12463 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
12468 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
12473 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
12478 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12480 else if (unformat (line_input, "teb"))
12484 errmsg ("parse error '%U'", format_unformat_error, line_input);
12491 errmsg ("tunnel src address not specified");
12496 errmsg ("tunnel dst address not specified");
12499 if (ipv4_set && ipv6_set)
12501 errmsg ("both IPv4 and IPv6 addresses specified");
12506 M (GRE_ADD_DEL_TUNNEL, mp);
12510 clib_memcpy (&mp->src_address, &src4, 4);
12511 clib_memcpy (&mp->dst_address, &dst4, 4);
12515 clib_memcpy (&mp->src_address, &src6, 16);
12516 clib_memcpy (&mp->dst_address, &dst6, 16);
12518 mp->outer_fib_id = ntohl (outer_fib_id);
12519 mp->is_add = is_add;
12521 mp->is_ipv6 = ipv6_set;
12528 static void vl_api_gre_tunnel_details_t_handler
12529 (vl_api_gre_tunnel_details_t * mp)
12531 vat_main_t *vam = &vat_main;
12532 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
12533 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
12535 print (vam->ofp, "%11d%24U%24U%6d%14d",
12536 ntohl (mp->sw_if_index),
12537 format_ip46_address, &src, IP46_TYPE_ANY,
12538 format_ip46_address, &dst, IP46_TYPE_ANY,
12539 mp->teb, ntohl (mp->outer_fib_id));
12542 static void vl_api_gre_tunnel_details_t_handler_json
12543 (vl_api_gre_tunnel_details_t * mp)
12545 vat_main_t *vam = &vat_main;
12546 vat_json_node_t *node = NULL;
12547 struct in_addr ip4;
12548 struct in6_addr ip6;
12550 if (VAT_JSON_ARRAY != vam->json_tree.type)
12552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12553 vat_json_init_array (&vam->json_tree);
12555 node = vat_json_array_add (&vam->json_tree);
12557 vat_json_init_object (node);
12558 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12561 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
12562 vat_json_object_add_ip4 (node, "src_address", ip4);
12563 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
12564 vat_json_object_add_ip4 (node, "dst_address", ip4);
12568 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
12569 vat_json_object_add_ip6 (node, "src_address", ip6);
12570 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
12571 vat_json_object_add_ip6 (node, "dst_address", ip6);
12573 vat_json_object_add_uint (node, "teb", mp->teb);
12574 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
12575 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
12579 api_gre_tunnel_dump (vat_main_t * vam)
12581 unformat_input_t *i = vam->input;
12582 vl_api_gre_tunnel_dump_t *mp;
12583 vl_api_control_ping_t *mp_ping;
12585 u8 sw_if_index_set = 0;
12588 /* Parse args required to build the message */
12589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12591 if (unformat (i, "sw_if_index %d", &sw_if_index))
12592 sw_if_index_set = 1;
12597 if (sw_if_index_set == 0)
12602 if (!vam->json_output)
12604 print (vam->ofp, "%11s%24s%24s%6s%14s",
12605 "sw_if_index", "src_address", "dst_address", "teb",
12609 /* Get list of gre-tunnel interfaces */
12610 M (GRE_TUNNEL_DUMP, mp);
12612 mp->sw_if_index = htonl (sw_if_index);
12616 /* Use a control ping for synchronization */
12617 MPING (CONTROL_PING, mp_ping);
12625 api_l2_fib_clear_table (vat_main_t * vam)
12627 // unformat_input_t * i = vam->input;
12628 vl_api_l2_fib_clear_table_t *mp;
12631 M (L2_FIB_CLEAR_TABLE, mp);
12639 api_l2_interface_efp_filter (vat_main_t * vam)
12641 unformat_input_t *i = vam->input;
12642 vl_api_l2_interface_efp_filter_t *mp;
12645 u8 sw_if_index_set = 0;
12648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12651 sw_if_index_set = 1;
12652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12653 sw_if_index_set = 1;
12654 else if (unformat (i, "enable"))
12656 else if (unformat (i, "disable"))
12660 clib_warning ("parse error '%U'", format_unformat_error, i);
12665 if (sw_if_index_set == 0)
12667 errmsg ("missing sw_if_index");
12671 M (L2_INTERFACE_EFP_FILTER, mp);
12673 mp->sw_if_index = ntohl (sw_if_index);
12674 mp->enable_disable = enable;
12681 #define foreach_vtr_op \
12682 _("disable", L2_VTR_DISABLED) \
12683 _("push-1", L2_VTR_PUSH_1) \
12684 _("push-2", L2_VTR_PUSH_2) \
12685 _("pop-1", L2_VTR_POP_1) \
12686 _("pop-2", L2_VTR_POP_2) \
12687 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12688 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12689 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12690 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12693 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12695 unformat_input_t *i = vam->input;
12696 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12698 u8 sw_if_index_set = 0;
12701 u32 push_dot1q = 1;
12706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12708 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12709 sw_if_index_set = 1;
12710 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12711 sw_if_index_set = 1;
12712 else if (unformat (i, "vtr_op %d", &vtr_op))
12714 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12717 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12719 else if (unformat (i, "tag1 %d", &tag1))
12721 else if (unformat (i, "tag2 %d", &tag2))
12725 clib_warning ("parse error '%U'", format_unformat_error, i);
12730 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12732 errmsg ("missing vtr operation or sw_if_index");
12736 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12737 mp->sw_if_index = ntohl (sw_if_index);
12738 mp->vtr_op = ntohl (vtr_op);
12739 mp->push_dot1q = ntohl (push_dot1q);
12740 mp->tag1 = ntohl (tag1);
12741 mp->tag2 = ntohl (tag2);
12749 api_create_vhost_user_if (vat_main_t * vam)
12751 unformat_input_t *i = vam->input;
12752 vl_api_create_vhost_user_if_t *mp;
12755 u8 file_name_set = 0;
12756 u32 custom_dev_instance = ~0;
12758 u8 use_custom_mac = 0;
12762 /* Shut up coverity */
12763 memset (hwaddr, 0, sizeof (hwaddr));
12765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12767 if (unformat (i, "socket %s", &file_name))
12771 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12773 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12774 use_custom_mac = 1;
12775 else if (unformat (i, "server"))
12777 else if (unformat (i, "tag %s", &tag))
12783 if (file_name_set == 0)
12785 errmsg ("missing socket file name");
12789 if (vec_len (file_name) > 255)
12791 errmsg ("socket file name too long");
12794 vec_add1 (file_name, 0);
12796 M (CREATE_VHOST_USER_IF, mp);
12798 mp->is_server = is_server;
12799 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12800 vec_free (file_name);
12801 if (custom_dev_instance != ~0)
12804 mp->custom_dev_instance = ntohl (custom_dev_instance);
12806 mp->use_custom_mac = use_custom_mac;
12807 clib_memcpy (mp->mac_address, hwaddr, 6);
12809 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12818 api_modify_vhost_user_if (vat_main_t * vam)
12820 unformat_input_t *i = vam->input;
12821 vl_api_modify_vhost_user_if_t *mp;
12824 u8 file_name_set = 0;
12825 u32 custom_dev_instance = ~0;
12826 u8 sw_if_index_set = 0;
12827 u32 sw_if_index = (u32) ~ 0;
12830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12832 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12833 sw_if_index_set = 1;
12834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12835 sw_if_index_set = 1;
12836 else if (unformat (i, "socket %s", &file_name))
12840 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12842 else if (unformat (i, "server"))
12848 if (sw_if_index_set == 0)
12850 errmsg ("missing sw_if_index or interface name");
12854 if (file_name_set == 0)
12856 errmsg ("missing socket file name");
12860 if (vec_len (file_name) > 255)
12862 errmsg ("socket file name too long");
12865 vec_add1 (file_name, 0);
12867 M (MODIFY_VHOST_USER_IF, mp);
12869 mp->sw_if_index = ntohl (sw_if_index);
12870 mp->is_server = is_server;
12871 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12872 vec_free (file_name);
12873 if (custom_dev_instance != ~0)
12876 mp->custom_dev_instance = ntohl (custom_dev_instance);
12885 api_delete_vhost_user_if (vat_main_t * vam)
12887 unformat_input_t *i = vam->input;
12888 vl_api_delete_vhost_user_if_t *mp;
12889 u32 sw_if_index = ~0;
12890 u8 sw_if_index_set = 0;
12893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12896 sw_if_index_set = 1;
12897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12898 sw_if_index_set = 1;
12903 if (sw_if_index_set == 0)
12905 errmsg ("missing sw_if_index or interface name");
12910 M (DELETE_VHOST_USER_IF, mp);
12912 mp->sw_if_index = ntohl (sw_if_index);
12919 static void vl_api_sw_interface_vhost_user_details_t_handler
12920 (vl_api_sw_interface_vhost_user_details_t * mp)
12922 vat_main_t *vam = &vat_main;
12924 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12925 (char *) mp->interface_name,
12926 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12927 clib_net_to_host_u64 (mp->features), mp->is_server,
12928 ntohl (mp->num_regions), (char *) mp->sock_filename);
12929 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12932 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12933 (vl_api_sw_interface_vhost_user_details_t * mp)
12935 vat_main_t *vam = &vat_main;
12936 vat_json_node_t *node = NULL;
12938 if (VAT_JSON_ARRAY != vam->json_tree.type)
12940 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12941 vat_json_init_array (&vam->json_tree);
12943 node = vat_json_array_add (&vam->json_tree);
12945 vat_json_init_object (node);
12946 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12947 vat_json_object_add_string_copy (node, "interface_name",
12948 mp->interface_name);
12949 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12950 ntohl (mp->virtio_net_hdr_sz));
12951 vat_json_object_add_uint (node, "features",
12952 clib_net_to_host_u64 (mp->features));
12953 vat_json_object_add_uint (node, "is_server", mp->is_server);
12954 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12955 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12956 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12960 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12962 vl_api_sw_interface_vhost_user_dump_t *mp;
12963 vl_api_control_ping_t *mp_ping;
12966 "Interface name idx hdr_sz features server regions filename");
12968 /* Get list of vhost-user interfaces */
12969 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12972 /* Use a control ping for synchronization */
12973 MPING (CONTROL_PING, mp_ping);
12981 api_show_version (vat_main_t * vam)
12983 vl_api_show_version_t *mp;
12986 M (SHOW_VERSION, mp);
12995 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12997 unformat_input_t *line_input = vam->input;
12998 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12999 ip4_address_t local4, remote4;
13000 ip6_address_t local6, remote6;
13002 u8 ipv4_set = 0, ipv6_set = 0;
13006 u32 mcast_sw_if_index = ~0;
13007 u32 encap_vrf_id = 0;
13008 u32 decap_vrf_id = 0;
13014 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13015 memset (&local4, 0, sizeof local4);
13016 memset (&remote4, 0, sizeof remote4);
13017 memset (&local6, 0, sizeof local6);
13018 memset (&remote6, 0, sizeof remote6);
13020 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13022 if (unformat (line_input, "del"))
13024 else if (unformat (line_input, "local %U",
13025 unformat_ip4_address, &local4))
13030 else if (unformat (line_input, "remote %U",
13031 unformat_ip4_address, &remote4))
13036 else if (unformat (line_input, "local %U",
13037 unformat_ip6_address, &local6))
13042 else if (unformat (line_input, "remote %U",
13043 unformat_ip6_address, &remote6))
13048 else if (unformat (line_input, "group %U %U",
13049 unformat_ip4_address, &remote4,
13050 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13052 grp_set = remote_set = 1;
13055 else if (unformat (line_input, "group %U",
13056 unformat_ip4_address, &remote4))
13058 grp_set = remote_set = 1;
13061 else if (unformat (line_input, "group %U %U",
13062 unformat_ip6_address, &remote6,
13063 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13065 grp_set = remote_set = 1;
13068 else if (unformat (line_input, "group %U",
13069 unformat_ip6_address, &remote6))
13071 grp_set = remote_set = 1;
13075 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13077 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13079 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13081 else if (unformat (line_input, "vni %d", &vni))
13083 else if (unformat (line_input, "next-ip4"))
13085 else if (unformat (line_input, "next-ip6"))
13087 else if (unformat (line_input, "next-ethernet"))
13089 else if (unformat (line_input, "next-nsh"))
13093 errmsg ("parse error '%U'", format_unformat_error, line_input);
13098 if (local_set == 0)
13100 errmsg ("tunnel local address not specified");
13103 if (remote_set == 0)
13105 errmsg ("tunnel remote address not specified");
13108 if (grp_set && mcast_sw_if_index == ~0)
13110 errmsg ("tunnel nonexistent multicast device");
13113 if (ipv4_set && ipv6_set)
13115 errmsg ("both IPv4 and IPv6 addresses specified");
13121 errmsg ("vni not specified");
13125 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13130 clib_memcpy (&mp->local, &local6, sizeof (local6));
13131 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13135 clib_memcpy (&mp->local, &local4, sizeof (local4));
13136 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13139 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13140 mp->encap_vrf_id = ntohl (encap_vrf_id);
13141 mp->decap_vrf_id = ntohl (decap_vrf_id);
13142 mp->protocol = protocol;
13143 mp->vni = ntohl (vni);
13144 mp->is_add = is_add;
13145 mp->is_ipv6 = ipv6_set;
13152 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13153 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13155 vat_main_t *vam = &vat_main;
13156 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13157 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13159 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13160 ntohl (mp->sw_if_index),
13161 format_ip46_address, &local, IP46_TYPE_ANY,
13162 format_ip46_address, &remote, IP46_TYPE_ANY,
13163 ntohl (mp->vni), mp->protocol,
13164 ntohl (mp->mcast_sw_if_index),
13165 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13169 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13170 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13172 vat_main_t *vam = &vat_main;
13173 vat_json_node_t *node = NULL;
13174 struct in_addr ip4;
13175 struct in6_addr ip6;
13177 if (VAT_JSON_ARRAY != vam->json_tree.type)
13179 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13180 vat_json_init_array (&vam->json_tree);
13182 node = vat_json_array_add (&vam->json_tree);
13184 vat_json_init_object (node);
13185 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13188 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13189 vat_json_object_add_ip6 (node, "local", ip6);
13190 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13191 vat_json_object_add_ip6 (node, "remote", ip6);
13195 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13196 vat_json_object_add_ip4 (node, "local", ip4);
13197 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13198 vat_json_object_add_ip4 (node, "remote", ip4);
13200 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13201 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13202 vat_json_object_add_uint (node, "mcast_sw_if_index",
13203 ntohl (mp->mcast_sw_if_index));
13204 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13205 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13206 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13210 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13212 unformat_input_t *i = vam->input;
13213 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13214 vl_api_control_ping_t *mp_ping;
13216 u8 sw_if_index_set = 0;
13219 /* Parse args required to build the message */
13220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13222 if (unformat (i, "sw_if_index %d", &sw_if_index))
13223 sw_if_index_set = 1;
13228 if (sw_if_index_set == 0)
13233 if (!vam->json_output)
13235 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13236 "sw_if_index", "local", "remote", "vni",
13237 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13240 /* Get list of vxlan-tunnel interfaces */
13241 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13243 mp->sw_if_index = htonl (sw_if_index);
13247 /* Use a control ping for synchronization */
13248 MPING (CONTROL_PING, mp_ping);
13257 format_l2_fib_mac_address (u8 * s, va_list * args)
13259 u8 *a = va_arg (*args, u8 *);
13261 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
13262 a[2], a[3], a[4], a[5], a[6], a[7]);
13265 static void vl_api_l2_fib_table_details_t_handler
13266 (vl_api_l2_fib_table_details_t * mp)
13268 vat_main_t *vam = &vat_main;
13270 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13272 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
13273 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13277 static void vl_api_l2_fib_table_details_t_handler_json
13278 (vl_api_l2_fib_table_details_t * mp)
13280 vat_main_t *vam = &vat_main;
13281 vat_json_node_t *node = NULL;
13283 if (VAT_JSON_ARRAY != vam->json_tree.type)
13285 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13286 vat_json_init_array (&vam->json_tree);
13288 node = vat_json_array_add (&vam->json_tree);
13290 vat_json_init_object (node);
13291 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13292 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
13293 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13294 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13295 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13296 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13300 api_l2_fib_table_dump (vat_main_t * vam)
13302 unformat_input_t *i = vam->input;
13303 vl_api_l2_fib_table_dump_t *mp;
13304 vl_api_control_ping_t *mp_ping;
13309 /* Parse args required to build the message */
13310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (i, "bd_id %d", &bd_id))
13318 if (bd_id_set == 0)
13320 errmsg ("missing bridge domain");
13324 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13326 /* Get list of l2 fib entries */
13327 M (L2_FIB_TABLE_DUMP, mp);
13329 mp->bd_id = ntohl (bd_id);
13332 /* Use a control ping for synchronization */
13333 MPING (CONTROL_PING, mp_ping);
13342 api_interface_name_renumber (vat_main_t * vam)
13344 unformat_input_t *line_input = vam->input;
13345 vl_api_interface_name_renumber_t *mp;
13346 u32 sw_if_index = ~0;
13347 u32 new_show_dev_instance = ~0;
13350 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13352 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13355 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13357 else if (unformat (line_input, "new_show_dev_instance %d",
13358 &new_show_dev_instance))
13364 if (sw_if_index == ~0)
13366 errmsg ("missing interface name or sw_if_index");
13370 if (new_show_dev_instance == ~0)
13372 errmsg ("missing new_show_dev_instance");
13376 M (INTERFACE_NAME_RENUMBER, mp);
13378 mp->sw_if_index = ntohl (sw_if_index);
13379 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13387 api_want_ip4_arp_events (vat_main_t * vam)
13389 unformat_input_t *line_input = vam->input;
13390 vl_api_want_ip4_arp_events_t *mp;
13391 ip4_address_t address;
13392 int address_set = 0;
13393 u32 enable_disable = 1;
13396 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13398 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13400 else if (unformat (line_input, "del"))
13401 enable_disable = 0;
13406 if (address_set == 0)
13408 errmsg ("missing addresses");
13412 M (WANT_IP4_ARP_EVENTS, mp);
13413 mp->enable_disable = enable_disable;
13414 mp->pid = htonl (getpid ());
13415 mp->address = address.as_u32;
13423 api_want_ip6_nd_events (vat_main_t * vam)
13425 unformat_input_t *line_input = vam->input;
13426 vl_api_want_ip6_nd_events_t *mp;
13427 ip6_address_t address;
13428 int address_set = 0;
13429 u32 enable_disable = 1;
13432 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13434 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
13436 else if (unformat (line_input, "del"))
13437 enable_disable = 0;
13442 if (address_set == 0)
13444 errmsg ("missing addresses");
13448 M (WANT_IP6_ND_EVENTS, mp);
13449 mp->enable_disable = enable_disable;
13450 mp->pid = htonl (getpid ());
13451 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
13459 api_want_l2_macs_events (vat_main_t * vam)
13461 unformat_input_t *line_input = vam->input;
13462 vl_api_want_l2_macs_events_t *mp;
13463 u8 enable_disable = 1;
13464 u32 scan_delay = 0;
13465 u32 max_macs_in_event = 0;
13466 u32 learn_limit = 0;
13469 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13471 if (unformat (line_input, "learn-limit %d", &learn_limit))
13473 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13475 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13477 else if (unformat (line_input, "disable"))
13478 enable_disable = 0;
13483 M (WANT_L2_MACS_EVENTS, mp);
13484 mp->enable_disable = enable_disable;
13485 mp->pid = htonl (getpid ());
13486 mp->learn_limit = htonl (learn_limit);
13487 mp->scan_delay = (u8) scan_delay;
13488 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13495 api_input_acl_set_interface (vat_main_t * vam)
13497 unformat_input_t *i = vam->input;
13498 vl_api_input_acl_set_interface_t *mp;
13500 int sw_if_index_set;
13501 u32 ip4_table_index = ~0;
13502 u32 ip6_table_index = ~0;
13503 u32 l2_table_index = ~0;
13507 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13510 sw_if_index_set = 1;
13511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13512 sw_if_index_set = 1;
13513 else if (unformat (i, "del"))
13515 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13517 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13519 else if (unformat (i, "l2-table %d", &l2_table_index))
13523 clib_warning ("parse error '%U'", format_unformat_error, i);
13528 if (sw_if_index_set == 0)
13530 errmsg ("missing interface name or sw_if_index");
13534 M (INPUT_ACL_SET_INTERFACE, mp);
13536 mp->sw_if_index = ntohl (sw_if_index);
13537 mp->ip4_table_index = ntohl (ip4_table_index);
13538 mp->ip6_table_index = ntohl (ip6_table_index);
13539 mp->l2_table_index = ntohl (l2_table_index);
13540 mp->is_add = is_add;
13548 api_ip_address_dump (vat_main_t * vam)
13550 unformat_input_t *i = vam->input;
13551 vl_api_ip_address_dump_t *mp;
13552 vl_api_control_ping_t *mp_ping;
13553 u32 sw_if_index = ~0;
13554 u8 sw_if_index_set = 0;
13559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13561 if (unformat (i, "sw_if_index %d", &sw_if_index))
13562 sw_if_index_set = 1;
13564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13565 sw_if_index_set = 1;
13566 else if (unformat (i, "ipv4"))
13568 else if (unformat (i, "ipv6"))
13574 if (ipv4_set && ipv6_set)
13576 errmsg ("ipv4 and ipv6 flags cannot be both set");
13580 if ((!ipv4_set) && (!ipv6_set))
13582 errmsg ("no ipv4 nor ipv6 flag set");
13586 if (sw_if_index_set == 0)
13588 errmsg ("missing interface name or sw_if_index");
13592 vam->current_sw_if_index = sw_if_index;
13593 vam->is_ipv6 = ipv6_set;
13595 M (IP_ADDRESS_DUMP, mp);
13596 mp->sw_if_index = ntohl (sw_if_index);
13597 mp->is_ipv6 = ipv6_set;
13600 /* Use a control ping for synchronization */
13601 MPING (CONTROL_PING, mp_ping);
13609 api_ip_dump (vat_main_t * vam)
13611 vl_api_ip_dump_t *mp;
13612 vl_api_control_ping_t *mp_ping;
13613 unformat_input_t *in = vam->input;
13620 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13622 if (unformat (in, "ipv4"))
13624 else if (unformat (in, "ipv6"))
13630 if (ipv4_set && ipv6_set)
13632 errmsg ("ipv4 and ipv6 flags cannot be both set");
13636 if ((!ipv4_set) && (!ipv6_set))
13638 errmsg ("no ipv4 nor ipv6 flag set");
13642 is_ipv6 = ipv6_set;
13643 vam->is_ipv6 = is_ipv6;
13645 /* free old data */
13646 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13648 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13650 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13653 mp->is_ipv6 = ipv6_set;
13656 /* Use a control ping for synchronization */
13657 MPING (CONTROL_PING, mp_ping);
13665 api_ipsec_spd_add_del (vat_main_t * vam)
13667 unformat_input_t *i = vam->input;
13668 vl_api_ipsec_spd_add_del_t *mp;
13673 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13675 if (unformat (i, "spd_id %d", &spd_id))
13677 else if (unformat (i, "del"))
13681 clib_warning ("parse error '%U'", format_unformat_error, i);
13687 errmsg ("spd_id must be set");
13691 M (IPSEC_SPD_ADD_DEL, mp);
13693 mp->spd_id = ntohl (spd_id);
13694 mp->is_add = is_add;
13702 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13704 unformat_input_t *i = vam->input;
13705 vl_api_ipsec_interface_add_del_spd_t *mp;
13707 u8 sw_if_index_set = 0;
13708 u32 spd_id = (u32) ~ 0;
13712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13714 if (unformat (i, "del"))
13716 else if (unformat (i, "spd_id %d", &spd_id))
13719 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13720 sw_if_index_set = 1;
13721 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13722 sw_if_index_set = 1;
13725 clib_warning ("parse error '%U'", format_unformat_error, i);
13731 if (spd_id == (u32) ~ 0)
13733 errmsg ("spd_id must be set");
13737 if (sw_if_index_set == 0)
13739 errmsg ("missing interface name or sw_if_index");
13743 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13745 mp->spd_id = ntohl (spd_id);
13746 mp->sw_if_index = ntohl (sw_if_index);
13747 mp->is_add = is_add;
13755 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13757 unformat_input_t *i = vam->input;
13758 vl_api_ipsec_spd_add_del_entry_t *mp;
13759 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13760 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13762 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13763 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13764 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13765 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13768 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13769 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13770 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13771 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13772 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13773 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13777 if (unformat (i, "del"))
13779 if (unformat (i, "outbound"))
13781 if (unformat (i, "inbound"))
13783 else if (unformat (i, "spd_id %d", &spd_id))
13785 else if (unformat (i, "sa_id %d", &sa_id))
13787 else if (unformat (i, "priority %d", &priority))
13789 else if (unformat (i, "protocol %d", &protocol))
13791 else if (unformat (i, "lport_start %d", &lport_start))
13793 else if (unformat (i, "lport_stop %d", &lport_stop))
13795 else if (unformat (i, "rport_start %d", &rport_start))
13797 else if (unformat (i, "rport_stop %d", &rport_stop))
13801 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13807 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13814 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13820 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13827 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13833 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13840 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13846 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13852 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13854 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13856 clib_warning ("unsupported action: 'resolve'");
13862 clib_warning ("parse error '%U'", format_unformat_error, i);
13868 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13870 mp->spd_id = ntohl (spd_id);
13871 mp->priority = ntohl (priority);
13872 mp->is_outbound = is_outbound;
13874 mp->is_ipv6 = is_ipv6;
13875 if (is_ipv6 || is_ip_any)
13877 clib_memcpy (mp->remote_address_start, &raddr6_start,
13878 sizeof (ip6_address_t));
13879 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13880 sizeof (ip6_address_t));
13881 clib_memcpy (mp->local_address_start, &laddr6_start,
13882 sizeof (ip6_address_t));
13883 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13884 sizeof (ip6_address_t));
13888 clib_memcpy (mp->remote_address_start, &raddr4_start,
13889 sizeof (ip4_address_t));
13890 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13891 sizeof (ip4_address_t));
13892 clib_memcpy (mp->local_address_start, &laddr4_start,
13893 sizeof (ip4_address_t));
13894 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13895 sizeof (ip4_address_t));
13897 mp->protocol = (u8) protocol;
13898 mp->local_port_start = ntohs ((u16) lport_start);
13899 mp->local_port_stop = ntohs ((u16) lport_stop);
13900 mp->remote_port_start = ntohs ((u16) rport_start);
13901 mp->remote_port_stop = ntohs ((u16) rport_stop);
13902 mp->policy = (u8) policy;
13903 mp->sa_id = ntohl (sa_id);
13904 mp->is_add = is_add;
13905 mp->is_ip_any = is_ip_any;
13912 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13914 unformat_input_t *i = vam->input;
13915 vl_api_ipsec_sad_add_del_entry_t *mp;
13916 u32 sad_id = 0, spi = 0;
13917 u8 *ck = 0, *ik = 0;
13920 u8 protocol = IPSEC_PROTOCOL_AH;
13921 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13922 u32 crypto_alg = 0, integ_alg = 0;
13923 ip4_address_t tun_src4;
13924 ip4_address_t tun_dst4;
13925 ip6_address_t tun_src6;
13926 ip6_address_t tun_dst6;
13929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13931 if (unformat (i, "del"))
13933 else if (unformat (i, "sad_id %d", &sad_id))
13935 else if (unformat (i, "spi %d", &spi))
13937 else if (unformat (i, "esp"))
13938 protocol = IPSEC_PROTOCOL_ESP;
13939 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13942 is_tunnel_ipv6 = 0;
13944 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13947 is_tunnel_ipv6 = 0;
13949 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13952 is_tunnel_ipv6 = 1;
13954 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13957 is_tunnel_ipv6 = 1;
13961 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13963 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13964 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13966 clib_warning ("unsupported crypto-alg: '%U'",
13967 format_ipsec_crypto_alg, crypto_alg);
13971 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13975 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13977 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13978 integ_alg >= IPSEC_INTEG_N_ALG)
13980 clib_warning ("unsupported integ-alg: '%U'",
13981 format_ipsec_integ_alg, integ_alg);
13985 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13989 clib_warning ("parse error '%U'", format_unformat_error, i);
13995 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13997 mp->sad_id = ntohl (sad_id);
13998 mp->is_add = is_add;
13999 mp->protocol = protocol;
14000 mp->spi = ntohl (spi);
14001 mp->is_tunnel = is_tunnel;
14002 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
14003 mp->crypto_algorithm = crypto_alg;
14004 mp->integrity_algorithm = integ_alg;
14005 mp->crypto_key_length = vec_len (ck);
14006 mp->integrity_key_length = vec_len (ik);
14008 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14009 mp->crypto_key_length = sizeof (mp->crypto_key);
14011 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14012 mp->integrity_key_length = sizeof (mp->integrity_key);
14015 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14017 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14021 if (is_tunnel_ipv6)
14023 clib_memcpy (mp->tunnel_src_address, &tun_src6,
14024 sizeof (ip6_address_t));
14025 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
14026 sizeof (ip6_address_t));
14030 clib_memcpy (mp->tunnel_src_address, &tun_src4,
14031 sizeof (ip4_address_t));
14032 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
14033 sizeof (ip4_address_t));
14043 api_ipsec_sa_set_key (vat_main_t * vam)
14045 unformat_input_t *i = vam->input;
14046 vl_api_ipsec_sa_set_key_t *mp;
14048 u8 *ck = 0, *ik = 0;
14051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14053 if (unformat (i, "sa_id %d", &sa_id))
14055 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14057 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14061 clib_warning ("parse error '%U'", format_unformat_error, i);
14066 M (IPSEC_SA_SET_KEY, mp);
14068 mp->sa_id = ntohl (sa_id);
14069 mp->crypto_key_length = vec_len (ck);
14070 mp->integrity_key_length = vec_len (ik);
14072 if (mp->crypto_key_length > sizeof (mp->crypto_key))
14073 mp->crypto_key_length = sizeof (mp->crypto_key);
14075 if (mp->integrity_key_length > sizeof (mp->integrity_key))
14076 mp->integrity_key_length = sizeof (mp->integrity_key);
14079 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
14081 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
14089 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14091 unformat_input_t *i = vam->input;
14092 vl_api_ipsec_tunnel_if_add_del_t *mp;
14093 u32 local_spi = 0, remote_spi = 0;
14094 u32 crypto_alg = 0, integ_alg = 0;
14095 u8 *lck = NULL, *rck = NULL;
14096 u8 *lik = NULL, *rik = NULL;
14097 ip4_address_t local_ip = { {0} };
14098 ip4_address_t remote_ip = { {0} };
14101 u8 anti_replay = 0;
14104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14106 if (unformat (i, "del"))
14108 else if (unformat (i, "esn"))
14110 else if (unformat (i, "anti_replay"))
14112 else if (unformat (i, "local_spi %d", &local_spi))
14114 else if (unformat (i, "remote_spi %d", &remote_spi))
14116 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
14118 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
14120 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14123 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14125 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14127 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14131 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
14133 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
14134 crypto_alg >= IPSEC_CRYPTO_N_ALG)
14136 errmsg ("unsupported crypto-alg: '%U'\n",
14137 format_ipsec_crypto_alg, crypto_alg);
14143 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
14145 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
14146 integ_alg >= IPSEC_INTEG_N_ALG)
14148 errmsg ("unsupported integ-alg: '%U'\n",
14149 format_ipsec_integ_alg, integ_alg);
14155 errmsg ("parse error '%U'\n", format_unformat_error, i);
14160 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14162 mp->is_add = is_add;
14164 mp->anti_replay = anti_replay;
14166 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
14167 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
14169 mp->local_spi = htonl (local_spi);
14170 mp->remote_spi = htonl (remote_spi);
14171 mp->crypto_alg = (u8) crypto_alg;
14173 mp->local_crypto_key_len = 0;
14176 mp->local_crypto_key_len = vec_len (lck);
14177 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14178 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14179 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14182 mp->remote_crypto_key_len = 0;
14185 mp->remote_crypto_key_len = vec_len (rck);
14186 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14187 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14188 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14191 mp->integ_alg = (u8) integ_alg;
14193 mp->local_integ_key_len = 0;
14196 mp->local_integ_key_len = vec_len (lik);
14197 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14198 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14199 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14202 mp->remote_integ_key_len = 0;
14205 mp->remote_integ_key_len = vec_len (rik);
14206 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14207 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14208 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14217 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14219 vat_main_t *vam = &vat_main;
14221 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14222 "crypto_key %U integ_alg %u integ_key %U use_esn %u "
14223 "use_anti_replay %u is_tunnel %u is_tunnel_ip6 %u "
14224 "tunnel_src_addr %U tunnel_dst_addr %U "
14225 "salt %u seq_outbound %lu last_seq_inbound %lu "
14226 "replay_window %lu total_data_size %lu\n",
14227 ntohl (mp->sa_id), ntohl (mp->sw_if_index), ntohl (mp->spi),
14229 mp->crypto_alg, format_hex_bytes, mp->crypto_key, mp->crypto_key_len,
14230 mp->integ_alg, format_hex_bytes, mp->integ_key, mp->integ_key_len,
14231 mp->use_esn, mp->use_anti_replay, mp->is_tunnel, mp->is_tunnel_ip6,
14232 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14233 mp->tunnel_src_addr,
14234 (mp->is_tunnel_ip6) ? format_ip6_address : format_ip4_address,
14235 mp->tunnel_dst_addr,
14237 clib_net_to_host_u64 (mp->seq_outbound),
14238 clib_net_to_host_u64 (mp->last_seq_inbound),
14239 clib_net_to_host_u64 (mp->replay_window),
14240 clib_net_to_host_u64 (mp->total_data_size));
14243 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14244 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14246 static void vl_api_ipsec_sa_details_t_handler_json
14247 (vl_api_ipsec_sa_details_t * mp)
14249 vat_main_t *vam = &vat_main;
14250 vat_json_node_t *node = NULL;
14251 struct in_addr src_ip4, dst_ip4;
14252 struct in6_addr src_ip6, dst_ip6;
14254 if (VAT_JSON_ARRAY != vam->json_tree.type)
14256 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14257 vat_json_init_array (&vam->json_tree);
14259 node = vat_json_array_add (&vam->json_tree);
14261 vat_json_init_object (node);
14262 vat_json_object_add_uint (node, "sa_id", ntohl (mp->sa_id));
14263 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14264 vat_json_object_add_uint (node, "spi", ntohl (mp->spi));
14265 vat_json_object_add_uint (node, "proto", mp->protocol);
14266 vat_json_object_add_uint (node, "crypto_alg", mp->crypto_alg);
14267 vat_json_object_add_uint (node, "integ_alg", mp->integ_alg);
14268 vat_json_object_add_uint (node, "use_esn", mp->use_esn);
14269 vat_json_object_add_uint (node, "use_anti_replay", mp->use_anti_replay);
14270 vat_json_object_add_uint (node, "is_tunnel", mp->is_tunnel);
14271 vat_json_object_add_uint (node, "is_tunnel_ip6", mp->is_tunnel_ip6);
14272 vat_json_object_add_bytes (node, "crypto_key", mp->crypto_key,
14273 mp->crypto_key_len);
14274 vat_json_object_add_bytes (node, "integ_key", mp->integ_key,
14275 mp->integ_key_len);
14276 if (mp->is_tunnel_ip6)
14278 clib_memcpy (&src_ip6, mp->tunnel_src_addr, sizeof (src_ip6));
14279 vat_json_object_add_ip6 (node, "tunnel_src_addr", src_ip6);
14280 clib_memcpy (&dst_ip6, mp->tunnel_dst_addr, sizeof (dst_ip6));
14281 vat_json_object_add_ip6 (node, "tunnel_dst_addr", dst_ip6);
14285 clib_memcpy (&src_ip4, mp->tunnel_src_addr, sizeof (src_ip4));
14286 vat_json_object_add_ip4 (node, "tunnel_src_addr", src_ip4);
14287 clib_memcpy (&dst_ip4, mp->tunnel_dst_addr, sizeof (dst_ip4));
14288 vat_json_object_add_ip4 (node, "tunnel_dst_addr", dst_ip4);
14290 vat_json_object_add_uint (node, "replay_window",
14291 clib_net_to_host_u64 (mp->replay_window));
14292 vat_json_object_add_uint (node, "total_data_size",
14293 clib_net_to_host_u64 (mp->total_data_size));
14298 api_ipsec_sa_dump (vat_main_t * vam)
14300 unformat_input_t *i = vam->input;
14301 vl_api_ipsec_sa_dump_t *mp;
14302 vl_api_control_ping_t *mp_ping;
14306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14308 if (unformat (i, "sa_id %d", &sa_id))
14312 clib_warning ("parse error '%U'", format_unformat_error, i);
14317 M (IPSEC_SA_DUMP, mp);
14319 mp->sa_id = ntohl (sa_id);
14323 /* Use a control ping for synchronization */
14324 M (CONTROL_PING, mp_ping);
14332 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
14334 unformat_input_t *i = vam->input;
14335 vl_api_ipsec_tunnel_if_set_key_t *mp;
14336 u32 sw_if_index = ~0;
14337 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
14342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14344 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14347 if (unformat (i, "local crypto %U", unformat_ipsec_crypto_alg, &alg))
14348 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
14350 if (unformat (i, "remote crypto %U", unformat_ipsec_crypto_alg, &alg))
14351 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
14352 else if (unformat (i, "local integ %U", unformat_ipsec_integ_alg, &alg))
14353 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
14355 if (unformat (i, "remote integ %U", unformat_ipsec_integ_alg, &alg))
14356 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
14357 else if (unformat (i, "%U", unformat_hex_string, &key))
14361 clib_warning ("parse error '%U'", format_unformat_error, i);
14366 if (sw_if_index == ~0)
14368 errmsg ("interface must be specified");
14372 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
14374 errmsg ("key type must be specified");
14380 errmsg ("algorithm must be specified");
14384 if (vec_len (key) == 0)
14386 errmsg ("key must be specified");
14390 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
14392 mp->sw_if_index = htonl (sw_if_index);
14394 mp->key_type = key_type;
14395 mp->key_len = vec_len (key);
14396 clib_memcpy (mp->key, key, vec_len (key));
14405 api_ikev2_profile_add_del (vat_main_t * vam)
14407 unformat_input_t *i = vam->input;
14408 vl_api_ikev2_profile_add_del_t *mp;
14413 const char *valid_chars = "a-zA-Z0-9_";
14415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14417 if (unformat (i, "del"))
14419 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14420 vec_add1 (name, 0);
14423 errmsg ("parse error '%U'", format_unformat_error, i);
14428 if (!vec_len (name))
14430 errmsg ("profile name must be specified");
14434 if (vec_len (name) > 64)
14436 errmsg ("profile name too long");
14440 M (IKEV2_PROFILE_ADD_DEL, mp);
14442 clib_memcpy (mp->name, name, vec_len (name));
14443 mp->is_add = is_add;
14452 api_ikev2_profile_set_auth (vat_main_t * vam)
14454 unformat_input_t *i = vam->input;
14455 vl_api_ikev2_profile_set_auth_t *mp;
14458 u32 auth_method = 0;
14462 const char *valid_chars = "a-zA-Z0-9_";
14464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14466 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14467 vec_add1 (name, 0);
14468 else if (unformat (i, "auth_method %U",
14469 unformat_ikev2_auth_method, &auth_method))
14471 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
14473 else if (unformat (i, "auth_data %v", &data))
14477 errmsg ("parse error '%U'", format_unformat_error, i);
14482 if (!vec_len (name))
14484 errmsg ("profile name must be specified");
14488 if (vec_len (name) > 64)
14490 errmsg ("profile name too long");
14494 if (!vec_len (data))
14496 errmsg ("auth_data must be specified");
14502 errmsg ("auth_method must be specified");
14506 M (IKEV2_PROFILE_SET_AUTH, mp);
14508 mp->is_hex = is_hex;
14509 mp->auth_method = (u8) auth_method;
14510 mp->data_len = vec_len (data);
14511 clib_memcpy (mp->name, name, vec_len (name));
14512 clib_memcpy (mp->data, data, vec_len (data));
14522 api_ikev2_profile_set_id (vat_main_t * vam)
14524 unformat_input_t *i = vam->input;
14525 vl_api_ikev2_profile_set_id_t *mp;
14533 const char *valid_chars = "a-zA-Z0-9_";
14535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14537 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14538 vec_add1 (name, 0);
14539 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
14541 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
14543 data = vec_new (u8, 4);
14544 clib_memcpy (data, ip4.as_u8, 4);
14546 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
14548 else if (unformat (i, "id_data %v", &data))
14550 else if (unformat (i, "local"))
14552 else if (unformat (i, "remote"))
14556 errmsg ("parse error '%U'", format_unformat_error, i);
14561 if (!vec_len (name))
14563 errmsg ("profile name must be specified");
14567 if (vec_len (name) > 64)
14569 errmsg ("profile name too long");
14573 if (!vec_len (data))
14575 errmsg ("id_data must be specified");
14581 errmsg ("id_type must be specified");
14585 M (IKEV2_PROFILE_SET_ID, mp);
14587 mp->is_local = is_local;
14588 mp->id_type = (u8) id_type;
14589 mp->data_len = vec_len (data);
14590 clib_memcpy (mp->name, name, vec_len (name));
14591 clib_memcpy (mp->data, data, vec_len (data));
14601 api_ikev2_profile_set_ts (vat_main_t * vam)
14603 unformat_input_t *i = vam->input;
14604 vl_api_ikev2_profile_set_ts_t *mp;
14607 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
14608 ip4_address_t start_addr, end_addr;
14610 const char *valid_chars = "a-zA-Z0-9_";
14613 start_addr.as_u32 = 0;
14614 end_addr.as_u32 = (u32) ~ 0;
14616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14618 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
14619 vec_add1 (name, 0);
14620 else if (unformat (i, "protocol %d", &proto))
14622 else if (unformat (i, "start_port %d", &start_port))
14624 else if (unformat (i, "end_port %d", &end_port))
14627 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
14629 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
14631 else if (unformat (i, "local"))
14633 else if (unformat (i, "remote"))
14637 errmsg ("parse error '%U'", format_unformat_error, i);
14642 if (!vec_len (name))
14644 errmsg ("profile name must be specified");
14648 if (vec_len (name) > 64)
14650 errmsg ("profile name too long");
14654 M (IKEV2_PROFILE_SET_TS, mp);
14656 mp->is_local = is_local;
14657 mp->proto = (u8) proto;
14658 mp->start_port = (u16) start_port;
14659 mp->end_port = (u16) end_port;
14660 mp->start_addr = start_addr.as_u32;
14661 mp->end_addr = end_addr.as_u32;
14662 clib_memcpy (mp->name, name, vec_len (name));
14671 api_ikev2_set_local_key (vat_main_t * vam)
14673 unformat_input_t *i = vam->input;
14674 vl_api_ikev2_set_local_key_t *mp;
14678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14680 if (unformat (i, "file %v", &file))
14681 vec_add1 (file, 0);
14684 errmsg ("parse error '%U'", format_unformat_error, i);
14689 if (!vec_len (file))
14691 errmsg ("RSA key file must be specified");
14695 if (vec_len (file) > 256)
14697 errmsg ("file name too long");
14701 M (IKEV2_SET_LOCAL_KEY, mp);
14703 clib_memcpy (mp->key_file, file, vec_len (file));
14712 api_ikev2_set_responder (vat_main_t * vam)
14714 unformat_input_t *i = vam->input;
14715 vl_api_ikev2_set_responder_t *mp;
14718 u32 sw_if_index = ~0;
14719 ip4_address_t address;
14721 const char *valid_chars = "a-zA-Z0-9_";
14723 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14726 (i, "%U interface %d address %U", unformat_token, valid_chars,
14727 &name, &sw_if_index, unformat_ip4_address, &address))
14728 vec_add1 (name, 0);
14731 errmsg ("parse error '%U'", format_unformat_error, i);
14736 if (!vec_len (name))
14738 errmsg ("profile name must be specified");
14742 if (vec_len (name) > 64)
14744 errmsg ("profile name too long");
14748 M (IKEV2_SET_RESPONDER, mp);
14750 clib_memcpy (mp->name, name, vec_len (name));
14753 mp->sw_if_index = sw_if_index;
14754 clib_memcpy (mp->address, &address, sizeof (address));
14762 api_ikev2_set_ike_transforms (vat_main_t * vam)
14764 unformat_input_t *i = vam->input;
14765 vl_api_ikev2_set_ike_transforms_t *mp;
14768 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14770 const char *valid_chars = "a-zA-Z0-9_";
14772 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14774 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14775 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14776 vec_add1 (name, 0);
14779 errmsg ("parse error '%U'", format_unformat_error, i);
14784 if (!vec_len (name))
14786 errmsg ("profile name must be specified");
14790 if (vec_len (name) > 64)
14792 errmsg ("profile name too long");
14796 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14798 clib_memcpy (mp->name, name, vec_len (name));
14800 mp->crypto_alg = crypto_alg;
14801 mp->crypto_key_size = crypto_key_size;
14802 mp->integ_alg = integ_alg;
14803 mp->dh_group = dh_group;
14812 api_ikev2_set_esp_transforms (vat_main_t * vam)
14814 unformat_input_t *i = vam->input;
14815 vl_api_ikev2_set_esp_transforms_t *mp;
14818 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14820 const char *valid_chars = "a-zA-Z0-9_";
14822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14824 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14825 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14826 vec_add1 (name, 0);
14829 errmsg ("parse error '%U'", format_unformat_error, i);
14834 if (!vec_len (name))
14836 errmsg ("profile name must be specified");
14840 if (vec_len (name) > 64)
14842 errmsg ("profile name too long");
14846 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14848 clib_memcpy (mp->name, name, vec_len (name));
14850 mp->crypto_alg = crypto_alg;
14851 mp->crypto_key_size = crypto_key_size;
14852 mp->integ_alg = integ_alg;
14853 mp->dh_group = dh_group;
14861 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14863 unformat_input_t *i = vam->input;
14864 vl_api_ikev2_set_sa_lifetime_t *mp;
14867 u64 lifetime, lifetime_maxdata;
14868 u32 lifetime_jitter, handover;
14870 const char *valid_chars = "a-zA-Z0-9_";
14872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14874 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14875 &lifetime, &lifetime_jitter, &handover,
14876 &lifetime_maxdata))
14877 vec_add1 (name, 0);
14880 errmsg ("parse error '%U'", format_unformat_error, i);
14885 if (!vec_len (name))
14887 errmsg ("profile name must be specified");
14891 if (vec_len (name) > 64)
14893 errmsg ("profile name too long");
14897 M (IKEV2_SET_SA_LIFETIME, mp);
14899 clib_memcpy (mp->name, name, vec_len (name));
14901 mp->lifetime = lifetime;
14902 mp->lifetime_jitter = lifetime_jitter;
14903 mp->handover = handover;
14904 mp->lifetime_maxdata = lifetime_maxdata;
14912 api_ikev2_initiate_sa_init (vat_main_t * vam)
14914 unformat_input_t *i = vam->input;
14915 vl_api_ikev2_initiate_sa_init_t *mp;
14919 const char *valid_chars = "a-zA-Z0-9_";
14921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14923 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14924 vec_add1 (name, 0);
14927 errmsg ("parse error '%U'", format_unformat_error, i);
14932 if (!vec_len (name))
14934 errmsg ("profile name must be specified");
14938 if (vec_len (name) > 64)
14940 errmsg ("profile name too long");
14944 M (IKEV2_INITIATE_SA_INIT, mp);
14946 clib_memcpy (mp->name, name, vec_len (name));
14955 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14957 unformat_input_t *i = vam->input;
14958 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14965 if (unformat (i, "%lx", &ispi))
14969 errmsg ("parse error '%U'", format_unformat_error, i);
14974 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14984 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14986 unformat_input_t *i = vam->input;
14987 vl_api_ikev2_initiate_del_child_sa_t *mp;
14992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14994 if (unformat (i, "%x", &ispi))
14998 errmsg ("parse error '%U'", format_unformat_error, i);
15003 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
15013 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
15015 unformat_input_t *i = vam->input;
15016 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
15021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15023 if (unformat (i, "%x", &ispi))
15027 errmsg ("parse error '%U'", format_unformat_error, i);
15032 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
15045 api_map_add_domain (vat_main_t * vam)
15047 unformat_input_t *i = vam->input;
15048 vl_api_map_add_domain_t *mp;
15050 ip4_address_t ip4_prefix;
15051 ip6_address_t ip6_prefix;
15052 ip6_address_t ip6_src;
15053 u32 num_m_args = 0;
15054 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
15055 0, psid_length = 0;
15056 u8 is_translation = 0;
15058 u32 ip6_src_len = 128;
15061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15063 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
15064 &ip4_prefix, &ip4_prefix_len))
15066 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
15067 &ip6_prefix, &ip6_prefix_len))
15071 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
15074 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
15076 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
15078 else if (unformat (i, "psid-offset %d", &psid_offset))
15080 else if (unformat (i, "psid-len %d", &psid_length))
15082 else if (unformat (i, "mtu %d", &mtu))
15084 else if (unformat (i, "map-t"))
15085 is_translation = 1;
15088 clib_warning ("parse error '%U'", format_unformat_error, i);
15093 if (num_m_args < 3)
15095 errmsg ("mandatory argument(s) missing");
15099 /* Construct the API message */
15100 M (MAP_ADD_DOMAIN, mp);
15102 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
15103 mp->ip4_prefix_len = ip4_prefix_len;
15105 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
15106 mp->ip6_prefix_len = ip6_prefix_len;
15108 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
15109 mp->ip6_src_prefix_len = ip6_src_len;
15111 mp->ea_bits_len = ea_bits_len;
15112 mp->psid_offset = psid_offset;
15113 mp->psid_length = psid_length;
15114 mp->is_translation = is_translation;
15115 mp->mtu = htons (mtu);
15120 /* Wait for a reply, return good/bad news */
15126 api_map_del_domain (vat_main_t * vam)
15128 unformat_input_t *i = vam->input;
15129 vl_api_map_del_domain_t *mp;
15131 u32 num_m_args = 0;
15135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15137 if (unformat (i, "index %d", &index))
15141 clib_warning ("parse error '%U'", format_unformat_error, i);
15146 if (num_m_args != 1)
15148 errmsg ("mandatory argument(s) missing");
15152 /* Construct the API message */
15153 M (MAP_DEL_DOMAIN, mp);
15155 mp->index = ntohl (index);
15160 /* Wait for a reply, return good/bad news */
15166 api_map_add_del_rule (vat_main_t * vam)
15168 unformat_input_t *i = vam->input;
15169 vl_api_map_add_del_rule_t *mp;
15171 ip6_address_t ip6_dst;
15172 u32 num_m_args = 0, index, psid = 0;
15175 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15177 if (unformat (i, "index %d", &index))
15179 else if (unformat (i, "psid %d", &psid))
15181 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
15183 else if (unformat (i, "del"))
15189 clib_warning ("parse error '%U'", format_unformat_error, i);
15194 /* Construct the API message */
15195 M (MAP_ADD_DEL_RULE, mp);
15197 mp->index = ntohl (index);
15198 mp->is_add = is_add;
15199 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
15200 mp->psid = ntohs (psid);
15205 /* Wait for a reply, return good/bad news */
15211 api_map_domain_dump (vat_main_t * vam)
15213 vl_api_map_domain_dump_t *mp;
15214 vl_api_control_ping_t *mp_ping;
15217 /* Construct the API message */
15218 M (MAP_DOMAIN_DUMP, mp);
15223 /* Use a control ping for synchronization */
15224 MPING (CONTROL_PING, mp_ping);
15232 api_map_rule_dump (vat_main_t * vam)
15234 unformat_input_t *i = vam->input;
15235 vl_api_map_rule_dump_t *mp;
15236 vl_api_control_ping_t *mp_ping;
15237 u32 domain_index = ~0;
15240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15242 if (unformat (i, "index %u", &domain_index))
15248 if (domain_index == ~0)
15250 clib_warning ("parse error: domain index expected");
15254 /* Construct the API message */
15255 M (MAP_RULE_DUMP, mp);
15257 mp->domain_index = htonl (domain_index);
15262 /* Use a control ping for synchronization */
15263 MPING (CONTROL_PING, mp_ping);
15270 static void vl_api_map_add_domain_reply_t_handler
15271 (vl_api_map_add_domain_reply_t * mp)
15273 vat_main_t *vam = &vat_main;
15274 i32 retval = ntohl (mp->retval);
15276 if (vam->async_mode)
15278 vam->async_errors += (retval < 0);
15282 vam->retval = retval;
15283 vam->result_ready = 1;
15287 static void vl_api_map_add_domain_reply_t_handler_json
15288 (vl_api_map_add_domain_reply_t * mp)
15290 vat_main_t *vam = &vat_main;
15291 vat_json_node_t node;
15293 vat_json_init_object (&node);
15294 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
15295 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
15297 vat_json_print (vam->ofp, &node);
15298 vat_json_free (&node);
15300 vam->retval = ntohl (mp->retval);
15301 vam->result_ready = 1;
15305 api_get_first_msg_id (vat_main_t * vam)
15307 vl_api_get_first_msg_id_t *mp;
15308 unformat_input_t *i = vam->input;
15313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15315 if (unformat (i, "client %s", &name))
15323 errmsg ("missing client name");
15326 vec_add1 (name, 0);
15328 if (vec_len (name) > 63)
15330 errmsg ("client name too long");
15334 M (GET_FIRST_MSG_ID, mp);
15335 clib_memcpy (mp->name, name, vec_len (name));
15342 api_cop_interface_enable_disable (vat_main_t * vam)
15344 unformat_input_t *line_input = vam->input;
15345 vl_api_cop_interface_enable_disable_t *mp;
15346 u32 sw_if_index = ~0;
15347 u8 enable_disable = 1;
15350 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15352 if (unformat (line_input, "disable"))
15353 enable_disable = 0;
15354 if (unformat (line_input, "enable"))
15355 enable_disable = 1;
15356 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15357 vam, &sw_if_index))
15359 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15365 if (sw_if_index == ~0)
15367 errmsg ("missing interface name or sw_if_index");
15371 /* Construct the API message */
15372 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15373 mp->sw_if_index = ntohl (sw_if_index);
15374 mp->enable_disable = enable_disable;
15378 /* Wait for the reply */
15384 api_cop_whitelist_enable_disable (vat_main_t * vam)
15386 unformat_input_t *line_input = vam->input;
15387 vl_api_cop_whitelist_enable_disable_t *mp;
15388 u32 sw_if_index = ~0;
15389 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15393 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15395 if (unformat (line_input, "ip4"))
15397 else if (unformat (line_input, "ip6"))
15399 else if (unformat (line_input, "default"))
15401 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15402 vam, &sw_if_index))
15404 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15406 else if (unformat (line_input, "fib-id %d", &fib_id))
15412 if (sw_if_index == ~0)
15414 errmsg ("missing interface name or sw_if_index");
15418 /* Construct the API message */
15419 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15420 mp->sw_if_index = ntohl (sw_if_index);
15421 mp->fib_id = ntohl (fib_id);
15424 mp->default_cop = default_cop;
15428 /* Wait for the reply */
15434 api_get_node_graph (vat_main_t * vam)
15436 vl_api_get_node_graph_t *mp;
15439 M (GET_NODE_GRAPH, mp);
15443 /* Wait for the reply */
15449 /** Used for parsing LISP eids */
15450 typedef CLIB_PACKED(struct{
15451 u8 addr[16]; /**< eid address */
15452 u32 len; /**< prefix length if IP */
15453 u8 type; /**< type of eid */
15458 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15460 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15462 memset (a, 0, sizeof (a[0]));
15464 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15466 a->type = 0; /* ipv4 type */
15468 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15470 a->type = 1; /* ipv6 type */
15472 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15474 a->type = 2; /* mac type */
15476 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15478 a->type = 3; /* NSH type */
15479 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15480 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15487 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15496 lisp_eid_size_vat (u8 type)
15513 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15515 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15519 api_one_add_del_locator_set (vat_main_t * vam)
15521 unformat_input_t *input = vam->input;
15522 vl_api_one_add_del_locator_set_t *mp;
15524 u8 *locator_set_name = NULL;
15525 u8 locator_set_name_set = 0;
15526 vl_api_local_locator_t locator, *locators = 0;
15527 u32 sw_if_index, priority, weight;
15531 /* Parse args required to build the message */
15532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15534 if (unformat (input, "del"))
15538 else if (unformat (input, "locator-set %s", &locator_set_name))
15540 locator_set_name_set = 1;
15542 else if (unformat (input, "sw_if_index %u p %u w %u",
15543 &sw_if_index, &priority, &weight))
15545 locator.sw_if_index = htonl (sw_if_index);
15546 locator.priority = priority;
15547 locator.weight = weight;
15548 vec_add1 (locators, locator);
15552 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15553 &sw_if_index, &priority, &weight))
15555 locator.sw_if_index = htonl (sw_if_index);
15556 locator.priority = priority;
15557 locator.weight = weight;
15558 vec_add1 (locators, locator);
15564 if (locator_set_name_set == 0)
15566 errmsg ("missing locator-set name");
15567 vec_free (locators);
15571 if (vec_len (locator_set_name) > 64)
15573 errmsg ("locator-set name too long");
15574 vec_free (locator_set_name);
15575 vec_free (locators);
15578 vec_add1 (locator_set_name, 0);
15580 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15582 /* Construct the API message */
15583 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15585 mp->is_add = is_add;
15586 clib_memcpy (mp->locator_set_name, locator_set_name,
15587 vec_len (locator_set_name));
15588 vec_free (locator_set_name);
15590 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15592 clib_memcpy (mp->locators, locators, data_len);
15593 vec_free (locators);
15598 /* Wait for a reply... */
15603 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15606 api_one_add_del_locator (vat_main_t * vam)
15608 unformat_input_t *input = vam->input;
15609 vl_api_one_add_del_locator_t *mp;
15610 u32 tmp_if_index = ~0;
15611 u32 sw_if_index = ~0;
15612 u8 sw_if_index_set = 0;
15613 u8 sw_if_index_if_name_set = 0;
15615 u8 priority_set = 0;
15619 u8 *locator_set_name = NULL;
15620 u8 locator_set_name_set = 0;
15623 /* Parse args required to build the message */
15624 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15626 if (unformat (input, "del"))
15630 else if (unformat (input, "locator-set %s", &locator_set_name))
15632 locator_set_name_set = 1;
15634 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15637 sw_if_index_if_name_set = 1;
15638 sw_if_index = tmp_if_index;
15640 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15642 sw_if_index_set = 1;
15643 sw_if_index = tmp_if_index;
15645 else if (unformat (input, "p %d", &priority))
15649 else if (unformat (input, "w %d", &weight))
15657 if (locator_set_name_set == 0)
15659 errmsg ("missing locator-set name");
15663 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15665 errmsg ("missing sw_if_index");
15666 vec_free (locator_set_name);
15670 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15672 errmsg ("cannot use both params interface name and sw_if_index");
15673 vec_free (locator_set_name);
15677 if (priority_set == 0)
15679 errmsg ("missing locator-set priority");
15680 vec_free (locator_set_name);
15684 if (weight_set == 0)
15686 errmsg ("missing locator-set weight");
15687 vec_free (locator_set_name);
15691 if (vec_len (locator_set_name) > 64)
15693 errmsg ("locator-set name too long");
15694 vec_free (locator_set_name);
15697 vec_add1 (locator_set_name, 0);
15699 /* Construct the API message */
15700 M (ONE_ADD_DEL_LOCATOR, mp);
15702 mp->is_add = is_add;
15703 mp->sw_if_index = ntohl (sw_if_index);
15704 mp->priority = priority;
15705 mp->weight = weight;
15706 clib_memcpy (mp->locator_set_name, locator_set_name,
15707 vec_len (locator_set_name));
15708 vec_free (locator_set_name);
15713 /* Wait for a reply... */
15718 #define api_lisp_add_del_locator api_one_add_del_locator
15721 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15723 u32 *key_id = va_arg (*args, u32 *);
15726 if (unformat (input, "%s", &s))
15728 if (!strcmp ((char *) s, "sha1"))
15729 key_id[0] = HMAC_SHA_1_96;
15730 else if (!strcmp ((char *) s, "sha256"))
15731 key_id[0] = HMAC_SHA_256_128;
15734 clib_warning ("invalid key_id: '%s'", s);
15735 key_id[0] = HMAC_NO_KEY;
15746 api_one_add_del_local_eid (vat_main_t * vam)
15748 unformat_input_t *input = vam->input;
15749 vl_api_one_add_del_local_eid_t *mp;
15752 lisp_eid_vat_t _eid, *eid = &_eid;
15753 u8 *locator_set_name = 0;
15754 u8 locator_set_name_set = 0;
15760 /* Parse args required to build the message */
15761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15763 if (unformat (input, "del"))
15767 else if (unformat (input, "vni %d", &vni))
15771 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15775 else if (unformat (input, "locator-set %s", &locator_set_name))
15777 locator_set_name_set = 1;
15779 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15781 else if (unformat (input, "secret-key %_%v%_", &key))
15787 if (locator_set_name_set == 0)
15789 errmsg ("missing locator-set name");
15795 errmsg ("EID address not set!");
15796 vec_free (locator_set_name);
15800 if (key && (0 == key_id))
15802 errmsg ("invalid key_id!");
15806 if (vec_len (key) > 64)
15808 errmsg ("key too long");
15813 if (vec_len (locator_set_name) > 64)
15815 errmsg ("locator-set name too long");
15816 vec_free (locator_set_name);
15819 vec_add1 (locator_set_name, 0);
15821 /* Construct the API message */
15822 M (ONE_ADD_DEL_LOCAL_EID, mp);
15824 mp->is_add = is_add;
15825 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15826 mp->eid_type = eid->type;
15827 mp->prefix_len = eid->len;
15828 mp->vni = clib_host_to_net_u32 (vni);
15829 mp->key_id = clib_host_to_net_u16 (key_id);
15830 clib_memcpy (mp->locator_set_name, locator_set_name,
15831 vec_len (locator_set_name));
15832 clib_memcpy (mp->key, key, vec_len (key));
15834 vec_free (locator_set_name);
15840 /* Wait for a reply... */
15845 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15848 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15850 u32 dp_table = 0, vni = 0;;
15851 unformat_input_t *input = vam->input;
15852 vl_api_gpe_add_del_fwd_entry_t *mp;
15854 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15855 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15856 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15857 u32 action = ~0, w;
15858 ip4_address_t rmt_rloc4, lcl_rloc4;
15859 ip6_address_t rmt_rloc6, lcl_rloc6;
15860 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15863 memset (&rloc, 0, sizeof (rloc));
15865 /* Parse args required to build the message */
15866 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15868 if (unformat (input, "del"))
15870 else if (unformat (input, "add"))
15872 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15876 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15880 else if (unformat (input, "vrf %d", &dp_table))
15882 else if (unformat (input, "bd %d", &dp_table))
15884 else if (unformat (input, "vni %d", &vni))
15886 else if (unformat (input, "w %d", &w))
15890 errmsg ("No RLOC configured for setting priority/weight!");
15893 curr_rloc->weight = w;
15895 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15896 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15900 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15902 vec_add1 (lcl_locs, rloc);
15904 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15905 vec_add1 (rmt_locs, rloc);
15906 /* weight saved in rmt loc */
15907 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15909 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15910 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15913 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15915 vec_add1 (lcl_locs, rloc);
15917 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15918 vec_add1 (rmt_locs, rloc);
15919 /* weight saved in rmt loc */
15920 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15922 else if (unformat (input, "action %d", &action))
15928 clib_warning ("parse error '%U'", format_unformat_error, input);
15935 errmsg ("remote eid addresses not set");
15939 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15941 errmsg ("eid types don't match");
15945 if (0 == rmt_locs && (u32) ~ 0 == action)
15947 errmsg ("action not set for negative mapping");
15951 /* Construct the API message */
15952 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15953 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15955 mp->is_add = is_add;
15956 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15957 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15958 mp->eid_type = rmt_eid->type;
15959 mp->dp_table = clib_host_to_net_u32 (dp_table);
15960 mp->vni = clib_host_to_net_u32 (vni);
15961 mp->rmt_len = rmt_eid->len;
15962 mp->lcl_len = lcl_eid->len;
15963 mp->action = action;
15965 if (0 != rmt_locs && 0 != lcl_locs)
15967 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15968 clib_memcpy (mp->locs, lcl_locs,
15969 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15971 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15972 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15973 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15975 vec_free (lcl_locs);
15976 vec_free (rmt_locs);
15981 /* Wait for a reply... */
15987 api_one_add_del_map_server (vat_main_t * vam)
15989 unformat_input_t *input = vam->input;
15990 vl_api_one_add_del_map_server_t *mp;
15994 ip4_address_t ipv4;
15995 ip6_address_t ipv6;
15998 /* Parse args required to build the message */
15999 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16001 if (unformat (input, "del"))
16005 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16009 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16017 if (ipv4_set && ipv6_set)
16019 errmsg ("both eid v4 and v6 addresses set");
16023 if (!ipv4_set && !ipv6_set)
16025 errmsg ("eid addresses not set");
16029 /* Construct the API message */
16030 M (ONE_ADD_DEL_MAP_SERVER, mp);
16032 mp->is_add = is_add;
16036 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16041 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16047 /* Wait for a reply... */
16052 #define api_lisp_add_del_map_server api_one_add_del_map_server
16055 api_one_add_del_map_resolver (vat_main_t * vam)
16057 unformat_input_t *input = vam->input;
16058 vl_api_one_add_del_map_resolver_t *mp;
16062 ip4_address_t ipv4;
16063 ip6_address_t ipv6;
16066 /* Parse args required to build the message */
16067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16069 if (unformat (input, "del"))
16073 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16077 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16085 if (ipv4_set && ipv6_set)
16087 errmsg ("both eid v4 and v6 addresses set");
16091 if (!ipv4_set && !ipv6_set)
16093 errmsg ("eid addresses not set");
16097 /* Construct the API message */
16098 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16100 mp->is_add = is_add;
16104 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16109 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16115 /* Wait for a reply... */
16120 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16123 api_lisp_gpe_enable_disable (vat_main_t * vam)
16125 unformat_input_t *input = vam->input;
16126 vl_api_gpe_enable_disable_t *mp;
16131 /* Parse args required to build the message */
16132 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16134 if (unformat (input, "enable"))
16139 else if (unformat (input, "disable"))
16150 errmsg ("Value not set");
16154 /* Construct the API message */
16155 M (GPE_ENABLE_DISABLE, mp);
16162 /* Wait for a reply... */
16168 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16170 unformat_input_t *input = vam->input;
16171 vl_api_one_rloc_probe_enable_disable_t *mp;
16176 /* Parse args required to build the message */
16177 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16179 if (unformat (input, "enable"))
16184 else if (unformat (input, "disable"))
16192 errmsg ("Value not set");
16196 /* Construct the API message */
16197 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16199 mp->is_enabled = is_en;
16204 /* Wait for a reply... */
16209 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16212 api_one_map_register_enable_disable (vat_main_t * vam)
16214 unformat_input_t *input = vam->input;
16215 vl_api_one_map_register_enable_disable_t *mp;
16220 /* Parse args required to build the message */
16221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16223 if (unformat (input, "enable"))
16228 else if (unformat (input, "disable"))
16236 errmsg ("Value not set");
16240 /* Construct the API message */
16241 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16243 mp->is_enabled = is_en;
16248 /* Wait for a reply... */
16253 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16256 api_one_enable_disable (vat_main_t * vam)
16258 unformat_input_t *input = vam->input;
16259 vl_api_one_enable_disable_t *mp;
16264 /* Parse args required to build the message */
16265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16267 if (unformat (input, "enable"))
16272 else if (unformat (input, "disable"))
16282 errmsg ("Value not set");
16286 /* Construct the API message */
16287 M (ONE_ENABLE_DISABLE, mp);
16294 /* Wait for a reply... */
16299 #define api_lisp_enable_disable api_one_enable_disable
16302 api_show_one_map_register_state (vat_main_t * vam)
16304 vl_api_show_one_map_register_state_t *mp;
16307 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16312 /* wait for reply */
16317 #define api_show_lisp_map_register_state api_show_one_map_register_state
16320 api_show_one_rloc_probe_state (vat_main_t * vam)
16322 vl_api_show_one_rloc_probe_state_t *mp;
16325 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16330 /* wait for reply */
16335 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16338 api_one_add_del_ndp_entry (vat_main_t * vam)
16340 vl_api_one_add_del_ndp_entry_t *mp;
16341 unformat_input_t *input = vam->input;
16346 u8 mac[6] = { 0, };
16347 u8 ip6[16] = { 0, };
16351 /* Parse args required to build the message */
16352 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16354 if (unformat (input, "del"))
16356 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16358 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16360 else if (unformat (input, "bd %d", &bd))
16364 errmsg ("parse error '%U'", format_unformat_error, input);
16369 if (!bd_set || !ip_set || (!mac_set && is_add))
16371 errmsg ("Missing BD, IP or MAC!");
16375 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16376 mp->is_add = is_add;
16377 clib_memcpy (mp->mac, mac, 6);
16378 mp->bd = clib_host_to_net_u32 (bd);
16379 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16384 /* wait for reply */
16390 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16392 vl_api_one_add_del_l2_arp_entry_t *mp;
16393 unformat_input_t *input = vam->input;
16398 u8 mac[6] = { 0, };
16399 u32 ip4 = 0, bd = ~0;
16402 /* Parse args required to build the message */
16403 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16405 if (unformat (input, "del"))
16407 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16409 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16411 else if (unformat (input, "bd %d", &bd))
16415 errmsg ("parse error '%U'", format_unformat_error, input);
16420 if (!bd_set || !ip_set || (!mac_set && is_add))
16422 errmsg ("Missing BD, IP or MAC!");
16426 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16427 mp->is_add = is_add;
16428 clib_memcpy (mp->mac, mac, 6);
16429 mp->bd = clib_host_to_net_u32 (bd);
16435 /* wait for reply */
16441 api_one_ndp_bd_get (vat_main_t * vam)
16443 vl_api_one_ndp_bd_get_t *mp;
16446 M (ONE_NDP_BD_GET, mp);
16451 /* wait for reply */
16457 api_one_ndp_entries_get (vat_main_t * vam)
16459 vl_api_one_ndp_entries_get_t *mp;
16460 unformat_input_t *input = vam->input;
16465 /* Parse args required to build the message */
16466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16468 if (unformat (input, "bd %d", &bd))
16472 errmsg ("parse error '%U'", format_unformat_error, input);
16479 errmsg ("Expected bridge domain!");
16483 M (ONE_NDP_ENTRIES_GET, mp);
16484 mp->bd = clib_host_to_net_u32 (bd);
16489 /* wait for reply */
16495 api_one_l2_arp_bd_get (vat_main_t * vam)
16497 vl_api_one_l2_arp_bd_get_t *mp;
16500 M (ONE_L2_ARP_BD_GET, mp);
16505 /* wait for reply */
16511 api_one_l2_arp_entries_get (vat_main_t * vam)
16513 vl_api_one_l2_arp_entries_get_t *mp;
16514 unformat_input_t *input = vam->input;
16519 /* Parse args required to build the message */
16520 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16522 if (unformat (input, "bd %d", &bd))
16526 errmsg ("parse error '%U'", format_unformat_error, input);
16533 errmsg ("Expected bridge domain!");
16537 M (ONE_L2_ARP_ENTRIES_GET, mp);
16538 mp->bd = clib_host_to_net_u32 (bd);
16543 /* wait for reply */
16549 api_one_stats_enable_disable (vat_main_t * vam)
16551 vl_api_one_stats_enable_disable_t *mp;
16552 unformat_input_t *input = vam->input;
16557 /* Parse args required to build the message */
16558 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16560 if (unformat (input, "enable"))
16565 else if (unformat (input, "disable"))
16575 errmsg ("Value not set");
16579 M (ONE_STATS_ENABLE_DISABLE, mp);
16585 /* wait for reply */
16591 api_show_one_stats_enable_disable (vat_main_t * vam)
16593 vl_api_show_one_stats_enable_disable_t *mp;
16596 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16601 /* wait for reply */
16607 api_show_one_map_request_mode (vat_main_t * vam)
16609 vl_api_show_one_map_request_mode_t *mp;
16612 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16617 /* wait for reply */
16622 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16625 api_one_map_request_mode (vat_main_t * vam)
16627 unformat_input_t *input = vam->input;
16628 vl_api_one_map_request_mode_t *mp;
16632 /* Parse args required to build the message */
16633 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16635 if (unformat (input, "dst-only"))
16637 else if (unformat (input, "src-dst"))
16641 errmsg ("parse error '%U'", format_unformat_error, input);
16646 M (ONE_MAP_REQUEST_MODE, mp);
16653 /* wait for reply */
16658 #define api_lisp_map_request_mode api_one_map_request_mode
16661 * Enable/disable ONE proxy ITR.
16663 * @param vam vpp API test context
16664 * @return return code
16667 api_one_pitr_set_locator_set (vat_main_t * vam)
16669 u8 ls_name_set = 0;
16670 unformat_input_t *input = vam->input;
16671 vl_api_one_pitr_set_locator_set_t *mp;
16676 /* Parse args required to build the message */
16677 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16679 if (unformat (input, "del"))
16681 else if (unformat (input, "locator-set %s", &ls_name))
16685 errmsg ("parse error '%U'", format_unformat_error, input);
16692 errmsg ("locator-set name not set!");
16696 M (ONE_PITR_SET_LOCATOR_SET, mp);
16698 mp->is_add = is_add;
16699 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16700 vec_free (ls_name);
16705 /* wait for reply */
16710 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16713 api_one_nsh_set_locator_set (vat_main_t * vam)
16715 u8 ls_name_set = 0;
16716 unformat_input_t *input = vam->input;
16717 vl_api_one_nsh_set_locator_set_t *mp;
16722 /* Parse args required to build the message */
16723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16725 if (unformat (input, "del"))
16727 else if (unformat (input, "ls %s", &ls_name))
16731 errmsg ("parse error '%U'", format_unformat_error, input);
16736 if (!ls_name_set && is_add)
16738 errmsg ("locator-set name not set!");
16742 M (ONE_NSH_SET_LOCATOR_SET, mp);
16744 mp->is_add = is_add;
16745 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16746 vec_free (ls_name);
16751 /* wait for reply */
16757 api_show_one_pitr (vat_main_t * vam)
16759 vl_api_show_one_pitr_t *mp;
16762 if (!vam->json_output)
16764 print (vam->ofp, "%=20s", "lisp status:");
16767 M (SHOW_ONE_PITR, mp);
16771 /* Wait for a reply... */
16776 #define api_show_lisp_pitr api_show_one_pitr
16779 api_one_use_petr (vat_main_t * vam)
16781 unformat_input_t *input = vam->input;
16782 vl_api_one_use_petr_t *mp;
16787 memset (&ip, 0, sizeof (ip));
16789 /* Parse args required to build the message */
16790 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16792 if (unformat (input, "disable"))
16795 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16798 ip_addr_version (&ip) = IP4;
16801 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16804 ip_addr_version (&ip) = IP6;
16808 errmsg ("parse error '%U'", format_unformat_error, input);
16813 M (ONE_USE_PETR, mp);
16815 mp->is_add = is_add;
16818 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16820 clib_memcpy (mp->address, &ip, 4);
16822 clib_memcpy (mp->address, &ip, 16);
16828 /* wait for reply */
16833 #define api_lisp_use_petr api_one_use_petr
16836 api_show_one_nsh_mapping (vat_main_t * vam)
16838 vl_api_show_one_use_petr_t *mp;
16841 if (!vam->json_output)
16843 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16846 M (SHOW_ONE_NSH_MAPPING, mp);
16850 /* Wait for a reply... */
16856 api_show_one_use_petr (vat_main_t * vam)
16858 vl_api_show_one_use_petr_t *mp;
16861 if (!vam->json_output)
16863 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16866 M (SHOW_ONE_USE_PETR, mp);
16870 /* Wait for a reply... */
16875 #define api_show_lisp_use_petr api_show_one_use_petr
16878 * Add/delete mapping between vni and vrf
16881 api_one_eid_table_add_del_map (vat_main_t * vam)
16883 unformat_input_t *input = vam->input;
16884 vl_api_one_eid_table_add_del_map_t *mp;
16885 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16886 u32 vni, vrf, bd_index;
16889 /* Parse args required to build the message */
16890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16892 if (unformat (input, "del"))
16894 else if (unformat (input, "vrf %d", &vrf))
16896 else if (unformat (input, "bd_index %d", &bd_index))
16898 else if (unformat (input, "vni %d", &vni))
16904 if (!vni_set || (!vrf_set && !bd_index_set))
16906 errmsg ("missing arguments!");
16910 if (vrf_set && bd_index_set)
16912 errmsg ("error: both vrf and bd entered!");
16916 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16918 mp->is_add = is_add;
16919 mp->vni = htonl (vni);
16920 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16921 mp->is_l2 = bd_index_set;
16926 /* wait for reply */
16931 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16934 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16936 u32 *action = va_arg (*args, u32 *);
16939 if (unformat (input, "%s", &s))
16941 if (!strcmp ((char *) s, "no-action"))
16943 else if (!strcmp ((char *) s, "natively-forward"))
16945 else if (!strcmp ((char *) s, "send-map-request"))
16947 else if (!strcmp ((char *) s, "drop"))
16951 clib_warning ("invalid action: '%s'", s);
16963 * Add/del remote mapping to/from ONE control plane
16965 * @param vam vpp API test context
16966 * @return return code
16969 api_one_add_del_remote_mapping (vat_main_t * vam)
16971 unformat_input_t *input = vam->input;
16972 vl_api_one_add_del_remote_mapping_t *mp;
16974 lisp_eid_vat_t _eid, *eid = &_eid;
16975 lisp_eid_vat_t _seid, *seid = &_seid;
16976 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16977 u32 action = ~0, p, w, data_len;
16978 ip4_address_t rloc4;
16979 ip6_address_t rloc6;
16980 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16983 memset (&rloc, 0, sizeof (rloc));
16985 /* Parse args required to build the message */
16986 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16988 if (unformat (input, "del-all"))
16992 else if (unformat (input, "del"))
16996 else if (unformat (input, "add"))
17000 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17004 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17008 else if (unformat (input, "vni %d", &vni))
17012 else if (unformat (input, "p %d w %d", &p, &w))
17016 errmsg ("No RLOC configured for setting priority/weight!");
17019 curr_rloc->priority = p;
17020 curr_rloc->weight = w;
17022 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17025 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17026 vec_add1 (rlocs, rloc);
17027 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17029 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17032 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17033 vec_add1 (rlocs, rloc);
17034 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17036 else if (unformat (input, "action %U",
17037 unformat_negative_mapping_action, &action))
17043 clib_warning ("parse error '%U'", format_unformat_error, input);
17050 errmsg ("missing params!");
17054 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17056 errmsg ("no action set for negative map-reply!");
17060 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17062 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17063 mp->is_add = is_add;
17064 mp->vni = htonl (vni);
17065 mp->action = (u8) action;
17066 mp->is_src_dst = seid_set;
17067 mp->eid_len = eid->len;
17068 mp->seid_len = seid->len;
17069 mp->del_all = del_all;
17070 mp->eid_type = eid->type;
17071 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17072 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17074 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17075 clib_memcpy (mp->rlocs, rlocs, data_len);
17081 /* Wait for a reply... */
17086 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17089 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17090 * forwarding entries in data-plane accordingly.
17092 * @param vam vpp API test context
17093 * @return return code
17096 api_one_add_del_adjacency (vat_main_t * vam)
17098 unformat_input_t *input = vam->input;
17099 vl_api_one_add_del_adjacency_t *mp;
17101 ip4_address_t leid4, reid4;
17102 ip6_address_t leid6, reid6;
17103 u8 reid_mac[6] = { 0 };
17104 u8 leid_mac[6] = { 0 };
17105 u8 reid_type, leid_type;
17106 u32 leid_len = 0, reid_len = 0, len;
17110 leid_type = reid_type = (u8) ~ 0;
17112 /* Parse args required to build the message */
17113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17115 if (unformat (input, "del"))
17119 else if (unformat (input, "add"))
17123 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17126 reid_type = 0; /* ipv4 */
17129 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17132 reid_type = 1; /* ipv6 */
17135 else if (unformat (input, "reid %U", unformat_ethernet_address,
17138 reid_type = 2; /* mac */
17140 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17143 leid_type = 0; /* ipv4 */
17146 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17149 leid_type = 1; /* ipv6 */
17152 else if (unformat (input, "leid %U", unformat_ethernet_address,
17155 leid_type = 2; /* mac */
17157 else if (unformat (input, "vni %d", &vni))
17163 errmsg ("parse error '%U'", format_unformat_error, input);
17168 if ((u8) ~ 0 == reid_type)
17170 errmsg ("missing params!");
17174 if (leid_type != reid_type)
17176 errmsg ("remote and local EIDs are of different types!");
17180 M (ONE_ADD_DEL_ADJACENCY, mp);
17181 mp->is_add = is_add;
17182 mp->vni = htonl (vni);
17183 mp->leid_len = leid_len;
17184 mp->reid_len = reid_len;
17185 mp->eid_type = reid_type;
17187 switch (mp->eid_type)
17190 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17191 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17194 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17195 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17198 clib_memcpy (mp->leid, leid_mac, 6);
17199 clib_memcpy (mp->reid, reid_mac, 6);
17202 errmsg ("unknown EID type %d!", mp->eid_type);
17209 /* Wait for a reply... */
17214 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17217 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17219 u32 *mode = va_arg (*args, u32 *);
17221 if (unformat (input, "lisp"))
17223 else if (unformat (input, "vxlan"))
17232 api_gpe_get_encap_mode (vat_main_t * vam)
17234 vl_api_gpe_get_encap_mode_t *mp;
17237 /* Construct the API message */
17238 M (GPE_GET_ENCAP_MODE, mp);
17243 /* Wait for a reply... */
17249 api_gpe_set_encap_mode (vat_main_t * vam)
17251 unformat_input_t *input = vam->input;
17252 vl_api_gpe_set_encap_mode_t *mp;
17256 /* Parse args required to build the message */
17257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17259 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17265 /* Construct the API message */
17266 M (GPE_SET_ENCAP_MODE, mp);
17273 /* Wait for a reply... */
17279 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17281 unformat_input_t *input = vam->input;
17282 vl_api_gpe_add_del_iface_t *mp;
17283 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17284 u32 dp_table = 0, vni = 0;
17287 /* Parse args required to build the message */
17288 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17290 if (unformat (input, "up"))
17295 else if (unformat (input, "down"))
17300 else if (unformat (input, "table_id %d", &dp_table))
17304 else if (unformat (input, "bd_id %d", &dp_table))
17309 else if (unformat (input, "vni %d", &vni))
17317 if (action_set == 0)
17319 errmsg ("Action not set");
17322 if (dp_table_set == 0 || vni_set == 0)
17324 errmsg ("vni and dp_table must be set");
17328 /* Construct the API message */
17329 M (GPE_ADD_DEL_IFACE, mp);
17331 mp->is_add = is_add;
17332 mp->dp_table = clib_host_to_net_u32 (dp_table);
17334 mp->vni = clib_host_to_net_u32 (vni);
17339 /* Wait for a reply... */
17345 api_one_map_register_fallback_threshold (vat_main_t * vam)
17347 unformat_input_t *input = vam->input;
17348 vl_api_one_map_register_fallback_threshold_t *mp;
17353 /* Parse args required to build the message */
17354 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17356 if (unformat (input, "%u", &value))
17360 clib_warning ("parse error '%U'", format_unformat_error, input);
17367 errmsg ("fallback threshold value is missing!");
17371 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17372 mp->value = clib_host_to_net_u32 (value);
17377 /* Wait for a reply... */
17383 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17385 vl_api_show_one_map_register_fallback_threshold_t *mp;
17388 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17393 /* Wait for a reply... */
17399 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17401 u32 *proto = va_arg (*args, u32 *);
17403 if (unformat (input, "udp"))
17405 else if (unformat (input, "api"))
17414 api_one_set_transport_protocol (vat_main_t * vam)
17416 unformat_input_t *input = vam->input;
17417 vl_api_one_set_transport_protocol_t *mp;
17422 /* Parse args required to build the message */
17423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17425 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17429 clib_warning ("parse error '%U'", format_unformat_error, input);
17436 errmsg ("Transport protocol missing!");
17440 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17441 mp->protocol = (u8) protocol;
17446 /* Wait for a reply... */
17452 api_one_get_transport_protocol (vat_main_t * vam)
17454 vl_api_one_get_transport_protocol_t *mp;
17457 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17462 /* Wait for a reply... */
17468 api_one_map_register_set_ttl (vat_main_t * vam)
17470 unformat_input_t *input = vam->input;
17471 vl_api_one_map_register_set_ttl_t *mp;
17476 /* Parse args required to build the message */
17477 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17479 if (unformat (input, "%u", &ttl))
17483 clib_warning ("parse error '%U'", format_unformat_error, input);
17490 errmsg ("TTL value missing!");
17494 M (ONE_MAP_REGISTER_SET_TTL, mp);
17495 mp->ttl = clib_host_to_net_u32 (ttl);
17500 /* Wait for a reply... */
17506 api_show_one_map_register_ttl (vat_main_t * vam)
17508 vl_api_show_one_map_register_ttl_t *mp;
17511 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17516 /* Wait for a reply... */
17522 * Add/del map request itr rlocs from ONE control plane and updates
17524 * @param vam vpp API test context
17525 * @return return code
17528 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17530 unformat_input_t *input = vam->input;
17531 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17532 u8 *locator_set_name = 0;
17533 u8 locator_set_name_set = 0;
17537 /* Parse args required to build the message */
17538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17540 if (unformat (input, "del"))
17544 else if (unformat (input, "%_%v%_", &locator_set_name))
17546 locator_set_name_set = 1;
17550 clib_warning ("parse error '%U'", format_unformat_error, input);
17555 if (is_add && !locator_set_name_set)
17557 errmsg ("itr-rloc is not set!");
17561 if (is_add && vec_len (locator_set_name) > 64)
17563 errmsg ("itr-rloc locator-set name too long");
17564 vec_free (locator_set_name);
17568 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17569 mp->is_add = is_add;
17572 clib_memcpy (mp->locator_set_name, locator_set_name,
17573 vec_len (locator_set_name));
17577 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17579 vec_free (locator_set_name);
17584 /* Wait for a reply... */
17589 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17592 api_one_locator_dump (vat_main_t * vam)
17594 unformat_input_t *input = vam->input;
17595 vl_api_one_locator_dump_t *mp;
17596 vl_api_control_ping_t *mp_ping;
17597 u8 is_index_set = 0, is_name_set = 0;
17602 /* Parse args required to build the message */
17603 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17605 if (unformat (input, "ls_name %_%v%_", &ls_name))
17609 else if (unformat (input, "ls_index %d", &ls_index))
17615 errmsg ("parse error '%U'", format_unformat_error, input);
17620 if (!is_index_set && !is_name_set)
17622 errmsg ("error: expected one of index or name!");
17626 if (is_index_set && is_name_set)
17628 errmsg ("error: only one param expected!");
17632 if (vec_len (ls_name) > 62)
17634 errmsg ("error: locator set name too long!");
17638 if (!vam->json_output)
17640 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17643 M (ONE_LOCATOR_DUMP, mp);
17644 mp->is_index_set = is_index_set;
17647 mp->ls_index = clib_host_to_net_u32 (ls_index);
17650 vec_add1 (ls_name, 0);
17651 strncpy ((char *) mp->ls_name, (char *) ls_name,
17652 sizeof (mp->ls_name) - 1);
17658 /* Use a control ping for synchronization */
17659 MPING (CONTROL_PING, mp_ping);
17662 /* Wait for a reply... */
17667 #define api_lisp_locator_dump api_one_locator_dump
17670 api_one_locator_set_dump (vat_main_t * vam)
17672 vl_api_one_locator_set_dump_t *mp;
17673 vl_api_control_ping_t *mp_ping;
17674 unformat_input_t *input = vam->input;
17678 /* Parse args required to build the message */
17679 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17681 if (unformat (input, "local"))
17685 else if (unformat (input, "remote"))
17691 errmsg ("parse error '%U'", format_unformat_error, input);
17696 if (!vam->json_output)
17698 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17701 M (ONE_LOCATOR_SET_DUMP, mp);
17703 mp->filter = filter;
17708 /* Use a control ping for synchronization */
17709 MPING (CONTROL_PING, mp_ping);
17712 /* Wait for a reply... */
17717 #define api_lisp_locator_set_dump api_one_locator_set_dump
17720 api_one_eid_table_map_dump (vat_main_t * vam)
17724 unformat_input_t *input = vam->input;
17725 vl_api_one_eid_table_map_dump_t *mp;
17726 vl_api_control_ping_t *mp_ping;
17729 /* Parse args required to build the message */
17730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17732 if (unformat (input, "l2"))
17737 else if (unformat (input, "l3"))
17744 errmsg ("parse error '%U'", format_unformat_error, input);
17751 errmsg ("expected one of 'l2' or 'l3' parameter!");
17755 if (!vam->json_output)
17757 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17760 M (ONE_EID_TABLE_MAP_DUMP, mp);
17766 /* Use a control ping for synchronization */
17767 MPING (CONTROL_PING, mp_ping);
17770 /* Wait for a reply... */
17775 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17778 api_one_eid_table_vni_dump (vat_main_t * vam)
17780 vl_api_one_eid_table_vni_dump_t *mp;
17781 vl_api_control_ping_t *mp_ping;
17784 if (!vam->json_output)
17786 print (vam->ofp, "VNI");
17789 M (ONE_EID_TABLE_VNI_DUMP, mp);
17794 /* Use a control ping for synchronization */
17795 MPING (CONTROL_PING, mp_ping);
17798 /* Wait for a reply... */
17803 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17806 api_one_eid_table_dump (vat_main_t * vam)
17808 unformat_input_t *i = vam->input;
17809 vl_api_one_eid_table_dump_t *mp;
17810 vl_api_control_ping_t *mp_ping;
17811 struct in_addr ip4;
17812 struct in6_addr ip6;
17814 u8 eid_type = ~0, eid_set = 0;
17815 u32 prefix_length = ~0, t, vni = 0;
17818 lisp_nsh_api_t nsh;
17820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17822 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17828 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17834 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17839 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17844 else if (unformat (i, "vni %d", &t))
17848 else if (unformat (i, "local"))
17852 else if (unformat (i, "remote"))
17858 errmsg ("parse error '%U'", format_unformat_error, i);
17863 if (!vam->json_output)
17865 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17866 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17869 M (ONE_EID_TABLE_DUMP, mp);
17871 mp->filter = filter;
17875 mp->vni = htonl (vni);
17876 mp->eid_type = eid_type;
17880 mp->prefix_length = prefix_length;
17881 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17884 mp->prefix_length = prefix_length;
17885 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17888 clib_memcpy (mp->eid, mac, sizeof (mac));
17891 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17894 errmsg ("unknown EID type %d!", eid_type);
17902 /* Use a control ping for synchronization */
17903 MPING (CONTROL_PING, mp_ping);
17906 /* Wait for a reply... */
17911 #define api_lisp_eid_table_dump api_one_eid_table_dump
17914 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17916 unformat_input_t *i = vam->input;
17917 vl_api_gpe_fwd_entries_get_t *mp;
17922 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17924 if (unformat (i, "vni %d", &vni))
17930 errmsg ("parse error '%U'", format_unformat_error, i);
17937 errmsg ("vni not set!");
17941 if (!vam->json_output)
17943 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17947 M (GPE_FWD_ENTRIES_GET, mp);
17948 mp->vni = clib_host_to_net_u32 (vni);
17953 /* Wait for a reply... */
17958 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17959 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17960 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17961 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17962 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17963 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17964 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17965 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17968 api_one_adjacencies_get (vat_main_t * vam)
17970 unformat_input_t *i = vam->input;
17971 vl_api_one_adjacencies_get_t *mp;
17976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17978 if (unformat (i, "vni %d", &vni))
17984 errmsg ("parse error '%U'", format_unformat_error, i);
17991 errmsg ("vni not set!");
17995 if (!vam->json_output)
17997 print (vam->ofp, "%s %40s", "leid", "reid");
18000 M (ONE_ADJACENCIES_GET, mp);
18001 mp->vni = clib_host_to_net_u32 (vni);
18006 /* Wait for a reply... */
18011 #define api_lisp_adjacencies_get api_one_adjacencies_get
18014 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18016 unformat_input_t *i = vam->input;
18017 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18019 u8 ip_family_set = 0, is_ip4 = 1;
18021 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18023 if (unformat (i, "ip4"))
18028 else if (unformat (i, "ip6"))
18035 errmsg ("parse error '%U'", format_unformat_error, i);
18040 if (!ip_family_set)
18042 errmsg ("ip family not set!");
18046 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18047 mp->is_ip4 = is_ip4;
18052 /* Wait for a reply... */
18058 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18060 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18063 if (!vam->json_output)
18065 print (vam->ofp, "VNIs");
18068 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18073 /* Wait for a reply... */
18079 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18081 unformat_input_t *i = vam->input;
18082 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18084 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18085 struct in_addr ip4;
18086 struct in6_addr ip6;
18087 u32 table_id = 0, nh_sw_if_index = ~0;
18089 memset (&ip4, 0, sizeof (ip4));
18090 memset (&ip6, 0, sizeof (ip6));
18092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18094 if (unformat (i, "del"))
18096 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18097 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18102 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18103 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18108 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18112 nh_sw_if_index = ~0;
18114 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18118 nh_sw_if_index = ~0;
18120 else if (unformat (i, "table %d", &table_id))
18124 errmsg ("parse error '%U'", format_unformat_error, i);
18131 errmsg ("nh addr not set!");
18135 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18136 mp->is_add = is_add;
18137 mp->table_id = clib_host_to_net_u32 (table_id);
18138 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18139 mp->is_ip4 = is_ip4;
18141 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18143 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18148 /* Wait for a reply... */
18154 api_one_map_server_dump (vat_main_t * vam)
18156 vl_api_one_map_server_dump_t *mp;
18157 vl_api_control_ping_t *mp_ping;
18160 if (!vam->json_output)
18162 print (vam->ofp, "%=20s", "Map server");
18165 M (ONE_MAP_SERVER_DUMP, mp);
18169 /* Use a control ping for synchronization */
18170 MPING (CONTROL_PING, mp_ping);
18173 /* Wait for a reply... */
18178 #define api_lisp_map_server_dump api_one_map_server_dump
18181 api_one_map_resolver_dump (vat_main_t * vam)
18183 vl_api_one_map_resolver_dump_t *mp;
18184 vl_api_control_ping_t *mp_ping;
18187 if (!vam->json_output)
18189 print (vam->ofp, "%=20s", "Map resolver");
18192 M (ONE_MAP_RESOLVER_DUMP, mp);
18196 /* Use a control ping for synchronization */
18197 MPING (CONTROL_PING, mp_ping);
18200 /* Wait for a reply... */
18205 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18208 api_one_stats_flush (vat_main_t * vam)
18210 vl_api_one_stats_flush_t *mp;
18213 M (ONE_STATS_FLUSH, mp);
18220 api_one_stats_dump (vat_main_t * vam)
18222 vl_api_one_stats_dump_t *mp;
18223 vl_api_control_ping_t *mp_ping;
18226 M (ONE_STATS_DUMP, mp);
18230 /* Use a control ping for synchronization */
18231 MPING (CONTROL_PING, mp_ping);
18234 /* Wait for a reply... */
18240 api_show_one_status (vat_main_t * vam)
18242 vl_api_show_one_status_t *mp;
18245 if (!vam->json_output)
18247 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18250 M (SHOW_ONE_STATUS, mp);
18253 /* Wait for a reply... */
18258 #define api_show_lisp_status api_show_one_status
18261 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18263 vl_api_gpe_fwd_entry_path_dump_t *mp;
18264 vl_api_control_ping_t *mp_ping;
18265 unformat_input_t *i = vam->input;
18266 u32 fwd_entry_index = ~0;
18269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18271 if (unformat (i, "index %d", &fwd_entry_index))
18277 if (~0 == fwd_entry_index)
18279 errmsg ("no index specified!");
18283 if (!vam->json_output)
18285 print (vam->ofp, "first line");
18288 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18292 /* Use a control ping for synchronization */
18293 MPING (CONTROL_PING, mp_ping);
18296 /* Wait for a reply... */
18302 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18304 vl_api_one_get_map_request_itr_rlocs_t *mp;
18307 if (!vam->json_output)
18309 print (vam->ofp, "%=20s", "itr-rlocs:");
18312 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18315 /* Wait for a reply... */
18320 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18323 api_af_packet_create (vat_main_t * vam)
18325 unformat_input_t *i = vam->input;
18326 vl_api_af_packet_create_t *mp;
18327 u8 *host_if_name = 0;
18329 u8 random_hw_addr = 1;
18332 memset (hw_addr, 0, sizeof (hw_addr));
18334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18336 if (unformat (i, "name %s", &host_if_name))
18337 vec_add1 (host_if_name, 0);
18338 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18339 random_hw_addr = 0;
18344 if (!vec_len (host_if_name))
18346 errmsg ("host-interface name must be specified");
18350 if (vec_len (host_if_name) > 64)
18352 errmsg ("host-interface name too long");
18356 M (AF_PACKET_CREATE, mp);
18358 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18359 clib_memcpy (mp->hw_addr, hw_addr, 6);
18360 mp->use_random_hw_addr = random_hw_addr;
18361 vec_free (host_if_name);
18369 fprintf (vam->ofp ? vam->ofp : stderr,
18370 " new sw_if_index = %d\n", vam->sw_if_index);
18377 api_af_packet_delete (vat_main_t * vam)
18379 unformat_input_t *i = vam->input;
18380 vl_api_af_packet_delete_t *mp;
18381 u8 *host_if_name = 0;
18384 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18386 if (unformat (i, "name %s", &host_if_name))
18387 vec_add1 (host_if_name, 0);
18392 if (!vec_len (host_if_name))
18394 errmsg ("host-interface name must be specified");
18398 if (vec_len (host_if_name) > 64)
18400 errmsg ("host-interface name too long");
18404 M (AF_PACKET_DELETE, mp);
18406 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18407 vec_free (host_if_name);
18415 api_policer_add_del (vat_main_t * vam)
18417 unformat_input_t *i = vam->input;
18418 vl_api_policer_add_del_t *mp;
18428 u8 color_aware = 0;
18429 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18432 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18433 conform_action.dscp = 0;
18434 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18435 exceed_action.dscp = 0;
18436 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18437 violate_action.dscp = 0;
18439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18441 if (unformat (i, "del"))
18443 else if (unformat (i, "name %s", &name))
18444 vec_add1 (name, 0);
18445 else if (unformat (i, "cir %u", &cir))
18447 else if (unformat (i, "eir %u", &eir))
18449 else if (unformat (i, "cb %u", &cb))
18451 else if (unformat (i, "eb %u", &eb))
18453 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18456 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18459 else if (unformat (i, "type %U", unformat_policer_type, &type))
18461 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18464 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18467 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18470 else if (unformat (i, "color-aware"))
18476 if (!vec_len (name))
18478 errmsg ("policer name must be specified");
18482 if (vec_len (name) > 64)
18484 errmsg ("policer name too long");
18488 M (POLICER_ADD_DEL, mp);
18490 clib_memcpy (mp->name, name, vec_len (name));
18492 mp->is_add = is_add;
18493 mp->cir = ntohl (cir);
18494 mp->eir = ntohl (eir);
18495 mp->cb = clib_net_to_host_u64 (cb);
18496 mp->eb = clib_net_to_host_u64 (eb);
18497 mp->rate_type = rate_type;
18498 mp->round_type = round_type;
18500 mp->conform_action_type = conform_action.action_type;
18501 mp->conform_dscp = conform_action.dscp;
18502 mp->exceed_action_type = exceed_action.action_type;
18503 mp->exceed_dscp = exceed_action.dscp;
18504 mp->violate_action_type = violate_action.action_type;
18505 mp->violate_dscp = violate_action.dscp;
18506 mp->color_aware = color_aware;
18514 api_policer_dump (vat_main_t * vam)
18516 unformat_input_t *i = vam->input;
18517 vl_api_policer_dump_t *mp;
18518 vl_api_control_ping_t *mp_ping;
18519 u8 *match_name = 0;
18520 u8 match_name_valid = 0;
18523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18525 if (unformat (i, "name %s", &match_name))
18527 vec_add1 (match_name, 0);
18528 match_name_valid = 1;
18534 M (POLICER_DUMP, mp);
18535 mp->match_name_valid = match_name_valid;
18536 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18537 vec_free (match_name);
18541 /* Use a control ping for synchronization */
18542 MPING (CONTROL_PING, mp_ping);
18545 /* Wait for a reply... */
18551 api_policer_classify_set_interface (vat_main_t * vam)
18553 unformat_input_t *i = vam->input;
18554 vl_api_policer_classify_set_interface_t *mp;
18556 int sw_if_index_set;
18557 u32 ip4_table_index = ~0;
18558 u32 ip6_table_index = ~0;
18559 u32 l2_table_index = ~0;
18563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18565 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18566 sw_if_index_set = 1;
18567 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18568 sw_if_index_set = 1;
18569 else if (unformat (i, "del"))
18571 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18573 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18575 else if (unformat (i, "l2-table %d", &l2_table_index))
18579 clib_warning ("parse error '%U'", format_unformat_error, i);
18584 if (sw_if_index_set == 0)
18586 errmsg ("missing interface name or sw_if_index");
18590 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18592 mp->sw_if_index = ntohl (sw_if_index);
18593 mp->ip4_table_index = ntohl (ip4_table_index);
18594 mp->ip6_table_index = ntohl (ip6_table_index);
18595 mp->l2_table_index = ntohl (l2_table_index);
18596 mp->is_add = is_add;
18604 api_policer_classify_dump (vat_main_t * vam)
18606 unformat_input_t *i = vam->input;
18607 vl_api_policer_classify_dump_t *mp;
18608 vl_api_control_ping_t *mp_ping;
18609 u8 type = POLICER_CLASSIFY_N_TABLES;
18612 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18616 errmsg ("classify table type must be specified");
18620 if (!vam->json_output)
18622 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18625 M (POLICER_CLASSIFY_DUMP, mp);
18630 /* Use a control ping for synchronization */
18631 MPING (CONTROL_PING, mp_ping);
18634 /* Wait for a reply... */
18640 api_netmap_create (vat_main_t * vam)
18642 unformat_input_t *i = vam->input;
18643 vl_api_netmap_create_t *mp;
18646 u8 random_hw_addr = 1;
18651 memset (hw_addr, 0, sizeof (hw_addr));
18653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18655 if (unformat (i, "name %s", &if_name))
18656 vec_add1 (if_name, 0);
18657 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18658 random_hw_addr = 0;
18659 else if (unformat (i, "pipe"))
18661 else if (unformat (i, "master"))
18663 else if (unformat (i, "slave"))
18669 if (!vec_len (if_name))
18671 errmsg ("interface name must be specified");
18675 if (vec_len (if_name) > 64)
18677 errmsg ("interface name too long");
18681 M (NETMAP_CREATE, mp);
18683 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18684 clib_memcpy (mp->hw_addr, hw_addr, 6);
18685 mp->use_random_hw_addr = random_hw_addr;
18686 mp->is_pipe = is_pipe;
18687 mp->is_master = is_master;
18688 vec_free (if_name);
18696 api_netmap_delete (vat_main_t * vam)
18698 unformat_input_t *i = vam->input;
18699 vl_api_netmap_delete_t *mp;
18703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18705 if (unformat (i, "name %s", &if_name))
18706 vec_add1 (if_name, 0);
18711 if (!vec_len (if_name))
18713 errmsg ("interface name must be specified");
18717 if (vec_len (if_name) > 64)
18719 errmsg ("interface name too long");
18723 M (NETMAP_DELETE, mp);
18725 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18726 vec_free (if_name);
18734 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
18736 if (fp->afi == IP46_TYPE_IP6)
18738 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18739 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18740 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18741 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18742 format_ip6_address, fp->next_hop);
18743 else if (fp->afi == IP46_TYPE_IP4)
18745 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18746 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18747 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18748 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18749 format_ip4_address, fp->next_hop);
18753 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18754 vl_api_fib_path2_t * fp)
18756 struct in_addr ip4;
18757 struct in6_addr ip6;
18759 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18760 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18761 vat_json_object_add_uint (node, "is_local", fp->is_local);
18762 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18763 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18764 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18765 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18766 if (fp->afi == IP46_TYPE_IP4)
18768 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18769 vat_json_object_add_ip4 (node, "next_hop", ip4);
18771 else if (fp->afi == IP46_TYPE_IP6)
18773 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18774 vat_json_object_add_ip6 (node, "next_hop", ip6);
18779 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18781 vat_main_t *vam = &vat_main;
18782 int count = ntohl (mp->mt_count);
18783 vl_api_fib_path2_t *fp;
18786 print (vam->ofp, "[%d]: sw_if_index %d via:",
18787 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
18789 for (i = 0; i < count; i++)
18791 vl_api_mpls_fib_path_print (vam, fp);
18795 print (vam->ofp, "");
18798 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18799 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18802 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18804 vat_main_t *vam = &vat_main;
18805 vat_json_node_t *node = NULL;
18806 int count = ntohl (mp->mt_count);
18807 vl_api_fib_path2_t *fp;
18810 if (VAT_JSON_ARRAY != vam->json_tree.type)
18812 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18813 vat_json_init_array (&vam->json_tree);
18815 node = vat_json_array_add (&vam->json_tree);
18817 vat_json_init_object (node);
18818 vat_json_object_add_uint (node, "tunnel_index",
18819 ntohl (mp->mt_tunnel_index));
18820 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
18822 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
18825 for (i = 0; i < count; i++)
18827 vl_api_mpls_fib_path_json_print (node, fp);
18833 api_mpls_tunnel_dump (vat_main_t * vam)
18835 vl_api_mpls_tunnel_dump_t *mp;
18836 vl_api_control_ping_t *mp_ping;
18840 /* Parse args required to build the message */
18841 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
18843 if (!unformat (vam->input, "tunnel_index %d", &index))
18850 print (vam->ofp, " tunnel_index %d", index);
18852 M (MPLS_TUNNEL_DUMP, mp);
18853 mp->tunnel_index = htonl (index);
18856 /* Use a control ping for synchronization */
18857 MPING (CONTROL_PING, mp_ping);
18864 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
18865 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18869 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18871 vat_main_t *vam = &vat_main;
18872 int count = ntohl (mp->count);
18873 vl_api_fib_path2_t *fp;
18877 "table-id %d, label %u, ess_bit %u",
18878 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18880 for (i = 0; i < count; i++)
18882 vl_api_mpls_fib_path_print (vam, fp);
18887 static void vl_api_mpls_fib_details_t_handler_json
18888 (vl_api_mpls_fib_details_t * mp)
18890 vat_main_t *vam = &vat_main;
18891 int count = ntohl (mp->count);
18892 vat_json_node_t *node = NULL;
18893 vl_api_fib_path2_t *fp;
18896 if (VAT_JSON_ARRAY != vam->json_tree.type)
18898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18899 vat_json_init_array (&vam->json_tree);
18901 node = vat_json_array_add (&vam->json_tree);
18903 vat_json_init_object (node);
18904 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18905 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18906 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18907 vat_json_object_add_uint (node, "path_count", count);
18909 for (i = 0; i < count; i++)
18911 vl_api_mpls_fib_path_json_print (node, fp);
18917 api_mpls_fib_dump (vat_main_t * vam)
18919 vl_api_mpls_fib_dump_t *mp;
18920 vl_api_control_ping_t *mp_ping;
18923 M (MPLS_FIB_DUMP, mp);
18926 /* Use a control ping for synchronization */
18927 MPING (CONTROL_PING, mp_ping);
18934 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18935 #define vl_api_ip_fib_details_t_print vl_noop_handler
18938 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18940 vat_main_t *vam = &vat_main;
18941 int count = ntohl (mp->count);
18942 vl_api_fib_path_t *fp;
18946 "table-id %d, prefix %U/%d",
18947 ntohl (mp->table_id), format_ip4_address, mp->address,
18948 mp->address_length);
18950 for (i = 0; i < count; i++)
18952 if (fp->afi == IP46_TYPE_IP6)
18954 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18955 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18956 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18957 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18958 format_ip6_address, fp->next_hop);
18959 else if (fp->afi == IP46_TYPE_IP4)
18961 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18962 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18963 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18964 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18965 format_ip4_address, fp->next_hop);
18970 static void vl_api_ip_fib_details_t_handler_json
18971 (vl_api_ip_fib_details_t * mp)
18973 vat_main_t *vam = &vat_main;
18974 int count = ntohl (mp->count);
18975 vat_json_node_t *node = NULL;
18976 struct in_addr ip4;
18977 struct in6_addr ip6;
18978 vl_api_fib_path_t *fp;
18981 if (VAT_JSON_ARRAY != vam->json_tree.type)
18983 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18984 vat_json_init_array (&vam->json_tree);
18986 node = vat_json_array_add (&vam->json_tree);
18988 vat_json_init_object (node);
18989 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18990 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18991 vat_json_object_add_ip4 (node, "prefix", ip4);
18992 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18993 vat_json_object_add_uint (node, "path_count", count);
18995 for (i = 0; i < count; i++)
18997 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18998 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18999 vat_json_object_add_uint (node, "is_local", fp->is_local);
19000 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19001 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19002 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19003 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19004 if (fp->afi == IP46_TYPE_IP4)
19006 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19007 vat_json_object_add_ip4 (node, "next_hop", ip4);
19009 else if (fp->afi == IP46_TYPE_IP6)
19011 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19012 vat_json_object_add_ip6 (node, "next_hop", ip6);
19018 api_ip_fib_dump (vat_main_t * vam)
19020 vl_api_ip_fib_dump_t *mp;
19021 vl_api_control_ping_t *mp_ping;
19024 M (IP_FIB_DUMP, mp);
19027 /* Use a control ping for synchronization */
19028 MPING (CONTROL_PING, mp_ping);
19036 api_ip_mfib_dump (vat_main_t * vam)
19038 vl_api_ip_mfib_dump_t *mp;
19039 vl_api_control_ping_t *mp_ping;
19042 M (IP_MFIB_DUMP, mp);
19045 /* Use a control ping for synchronization */
19046 MPING (CONTROL_PING, mp_ping);
19053 static void vl_api_ip_neighbor_details_t_handler
19054 (vl_api_ip_neighbor_details_t * mp)
19056 vat_main_t *vam = &vat_main;
19058 print (vam->ofp, "%c %U %U",
19059 (mp->is_static) ? 'S' : 'D',
19060 format_ethernet_address, &mp->mac_address,
19061 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
19065 static void vl_api_ip_neighbor_details_t_handler_json
19066 (vl_api_ip_neighbor_details_t * mp)
19069 vat_main_t *vam = &vat_main;
19070 vat_json_node_t *node;
19071 struct in_addr ip4;
19072 struct in6_addr ip6;
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_string_copy (node, "flag",
19083 (mp->is_static) ? (u8 *) "static" : (u8 *)
19086 vat_json_object_add_string_copy (node, "link_layer",
19087 format (0, "%U", format_ethernet_address,
19088 &mp->mac_address));
19092 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
19093 vat_json_object_add_ip6 (node, "ip_address", ip6);
19097 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
19098 vat_json_object_add_ip4 (node, "ip_address", ip4);
19103 api_ip_neighbor_dump (vat_main_t * vam)
19105 unformat_input_t *i = vam->input;
19106 vl_api_ip_neighbor_dump_t *mp;
19107 vl_api_control_ping_t *mp_ping;
19109 u32 sw_if_index = ~0;
19112 /* Parse args required to build the message */
19113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19117 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19119 else if (unformat (i, "ip6"))
19125 if (sw_if_index == ~0)
19127 errmsg ("missing interface name or sw_if_index");
19131 M (IP_NEIGHBOR_DUMP, mp);
19132 mp->is_ipv6 = (u8) is_ipv6;
19133 mp->sw_if_index = ntohl (sw_if_index);
19136 /* Use a control ping for synchronization */
19137 MPING (CONTROL_PING, mp_ping);
19144 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19145 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19148 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19150 vat_main_t *vam = &vat_main;
19151 int count = ntohl (mp->count);
19152 vl_api_fib_path_t *fp;
19156 "table-id %d, prefix %U/%d",
19157 ntohl (mp->table_id), format_ip6_address, mp->address,
19158 mp->address_length);
19160 for (i = 0; i < count; i++)
19162 if (fp->afi == IP46_TYPE_IP6)
19164 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19165 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19166 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19167 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19168 format_ip6_address, fp->next_hop);
19169 else if (fp->afi == IP46_TYPE_IP4)
19171 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19172 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19173 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19174 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19175 format_ip4_address, fp->next_hop);
19180 static void vl_api_ip6_fib_details_t_handler_json
19181 (vl_api_ip6_fib_details_t * mp)
19183 vat_main_t *vam = &vat_main;
19184 int count = ntohl (mp->count);
19185 vat_json_node_t *node = NULL;
19186 struct in_addr ip4;
19187 struct in6_addr ip6;
19188 vl_api_fib_path_t *fp;
19191 if (VAT_JSON_ARRAY != vam->json_tree.type)
19193 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19194 vat_json_init_array (&vam->json_tree);
19196 node = vat_json_array_add (&vam->json_tree);
19198 vat_json_init_object (node);
19199 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19200 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19201 vat_json_object_add_ip6 (node, "prefix", ip6);
19202 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19203 vat_json_object_add_uint (node, "path_count", count);
19205 for (i = 0; i < count; i++)
19207 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19208 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19209 vat_json_object_add_uint (node, "is_local", fp->is_local);
19210 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19211 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19212 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19213 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19214 if (fp->afi == IP46_TYPE_IP4)
19216 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19217 vat_json_object_add_ip4 (node, "next_hop", ip4);
19219 else if (fp->afi == IP46_TYPE_IP6)
19221 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19222 vat_json_object_add_ip6 (node, "next_hop", ip6);
19228 api_ip6_fib_dump (vat_main_t * vam)
19230 vl_api_ip6_fib_dump_t *mp;
19231 vl_api_control_ping_t *mp_ping;
19234 M (IP6_FIB_DUMP, mp);
19237 /* Use a control ping for synchronization */
19238 MPING (CONTROL_PING, mp_ping);
19246 api_ip6_mfib_dump (vat_main_t * vam)
19248 vl_api_ip6_mfib_dump_t *mp;
19249 vl_api_control_ping_t *mp_ping;
19252 M (IP6_MFIB_DUMP, mp);
19255 /* Use a control ping for synchronization */
19256 MPING (CONTROL_PING, mp_ping);
19264 api_classify_table_ids (vat_main_t * vam)
19266 vl_api_classify_table_ids_t *mp;
19269 /* Construct the API message */
19270 M (CLASSIFY_TABLE_IDS, mp);
19279 api_classify_table_by_interface (vat_main_t * vam)
19281 unformat_input_t *input = vam->input;
19282 vl_api_classify_table_by_interface_t *mp;
19284 u32 sw_if_index = ~0;
19286 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19288 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19290 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19295 if (sw_if_index == ~0)
19297 errmsg ("missing interface name or sw_if_index");
19301 /* Construct the API message */
19302 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19304 mp->sw_if_index = ntohl (sw_if_index);
19312 api_classify_table_info (vat_main_t * vam)
19314 unformat_input_t *input = vam->input;
19315 vl_api_classify_table_info_t *mp;
19319 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19321 if (unformat (input, "table_id %d", &table_id))
19326 if (table_id == ~0)
19328 errmsg ("missing table id");
19332 /* Construct the API message */
19333 M (CLASSIFY_TABLE_INFO, mp);
19335 mp->table_id = ntohl (table_id);
19343 api_classify_session_dump (vat_main_t * vam)
19345 unformat_input_t *input = vam->input;
19346 vl_api_classify_session_dump_t *mp;
19347 vl_api_control_ping_t *mp_ping;
19351 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19353 if (unformat (input, "table_id %d", &table_id))
19358 if (table_id == ~0)
19360 errmsg ("missing table id");
19364 /* Construct the API message */
19365 M (CLASSIFY_SESSION_DUMP, mp);
19367 mp->table_id = ntohl (table_id);
19370 /* Use a control ping for synchronization */
19371 MPING (CONTROL_PING, mp_ping);
19379 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19381 vat_main_t *vam = &vat_main;
19383 print (vam->ofp, "collector_address %U, collector_port %d, "
19384 "src_address %U, vrf_id %d, path_mtu %u, "
19385 "template_interval %u, udp_checksum %d",
19386 format_ip4_address, mp->collector_address,
19387 ntohs (mp->collector_port),
19388 format_ip4_address, mp->src_address,
19389 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19390 ntohl (mp->template_interval), mp->udp_checksum);
19393 vam->result_ready = 1;
19397 vl_api_ipfix_exporter_details_t_handler_json
19398 (vl_api_ipfix_exporter_details_t * mp)
19400 vat_main_t *vam = &vat_main;
19401 vat_json_node_t node;
19402 struct in_addr collector_address;
19403 struct in_addr src_address;
19405 vat_json_init_object (&node);
19406 clib_memcpy (&collector_address, &mp->collector_address,
19407 sizeof (collector_address));
19408 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19409 vat_json_object_add_uint (&node, "collector_port",
19410 ntohs (mp->collector_port));
19411 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19412 vat_json_object_add_ip4 (&node, "src_address", src_address);
19413 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19414 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19415 vat_json_object_add_uint (&node, "template_interval",
19416 ntohl (mp->template_interval));
19417 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19419 vat_json_print (vam->ofp, &node);
19420 vat_json_free (&node);
19422 vam->result_ready = 1;
19426 api_ipfix_exporter_dump (vat_main_t * vam)
19428 vl_api_ipfix_exporter_dump_t *mp;
19431 /* Construct the API message */
19432 M (IPFIX_EXPORTER_DUMP, mp);
19441 api_ipfix_classify_stream_dump (vat_main_t * vam)
19443 vl_api_ipfix_classify_stream_dump_t *mp;
19446 /* Construct the API message */
19447 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19458 vl_api_ipfix_classify_stream_details_t_handler
19459 (vl_api_ipfix_classify_stream_details_t * mp)
19461 vat_main_t *vam = &vat_main;
19462 print (vam->ofp, "domain_id %d, src_port %d",
19463 ntohl (mp->domain_id), ntohs (mp->src_port));
19465 vam->result_ready = 1;
19469 vl_api_ipfix_classify_stream_details_t_handler_json
19470 (vl_api_ipfix_classify_stream_details_t * mp)
19472 vat_main_t *vam = &vat_main;
19473 vat_json_node_t node;
19475 vat_json_init_object (&node);
19476 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19477 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19479 vat_json_print (vam->ofp, &node);
19480 vat_json_free (&node);
19482 vam->result_ready = 1;
19486 api_ipfix_classify_table_dump (vat_main_t * vam)
19488 vl_api_ipfix_classify_table_dump_t *mp;
19489 vl_api_control_ping_t *mp_ping;
19492 if (!vam->json_output)
19494 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19495 "transport_protocol");
19498 /* Construct the API message */
19499 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19504 /* Use a control ping for synchronization */
19505 MPING (CONTROL_PING, mp_ping);
19513 vl_api_ipfix_classify_table_details_t_handler
19514 (vl_api_ipfix_classify_table_details_t * mp)
19516 vat_main_t *vam = &vat_main;
19517 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19518 mp->transport_protocol);
19522 vl_api_ipfix_classify_table_details_t_handler_json
19523 (vl_api_ipfix_classify_table_details_t * mp)
19525 vat_json_node_t *node = NULL;
19526 vat_main_t *vam = &vat_main;
19528 if (VAT_JSON_ARRAY != vam->json_tree.type)
19530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19531 vat_json_init_array (&vam->json_tree);
19534 node = vat_json_array_add (&vam->json_tree);
19535 vat_json_init_object (node);
19537 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19538 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19539 vat_json_object_add_uint (node, "transport_protocol",
19540 mp->transport_protocol);
19544 api_sw_interface_span_enable_disable (vat_main_t * vam)
19546 unformat_input_t *i = vam->input;
19547 vl_api_sw_interface_span_enable_disable_t *mp;
19548 u32 src_sw_if_index = ~0;
19549 u32 dst_sw_if_index = ~0;
19554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19557 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19559 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19563 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19565 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19567 else if (unformat (i, "disable"))
19569 else if (unformat (i, "rx"))
19571 else if (unformat (i, "tx"))
19573 else if (unformat (i, "both"))
19575 else if (unformat (i, "l2"))
19581 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19583 mp->sw_if_index_from = htonl (src_sw_if_index);
19584 mp->sw_if_index_to = htonl (dst_sw_if_index);
19594 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19597 vat_main_t *vam = &vat_main;
19598 u8 *sw_if_from_name = 0;
19599 u8 *sw_if_to_name = 0;
19600 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19601 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19602 char *states[] = { "none", "rx", "tx", "both" };
19606 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19608 if ((u32) p->value[0] == sw_if_index_from)
19610 sw_if_from_name = (u8 *)(p->key);
19614 if ((u32) p->value[0] == sw_if_index_to)
19616 sw_if_to_name = (u8 *)(p->key);
19617 if (sw_if_from_name)
19622 print (vam->ofp, "%20s => %20s (%s)",
19623 sw_if_from_name, sw_if_to_name, states[mp->state]);
19627 vl_api_sw_interface_span_details_t_handler_json
19628 (vl_api_sw_interface_span_details_t * mp)
19630 vat_main_t *vam = &vat_main;
19631 vat_json_node_t *node = NULL;
19632 u8 *sw_if_from_name = 0;
19633 u8 *sw_if_to_name = 0;
19634 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19635 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19639 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19641 if ((u32) p->value[0] == sw_if_index_from)
19643 sw_if_from_name = (u8 *)(p->key);
19647 if ((u32) p->value[0] == sw_if_index_to)
19649 sw_if_to_name = (u8 *)(p->key);
19650 if (sw_if_from_name)
19656 if (VAT_JSON_ARRAY != vam->json_tree.type)
19658 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19659 vat_json_init_array (&vam->json_tree);
19661 node = vat_json_array_add (&vam->json_tree);
19663 vat_json_init_object (node);
19664 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19665 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19666 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19667 if (0 != sw_if_to_name)
19669 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19671 vat_json_object_add_uint (node, "state", mp->state);
19675 api_sw_interface_span_dump (vat_main_t * vam)
19677 unformat_input_t *input = vam->input;
19678 vl_api_sw_interface_span_dump_t *mp;
19679 vl_api_control_ping_t *mp_ping;
19683 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19685 if (unformat (input, "l2"))
19691 M (SW_INTERFACE_SPAN_DUMP, mp);
19695 /* Use a control ping for synchronization */
19696 MPING (CONTROL_PING, mp_ping);
19704 api_pg_create_interface (vat_main_t * vam)
19706 unformat_input_t *input = vam->input;
19707 vl_api_pg_create_interface_t *mp;
19711 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19713 if (unformat (input, "if_id %d", &if_id))
19720 errmsg ("missing pg interface index");
19724 /* Construct the API message */
19725 M (PG_CREATE_INTERFACE, mp);
19727 mp->interface_id = ntohl (if_id);
19735 api_pg_capture (vat_main_t * vam)
19737 unformat_input_t *input = vam->input;
19738 vl_api_pg_capture_t *mp;
19743 u8 pcap_file_set = 0;
19746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19748 if (unformat (input, "if_id %d", &if_id))
19750 else if (unformat (input, "pcap %s", &pcap_file))
19752 else if (unformat (input, "count %d", &count))
19754 else if (unformat (input, "disable"))
19761 errmsg ("missing pg interface index");
19764 if (pcap_file_set > 0)
19766 if (vec_len (pcap_file) > 255)
19768 errmsg ("pcap file name is too long");
19773 u32 name_len = vec_len (pcap_file);
19774 /* Construct the API message */
19775 M (PG_CAPTURE, mp);
19777 mp->interface_id = ntohl (if_id);
19778 mp->is_enabled = enable;
19779 mp->count = ntohl (count);
19780 mp->pcap_name_length = ntohl (name_len);
19781 if (pcap_file_set != 0)
19783 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19785 vec_free (pcap_file);
19793 api_pg_enable_disable (vat_main_t * vam)
19795 unformat_input_t *input = vam->input;
19796 vl_api_pg_enable_disable_t *mp;
19799 u8 stream_name_set = 0;
19800 u8 *stream_name = 0;
19802 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19804 if (unformat (input, "stream %s", &stream_name))
19805 stream_name_set = 1;
19806 else if (unformat (input, "disable"))
19812 if (stream_name_set > 0)
19814 if (vec_len (stream_name) > 255)
19816 errmsg ("stream name too long");
19821 u32 name_len = vec_len (stream_name);
19822 /* Construct the API message */
19823 M (PG_ENABLE_DISABLE, mp);
19825 mp->is_enabled = enable;
19826 if (stream_name_set != 0)
19828 mp->stream_name_length = ntohl (name_len);
19829 clib_memcpy (mp->stream_name, stream_name, name_len);
19831 vec_free (stream_name);
19839 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19841 unformat_input_t *input = vam->input;
19842 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19844 u16 *low_ports = 0;
19845 u16 *high_ports = 0;
19848 ip4_address_t ip4_addr;
19849 ip6_address_t ip6_addr;
19858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19860 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19866 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19871 else if (unformat (input, "vrf %d", &vrf_id))
19873 else if (unformat (input, "del"))
19875 else if (unformat (input, "port %d", &tmp))
19877 if (tmp == 0 || tmp > 65535)
19879 errmsg ("port %d out of range", tmp);
19883 this_hi = this_low + 1;
19884 vec_add1 (low_ports, this_low);
19885 vec_add1 (high_ports, this_hi);
19887 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19889 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19891 errmsg ("incorrect range parameters");
19895 /* Note: in debug CLI +1 is added to high before
19896 passing to real fn that does "the work"
19897 (ip_source_and_port_range_check_add_del).
19898 This fn is a wrapper around the binary API fn a
19899 control plane will call, which expects this increment
19900 to have occurred. Hence letting the binary API control
19901 plane fn do the increment for consistency between VAT
19902 and other control planes.
19905 vec_add1 (low_ports, this_low);
19906 vec_add1 (high_ports, this_hi);
19912 if (prefix_set == 0)
19914 errmsg ("<address>/<mask> not specified");
19920 errmsg ("VRF ID required, not specified");
19927 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19931 if (vec_len (low_ports) == 0)
19933 errmsg ("At least one port or port range required");
19937 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19939 mp->is_add = is_add;
19944 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19949 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19952 mp->mask_length = length;
19953 mp->number_of_ranges = vec_len (low_ports);
19955 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19956 vec_free (low_ports);
19958 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19959 vec_free (high_ports);
19961 mp->vrf_id = ntohl (vrf_id);
19969 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19971 unformat_input_t *input = vam->input;
19972 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19973 u32 sw_if_index = ~0;
19975 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19976 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19980 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19982 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19984 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19986 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19988 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19990 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19992 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19994 else if (unformat (input, "del"))
20000 if (sw_if_index == ~0)
20002 errmsg ("Interface required but not specified");
20008 errmsg ("VRF ID required but not specified");
20012 if (tcp_out_vrf_id == 0
20013 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20016 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20020 /* Construct the API message */
20021 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20023 mp->sw_if_index = ntohl (sw_if_index);
20024 mp->is_add = is_add;
20025 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20026 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20027 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20028 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20033 /* Wait for a reply... */
20039 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20041 unformat_input_t *i = vam->input;
20042 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20043 u32 local_sa_id = 0;
20044 u32 remote_sa_id = 0;
20045 ip4_address_t src_address;
20046 ip4_address_t dst_address;
20050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20052 if (unformat (i, "local_sa %d", &local_sa_id))
20054 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20056 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20058 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20060 else if (unformat (i, "del"))
20064 clib_warning ("parse error '%U'", format_unformat_error, i);
20069 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20071 mp->local_sa_id = ntohl (local_sa_id);
20072 mp->remote_sa_id = ntohl (remote_sa_id);
20073 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20074 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20075 mp->is_add = is_add;
20083 api_punt (vat_main_t * vam)
20085 unformat_input_t *i = vam->input;
20093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20095 if (unformat (i, "ip %d", &ipv))
20097 else if (unformat (i, "protocol %d", &protocol))
20099 else if (unformat (i, "port %d", &port))
20101 else if (unformat (i, "del"))
20105 clib_warning ("parse error '%U'", format_unformat_error, i);
20112 mp->is_add = (u8) is_add;
20113 mp->ipv = (u8) ipv;
20114 mp->l4_protocol = (u8) protocol;
20115 mp->l4_port = htons ((u16) port);
20122 static void vl_api_ipsec_gre_tunnel_details_t_handler
20123 (vl_api_ipsec_gre_tunnel_details_t * mp)
20125 vat_main_t *vam = &vat_main;
20127 print (vam->ofp, "%11d%15U%15U%14d%14d",
20128 ntohl (mp->sw_if_index),
20129 format_ip4_address, &mp->src_address,
20130 format_ip4_address, &mp->dst_address,
20131 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20134 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20135 (vl_api_ipsec_gre_tunnel_details_t * mp)
20137 vat_main_t *vam = &vat_main;
20138 vat_json_node_t *node = NULL;
20139 struct in_addr ip4;
20141 if (VAT_JSON_ARRAY != vam->json_tree.type)
20143 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20144 vat_json_init_array (&vam->json_tree);
20146 node = vat_json_array_add (&vam->json_tree);
20148 vat_json_init_object (node);
20149 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20150 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20151 vat_json_object_add_ip4 (node, "src_address", ip4);
20152 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20153 vat_json_object_add_ip4 (node, "dst_address", ip4);
20154 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20155 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20159 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20161 unformat_input_t *i = vam->input;
20162 vl_api_ipsec_gre_tunnel_dump_t *mp;
20163 vl_api_control_ping_t *mp_ping;
20165 u8 sw_if_index_set = 0;
20168 /* Parse args required to build the message */
20169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20171 if (unformat (i, "sw_if_index %d", &sw_if_index))
20172 sw_if_index_set = 1;
20177 if (sw_if_index_set == 0)
20182 if (!vam->json_output)
20184 print (vam->ofp, "%11s%15s%15s%14s%14s",
20185 "sw_if_index", "src_address", "dst_address",
20186 "local_sa_id", "remote_sa_id");
20189 /* Get list of gre-tunnel interfaces */
20190 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20192 mp->sw_if_index = htonl (sw_if_index);
20196 /* Use a control ping for synchronization */
20197 MPING (CONTROL_PING, mp_ping);
20205 api_delete_subif (vat_main_t * vam)
20207 unformat_input_t *i = vam->input;
20208 vl_api_delete_subif_t *mp;
20209 u32 sw_if_index = ~0;
20212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20216 if (unformat (i, "sw_if_index %d", &sw_if_index))
20222 if (sw_if_index == ~0)
20224 errmsg ("missing sw_if_index");
20228 /* Construct the API message */
20229 M (DELETE_SUBIF, mp);
20230 mp->sw_if_index = ntohl (sw_if_index);
20237 #define foreach_pbb_vtr_op \
20238 _("disable", L2_VTR_DISABLED) \
20239 _("pop", L2_VTR_POP_2) \
20240 _("push", L2_VTR_PUSH_2)
20243 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20245 unformat_input_t *i = vam->input;
20246 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20247 u32 sw_if_index = ~0, vtr_op = ~0;
20248 u16 outer_tag = ~0;
20249 u8 dmac[6], smac[6];
20250 u8 dmac_set = 0, smac_set = 0;
20256 /* Shut up coverity */
20257 memset (dmac, 0, sizeof (dmac));
20258 memset (smac, 0, sizeof (smac));
20260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20262 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20264 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20266 else if (unformat (i, "vtr_op %d", &vtr_op))
20268 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20271 else if (unformat (i, "translate_pbb_stag"))
20273 if (unformat (i, "%d", &tmp))
20275 vtr_op = L2_VTR_TRANSLATE_2_1;
20281 ("translate_pbb_stag operation requires outer tag definition");
20285 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20287 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20289 else if (unformat (i, "sid %d", &sid))
20291 else if (unformat (i, "vlanid %d", &tmp))
20295 clib_warning ("parse error '%U'", format_unformat_error, i);
20300 if ((sw_if_index == ~0) || (vtr_op == ~0))
20302 errmsg ("missing sw_if_index or vtr operation");
20305 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20306 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20309 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20313 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20314 mp->sw_if_index = ntohl (sw_if_index);
20315 mp->vtr_op = ntohl (vtr_op);
20316 mp->outer_tag = ntohs (outer_tag);
20317 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20318 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20319 mp->b_vlanid = ntohs (vlanid);
20320 mp->i_sid = ntohl (sid);
20328 api_flow_classify_set_interface (vat_main_t * vam)
20330 unformat_input_t *i = vam->input;
20331 vl_api_flow_classify_set_interface_t *mp;
20333 int sw_if_index_set;
20334 u32 ip4_table_index = ~0;
20335 u32 ip6_table_index = ~0;
20339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20341 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20342 sw_if_index_set = 1;
20343 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20344 sw_if_index_set = 1;
20345 else if (unformat (i, "del"))
20347 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20349 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20353 clib_warning ("parse error '%U'", format_unformat_error, i);
20358 if (sw_if_index_set == 0)
20360 errmsg ("missing interface name or sw_if_index");
20364 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20366 mp->sw_if_index = ntohl (sw_if_index);
20367 mp->ip4_table_index = ntohl (ip4_table_index);
20368 mp->ip6_table_index = ntohl (ip6_table_index);
20369 mp->is_add = is_add;
20377 api_flow_classify_dump (vat_main_t * vam)
20379 unformat_input_t *i = vam->input;
20380 vl_api_flow_classify_dump_t *mp;
20381 vl_api_control_ping_t *mp_ping;
20382 u8 type = FLOW_CLASSIFY_N_TABLES;
20385 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20389 errmsg ("classify table type must be specified");
20393 if (!vam->json_output)
20395 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20398 M (FLOW_CLASSIFY_DUMP, mp);
20403 /* Use a control ping for synchronization */
20404 MPING (CONTROL_PING, mp_ping);
20407 /* Wait for a reply... */
20413 api_feature_enable_disable (vat_main_t * vam)
20415 unformat_input_t *i = vam->input;
20416 vl_api_feature_enable_disable_t *mp;
20418 u8 *feature_name = 0;
20419 u32 sw_if_index = ~0;
20423 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20425 if (unformat (i, "arc_name %s", &arc_name))
20427 else if (unformat (i, "feature_name %s", &feature_name))
20430 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20432 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20434 else if (unformat (i, "disable"))
20442 errmsg ("missing arc name");
20445 if (vec_len (arc_name) > 63)
20447 errmsg ("arc name too long");
20450 if (feature_name == 0)
20452 errmsg ("missing feature name");
20455 if (vec_len (feature_name) > 63)
20457 errmsg ("feature name too long");
20460 if (sw_if_index == ~0)
20462 errmsg ("missing interface name or sw_if_index");
20466 /* Construct the API message */
20467 M (FEATURE_ENABLE_DISABLE, mp);
20468 mp->sw_if_index = ntohl (sw_if_index);
20469 mp->enable = enable;
20470 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20471 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20472 vec_free (arc_name);
20473 vec_free (feature_name);
20481 api_sw_interface_tag_add_del (vat_main_t * vam)
20483 unformat_input_t *i = vam->input;
20484 vl_api_sw_interface_tag_add_del_t *mp;
20485 u32 sw_if_index = ~0;
20490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20492 if (unformat (i, "tag %s", &tag))
20494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20498 else if (unformat (i, "del"))
20504 if (sw_if_index == ~0)
20506 errmsg ("missing interface name or sw_if_index");
20510 if (enable && (tag == 0))
20512 errmsg ("no tag specified");
20516 /* Construct the API message */
20517 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20518 mp->sw_if_index = ntohl (sw_if_index);
20519 mp->is_add = enable;
20521 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20529 static void vl_api_l2_xconnect_details_t_handler
20530 (vl_api_l2_xconnect_details_t * mp)
20532 vat_main_t *vam = &vat_main;
20534 print (vam->ofp, "%15d%15d",
20535 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20538 static void vl_api_l2_xconnect_details_t_handler_json
20539 (vl_api_l2_xconnect_details_t * mp)
20541 vat_main_t *vam = &vat_main;
20542 vat_json_node_t *node = NULL;
20544 if (VAT_JSON_ARRAY != vam->json_tree.type)
20546 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20547 vat_json_init_array (&vam->json_tree);
20549 node = vat_json_array_add (&vam->json_tree);
20551 vat_json_init_object (node);
20552 vat_json_object_add_uint (node, "rx_sw_if_index",
20553 ntohl (mp->rx_sw_if_index));
20554 vat_json_object_add_uint (node, "tx_sw_if_index",
20555 ntohl (mp->tx_sw_if_index));
20559 api_l2_xconnect_dump (vat_main_t * vam)
20561 vl_api_l2_xconnect_dump_t *mp;
20562 vl_api_control_ping_t *mp_ping;
20565 if (!vam->json_output)
20567 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20570 M (L2_XCONNECT_DUMP, mp);
20574 /* Use a control ping for synchronization */
20575 MPING (CONTROL_PING, mp_ping);
20583 api_sw_interface_set_mtu (vat_main_t * vam)
20585 unformat_input_t *i = vam->input;
20586 vl_api_sw_interface_set_mtu_t *mp;
20587 u32 sw_if_index = ~0;
20591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20593 if (unformat (i, "mtu %d", &mtu))
20595 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20597 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20603 if (sw_if_index == ~0)
20605 errmsg ("missing interface name or sw_if_index");
20611 errmsg ("no mtu specified");
20615 /* Construct the API message */
20616 M (SW_INTERFACE_SET_MTU, mp);
20617 mp->sw_if_index = ntohl (sw_if_index);
20618 mp->mtu = ntohs ((u16) mtu);
20626 api_p2p_ethernet_add (vat_main_t * vam)
20628 unformat_input_t *i = vam->input;
20629 vl_api_p2p_ethernet_add_t *mp;
20630 u32 parent_if_index = ~0;
20636 memset (remote_mac, 0, sizeof (remote_mac));
20637 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20639 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20641 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20645 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20647 else if (unformat (i, "sub_id %d", &sub_id))
20651 clib_warning ("parse error '%U'", format_unformat_error, i);
20656 if (parent_if_index == ~0)
20658 errmsg ("missing interface name or sw_if_index");
20663 errmsg ("missing remote mac address");
20668 errmsg ("missing sub-interface id");
20672 M (P2P_ETHERNET_ADD, mp);
20673 mp->parent_if_index = ntohl (parent_if_index);
20674 mp->subif_id = ntohl (sub_id);
20675 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20683 api_p2p_ethernet_del (vat_main_t * vam)
20685 unformat_input_t *i = vam->input;
20686 vl_api_p2p_ethernet_del_t *mp;
20687 u32 parent_if_index = ~0;
20692 memset (remote_mac, 0, sizeof (remote_mac));
20693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20697 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20701 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20705 clib_warning ("parse error '%U'", format_unformat_error, i);
20710 if (parent_if_index == ~0)
20712 errmsg ("missing interface name or sw_if_index");
20717 errmsg ("missing remote mac address");
20721 M (P2P_ETHERNET_DEL, mp);
20722 mp->parent_if_index = ntohl (parent_if_index);
20723 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20731 api_lldp_config (vat_main_t * vam)
20733 unformat_input_t *i = vam->input;
20734 vl_api_lldp_config_t *mp;
20736 int tx_interval = 0;
20737 u8 *sys_name = NULL;
20740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20742 if (unformat (i, "system-name %s", &sys_name))
20744 else if (unformat (i, "tx-hold %d", &tx_hold))
20746 else if (unformat (i, "tx-interval %d", &tx_interval))
20750 clib_warning ("parse error '%U'", format_unformat_error, i);
20755 vec_add1 (sys_name, 0);
20757 M (LLDP_CONFIG, mp);
20758 mp->tx_hold = htonl (tx_hold);
20759 mp->tx_interval = htonl (tx_interval);
20760 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20761 vec_free (sys_name);
20769 api_sw_interface_set_lldp (vat_main_t * vam)
20771 unformat_input_t *i = vam->input;
20772 vl_api_sw_interface_set_lldp_t *mp;
20773 u32 sw_if_index = ~0;
20775 u8 *port_desc = NULL, *mgmt_oid = NULL;
20776 ip4_address_t ip4_addr;
20777 ip6_address_t ip6_addr;
20780 memset (&ip4_addr, 0, sizeof (ip4_addr));
20781 memset (&ip6_addr, 0, sizeof (ip6_addr));
20783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20785 if (unformat (i, "disable"))
20788 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20790 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20792 else if (unformat (i, "port-desc %s", &port_desc))
20794 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20796 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20798 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20804 if (sw_if_index == ~0)
20806 errmsg ("missing interface name or sw_if_index");
20810 /* Construct the API message */
20811 vec_add1 (port_desc, 0);
20812 vec_add1 (mgmt_oid, 0);
20813 M (SW_INTERFACE_SET_LLDP, mp);
20814 mp->sw_if_index = ntohl (sw_if_index);
20815 mp->enable = enable;
20816 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20817 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20818 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20819 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20820 vec_free (port_desc);
20821 vec_free (mgmt_oid);
20829 api_tcp_configure_src_addresses (vat_main_t * vam)
20831 vl_api_tcp_configure_src_addresses_t *mp;
20832 unformat_input_t *i = vam->input;
20833 ip4_address_t v4first, v4last;
20834 ip6_address_t v6first, v6last;
20839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20841 if (unformat (i, "%U - %U",
20842 unformat_ip4_address, &v4first,
20843 unformat_ip4_address, &v4last))
20847 errmsg ("one range per message (range already set)");
20852 else if (unformat (i, "%U - %U",
20853 unformat_ip6_address, &v6first,
20854 unformat_ip6_address, &v6last))
20858 errmsg ("one range per message (range already set)");
20863 else if (unformat (i, "vrf %d", &vrf_id))
20869 if (range_set == 0)
20871 errmsg ("address range not set");
20875 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20876 mp->vrf_id = ntohl (vrf_id);
20878 if (range_set == 2)
20881 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20882 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20887 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20888 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20896 api_app_namespace_add_del (vat_main_t * vam)
20898 vl_api_app_namespace_add_del_t *mp;
20899 unformat_input_t *i = vam->input;
20900 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20901 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20907 if (unformat (i, "id %_%v%_", &ns_id))
20909 else if (unformat (i, "secret %lu", &secret))
20911 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20912 sw_if_index_set = 1;
20913 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20915 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20920 if (!ns_id || !secret_set || !sw_if_index_set)
20922 errmsg ("namespace id, secret and sw_if_index must be set");
20925 if (vec_len (ns_id) > 64)
20927 errmsg ("namespace id too long");
20930 M (APP_NAMESPACE_ADD_DEL, mp);
20932 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20933 mp->namespace_id_len = vec_len (ns_id);
20934 mp->secret = secret;
20935 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20936 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20937 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20945 api_memfd_segment_create (vat_main_t * vam)
20947 #if VPP_API_TEST_BUILTIN == 0
20948 unformat_input_t *i = vam->input;
20949 vl_api_memfd_segment_create_t *mp;
20950 u64 size = 64 << 20;
20953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20955 if (unformat (i, "size %U", unformat_memory_size, &size))
20961 M (MEMFD_SEGMENT_CREATE, mp);
20962 mp->requested_size = size;
20968 errmsg ("memfd_segment_create (builtin) not supported");
20974 api_dns_enable_disable (vat_main_t * vam)
20976 unformat_input_t *line_input = vam->input;
20977 vl_api_dns_enable_disable_t *mp;
20978 u8 enable_disable = 1;
20981 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20983 if (unformat (line_input, "disable"))
20984 enable_disable = 0;
20985 if (unformat (line_input, "enable"))
20986 enable_disable = 1;
20991 /* Construct the API message */
20992 M (DNS_ENABLE_DISABLE, mp);
20993 mp->enable = enable_disable;
20997 /* Wait for the reply */
21003 api_dns_resolve_name (vat_main_t * vam)
21005 unformat_input_t *line_input = vam->input;
21006 vl_api_dns_resolve_name_t *mp;
21010 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21012 if (unformat (line_input, "%s", &name))
21018 if (vec_len (name) > 127)
21020 errmsg ("name too long");
21024 /* Construct the API message */
21025 M (DNS_RESOLVE_NAME, mp);
21026 memcpy (mp->name, name, vec_len (name));
21031 /* Wait for the reply */
21037 api_dns_resolve_ip (vat_main_t * vam)
21039 unformat_input_t *line_input = vam->input;
21040 vl_api_dns_resolve_ip_t *mp;
21042 ip4_address_t addr4;
21043 ip6_address_t addr6;
21046 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21048 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21050 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21058 errmsg ("missing address");
21062 /* Construct the API message */
21063 M (DNS_RESOLVE_IP, mp);
21064 mp->is_ip6 = is_ip6;
21066 memcpy (mp->address, &addr6, sizeof (addr6));
21068 memcpy (mp->address, &addr4, sizeof (addr4));
21072 /* Wait for the reply */
21078 api_dns_name_server_add_del (vat_main_t * vam)
21080 unformat_input_t *i = vam->input;
21081 vl_api_dns_name_server_add_del_t *mp;
21083 ip6_address_t ip6_server;
21084 ip4_address_t ip4_server;
21089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21091 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21093 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21095 else if (unformat (i, "del"))
21099 clib_warning ("parse error '%U'", format_unformat_error, i);
21104 if (ip4_set && ip6_set)
21106 errmsg ("Only one server address allowed per message");
21109 if ((ip4_set + ip6_set) == 0)
21111 errmsg ("Server address required");
21115 /* Construct the API message */
21116 M (DNS_NAME_SERVER_ADD_DEL, mp);
21120 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21125 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21129 mp->is_add = is_add;
21134 /* Wait for a reply, return good/bad news */
21141 q_or_quit (vat_main_t * vam)
21143 #if VPP_API_TEST_BUILTIN == 0
21144 longjmp (vam->jump_buf, 1);
21146 return 0; /* not so much */
21150 q (vat_main_t * vam)
21152 return q_or_quit (vam);
21156 quit (vat_main_t * vam)
21158 return q_or_quit (vam);
21162 comment (vat_main_t * vam)
21168 cmd_cmp (void *a1, void *a2)
21173 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21177 help (vat_main_t * vam)
21182 unformat_input_t *i = vam->input;
21185 if (unformat (i, "%s", &name))
21189 vec_add1 (name, 0);
21191 hs = hash_get_mem (vam->help_by_name, name);
21193 print (vam->ofp, "usage: %s %s", name, hs[0]);
21195 print (vam->ofp, "No such msg / command '%s'", name);
21200 print (vam->ofp, "Help is available for the following:");
21203 hash_foreach_pair (p, vam->function_by_name,
21205 vec_add1 (cmds, (u8 *)(p->key));
21209 vec_sort_with_function (cmds, cmd_cmp);
21211 for (j = 0; j < vec_len (cmds); j++)
21212 print (vam->ofp, "%s", cmds[j]);
21219 set (vat_main_t * vam)
21221 u8 *name = 0, *value = 0;
21222 unformat_input_t *i = vam->input;
21224 if (unformat (i, "%s", &name))
21226 /* The input buffer is a vector, not a string. */
21227 value = vec_dup (i->buffer);
21228 vec_delete (value, i->index, 0);
21229 /* Almost certainly has a trailing newline */
21230 if (value[vec_len (value) - 1] == '\n')
21231 value[vec_len (value) - 1] = 0;
21232 /* Make sure it's a proper string, one way or the other */
21233 vec_add1 (value, 0);
21234 (void) clib_macro_set_value (&vam->macro_main,
21235 (char *) name, (char *) value);
21238 errmsg ("usage: set <name> <value>");
21246 unset (vat_main_t * vam)
21250 if (unformat (vam->input, "%s", &name))
21251 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21252 errmsg ("unset: %s wasn't set", name);
21265 macro_sort_cmp (void *a1, void *a2)
21267 macro_sort_t *s1 = a1;
21268 macro_sort_t *s2 = a2;
21270 return strcmp ((char *) (s1->name), (char *) (s2->name));
21274 dump_macro_table (vat_main_t * vam)
21276 macro_sort_t *sort_me = 0, *sm;
21281 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21283 vec_add2 (sort_me, sm, 1);
21284 sm->name = (u8 *)(p->key);
21285 sm->value = (u8 *) (p->value[0]);
21289 vec_sort_with_function (sort_me, macro_sort_cmp);
21291 if (vec_len (sort_me))
21292 print (vam->ofp, "%-15s%s", "Name", "Value");
21294 print (vam->ofp, "The macro table is empty...");
21296 for (i = 0; i < vec_len (sort_me); i++)
21297 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21302 dump_node_table (vat_main_t * vam)
21305 vlib_node_t *node, *next_node;
21307 if (vec_len (vam->graph_nodes) == 0)
21309 print (vam->ofp, "Node table empty, issue get_node_graph...");
21313 for (i = 0; i < vec_len (vam->graph_nodes); i++)
21315 node = vam->graph_nodes[i];
21316 print (vam->ofp, "[%d] %s", i, node->name);
21317 for (j = 0; j < vec_len (node->next_nodes); j++)
21319 if (node->next_nodes[j] != ~0)
21321 next_node = vam->graph_nodes[node->next_nodes[j]];
21322 print (vam->ofp, " [%d] %s", j, next_node->name);
21330 value_sort_cmp (void *a1, void *a2)
21332 name_sort_t *n1 = a1;
21333 name_sort_t *n2 = a2;
21335 if (n1->value < n2->value)
21337 if (n1->value > n2->value)
21344 dump_msg_api_table (vat_main_t * vam)
21346 api_main_t *am = &api_main;
21347 name_sort_t *nses = 0, *ns;
21352 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21354 vec_add2 (nses, ns, 1);
21355 ns->name = (u8 *)(hp->key);
21356 ns->value = (u32) hp->value[0];
21360 vec_sort_with_function (nses, value_sort_cmp);
21362 for (i = 0; i < vec_len (nses); i++)
21363 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21369 get_msg_id (vat_main_t * vam)
21374 if (unformat (vam->input, "%s", &name_and_crc))
21376 message_index = vl_api_get_msg_index (name_and_crc);
21377 if (message_index == ~0)
21379 print (vam->ofp, " '%s' not found", name_and_crc);
21382 print (vam->ofp, " '%s' has message index %d",
21383 name_and_crc, message_index);
21386 errmsg ("name_and_crc required...");
21391 search_node_table (vat_main_t * vam)
21393 unformat_input_t *line_input = vam->input;
21396 vlib_node_t *node, *next_node;
21399 if (vam->graph_node_index_by_name == 0)
21401 print (vam->ofp, "Node table empty, issue get_node_graph...");
21405 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21407 if (unformat (line_input, "%s", &node_to_find))
21409 vec_add1 (node_to_find, 0);
21410 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21413 print (vam->ofp, "%s not found...", node_to_find);
21416 node = vam->graph_nodes[p[0]];
21417 print (vam->ofp, "[%d] %s", p[0], node->name);
21418 for (j = 0; j < vec_len (node->next_nodes); j++)
21420 if (node->next_nodes[j] != ~0)
21422 next_node = vam->graph_nodes[node->next_nodes[j]];
21423 print (vam->ofp, " [%d] %s", j, next_node->name);
21430 clib_warning ("parse error '%U'", format_unformat_error,
21436 vec_free (node_to_find);
21445 script (vat_main_t * vam)
21447 #if (VPP_API_TEST_BUILTIN==0)
21449 char *save_current_file;
21450 unformat_input_t save_input;
21451 jmp_buf save_jump_buf;
21452 u32 save_line_number;
21454 FILE *new_fp, *save_ifp;
21456 if (unformat (vam->input, "%s", &s))
21458 new_fp = fopen ((char *) s, "r");
21461 errmsg ("Couldn't open script file %s", s);
21468 errmsg ("Missing script name");
21472 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21473 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21474 save_ifp = vam->ifp;
21475 save_line_number = vam->input_line_number;
21476 save_current_file = (char *) vam->current_file;
21478 vam->input_line_number = 0;
21480 vam->current_file = s;
21483 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
21484 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21485 vam->ifp = save_ifp;
21486 vam->input_line_number = save_line_number;
21487 vam->current_file = (u8 *) save_current_file;
21492 clib_warning ("use the exec command...");
21498 echo (vat_main_t * vam)
21500 print (vam->ofp, "%v", vam->input->buffer);
21504 /* List of API message constructors, CLI names map to api_xxx */
21505 #define foreach_vpe_api_msg \
21506 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21507 _(sw_interface_dump,"") \
21508 _(sw_interface_set_flags, \
21509 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21510 _(sw_interface_add_del_address, \
21511 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21512 _(sw_interface_set_table, \
21513 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21514 _(sw_interface_set_mpls_enable, \
21515 "<intfc> | sw_if_index [disable | dis]") \
21516 _(sw_interface_set_vpath, \
21517 "<intfc> | sw_if_index <id> enable | disable") \
21518 _(sw_interface_set_vxlan_bypass, \
21519 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21520 _(sw_interface_set_geneve_bypass, \
21521 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21522 _(sw_interface_set_l2_xconnect, \
21523 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21524 "enable | disable") \
21525 _(sw_interface_set_l2_bridge, \
21526 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21527 "[shg <split-horizon-group>] [bvi]\n" \
21528 "enable | disable") \
21529 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21530 _(bridge_domain_add_del, \
21531 "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") \
21532 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21534 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21535 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21536 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21538 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21540 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21542 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
21544 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
21546 "<vpp-if-name> | sw_if_index <id>") \
21547 _(sw_interface_tap_dump, "") \
21548 _(ip_table_add_del, \
21549 "table-id <n> [ipv6]\n") \
21550 _(ip_add_del_route, \
21551 "<addr>/<mask> via <addr> [table-id <n>]\n" \
21552 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21553 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21554 "[multipath] [count <n>]") \
21555 _(ip_mroute_add_del, \
21556 "<src> <grp>/<mask> [table-id <n>]\n" \
21557 "[<intfc> | sw_if_index <id>] [local] [del]") \
21558 _(mpls_table_add_del, \
21559 "table-id <n>\n") \
21560 _(mpls_route_add_del, \
21561 "<label> <eos> via <addr> [table-id <n>]\n" \
21562 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
21563 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
21564 "[multipath] [count <n>]") \
21565 _(mpls_ip_bind_unbind, \
21566 "<label> <addr/len>") \
21567 _(mpls_tunnel_add_del, \
21568 " via <addr> [table-id <n>]\n" \
21569 "sw_if_index <id>] [l2] [del]") \
21570 _(proxy_arp_add_del, \
21571 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21572 _(proxy_arp_intfc_enable_disable, \
21573 "<intfc> | sw_if_index <id> enable | disable") \
21574 _(sw_interface_set_unnumbered, \
21575 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21576 _(ip_neighbor_add_del, \
21577 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21578 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21579 _(reset_vrf, "vrf <id> [ipv6]") \
21580 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21581 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21582 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21583 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21584 "[outer_vlan_id_any][inner_vlan_id_any]") \
21585 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
21586 _(reset_fib, "vrf <n> [ipv6]") \
21587 _(dhcp_proxy_config, \
21588 "svr <v46-address> src <v46-address>\n" \
21589 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
21590 _(dhcp_proxy_set_vss, \
21591 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
21592 _(dhcp_proxy_dump, "ip6") \
21593 _(dhcp_client_config, \
21594 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
21595 _(set_ip_flow_hash, \
21596 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21597 _(sw_interface_ip6_enable_disable, \
21598 "<intfc> | sw_if_index <id> enable | disable") \
21599 _(sw_interface_ip6_set_link_local_address, \
21600 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
21601 _(ip6nd_proxy_add_del, \
21602 "<intfc> | sw_if_index <id> <ip6-address>") \
21603 _(ip6nd_proxy_dump, "") \
21604 _(sw_interface_ip6nd_ra_prefix, \
21605 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21606 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21607 "[nolink] [isno]") \
21608 _(sw_interface_ip6nd_ra_config, \
21609 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21610 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21611 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21612 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21613 _(l2_patch_add_del, \
21614 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21615 "enable | disable") \
21616 _(sr_localsid_add_del, \
21617 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21618 "fib-table <num> (end.psp) sw_if_index <num>") \
21619 _(classify_add_del_table, \
21620 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21621 " [del] [del-chain] mask <mask-value>\n" \
21622 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21623 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21624 _(classify_add_del_session, \
21625 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21626 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21627 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21628 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21629 _(classify_set_interface_ip_table, \
21630 "<intfc> | sw_if_index <nn> table <nn>") \
21631 _(classify_set_interface_l2_tables, \
21632 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21633 " [other-table <nn>]") \
21634 _(get_node_index, "node <node-name") \
21635 _(add_node_next, "node <node-name> next <next-node-name>") \
21636 _(l2tpv3_create_tunnel, \
21637 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21638 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21639 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21640 _(l2tpv3_set_tunnel_cookies, \
21641 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21642 "[new_remote_cookie <nn>]\n") \
21643 _(l2tpv3_interface_enable_disable, \
21644 "<intfc> | sw_if_index <nn> enable | disable") \
21645 _(l2tpv3_set_lookup_key, \
21646 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21647 _(sw_if_l2tpv3_tunnel_dump, "") \
21648 _(vxlan_add_del_tunnel, \
21649 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21650 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21651 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21652 _(geneve_add_del_tunnel, \
21653 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21654 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21655 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21656 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21657 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21658 _(gre_add_del_tunnel, \
21659 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
21660 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21661 _(l2_fib_clear_table, "") \
21662 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21663 _(l2_interface_vlan_tag_rewrite, \
21664 "<intfc> | sw_if_index <nn> \n" \
21665 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21666 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21667 _(create_vhost_user_if, \
21668 "socket <filename> [server] [renumber <dev_instance>] " \
21669 "[mac <mac_address>]") \
21670 _(modify_vhost_user_if, \
21671 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21672 "[server] [renumber <dev_instance>]") \
21673 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21674 _(sw_interface_vhost_user_dump, "") \
21675 _(show_version, "") \
21676 _(vxlan_gpe_add_del_tunnel, \
21677 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21678 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21679 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21680 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21681 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21682 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21683 _(interface_name_renumber, \
21684 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21685 _(input_acl_set_interface, \
21686 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21687 " [l2-table <nn>] [del]") \
21688 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21689 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21690 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21691 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21692 _(ip_dump, "ipv4 | ipv6") \
21693 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21694 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21696 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21697 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21698 " integ_alg <alg> integ_key <hex>") \
21699 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
21700 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21701 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21702 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21703 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
21704 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21705 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21706 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21707 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
21708 _(ipsec_sa_dump, "[sa_id <n>]") \
21709 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
21710 " <alg> <hex>\n") \
21711 _(ikev2_profile_add_del, "name <profile_name> [del]") \
21712 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
21713 "(auth_data 0x<data> | auth_data <data>)") \
21714 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
21715 "(id_data 0x<data> | id_data <data>) (local|remote)") \
21716 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
21717 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
21718 "(local|remote)") \
21719 _(ikev2_set_local_key, "file <absolute_file_path>") \
21720 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
21721 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21722 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
21723 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
21724 _(ikev2_initiate_sa_init, "<profile_name>") \
21725 _(ikev2_initiate_del_ike_sa, "<ispi>") \
21726 _(ikev2_initiate_del_child_sa, "<ispi>") \
21727 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
21728 _(delete_loopback,"sw_if_index <nn>") \
21729 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21730 _(map_add_domain, \
21731 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
21732 "ip6-src <ip6addr> " \
21733 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
21734 _(map_del_domain, "index <n>") \
21735 _(map_add_del_rule, \
21736 "index <n> psid <n> dst <ip6addr> [del]") \
21737 _(map_domain_dump, "") \
21738 _(map_rule_dump, "index <map-domain>") \
21739 _(want_interface_events, "enable|disable") \
21740 _(want_stats,"enable|disable") \
21741 _(get_first_msg_id, "client <name>") \
21742 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21743 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21744 "fib-id <nn> [ip4][ip6][default]") \
21745 _(get_node_graph, " ") \
21746 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21747 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21748 _(ioam_disable, "") \
21749 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21750 " sw_if_index <sw_if_index> p <priority> " \
21751 "w <weight>] [del]") \
21752 _(one_add_del_locator, "locator-set <locator_name> " \
21753 "iface <intf> | sw_if_index <sw_if_index> " \
21754 "p <priority> w <weight> [del]") \
21755 _(one_add_del_local_eid,"vni <vni> eid " \
21756 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21757 "locator-set <locator_name> [del]" \
21758 "[key-id sha1|sha256 secret-key <secret-key>]")\
21759 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21760 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21761 _(one_enable_disable, "enable|disable") \
21762 _(one_map_register_enable_disable, "enable|disable") \
21763 _(one_map_register_fallback_threshold, "<value>") \
21764 _(one_rloc_probe_enable_disable, "enable|disable") \
21765 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21767 "rloc <locator> p <prio> " \
21768 "w <weight> [rloc <loc> ... ] " \
21769 "action <action> [del-all]") \
21770 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21772 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21773 _(one_use_petr, "ip-address> | disable") \
21774 _(one_map_request_mode, "src-dst|dst-only") \
21775 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21776 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21777 _(one_locator_set_dump, "[local | remote]") \
21778 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21779 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21780 "[local] | [remote]") \
21781 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21782 _(one_ndp_bd_get, "") \
21783 _(one_ndp_entries_get, "bd <bridge-domain>") \
21784 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21785 _(one_l2_arp_bd_get, "") \
21786 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21787 _(one_stats_enable_disable, "enable|disalbe") \
21788 _(show_one_stats_enable_disable, "") \
21789 _(one_eid_table_vni_dump, "") \
21790 _(one_eid_table_map_dump, "l2|l3") \
21791 _(one_map_resolver_dump, "") \
21792 _(one_map_server_dump, "") \
21793 _(one_adjacencies_get, "vni <vni>") \
21794 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21795 _(show_one_rloc_probe_state, "") \
21796 _(show_one_map_register_state, "") \
21797 _(show_one_status, "") \
21798 _(one_stats_dump, "") \
21799 _(one_stats_flush, "") \
21800 _(one_get_map_request_itr_rlocs, "") \
21801 _(one_map_register_set_ttl, "<ttl>") \
21802 _(one_set_transport_protocol, "udp|api") \
21803 _(one_get_transport_protocol, "") \
21804 _(show_one_nsh_mapping, "") \
21805 _(show_one_pitr, "") \
21806 _(show_one_use_petr, "") \
21807 _(show_one_map_request_mode, "") \
21808 _(show_one_map_register_ttl, "") \
21809 _(show_one_map_register_fallback_threshold, "") \
21810 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21811 " sw_if_index <sw_if_index> p <priority> " \
21812 "w <weight>] [del]") \
21813 _(lisp_add_del_locator, "locator-set <locator_name> " \
21814 "iface <intf> | sw_if_index <sw_if_index> " \
21815 "p <priority> w <weight> [del]") \
21816 _(lisp_add_del_local_eid,"vni <vni> eid " \
21817 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21818 "locator-set <locator_name> [del]" \
21819 "[key-id sha1|sha256 secret-key <secret-key>]") \
21820 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21821 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21822 _(lisp_enable_disable, "enable|disable") \
21823 _(lisp_map_register_enable_disable, "enable|disable") \
21824 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21825 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21827 "rloc <locator> p <prio> " \
21828 "w <weight> [rloc <loc> ... ] " \
21829 "action <action> [del-all]") \
21830 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21832 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21833 _(lisp_use_petr, "<ip-address> | disable") \
21834 _(lisp_map_request_mode, "src-dst|dst-only") \
21835 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21836 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21837 _(lisp_locator_set_dump, "[local | remote]") \
21838 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21839 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21840 "[local] | [remote]") \
21841 _(lisp_eid_table_vni_dump, "") \
21842 _(lisp_eid_table_map_dump, "l2|l3") \
21843 _(lisp_map_resolver_dump, "") \
21844 _(lisp_map_server_dump, "") \
21845 _(lisp_adjacencies_get, "vni <vni>") \
21846 _(gpe_fwd_entry_vnis_get, "") \
21847 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21848 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21849 "[table <table-id>]") \
21850 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21851 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21852 _(gpe_set_encap_mode, "lisp|vxlan") \
21853 _(gpe_get_encap_mode, "") \
21854 _(lisp_gpe_add_del_iface, "up|down") \
21855 _(lisp_gpe_enable_disable, "enable|disable") \
21856 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21857 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21858 _(show_lisp_rloc_probe_state, "") \
21859 _(show_lisp_map_register_state, "") \
21860 _(show_lisp_status, "") \
21861 _(lisp_get_map_request_itr_rlocs, "") \
21862 _(show_lisp_pitr, "") \
21863 _(show_lisp_use_petr, "") \
21864 _(show_lisp_map_request_mode, "") \
21865 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21866 _(af_packet_delete, "name <host interface name>") \
21867 _(policer_add_del, "name <policer name> <params> [del]") \
21868 _(policer_dump, "[name <policer name>]") \
21869 _(policer_classify_set_interface, \
21870 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21871 " [l2-table <nn>] [del]") \
21872 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21873 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21874 "[master|slave]") \
21875 _(netmap_delete, "name <interface name>") \
21876 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21877 _(mpls_fib_dump, "") \
21878 _(classify_table_ids, "") \
21879 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21880 _(classify_table_info, "table_id <nn>") \
21881 _(classify_session_dump, "table_id <nn>") \
21882 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21883 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21884 "[template_interval <nn>] [udp_checksum]") \
21885 _(ipfix_exporter_dump, "") \
21886 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21887 _(ipfix_classify_stream_dump, "") \
21888 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21889 _(ipfix_classify_table_dump, "") \
21890 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21891 _(sw_interface_span_dump, "[l2]") \
21892 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21893 _(pg_create_interface, "if_id <nn>") \
21894 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21895 _(pg_enable_disable, "[stream <id>] disable") \
21896 _(ip_source_and_port_range_check_add_del, \
21897 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21898 _(ip_source_and_port_range_check_interface_add_del, \
21899 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21900 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21901 _(ipsec_gre_add_del_tunnel, \
21902 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
21903 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
21904 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21905 _(l2_interface_pbb_tag_rewrite, \
21906 "<intfc> | sw_if_index <nn> \n" \
21907 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21908 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21909 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21910 _(flow_classify_set_interface, \
21911 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21912 _(flow_classify_dump, "type [ip4|ip6]") \
21913 _(ip_fib_dump, "") \
21914 _(ip_mfib_dump, "") \
21915 _(ip6_fib_dump, "") \
21916 _(ip6_mfib_dump, "") \
21917 _(feature_enable_disable, "arc_name <arc_name> " \
21918 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21919 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21921 _(l2_xconnect_dump, "") \
21922 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
21923 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21924 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21925 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21926 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21927 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21928 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21929 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21930 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21931 _(memfd_segment_create,"size <nnn>") \
21932 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21933 _(dns_enable_disable, "[enable][disable]") \
21934 _(dns_name_server_add_del, "<ip-address> [del]") \
21935 _(dns_resolve_name, "<hostname>") \
21936 _(dns_resolve_ip, "<ip4|ip6>")
21938 /* List of command functions, CLI names map directly to functions */
21939 #define foreach_cli_function \
21940 _(comment, "usage: comment <ignore-rest-of-line>") \
21941 _(dump_interface_table, "usage: dump_interface_table") \
21942 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21943 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21944 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21945 _(dump_stats_table, "usage: dump_stats_table") \
21946 _(dump_macro_table, "usage: dump_macro_table ") \
21947 _(dump_node_table, "usage: dump_node_table") \
21948 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21949 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21950 _(echo, "usage: echo <message>") \
21951 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21952 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21953 _(help, "usage: help") \
21954 _(q, "usage: quit") \
21955 _(quit, "usage: quit") \
21956 _(search_node_table, "usage: search_node_table <name>...") \
21957 _(set, "usage: set <variable-name> <value>") \
21958 _(script, "usage: script <file-name>") \
21959 _(unset, "usage: unset <variable-name>")
21961 static void vl_api_##n##_t_handler_uni \
21962 (vl_api_##n##_t * mp) \
21964 vat_main_t * vam = &vat_main; \
21965 if (vam->json_output) { \
21966 vl_api_##n##_t_handler_json(mp); \
21968 vl_api_##n##_t_handler(mp); \
21971 foreach_vpe_api_reply_msg;
21972 #if VPP_API_TEST_BUILTIN == 0
21973 foreach_standalone_reply_msg;
21978 vat_api_hookup (vat_main_t * vam)
21981 vl_msg_api_set_handlers(VL_API_##N, #n, \
21982 vl_api_##n##_t_handler_uni, \
21984 vl_api_##n##_t_endian, \
21985 vl_api_##n##_t_print, \
21986 sizeof(vl_api_##n##_t), 1);
21987 foreach_vpe_api_reply_msg;
21988 #if VPP_API_TEST_BUILTIN == 0
21989 foreach_standalone_reply_msg;
21993 #if (VPP_API_TEST_BUILTIN==0)
21994 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21996 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21998 vam->function_by_name = hash_create_string (0, sizeof (uword));
22000 vam->help_by_name = hash_create_string (0, sizeof (uword));
22003 /* API messages we can send */
22004 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22005 foreach_vpe_api_msg;
22009 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22010 foreach_vpe_api_msg;
22013 /* CLI functions */
22014 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22015 foreach_cli_function;
22019 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22020 foreach_cli_function;
22024 #if VPP_API_TEST_BUILTIN
22025 static clib_error_t *
22026 vat_api_hookup_shim (vlib_main_t * vm)
22028 vat_api_hookup (&vat_main);
22032 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22036 * fd.io coding-style-patch-verification: ON
22039 * eval: (c-set-style "gnu")